Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 181515 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/schema/SchemaAttribute.java (-1 / +3 lines)
Lines 67-73 Link Here
67
	}
67
	}
68
68
69
	public String getBasedOn() {
69
	public String getBasedOn() {
70
		return getKind() == JAVA ? basedOn : null;
70
		if (getKind() == JAVA || getKind() == XML_PATH)
71
			return basedOn;
72
		return null;
71
	}
73
	}
72
74
73
	public int getKind() {
75
	public int getKind() {
(-)src/org/eclipse/pde/internal/core/schema/Schema.java (+2 lines)
Lines 716-721 Link Here
716
				return IMetaAttribute.JAVA;
716
				return IMetaAttribute.JAVA;
717
			if (name.equals("resource")) //$NON-NLS-1$
717
			if (name.equals("resource")) //$NON-NLS-1$
718
				return IMetaAttribute.RESOURCE;
718
				return IMetaAttribute.RESOURCE;
719
			if (name.equals("xml_path")) //$NON-NLS-1$
720
				return IMetaAttribute.XML_PATH;
719
		}
721
		}
720
		return IMetaAttribute.STRING;
722
		return IMetaAttribute.STRING;
721
	}
723
	}
(-)src/org/eclipse/pde/internal/core/ischema/IMetaAttribute.java (-1 / +9 lines)
Lines 33-38 Link Here
33
	public static final int RESOURCE = 2;
33
	public static final int RESOURCE = 2;
34
34
35
	/**
35
	/**
36
	 * Indicates that the value of the associated attribute is defined
37
	 * in another extension element attribute.
38
	 * 
39
	 * @since 3.4
40
	 */
41
	public static final int XML_PATH = 3;
42
43
	/**
36
	 * Property that indicates if an attribute is translatable
44
	 * Property that indicates if an attribute is translatable
37
	 */
45
	 */
38
	public static final String P_TRANSLATABLE = "translatable"; //$NON-NLS-1$
46
	public static final String P_TRANSLATABLE = "translatable"; //$NON-NLS-1$
Lines 49-55 Link Here
49
57
50
	/**
58
	/**
51
	 * Returns optional name of the Java type this type must be based on (only
59
	 * Returns optional name of the Java type this type must be based on (only
52
	 * for JAVA kind).
60
	 * for JAVA kind), or the XML XPath (almost) for XML_PATH kind.
53
	 */
61
	 */
54
	public String getBasedOn();
62
	public String getBasedOn();
55
63
(-)src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionElementDetails.java (-6 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Provide more structure, safety, and convenience for ID-based references between extension points (id hell)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.plugin;
12
package org.eclipse.pde.internal.ui.editor.plugin;
12
13
Lines 86-96 Link Here
86
87
87
		if (schemaElement != null) {
88
		if (schemaElement != null) {
88
			ISchemaAttribute atts[] = schemaElement.getAttributes();
89
			ISchemaAttribute atts[] = schemaElement.getAttributes();
89
			// Compute horizontal span
90
			if (isEditable()) {
90
			for (int i = 0; i < atts.length; i++) {
91
				// Compute horizontal span
91
				if (isEditable() && (atts[i].getKind() == IMetaAttribute.JAVA || atts[i].getKind() == IMetaAttribute.RESOURCE)) {
92
				for (int i = 0; i < atts.length; i++) {
92
					span = 3;
93
					if (atts[i].getKind() == IMetaAttribute.JAVA || atts[i].getKind() == IMetaAttribute.RESOURCE || atts[i].getKind() == IMetaAttribute.XML_PATH) {
93
					break;
94
						span = 3;
95
						break;
96
					}
94
				}
97
				}
95
			}
98
			}
96
			glayout.numColumns = span;
99
			glayout.numColumns = span;
Lines 125-130 Link Here
125
			row = new ClassAttributeRow(this, att);
128
			row = new ClassAttributeRow(this, att);
126
		else if (att.getKind() == IMetaAttribute.RESOURCE)
129
		else if (att.getKind() == IMetaAttribute.RESOURCE)
127
			row = new ResourceAttributeRow(this, att);
130
			row = new ResourceAttributeRow(this, att);
131
		else if (att.getKind() == IMetaAttribute.XML_PATH)
132
			row = new IdAttributeRow(this, att);
128
		else if (att.isTranslatable())
133
		else if (att.isTranslatable())
129
			row = new TranslatableAttributeRow(this, att);
134
			row = new TranslatableAttributeRow(this, att);
130
		else {
135
		else {
(-)src/org/eclipse/pde/internal/ui/editor/plugin/rows/IdAttributeRow.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Remy Chi Jian Suen <remy.suen@gmail.com> - Provide more structure, safety, and convenience for ID-based references between extension points (id hell)
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.editor.plugin.rows;
13
14
import java.util.*;
15
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.IExtension;
17
import org.eclipse.jface.viewers.ILabelProvider;
18
import org.eclipse.jface.viewers.LabelProvider;
19
import org.eclipse.jface.window.Window;
20
import org.eclipse.pde.internal.core.PDECore;
21
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
22
import org.eclipse.pde.internal.ui.PDEPlugin;
23
import org.eclipse.pde.internal.ui.PDEUIMessages;
24
import org.eclipse.pde.internal.ui.editor.IContextPart;
25
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
26
27
public class IdAttributeRow extends ButtonAttributeRow {
28
29
	public IdAttributeRow(IContextPart part, ISchemaAttribute att) {
30
		super(part, att);
31
	}
32
33
	protected boolean isReferenceModel() {
34
		return !part.getPage().getModel().isEditable();
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ButtonAttributeRow#browse()
39
	 */
40
	protected void browse() {
41
		ILabelProvider provider = new LabelProvider();
42
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), provider);
43
		dialog.setTitle(PDEUIMessages.ResourceAttributeCellEditor_title);
44
		ArrayList attributesInfo = new ArrayList();
45
		gatherInfo(attributesInfo);
46
		dialog.setElements(attributesInfo.toArray());
47
		if (dialog.open() == Window.OK) {
48
			text.setText(dialog.getFirstResult().toString());
49
		}
50
	}
51
52
	private void gatherInfo(ArrayList attributesInfo) {
53
		String basedOn = getAttribute().getBasedOn();
54
		String[] path = basedOn.split("/"); //$NON-NLS-1$
55
		IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions(path[0], true);
56
		List members = new ArrayList();
57
		for (int i = 0; i < extensions.length; i++) {
58
			IConfigurationElement[] elements = extensions[i].getConfigurationElements();
59
			for (int j = 0; j < elements.length; j++) {
60
				if (elements[j].getName().equals(path[1])) {
61
					members.add(elements[j]);
62
				}
63
			}
64
		}
65
		List parents = members;
66
		for (int i = 2; i < path.length; i++) {
67
			if (path[i].startsWith("@")) { //$NON-NLS-1$
68
				String attName = path[i].substring(1);
69
				for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
70
					IConfigurationElement element = (IConfigurationElement) iterator.next();
71
					String value = element.getAttribute(attName);
72
					if (value != null) {
73
						attributesInfo.add(value);
74
					}
75
				}
76
				return;
77
			}
78
			members = new ArrayList();
79
			for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
80
				IConfigurationElement element = (IConfigurationElement) iterator.next();
81
				members.addAll(keepGoing(element, path[i]));
82
			}
83
			parents = members;
84
		}
85
	}
86
87
	private List keepGoing(IConfigurationElement element, String tag) {
88
		return Arrays.asList(element.getChildren(tag));
89
	}
90
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ReferenceAttributeRow#openReference()
93
	 */
94
	protected void openReference() {
95
		// do nothing for now
96
	}
97
98
}

Return to bug 181515