### Eclipse Workspace Patch 1.0 #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.33 diff -u -r1.33 SchemaAttributeDetails.java --- src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java 19 Jul 2007 20:29:27 -0000 1.33 +++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java 19 Jul 2007 21:16:24 -0000 @@ -36,22 +36,6 @@ public abstract class SchemaAttributeDetails extends AbstractSchemaDetails { - private static final String JAVA_TYPE = "java"; //$NON-NLS-1$ - private static final String RESOURCE_TYPE = "resource"; //$NON-NLS-1$ - protected static final int BOOL_IND = 0; - protected static final int STR_IND = 1; - protected static final int JAVA_IND = 2; - protected static final int RES_IND = 3; - protected static final String[] TYPES = new String[4]; - static { - TYPES[BOOL_IND]= BOOLEAN_TYPE; - TYPES[STR_IND] = STRING_TYPE; - TYPES[JAVA_IND] = JAVA_TYPE; - TYPES[RES_IND] = RESOURCE_TYPE; - } - private static final String[] USE = - new String[] {"optional", "required", "default"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - private SchemaAttribute fAttribute; private FormEntry fValue; private FormEntry fName; @@ -88,13 +72,13 @@ label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_type); label.setForeground(foreground); - fType = createComboPart(parent, toolkit, TYPES, 2); + fType = createComboPart(parent, toolkit, ISchemaAttribute.TYPES, 2); createTypeDetails(parent, toolkit); label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_use); label.setForeground(foreground); - fUse = createComboPart(parent, toolkit, USE, 2); + fUse = createComboPart(parent, toolkit, ISchemaAttribute.USE_TABLE, 2); fValue = new FormEntry(parent, toolkit, PDEUIMessages.SchemaAttributeDetails_defaultValue, null, false, 6); @@ -113,7 +97,7 @@ fDepTrue.setSelection(fAttribute.isDeprecated()); fDepFalse.setSelection(!fAttribute.isDeprecated()); - boolean isStringType = fAttribute.getType().getName().equals(STRING_TYPE); + boolean isStringType = fAttribute.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND]); int kind = fAttribute.getKind(); fType.select(isStringType ? 1 + kind : 0); @@ -183,8 +167,8 @@ if (blockListeners()) return; String typeString = fType.getSelection(); - if (!typeString.equals(BOOLEAN_TYPE)) - typeString = STRING_TYPE; + if (!typeString.equals(ISchemaAttribute.TYPES[ISchemaAttribute.BOOL_IND])) + typeString = ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND]; fAttribute.setType(new SchemaSimpleType(fAttribute.getSchema(), typeString)); 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.25 diff -u -r1.25 SchemaElementDetails.java --- src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java 19 Jul 2007 20:29:27 -0000 1.25 +++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java 19 Jul 2007 21:16:24 -0000 @@ -10,13 +10,9 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.editor.schema; -import java.util.ArrayList; - 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.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; @@ -25,7 +21,6 @@ import org.eclipse.pde.internal.core.schema.SchemaElementReference; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; -import org.eclipse.pde.internal.ui.parts.ComboPart; import org.eclipse.pde.internal.ui.parts.FormEntry; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -41,8 +36,6 @@ private SchemaElement fElement; private FormEntry fName; - private ComboPart fLabelProperty; - private ComboPart fIcon; private Button fDepTrue; private Button fDepFalse; private Button fTransTrue; @@ -63,14 +56,6 @@ Button[] buttons = createTrueFalseButtons(parent, toolkit, 2); fDepTrue = buttons[0]; fDepFalse = buttons[1]; - - label = toolkit.createLabel(parent, PDEUIMessages.SchemaElementDetails_labelProperty); - label.setForeground(foreground); - fLabelProperty = createComboPart(parent, toolkit, new String[0], 2); - - label = toolkit.createLabel(parent, PDEUIMessages.SchemaElementDetails_icon); - label.setForeground(foreground); - fIcon = createComboPart(parent, toolkit, new String[0], 2); label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_translatable); label.setForeground(foreground); @@ -89,12 +74,6 @@ return; setDecription(NLS.bind(PDEUIMessages.SchemaElementDetails_description, fElement.getName())); fName.setValue(fElement.getName(), true); - String labProp = fElement.getLabelProperty(); - fLabelProperty.setItems(getLabelItems()); - fLabelProperty.setText(labProp != null ? labProp : ""); //$NON-NLS-1$ - String icProp = fElement.getIconProperty(); - fIcon.setItems(getIconItems()); - fIcon.setText(icProp != null ? icProp : ""); //$NON-NLS-1$ fDepTrue.setSelection(fElement.isDeprecated()); fDepFalse.setSelection(!fElement.isDeprecated()); @@ -109,8 +88,6 @@ fTransFalse.setSelection(!fElement.hasTranslatableContent()); boolean editable = isEditableElement(); - fIcon.setEnabled(editable); - fLabelProperty.setEnabled(editable); fName.setEditable(editable); fDepTrue.setEnabled(editable); @@ -120,28 +97,6 @@ } public void hookListeners() { - fIcon.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (blockListeners()) - return; - String icon = fIcon.getSelection(); - if (icon == null || icon.equals("")) //$NON-NLS-1$ - fElement.setIconProperty(null); - else - fElement.setIconProperty(icon); - } - }); - fLabelProperty.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (blockListeners()) - return; - String label = fLabelProperty.getSelection(); - if (label == null || label.equals("")) //$NON-NLS-1$ - fElement.setLabelProperty(null); - else - fElement.setLabelProperty(label); - } - }); fName.setFormEntryListener(new FormEntryAdapter(this) { public void textValueChanged(FormEntry entry) { if (blockListeners()) @@ -183,28 +138,6 @@ }); } - private String[] getIconItems() { - ISchemaAttribute[] attribs = fElement.getAttributes(); - ArrayList list = new ArrayList(); - list.add(""); //$NON-NLS-1$ - for (int i = 0; i < attribs.length; i++) { - if (attribs[i].getKind() == IMetaAttribute.RESOURCE) { - list.add(attribs[i].getName()); - } - } - return (String[]) list.toArray(new String[list.size()]); - } - - private String[] getLabelItems() { - ISchemaAttribute[] attribs = fElement.getAttributes(); - String[] labels = new String[attribs.length + 1]; - labels[0] = ""; //$NON-NLS-1$ - for (int i = 0; i < attribs.length; i++) { - labels[i + 1] = attribs[i].getName(); - } - return labels; - } - public void modelChanged(IModelChangedEvent event) { Object[] changedObjs = event.getChangedObjects(); if(event.getChangeType() == IModelChangedEvent.INSERT && changedObjs.length > 0) { Index: src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java,v retrieving revision 1.22 diff -u -r1.22 SchemaFormPage.java --- src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java 18 Jul 2007 23:17:14 -0000 1.22 +++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java 19 Jul 2007 21:16:24 -0000 @@ -9,8 +9,6 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.pde.internal.ui.editor.schema; -import java.util.Arrays; - import org.eclipse.jface.action.ControlContribution; import org.eclipse.pde.core.IModelChangedEvent; import org.eclipse.pde.core.IModelChangedListener; @@ -88,9 +86,7 @@ case IMetaAttribute.JAVA : return SchemaJavaAttributeDetails.class; case IMetaAttribute.STRING : - int typeIndex = Arrays.binarySearch(SchemaAttributeDetails.TYPES, - att.getType().getName()); - if (typeIndex == SchemaAttributeDetails.STR_IND) + if (att.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND])) return SchemaStringAttributeDetails.class; } return SchemaOtherAttributeDetails.class; Index: src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java,v retrieving revision 1.21 diff -u -r1.21 AbstractSchemaDetails.java --- src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java 19 Jul 2007 18:17:07 -0000 1.21 +++ src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java 19 Jul 2007 21:16:24 -0000 @@ -44,8 +44,6 @@ public abstract class AbstractSchemaDetails extends PDEDetails { - protected static final String STRING_TYPE = "string"; //$NON-NLS-1$ - protected static final String BOOLEAN_TYPE = "boolean"; //$NON-NLS-1$ protected static final String[] BOOLS = new String[] { Boolean.toString(true), Boolean.toString(false) }; Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v retrieving revision 1.300 diff -u -r1.300 PDEUIMessages.java --- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 18 Jul 2007 23:17:14 -0000 1.300 +++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 19 Jul 2007 21:16:21 -0000 @@ -2396,10 +2396,6 @@ public static String SchemaIncludesSection_dialogMessage; - public static String SchemaElementDetails_labelProperty; - - public static String SchemaElementDetails_icon; - public static String SchemaDetails_translatable; public static String SchemaElementDetails_title; 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.892 diff -u -r1.892 pderesources.properties --- src/org/eclipse/pde/internal/ui/pderesources.properties 19 Jul 2007 15:58:29 -0000 1.892 +++ src/org/eclipse/pde/internal/ui/pderesources.properties 19 Jul 2007 21:16:23 -0000 @@ -400,7 +400,6 @@ SchemaIncludesSection_missingWarningMessage={0} could not be found. SchemaEditor_NewCompositor_tooltip = New {0} -SchemaElementDetails_labelProperty=Label Property: SchemaElementReferenceDetails_reference=Reference: SchemaAttributeDetails_removeRestButton=Remove SchemaElementReferenceDetails_title=Element Reference Details @@ -415,7 +414,6 @@ SchemaIncludesSection_title=Schema Inclusions SchemaAttributeDetails_type=Type: SchemaEditor_DocPage_title = Overview -SchemaElementDetails_icon=Icon: SchemaElementDetails_title=Element Details SchemaElementDetails_rootTitle=Extension Element Details SchemaAttributeDetails_use=Use: #P org.eclipse.pde.core Index: src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java,v retrieving revision 1.12 diff -u -r1.12 ISchemaAttribute.java --- src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java 3 May 2006 13:30:09 -0000 1.12 +++ src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java 19 Jul 2007 21:16:28 -0000 @@ -34,9 +34,20 @@ /** * Table of the 'use' clause choices. */ - public static final String[] useTable = { + public static final String[] USE_TABLE = { "optional", "required", "default" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + public static final int BOOL_IND = 0; + public static final int STR_IND = 1; + public static final int JAVA_IND = 2; + public static final int RES_IND = 3; + public static final String[] TYPES = { + "boolean", //$NON-NLS-1$ + "string", //$NON-NLS-1$ + "java", //$NON-NLS-1$ + "resource" //$NON-NLS-1$ + }; + /** * Returns the type of this attribute. Attributes can only have simple * types. 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.25 diff -u -r1.25 SchemaElement.java --- src/org/eclipse/pde/internal/core/schema/SchemaElement.java 19 Jul 2007 20:29:28 -0000 1.25 +++ src/org/eclipse/pde/internal/core/schema/SchemaElement.java 19 Jul 2007 21:16:28 -0000 @@ -12,6 +12,7 @@ import java.io.PrintWriter; +import org.eclipse.pde.internal.core.ischema.IMetaAttribute; import org.eclipse.pde.internal.core.ischema.ISchema; import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; import org.eclipse.pde.internal.core.ischema.ISchemaComplexType; @@ -158,11 +159,36 @@ } public String getIconProperty() { - return iconName; + if (iconName != null) + return iconName; + String result = null; + ISchemaAttribute[] attributes = getAttributes(); + for (int i = 0; i < attributes.length && result == null; i++) { + if (isValidIconProperty(attributes[i])) + result = attributes[i].getName(); + } + return result; } public String getLabelProperty() { - return labelProperty; + if (labelProperty != null) + return labelProperty; + String result = null; + ISchemaAttribute[] attributes = getAttributes(); + for (int i = 0; i < attributes.length && result == null; i++) { + if (isValidLabelProperty(attributes[i])) + result = attributes[i].getName(); + } + return result; + } + + private boolean isValidLabelProperty(ISchemaAttribute a) { + return a.getKind() == IMetaAttribute.STRING && + a.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND]) && + a.isTranslatable(); + } + private boolean isValidIconProperty(ISchemaAttribute a) { + return a.getKind() == IMetaAttribute.RESOURCE; } public ISchemaType getType() {