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 74185 Details for
Bug 196866
[Schema][Editors] Global element and local attribute identity constraints are not respected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
fixed patch
patch196866.txt (text/plain), 15.19 KB, created by
Adam Archer
on 2007-07-19 15:55:12 EDT
(
hide
)
Description:
fixed patch
Filename:
MIME Type:
Creator:
Adam Archer
Created:
2007-07-19 15:55:12 EDT
Size:
15.19 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/ischema/ISchemaElement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ischema/ISchemaElement.java,v >retrieving revision 1.8 >diff -u -r1.8 ISchemaElement.java >--- src/org/eclipse/pde/internal/core/ischema/ISchemaElement.java 12 Jul 2007 14:42:56 -0000 1.8 >+++ src/org/eclipse/pde/internal/core/ischema/ISchemaElement.java 19 Jul 2007 19:53:53 -0000 >@@ -37,4 +37,9 @@ > * or complex (with attributes and/or compositors). > */ > public ISchemaType getType(); >+/** >+ * Returns the names of the element's attributes. Placed here instead of ISchemaAttributeProvider >+ * so that SchemaComplexType does not need to implement needlessly. >+ */ >+public String[] getAttributeNames(); > } >Index: src/org/eclipse/pde/internal/core/ischema/ISchema.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ischema/ISchema.java,v >retrieving revision 1.15 >diff -u -r1.15 ISchema.java >--- src/org/eclipse/pde/internal/core/ischema/ISchema.java 3 Apr 2006 19:48:20 -0000 1.15 >+++ src/org/eclipse/pde/internal/core/ischema/ISchema.java 19 Jul 2007 19:53:53 -0000 >@@ -96,6 +96,14 @@ > public ISchemaElement[] getElements(); > > /** >+ * Returns an array of element names with the global scope defined in this >+ * schema. >+ * >+ * @return an array of global elements >+ */ >+ public String[] getElementNames(); >+ >+ /** > * Returns an array of elements with the global scope defined in this schema > * and all the included schemas. > * >Index: src/org/eclipse/pde/internal/core/schema/SchemaElementReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaElementReference.java,v >retrieving revision 1.20 >diff -u -r1.20 SchemaElementReference.java >--- src/org/eclipse/pde/internal/core/schema/SchemaElementReference.java 12 Jul 2007 14:42:56 -0000 1.20 >+++ src/org/eclipse/pde/internal/core/schema/SchemaElementReference.java 19 Jul 2007 19:53:54 -0000 >@@ -79,6 +79,12 @@ > return element.getAttributes(); > } > >+ public String[] getAttributeNames() { >+ if (element == null) >+ return new String[0]; >+ return element.getAttributeNames(); >+ } >+ > public ISchemaCompositor getCompositor() { > return compositor; > } >Index: src/org/eclipse/pde/internal/core/schema/SchemaElement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaElement.java,v >retrieving revision 1.24 >diff -u -r1.24 SchemaElement.java >--- src/org/eclipse/pde/internal/core/schema/SchemaElement.java 12 Jul 2007 14:42:56 -0000 1.24 >+++ src/org/eclipse/pde/internal/core/schema/SchemaElement.java 19 Jul 2007 19:53:53 -0000 >@@ -125,6 +125,14 @@ > } > return new ISchemaAttribute[0]; > } >+ >+ public String[] getAttributeNames() { >+ ISchemaAttribute[] attributes = getAttributes(); >+ String[] names = new String[attributes.length]; >+ for (int i = 0; i < attributes.length; i++) >+ names[i] = attributes[i].getName(); >+ return names; >+ } > > public String getDTDRepresentation(boolean addLinks) { > String text = ""; //$NON-NLS-1$ >Index: src/org/eclipse/pde/internal/core/schema/Schema.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/Schema.java,v >retrieving revision 1.68 >diff -u -r1.68 Schema.java >--- src/org/eclipse/pde/internal/core/schema/Schema.java 16 Jul 2007 21:13:52 -0000 1.68 >+++ src/org/eclipse/pde/internal/core/schema/Schema.java 19 Jul 2007 19:53:53 -0000 >@@ -270,6 +270,14 @@ > fElements.copyInto(result); > return result; > } >+ >+ public String[] getElementNames() { >+ ISchemaElement[] elements = getElements(); >+ String[] names = new String[elements.length]; >+ for (int i = 0; i < elements.length; i++) >+ names[i] = elements[i].getName(); >+ return names; >+ } > > public ISchemaElement[] getResolvedElements() { > if (fIncludes == null) >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java,v >retrieving revision 1.32 >diff -u -r1.32 SchemaAttributeDetails.java >--- src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java 18 Jul 2007 23:17:14 -0000 1.32 >+++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java 19 Jul 2007 19:53:55 -0000 >@@ -12,6 +12,8 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.pde.core.IModelChangedEvent; > import org.eclipse.pde.internal.core.ischema.IMetaAttribute; >+import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; >+import org.eclipse.pde.internal.core.ischema.ISchemaElement; > import org.eclipse.pde.internal.core.ischema.ISchemaObject; > import org.eclipse.pde.internal.core.ischema.ISchemaRestriction; > import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType; >@@ -145,11 +147,27 @@ > public void textValueChanged(FormEntry entry) { > if (blockListeners()) > return; >- if (fName.getValue().length() != 0) { >+ boolean revert = false; >+ if (fName.getValue().length() == 0) >+ revert = true; >+ else { >+ ISchemaObject parent = fAttribute.getParent(); >+ while (!(parent instanceof ISchemaElement)) >+ parent = parent.getParent(); >+ ISchemaElement element = (ISchemaElement)parent; >+ ISchemaAttribute[] attributes = element.getAttributes(); >+ for (int i = 0; i < attributes.length; i++) { >+ if (attributes[i] != fAttribute && attributes[i].getName().equalsIgnoreCase(fName.getValue())) { >+ revert = true; >+ break; >+ } >+ } >+ } >+ if (revert) >+ fName.setValue(fAttribute.getName(), true); >+ else { > fAttribute.setName(fName.getValue()); > setDecription(NLS.bind(PDEUIMessages.SchemaAttributeDetails_description, fAttribute.getName())); >- } else { >- fName.setValue(fAttribute.getName(), true); > } > } > }); >Index: src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java,v >retrieving revision 1.24 >diff -u -r1.24 SchemaElementDetails.java >--- src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java 18 Jul 2007 23:17:14 -0000 1.24 >+++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java 19 Jul 2007 19:53:55 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.pde.internal.core.ischema.ISchema; > import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; > import org.eclipse.pde.internal.core.ischema.ISchemaComplexType; >+import org.eclipse.pde.internal.core.ischema.ISchemaElement; > import org.eclipse.pde.internal.core.ischema.ISchemaObject; > import org.eclipse.pde.internal.core.schema.Schema; > import org.eclipse.pde.internal.core.schema.SchemaElement; >@@ -145,12 +146,24 @@ > public void textValueChanged(FormEntry entry) { > if (blockListeners()) > return; >- if (fName.getValue().length() != 0) { >+ boolean revert = false; >+ if (fName.getValue().length() == 0) >+ revert = true; >+ else { >+ ISchemaElement[] elements = fElement.getSchema().getElements(); >+ for (int i = 0; i < elements.length; i++) { >+ if (elements[i] != fElement && elements[i].getName().equalsIgnoreCase(fName.getValue())) { >+ revert = true; >+ break; >+ } >+ } >+ } >+ if (revert) >+ fName.setValue(fElement.getName(),true); >+ else { > fElement.setName(fName.getValue()); > ((Schema)fElement.getSchema()).updateReferencesFor(fElement, ISchema.REFRESH_RENAME); > setDecription(NLS.bind(PDEUIMessages.SchemaElementDetails_description, fElement.getName())); >- } else { >- fName.setValue(fElement.getName(),true); > } > } > }); >Index: src/org/eclipse/pde/internal/ui/editor/schema/SchemaRearranger.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/SchemaRearranger.java,v >retrieving revision 1.5 >diff -u -r1.5 SchemaRearranger.java >--- src/org/eclipse/pde/internal/ui/editor/schema/SchemaRearranger.java 3 Apr 2006 19:47:22 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaRearranger.java 19 Jul 2007 19:53:55 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.pde.internal.core.schema.SchemaElement; > import org.eclipse.pde.internal.core.schema.SchemaElementReference; > import org.eclipse.pde.internal.core.schema.SchemaSimpleType; >+import org.eclipse.pde.internal.ui.util.PDELabelUtility; > > public class SchemaRearranger { > >@@ -119,6 +120,9 @@ > oldType.removeAttribute(attribute); > } > attribute.setParent(newParent); >+ if (attribute instanceof SchemaAttribute) >+ ((SchemaAttribute)attribute).setName(PDELabelUtility.generateName( >+ newParent.getAttributeNames(), PDELabelUtility.getBaseName(attribute.getName(), false), false)); > type.addAttribute(attribute, sibling); > } > } >@@ -151,6 +155,8 @@ > public void pasteElement(ISchemaElement object, ISchemaObject sibling) { > SchemaElement element = (SchemaElement) object; > element.setParent(fSchema); >+ element.setName(PDELabelUtility.generateName(element.getSchema().getElementNames(), >+ PDELabelUtility.getBaseName(element.getName(), false), false)); > fSchema.addElement(element, (ISchemaElement) sibling); > fSchema.updateReferencesFor(element, ISchema.REFRESH_ADD); > } >@@ -159,6 +165,8 @@ > SchemaElement element = (SchemaElement) realTarget; > SchemaAttribute attribute = (SchemaAttribute) object; > attribute.setParent(element); >+ attribute.setName(PDELabelUtility.generateName(element.getAttributeNames(), >+ PDELabelUtility.getBaseName(attribute.getName(), false), false)); > ISchemaType type = element.getType(); > SchemaComplexType complexType = null; > if (!(type instanceof ISchemaComplexType)) { >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.11 >diff -u -r1.11 NewAttributeAction.java >--- src/org/eclipse/pde/internal/ui/editor/schema/NewAttributeAction.java 19 Jul 2007 15:58:29 -0000 1.11 >+++ src/org/eclipse/pde/internal/ui/editor/schema/NewAttributeAction.java 19 Jul 2007 19:53:55 -0000 >@@ -11,7 +11,6 @@ > package org.eclipse.pde.internal.ui.editor.schema; > > import org.eclipse.jface.action.Action; >-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; >@@ -33,16 +32,7 @@ > 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; >+ return PDELabelUtility.generateName(element.getAttributeNames(), PDEUIMessages.SchemaEditor_NewAttribute_initialName, false); > } > public void run() { > String name = getInitialName(); >Index: src/org/eclipse/pde/internal/ui/editor/schema/NewElementAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/NewElementAction.java,v >retrieving revision 1.14 >diff -u -r1.14 NewElementAction.java >--- src/org/eclipse/pde/internal/ui/editor/schema/NewElementAction.java 17 Jul 2007 18:41:33 -0000 1.14 >+++ src/org/eclipse/pde/internal/ui/editor/schema/NewElementAction.java 19 Jul 2007 19:53:55 -0000 >@@ -12,7 +12,6 @@ > > import org.eclipse.jface.action.Action; > import org.eclipse.pde.internal.core.ischema.ISchema; >-import org.eclipse.pde.internal.core.ischema.ISchemaElement; > import org.eclipse.pde.internal.core.schema.Schema; > import org.eclipse.pde.internal.core.schema.SchemaElement; > import org.eclipse.pde.internal.core.schema.SchemaRootElement; >@@ -29,16 +28,7 @@ > setToolTipText(PDEUIMessages.SchemaEditor_NewElement_tooltip); > } > private String getInitialName() { >- return PDELabelUtility.generateName(getElementNames(), PDEUIMessages.SchemaEditor_NewElement_initialName, false); >- } >- private String[] getElementNames() { >- if (schema == null) >- return new String[0]; >- ISchemaElement[] elements = schema.getElements(); >- String[] names = new String[elements.length]; >- for (int i = 0; i < elements.length; i++) >- names[i] = elements[i].getName(); >- return names; >+ return PDELabelUtility.generateName(schema.getElementNames(), PDEUIMessages.SchemaEditor_NewElement_initialName, false); > } > public org.eclipse.pde.internal.core.schema.Schema getSchema() { > return schema; >Index: src/org/eclipse/pde/internal/ui/util/PDELabelUtility.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/util/PDELabelUtility.java,v >retrieving revision 1.4 >diff -u -r1.4 PDELabelUtility.java >--- src/org/eclipse/pde/internal/ui/util/PDELabelUtility.java 17 Jul 2007 18:41:33 -0000 1.4 >+++ src/org/eclipse/pde/internal/ui/util/PDELabelUtility.java 19 Jul 2007 19:53:55 -0000 >@@ -128,7 +128,7 @@ > */ > private static void compareTitleWithBase(String base, boolean bracketed, HashSet set, String title) { > // Check to see it the name starts with the prefix >- if (title.startsWith(base)) { >+ if (title.toLowerCase().startsWith(base.toLowerCase())) { > // with brackets add on is: space, (, #, ) > int minSizeNumAddOn = 4; > if (!bracketed) >@@ -226,6 +226,23 @@ > PDELabelUtility.addNumberToBase(result, bracketed, set); > > return result.toString(); >- >+ } >+ >+ // Gets the base from a name that was generated by the generateName method. >+ public static String getBaseName(String name, boolean bracketed) { >+ String result = name; >+ if (bracketed){ >+ if (result.charAt(result.length()-1) != ')') >+ return name; >+ result = result.substring(0, result.length()-1); >+ } >+ while (Character.isDigit(result.charAt(result.length()-1))) >+ result = result.substring(0, result.length()-1); >+ if (bracketed) { >+ if (!result.substring(result.length()-2).equals(" (")) >+ return name; >+ result = result.substring(0, result.length()-2); >+ } >+ return result; > } > }
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
Actions:
View
|
Diff
Attachments on
bug 196866
:
74178
| 74185