Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 74108 Details for
Bug 196685
[Schema][Editors] New element and attribute name generation creates duplicates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
additional patch
patch196685b.txt (text/plain), 5.65 KB, created by
Adam Archer
on 2007-07-18 22:42:08 EDT
(
hide
)
Description:
additional patch
Filename:
MIME Type:
Creator:
Adam Archer
Created:
2007-07-18 22:42:08 EDT
Size:
5.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/editor/schema/NewAttributeAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/NewAttributeAction.java,v >retrieving revision 1.10 >diff -u -r1.10 NewAttributeAction.java >--- src/org/eclipse/pde/internal/ui/editor/schema/NewAttributeAction.java 12 Jul 2007 22:11:18 -0000 1.10 >+++ src/org/eclipse/pde/internal/ui/editor/schema/NewAttributeAction.java 19 Jul 2007 02:41:17 -0000 >@@ -10,63 +10,60 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.editor.schema; > >-import java.util.Hashtable; >- > import org.eclipse.jface.action.Action; >-import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; > import org.eclipse.pde.internal.core.ischema.ISchemaComplexType; > import org.eclipse.pde.internal.core.ischema.ISchemaType; > import org.eclipse.pde.internal.core.schema.SchemaAttribute; > import org.eclipse.pde.internal.core.schema.SchemaComplexType; > import org.eclipse.pde.internal.core.schema.SchemaElement; > import org.eclipse.pde.internal.core.schema.SchemaSimpleType; >-import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEPluginImages; > import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.util.PDELabelUtility; > > public class NewAttributeAction extends Action { > private SchemaElement element; >- private static final String NAME_COUNTER_KEY = "__schema_attribute_name"; //$NON-NLS-1$ > public NewAttributeAction() { >- setText(PDEUIMessages.SchemaEditor_NewAttribute_label); >- setImageDescriptor(PDEPluginImages.DESC_ATT_IMPL_OBJ); >- setToolTipText(PDEUIMessages.SchemaEditor_NewAttribute_tooltip); >-} >-public org.eclipse.pde.internal.core.schema.SchemaElement getElement() { >- return element; >-} >-private String getInitialName() { >- Hashtable counters = PDEPlugin.getDefault().getDefaultNameCounters(); >- Integer counter = (Integer)counters.get(NAME_COUNTER_KEY); >- if (counter==null) { >- counter = new Integer(1); >+ setText(PDEUIMessages.SchemaEditor_NewAttribute_label); >+ setImageDescriptor(PDEPluginImages.DESC_ATT_IMPL_OBJ); >+ setToolTipText(PDEUIMessages.SchemaEditor_NewAttribute_tooltip); > } >- else { >- counter = new Integer(counter.intValue()+1); >+ public org.eclipse.pde.internal.core.schema.SchemaElement getElement() { >+ return element; >+ } >+ private String getInitialName() { >+ return PDELabelUtility.generateName(getAttributeNames(), PDEUIMessages.SchemaEditor_NewAttribute_initialName, false); >+ } >+ private String[] getAttributeNames() { >+ if (element == null) >+ return new String[0]; >+ ISchemaAttribute[] attributes = element.getAttributes(); >+ String[] names = new String[attributes.length]; >+ for (int i = 0; i < attributes.length; i++) >+ names[i] = attributes[i].getName(); >+ return names; >+ } >+ public void run() { >+ String name = getInitialName(); >+ SchemaAttribute att = new SchemaAttribute(element, name); >+ att.setType(new SchemaSimpleType(element.getSchema(), "string")); //$NON-NLS-1$ >+ ISchemaType type = element.getType(); >+ SchemaComplexType complexType=null; >+ if (!(type instanceof ISchemaComplexType)) { >+ complexType = new SchemaComplexType(element.getSchema()); >+ element.setType(complexType); >+ } >+ else { >+ complexType = (SchemaComplexType)type; >+ } >+ complexType.addAttribute(att); >+ // Any element that defines attributes cannot be translatable >+ if (element.hasTranslatableContent()) { >+ element.setTranslatableProperty(false); >+ } >+ } >+ public void setElement(org.eclipse.pde.internal.core.schema.SchemaElement newElement) { >+ element = newElement; > } >- counters.put(NAME_COUNTER_KEY, counter); >- return NLS.bind(PDEUIMessages.SchemaEditor_NewAttribute_initialName, counter.intValue()+""); //$NON-NLS-1$ >-} >-public void run() { >- String name = getInitialName(); >- SchemaAttribute att = new SchemaAttribute(element, name); >- att.setType(new SchemaSimpleType(element.getSchema(), "string")); //$NON-NLS-1$ >- ISchemaType type = element.getType(); >- SchemaComplexType complexType=null; >- if (!(type instanceof ISchemaComplexType)) { >- complexType = new SchemaComplexType(element.getSchema()); >- element.setType(complexType); >- } >- else { >- complexType = (SchemaComplexType)type; >- } >- complexType.addAttribute(att); >- // Any element that defines attributes cannot be translatable >- if (element.hasTranslatableContent()) { >- element.setTranslatableProperty(false); >- } >-} >-public void setElement(org.eclipse.pde.internal.core.schema.SchemaElement newElement) { >- element = newElement; >-} > } >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.891 >diff -u -r1.891 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 18 Jul 2007 23:17:14 -0000 1.891 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 19 Jul 2007 02:41:17 -0000 >@@ -385,7 +385,7 @@ > SchemaEditor_NewAttribute_tooltip = New Attribute > SchemaIncludesSection_description=Specify schemas to be included with this schema. > SchemaAttributeDetails_implements=Implements: >-SchemaEditor_NewAttribute_initialName = new_attribute{0} >+SchemaEditor_NewAttribute_initialName = new_attribute > > SchemaEditor_NewElement_label = &Element > SchemaCompositorDetails_title=Compositor Details
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mike.pawlowski
:
review+
Actions:
View
|
Diff
Attachments on
bug 196685
:
73958
| 74108