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 89945 Details for
Bug 181515
Provide more structure, safety, and convenience for ID-based references between extension points (id hell)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
org.eclipse.pde.patch
clipboard.txt (text/plain), 32.79 KB, created by
Chris Aniszczyk
on 2008-02-17 13:49:55 EST
(
hide
)
Description:
org.eclipse.pde.patch
Filename:
MIME Type:
Creator:
Chris Aniszczyk
Created:
2008-02-17 13:49:55 EST
Size:
32.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.14 >diff -u -r1.14 ISchemaAttribute.java >--- src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java 2 Jan 2008 15:56:19 -0000 1.14 >+++ src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java 17 Feb 2008 18:44:17 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -43,7 +43,8 @@ > public static final String[] TYPES = {"boolean", //$NON-NLS-1$ > "string", //$NON-NLS-1$ > "java", //$NON-NLS-1$ >- "resource" //$NON-NLS-1$ >+ "resource", //$NON-NLS-1$ >+ "identifier" //$NON-NLS-1$ > }; > > /** >Index: src/org/eclipse/pde/internal/core/ischema/IMetaAttribute.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ischema/IMetaAttribute.java,v >retrieving revision 1.9 >diff -u -r1.9 IMetaAttribute.java >--- src/org/eclipse/pde/internal/core/ischema/IMetaAttribute.java 2 Jan 2008 15:56:19 -0000 1.9 >+++ src/org/eclipse/pde/internal/core/ischema/IMetaAttribute.java 17 Feb 2008 18:44:17 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -33,6 +33,14 @@ > public static final int RESOURCE = 2; > > /** >+ * Indicates that the value of the associated attribute is defined >+ * in another extension element attribute. >+ * >+ * @since 3.4 >+ */ >+ public static final int IDENTIFIER = 3; >+ >+ /** > * Property that indicates if an attribute is translatable > */ > public static final String P_TRANSLATABLE = "translatable"; //$NON-NLS-1$ >@@ -42,14 +50,9 @@ > */ > public static final String P_DEPRECATED = "deprecated"; //$NON-NLS-1$ > >- /* >- * non-Javadoc >- */ >- public static final String[] kindTable = {"string", "java", "resource"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- > /** > * Returns optional name of the Java type this type must be based on (only >- * for JAVA kind). >+ * for JAVA kind), or the path expression for IDENTIFIER kind. > */ > public String getBasedOn(); > >Index: src/org/eclipse/pde/internal/core/schema/SchemaAttribute.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/SchemaAttribute.java,v >retrieving revision 1.31 >diff -u -r1.31 SchemaAttribute.java >--- src/org/eclipse/pde/internal/core/schema/SchemaAttribute.java 9 Jan 2008 22:58:17 -0000 1.31 >+++ src/org/eclipse/pde/internal/core/schema/SchemaAttribute.java 17 Feb 2008 18:44:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,12 +12,7 @@ > package org.eclipse.pde.internal.core.schema; > > import java.io.PrintWriter; >- >-import org.eclipse.pde.internal.core.ischema.ISchema; >-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.ISchemaSimpleType; >+import org.eclipse.pde.internal.core.ischema.*; > import org.eclipse.pde.internal.core.util.SchemaUtil; > import org.eclipse.pde.internal.core.util.XMLComponentRegistry; > >@@ -67,7 +62,9 @@ > } > > public String getBasedOn() { >- return getKind() == JAVA ? basedOn : null; >+ if (getKind() == JAVA || getKind() == IDENTIFIER) >+ return basedOn; >+ return null; > } > > public int getKind() { >@@ -190,13 +187,15 @@ > writer.println(indent2 + "<appinfo>"); //$NON-NLS-1$ > writer.print(indent3 + "<meta.attribute"); //$NON-NLS-1$ > String kindValue = null; >- switch (getKind()) { >+ switch (getKind()) { // TODO let's use some constants ;D > case JAVA : > kindValue = "java"; //$NON-NLS-1$ > break; > case RESOURCE : > kindValue = "resource"; //$NON-NLS-1$ > break; >+ case IDENTIFIER : >+ kindValue = "identifier"; //$NON-NLS-1$ > } > if (kindValue != null) > writer.print(" kind=\"" + kindValue + "\""); //$NON-NLS-1$ //$NON-NLS-2$ >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.72 >diff -u -r1.72 Schema.java >--- src/org/eclipse/pde/internal/core/schema/Schema.java 9 Jan 2008 22:58:17 -0000 1.72 >+++ src/org/eclipse/pde/internal/core/schema/Schema.java 17 Feb 2008 18:44:19 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,43 +11,16 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.core.schema; > >-import java.io.FileNotFoundException; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.PrintWriter; >+import java.io.*; > import java.net.URL; >-import java.util.Collections; >-import java.util.Iterator; >-import java.util.Locale; >-import java.util.Vector; >- >+import java.util.*; > import org.eclipse.core.runtime.PlatformObject; >-import org.eclipse.pde.core.IModelChangedEvent; >-import org.eclipse.pde.core.IModelChangedListener; >-import org.eclipse.pde.core.ModelChangedEvent; >+import org.eclipse.pde.core.*; > import org.eclipse.pde.internal.core.PDECore; > import org.eclipse.pde.internal.core.XMLDefaultHandler; >-import org.eclipse.pde.internal.core.ischema.IDocumentSection; >-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.ISchemaCompositor; >-import org.eclipse.pde.internal.core.ischema.ISchemaDescriptor; >-import org.eclipse.pde.internal.core.ischema.ISchemaElement; >-import org.eclipse.pde.internal.core.ischema.ISchemaEnumeration; >-import org.eclipse.pde.internal.core.ischema.ISchemaInclude; >-import org.eclipse.pde.internal.core.ischema.ISchemaObject; >-import org.eclipse.pde.internal.core.ischema.ISchemaObjectReference; >-import org.eclipse.pde.internal.core.ischema.ISchemaRootElement; >-import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType; >-import org.eclipse.pde.internal.core.ischema.ISchemaType; >-import org.eclipse.pde.internal.core.util.PDEXMLHelper; >-import org.eclipse.pde.internal.core.util.SAXParserWrapper; >-import org.eclipse.pde.internal.core.util.SchemaUtil; >-import org.w3c.dom.NamedNodeMap; >-import org.w3c.dom.Node; >-import org.w3c.dom.NodeList; >+import org.eclipse.pde.internal.core.ischema.*; >+import org.eclipse.pde.internal.core.util.*; >+import org.w3c.dom.*; > import org.xml.sax.SAXException; > > public class Schema extends PlatformObject implements ISchema { >@@ -716,6 +689,8 @@ > return IMetaAttribute.JAVA; > if (name.equals("resource")) //$NON-NLS-1$ > return IMetaAttribute.RESOURCE; >+ if (name.equals("identifier")) //$NON-NLS-1$ >+ return IMetaAttribute.IDENTIFIER; > } > return IMetaAttribute.STRING; > } >#P org.eclipse.pde.ui >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.358 >diff -u -r1.358 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 15 Feb 2008 21:13:05 -0000 1.358 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 17 Feb 2008 18:44:36 -0000 >@@ -1081,6 +1081,10 @@ > public static String ResourceAttributeCellEditor_title; > public static String ResourceAttributeCellEditor_message; > >+ public static String IdAttributeRow_title; >+ public static String IdAttributeRow_message; >+ public static String IdAttributeRow_emptyMessage; >+ > public static String ManifestEditor_RuntimeForm_title; > public static String ManifestSourcePage_extensionPoints; > >@@ -2607,27 +2611,19 @@ > public static String SchemaDetails_deprecated; > > public static String SchemaAttributeDetails_use; >- > public static String SchemaAttributeDetails_type; >- > public static String SchemaAttributeDetails_restrictions; >- > public static String SchemaAttributeDetails_addRestButton; >- > public static String SchemaAttributeDetails_removeRestButton; >- > public static String SchemaAttributeDetails_extends; >- > public static String SchemaAttributeDetails_browseButton; >- > public static String SchemaAttributeDetails_implements; >- > public static String SchemaAttributeDetails_title; >- > public static String SchemaAttributeDetails_description; >- > public static String SchemaAttributeDetails_defaultDefaultValue; > >+ public static String SchemaStringAttributeDetails_reference; >+ > public static String SchemaDetails_name; > > public static String SchemaRootElementDetails_replacement; >@@ -3195,4 +3191,8 @@ > public static String FilteredPluginArtifactsSelectionDialog_showExtensionPoints; > public static String FilteredPluginArtifactsSelectionDialog_showExportedPackages; > >+ public static String FilteredSchemaAttributeSelectionDialog_title; >+ public static String FilteredSchemaAttributeSelectionDialog_message; >+ public static String FilteredSchemaAttributeSelectionDialog_searching; >+ > } >\ No newline at end of file >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.967 >diff -u -r1.967 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 15 Feb 2008 21:13:04 -0000 1.967 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 17 Feb 2008 18:44:45 -0000 >@@ -2474,4 +2474,11 @@ > FilteredPluginArtifactsSelectionDialog_searching=Searching... > FilteredPluginArtifactsSelectionDialog_showExtensions=Show Extensions > FilteredPluginArtifactsSelectionDialog_showExtensionPoints=Show Extension Points >-FilteredPluginArtifactsSelectionDialog_showExportedPackages=Show Exported Packages >\ No newline at end of file >+FilteredPluginArtifactsSelectionDialog_showExportedPackages=Show Exported Packages >+SchemaStringAttributeDetails_reference=Reference: >+IdAttributeRow_title=Select Identifier >+IdAttributeRow_message=Select an identifier: >+IdAttributeRow_emptyMessage=No identifiers found >+FilteredSchemaAttributeSelectionDialog_title=Select Attribute >+FilteredSchemaAttributeSelectionDialog_message=&Select an attribute (? = any character, * = any string): >+FilteredSchemaAttributeSelectionDialog_searching=Searching... >\ No newline at end of file >Index: src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionElementDetails.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionElementDetails.java,v >retrieving revision 1.28 >diff -u -r1.28 ExtensionElementDetails.java >--- src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionElementDetails.java 16 Jan 2008 17:07:46 -0000 1.28 >+++ src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionElementDetails.java 17 Feb 2008 18:44:45 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2007 IBM Corporation and others. >+ * Copyright (c) 2003, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Provide more structure, safety, and convenience for ID-based references between extension points (id hell) > *******************************************************************************/ > package org.eclipse.pde.internal.ui.editor.plugin; > >@@ -86,11 +87,13 @@ > > if (schemaElement != null) { > ISchemaAttribute atts[] = schemaElement.getAttributes(); >- // Compute horizontal span >- for (int i = 0; i < atts.length; i++) { >- if (isEditable() && (atts[i].getKind() == IMetaAttribute.JAVA || atts[i].getKind() == IMetaAttribute.RESOURCE)) { >- span = 3; >- break; >+ if (isEditable()) { >+ // Compute horizontal span >+ for (int i = 0; i < atts.length; i++) { >+ if (atts[i].getKind() == IMetaAttribute.JAVA || atts[i].getKind() == IMetaAttribute.RESOURCE || atts[i].getKind() == IMetaAttribute.IDENTIFIER) { >+ span = 3; >+ break; >+ } > } > } > glayout.numColumns = span; >@@ -125,6 +128,8 @@ > row = new ClassAttributeRow(this, att); > else if (att.getKind() == IMetaAttribute.RESOURCE) > row = new ResourceAttributeRow(this, att); >+ else if (att.getKind() == IMetaAttribute.IDENTIFIER) >+ row = new IdAttributeRow(this, att); > else if (att.isTranslatable()) > row = new TranslatableAttributeRow(this, att); > else { >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.24 >diff -u -r1.24 SchemaFormPage.java >--- src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java 16 Jan 2008 17:08:11 -0000 1.24 >+++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java 17 Feb 2008 18:44:45 -0000 >@@ -56,6 +56,7 @@ > detailsPart.registerPage(SchemaStringAttributeDetails.class, new SchemaStringAttributeDetails(fSection)); > detailsPart.registerPage(SchemaJavaAttributeDetails.class, new SchemaJavaAttributeDetails(fSection)); > detailsPart.registerPage(SchemaOtherAttributeDetails.class, new SchemaOtherAttributeDetails(fSection)); >+ detailsPart.registerPage(SchemaIdentifierAttributeDetails.class, new SchemaIdentifierAttributeDetails(fSection)); > detailsPart.setPageProvider(this); > } > >@@ -77,6 +78,8 @@ > case IMetaAttribute.STRING : > if (att.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND])) > return SchemaStringAttributeDetails.class; >+ case IMetaAttribute.IDENTIFIER : >+ return SchemaIdentifierAttributeDetails.class; > } > return SchemaOtherAttributeDetails.class; > } else >Index: src/org/eclipse/pde/internal/ui/editor/schema/SchemaIdentifierAttributeDetails.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/schema/SchemaIdentifierAttributeDetails.java >diff -N src/org/eclipse/pde/internal/ui/editor/schema/SchemaIdentifierAttributeDetails.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/schema/SchemaIdentifierAttributeDetails.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.schema; >+ >+import org.eclipse.jface.window.Window; >+import org.eclipse.pde.internal.core.ischema.*; >+import org.eclipse.pde.internal.core.schema.SchemaAttribute; >+import org.eclipse.pde.internal.ui.PDEPlugin; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.editor.FormEntryAdapter; >+import org.eclipse.pde.internal.ui.parts.FormEntry; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+ >+public class SchemaIdentifierAttributeDetails extends SchemaAttributeDetails { >+ >+ private FormEntry fReferenceEntry; >+ >+ public SchemaIdentifierAttributeDetails(ElementSection section) { >+ super(section); >+ } >+ >+ protected void createTypeDetails(Composite parent, FormToolkit toolkit) { >+ fReferenceEntry = new FormEntry(parent, toolkit, PDEUIMessages.SchemaStringAttributeDetails_reference, PDEUIMessages.SchemaAttributeDetails_browseButton, false, 11); >+ } >+ >+ public void updateFields(ISchemaObject object) { >+ if (!(object instanceof SchemaAttribute)) >+ return; >+ super.updateFields(object); >+ >+ boolean editable = isEditableElement(); >+ fReferenceEntry.setEditable(editable); >+ } >+ >+ public void hookListeners() { >+ super.hookListeners(); >+ IActionBars actionBars = getPage().getPDEEditor().getEditorSite().getActionBars(); >+ fReferenceEntry.setFormEntryListener(new FormEntryAdapter(this, actionBars) { >+ public void textValueChanged(FormEntry entry) { >+ if (blockListeners()) >+ return; >+ getAttribute().setBasedOn(entry.getValue()); >+ } >+ >+ public void browseButtonSelected(FormEntry entry) { >+ if (blockListeners()) >+ return; >+ doOpenSelectionDialog(fReferenceEntry); >+ } >+ }); >+ } >+ >+ private void doOpenSelectionDialog(FormEntry entry) { >+ FilteredSchemaAttributeSelectionDialog dialog = new FilteredSchemaAttributeSelectionDialog(PDEPlugin.getActiveWorkbenchShell()); >+ int status = dialog.open(); >+ if (status == Window.OK) { >+ Object[] result = dialog.getResult(); >+ Object object = result[0]; >+ if (object instanceof ISchemaAttribute) { >+ ISchemaAttribute attribute = (ISchemaAttribute) object; >+ String schemaId = attribute.getSchema().getQualifiedPointId(); >+ String refId = buildBasedOnValue(attribute); >+ String id = schemaId + '/' + refId; >+ entry.setValue(id); >+ } >+ } >+ } >+ >+ // TODO faulty recursion... this doesn't work in all cases probably... >+ private String buildBasedOnValue(ISchemaObject object) { >+ if (object instanceof ISchemaElement) >+ return object.getName() + '/' + buildBasedOnValue(object.getParent()); >+ return ""; //$NON-NLS-1$ >+ } >+ >+ private String buildBasedOnValue(ISchemaAttribute attribute) { >+ return buildBasedOnValue(attribute.getParent()) + "@" + attribute.getName(); //$NON-NLS-1$ >+ } >+ >+} >Index: src/org/eclipse/pde/internal/ui/editor/plugin/rows/IdAttributeRow.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/plugin/rows/IdAttributeRow.java >diff -N src/org/eclipse/pde/internal/ui/editor/plugin/rows/IdAttributeRow.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/plugin/rows/IdAttributeRow.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Remy Chi Jian Suen <remy.suen@gmail.com> - Provide more structure, safety, and convenience for ID-based references between extension points (id hell) >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.plugin.rows; >+ >+import java.util.*; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.window.Window; >+import org.eclipse.pde.core.plugin.IPluginModelBase; >+import org.eclipse.pde.core.plugin.PluginRegistry; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.pde.internal.ui.editor.IContextPart; >+import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.ui.dialogs.ElementListSelectionDialog; >+ >+public class IdAttributeRow extends ButtonAttributeRow { >+ >+ private class IdAttributeLabelProvider extends LabelProvider { >+ >+ public Image getImage(Object element) { >+ return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_GENERIC_XML_OBJ); >+ } >+ >+ } >+ >+ public IdAttributeRow(IContextPart part, ISchemaAttribute att) { >+ super(part, att); >+ } >+ >+ protected boolean isReferenceModel() { >+ return !part.getPage().getModel().isEditable(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ButtonAttributeRow#browse() >+ */ >+ protected void browse() { >+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), new IdAttributeLabelProvider()); >+ dialog.setTitle(PDEUIMessages.IdAttributeRow_title); >+ dialog.setMessage(PDEUIMessages.IdAttributeRow_message); >+ dialog.setEmptyListMessage(PDEUIMessages.IdAttributeRow_emptyMessage); >+ Map attributeMap = new HashMap(); >+ gatherInfo(attributeMap); >+ dialog.setElements(attributeMap.keySet().toArray()); >+ if (dialog.open() == Window.OK) { >+ text.setText(dialog.getFirstResult().toString()); >+ } >+ } >+ >+ private void gatherInfo(Map attributesInfo) { >+ String basedOn = getAttribute().getBasedOn(); >+ String[] path = basedOn.split("/"); //$NON-NLS-1$ >+ IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions(path[0], true); >+ List members = new ArrayList(); >+ for (int i = 0; i < extensions.length; i++) { >+ IConfigurationElement[] elements = extensions[i].getConfigurationElements(); >+ for (int j = 0; j < elements.length; j++) { >+ if (elements[j].getName().equals(path[1])) { >+ members.add(elements[j]); >+ } >+ } >+ } >+ List parents = members; >+ for (int i = 2; i < path.length; i++) { >+ if (path[i].startsWith("@")) { //$NON-NLS-1$ >+ String attName = path[i].substring(1); >+ for (Iterator iterator = parents.iterator(); iterator.hasNext();) { >+ IConfigurationElement element = (IConfigurationElement) iterator.next(); >+ String value = element.getAttribute(attName); >+ if (value != null) { >+ attributesInfo.put(value, element); >+ } >+ } >+ return; >+ } >+ members = new ArrayList(); >+ for (Iterator iterator = parents.iterator(); iterator.hasNext();) { >+ IConfigurationElement element = (IConfigurationElement) iterator.next(); >+ members.addAll(keepGoing(element, path[i])); >+ } >+ parents = members; >+ } >+ } >+ >+ private List keepGoing(IConfigurationElement element, String tag) { >+ return Arrays.asList(element.getChildren(tag)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ReferenceAttributeRow#openReference() >+ */ >+ protected void openReference() { >+ Map attributeMap = new HashMap(); >+ gatherInfo(attributeMap); >+ String id = text.getText(); >+ // TODO this is a hack, consider not even supporting openReference >+ IConfigurationElement element = (IConfigurationElement) attributeMap.get(id); >+ if (element != null) { >+ String pluginId = element.getContributor().getName(); >+ IPluginModelBase model = PluginRegistry.findModel(pluginId); >+// IExtensions e = model.getExtensions(); // can be null >+// IPluginExtension[] extensions = e.getExtensions(); >+// for (int i = 0; i < extensions.length; i++) { >+// IPluginExtension extension = extensions[i]; >+// } >+ >+ ManifestEditor.openPluginEditor(model, true); >+ } >+ } >+} >Index: src/org/eclipse/pde/internal/ui/editor/schema/FilteredSchemaAttributeSelectionDialog.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/schema/FilteredSchemaAttributeSelectionDialog.java >diff -N src/org/eclipse/pde/internal/ui/editor/schema/FilteredSchemaAttributeSelectionDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/editor/schema/FilteredSchemaAttributeSelectionDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,194 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.editor.schema; >+ >+import java.util.Comparator; >+import org.eclipse.core.runtime.*; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.viewers.ILabelDecorator; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.pde.core.plugin.*; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.ischema.*; >+import org.eclipse.pde.internal.core.schema.SchemaRegistry; >+import org.eclipse.pde.internal.core.util.IdUtil; >+import org.eclipse.pde.internal.ui.*; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; >+ >+public class FilteredSchemaAttributeSelectionDialog extends FilteredItemsSelectionDialog { >+ >+ private static final String DIALOG_SETTINGS = "org.eclipse.pde.ui.dialogs.SchemaAttributeFilteredItemsSelectionDialog"; //$NON-NLS-1$ >+ private final SchemaListLabelProvider listLabelProvider = new SchemaListLabelProvider(); >+ private final SchemaDetailsLabelProvider detailsLabelProvider = new SchemaDetailsLabelProvider(); >+ >+ public FilteredSchemaAttributeSelectionDialog(Shell shell) { >+ super(shell, false); >+ >+ setTitle(PDEUIMessages.FilteredSchemaAttributeSelectionDialog_title); >+ setMessage(PDEUIMessages.FilteredSchemaAttributeSelectionDialog_message); >+ >+ PDEPlugin.getDefault().getLabelProvider().connect(this); >+ setListLabelProvider(listLabelProvider); >+ setListSelectionLabelDecorator(listLabelProvider); >+ setDetailsLabelProvider(detailsLabelProvider); >+ } >+ >+ private class SchemaListLabelProvider extends LabelProvider implements ILabelDecorator { >+ public Image getImage(Object element) { >+ return PDEPlugin.getDefault().getLabelProvider().getImage(element); >+ } >+ >+ public String getText(Object element) { >+ if (element instanceof ISchemaAttribute) { >+ ISchemaAttribute attribute = (ISchemaAttribute) element; >+ String text = PDEPlugin.getDefault().getLabelProvider().getText(element); >+ if (isDuplicateElement(element)) { >+ ISchemaObject object = attribute.getParent(); >+ if (object != null) >+ return text + " - " + attribute.getParent().getName(); //$NON-NLS-1$ >+ } >+ } >+ return PDEPlugin.getDefault().getLabelProvider().getText(element); >+ } >+ >+ public Image decorateImage(Image image, Object element) { >+ return image; // nothing to decorate >+ } >+ >+ public String decorateText(String text, Object element) { >+ if (element instanceof ISchemaAttribute) { >+ ISchemaAttribute attribute = (ISchemaAttribute) element; >+ ISchemaObject object = attribute.getParent(); >+ if (object != null && !isDuplicateElement(element)) >+ return text + " - " + attribute.getParent().getName(); //$NON-NLS-1$ >+ } >+ return text; >+ } >+ >+ } >+ >+ private class SchemaDetailsLabelProvider extends LabelProvider { >+ >+ public Image getImage(Object element) { >+ return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_EXT_POINT_OBJ); >+ } >+ >+ public String getText(Object element) { >+ if (element instanceof ISchemaAttribute) { >+ ISchemaAttribute attribute = (ISchemaAttribute) element; >+ ISchema schema = attribute.getSchema(); >+ return schema.getPointId() + ' ' + '(' + schema.getPluginId() + ')'; >+ } >+ return super.getText(element); >+ } >+ } >+ >+ private class SchemaItemsFilter extends ItemsFilter { >+ >+ public boolean isConsistentItem(Object item) { >+ return true; >+ } >+ >+ public boolean matchItem(Object item) { >+ if (item instanceof ISchemaAttribute) { >+ ISchemaAttribute attribute = (ISchemaAttribute) item; >+ return matches(attribute.getName()); >+ } >+ return false; >+ } >+ >+ } >+ >+ private class SchemaComparator implements Comparator { >+ >+ public int compare(Object arg0, Object arg1) { >+ return 0; >+ } >+ >+ } >+ >+ protected ItemsFilter createFilter() { >+ return new SchemaItemsFilter(); >+ } >+ >+ protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException { >+ >+ IPluginModelBase[] models = PluginRegistry.getActiveModels(); >+ SchemaRegistry registry = PDECore.getDefault().getSchemaRegistry(); >+ >+ // cycle through all active plug-ins and their extension points >+ progressMonitor.beginTask(PDEUIMessages.FilteredSchemaAttributeSelectionDialog_searching, models.length); >+ for (int i = 0; i < models.length; i++) { >+ IPluginExtensionPoint[] points = models[i].getPluginBase().getExtensionPoints(); >+ >+ for (int j = 0; j < points.length; j++) { >+ String pointID = IdUtil.getFullId(points[j], models[i]); >+ >+ ISchema schema = registry.getSchema(pointID); >+ if (schema == null) // if we don't find a schema >+ continue; >+ ISchemaElement[] elements = schema.getElements(); >+ >+ for (int k = 0; k < elements.length; k++) { >+ ISchemaElement element = elements[k]; >+ ISchemaAttribute[] attributes = element.getAttributes(); >+ >+ for (int l = 0; l < attributes.length; l++) { >+ ISchemaAttribute attribute = attributes[l]; >+ // only add attributes of the string kind, isn't translatable and is required >+ if (attribute.getKind() == IMetaAttribute.STRING && !attribute.isTranslatable() && attribute.getUse() == ISchemaAttribute.REQUIRED) >+ contentProvider.add(attribute, itemsFilter); >+ } >+ } >+ } >+ progressMonitor.worked(1); >+ } >+ >+ progressMonitor.done(); >+ >+ } >+ >+ protected IDialogSettings getDialogSettings() { >+ IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS); >+ if (settings == null) { >+ settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS); >+ } >+ return settings; >+ } >+ >+ public String getElementName(Object item) { >+ if (item instanceof ISchemaAttribute) { >+ ISchemaAttribute attribute = (ISchemaAttribute) item; >+ return attribute.getName(); >+ } >+ return null; >+ } >+ >+ protected Comparator getItemsComparator() { >+ return new SchemaComparator(); >+ } >+ >+ protected IStatus validateItem(Object item) { >+ return new Status(IStatus.OK, "org.eclipse.pde.ui", 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ public boolean close() { >+ PDEPlugin.getDefault().getLabelProvider().disconnect(this); >+ return super.close(); >+ } >+ >+ protected Control createExtendedContentArea(Composite parent) { >+ return null; >+ } >+ >+}
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 181515
:
63844
|
64350
|
89585
|
89861
|
89892
| 89945 |
89946
|
89948
|
89999
|
90000
|
90001
|
90002
|
90010
|
90011
|
90013