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/ui/editor/plugin/ExtensionElementDetails.java (+2 lines)
Lines 125-130 Link Here
125
			row = new ClassAttributeRow(this, att);
125
			row = new ClassAttributeRow(this, att);
126
		else if (att.getKind() == IMetaAttribute.RESOURCE)
126
		else if (att.getKind() == IMetaAttribute.RESOURCE)
127
			row = new ResourceAttributeRow(this, att);
127
			row = new ResourceAttributeRow(this, att);
128
		else if (att.getKind() == IMetaAttribute.XML_PATH)
129
			row = new IdAttributeRow(this, att);
128
		else if (att.isTranslatable())
130
		else if (att.isTranslatable())
129
			row = new TranslatableAttributeRow(this, att);
131
			row = new TranslatableAttributeRow(this, att);
130
		else {
132
		else {
(-)src/org/eclipse/pde/internal/ui/editor/plugin/rows/IdAttributeRow.java (+94 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
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.plugin.rows;
12
13
import java.util.*;
14
import org.eclipse.core.runtime.IConfigurationElement;
15
import org.eclipse.core.runtime.IExtension;
16
import org.eclipse.jface.viewers.ILabelProvider;
17
import org.eclipse.jface.viewers.LabelProvider;
18
import org.eclipse.jface.window.Window;
19
import org.eclipse.pde.internal.core.PDECore;
20
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
21
import org.eclipse.pde.internal.ui.PDEPlugin;
22
import org.eclipse.pde.internal.ui.PDEUIMessages;
23
import org.eclipse.pde.internal.ui.editor.IContextPart;
24
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
25
26
public class IdAttributeRow extends ButtonAttributeRow {
27
28
	public IdAttributeRow(IContextPart part, ISchemaAttribute att) {
29
		super(part, att);
30
	}
31
32
	protected boolean isReferenceModel() {
33
		return !part.getPage().getModel().isEditable();
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ButtonAttributeRow#browse()
38
	 */
39
	protected void browse() {
40
		ILabelProvider provider = new LabelProvider();
41
		ElementListSelectionDialog dialog = new ElementListSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), provider);
42
		dialog.setTitle(PDEUIMessages.ResourceAttributeCellEditor_title);
43
		ArrayList attributesInfo = new ArrayList();
44
		gatherInfo(attributesInfo);
45
		dialog.setElements(attributesInfo.toArray());
46
		if (dialog.open() == Window.OK) {
47
			text.setText(dialog.getFirstResult().toString());
48
		}
49
	}
50
51
	private void gatherInfo(ArrayList attributesInfo) {
52
		String basedOn = getAttribute().getBasedOn();
53
		String[] path = basedOn.split("/"); //$NON-NLS-1$
54
		IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions(path[0], true);
55
		List members = new ArrayList();
56
		for (int i = 0; i < extensions.length; i++) {
57
			IConfigurationElement[] elements = extensions[i].getConfigurationElements();
58
			for (int j = 0; j < elements.length; j++) {
59
				if (elements[j].getName().equals(path[1])) {
60
					members.add(elements[j]);
61
				}
62
			}
63
		}
64
		List parents = members;
65
		for (int i = 2; i < path.length; i++) {
66
			if (path[i].startsWith("@")) { //$NON-NLS-1$
67
				String attName = path[i].substring(1);
68
				for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
69
					IConfigurationElement element = (IConfigurationElement) iterator.next();
70
					attributesInfo.add(element.getAttribute(attName));
71
				}
72
				return;
73
			}
74
			members = new ArrayList();
75
			for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
76
				IConfigurationElement element = (IConfigurationElement) iterator.next();
77
				members.addAll(keepGoing(element, path[i]));
78
			}
79
			parents = members;
80
		}
81
	}
82
83
	private List keepGoing(IConfigurationElement element, String tag) {
84
		return Arrays.asList(element.getChildren(tag));
85
	}
86
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.pde.internal.ui.editor.plugin.rows.ReferenceAttributeRow#openReference()
89
	 */
90
	protected void openReference() {
91
		// do nothing for now
92
	}
93
94
}
(-)src/org/eclipse/pde/internal/core/schema/Schema.java (-33 / +8 lines)
Lines 11-53 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.core.schema;
12
package org.eclipse.pde.internal.core.schema;
13
13
14
import java.io.FileNotFoundException;
14
import java.io.*;
15
import java.io.IOException;
16
import java.io.InputStream;
17
import java.io.PrintWriter;
18
import java.net.URL;
15
import java.net.URL;
19
import java.util.Collections;
16
import java.util.*;
20
import java.util.Iterator;
21
import java.util.Locale;
22
import java.util.Vector;
23
24
import org.eclipse.core.runtime.PlatformObject;
17
import org.eclipse.core.runtime.PlatformObject;
25
import org.eclipse.pde.core.IModelChangedEvent;
18
import org.eclipse.pde.core.*;
26
import org.eclipse.pde.core.IModelChangedListener;
27
import org.eclipse.pde.core.ModelChangedEvent;
28
import org.eclipse.pde.internal.core.PDECore;
19
import org.eclipse.pde.internal.core.PDECore;
29
import org.eclipse.pde.internal.core.XMLDefaultHandler;
20
import org.eclipse.pde.internal.core.XMLDefaultHandler;
30
import org.eclipse.pde.internal.core.ischema.IDocumentSection;
21
import org.eclipse.pde.internal.core.ischema.*;
31
import org.eclipse.pde.internal.core.ischema.IMetaAttribute;
22
import org.eclipse.pde.internal.core.util.*;
32
import org.eclipse.pde.internal.core.ischema.ISchema;
23
import org.w3c.dom.*;
33
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
34
import org.eclipse.pde.internal.core.ischema.ISchemaComplexType;
35
import org.eclipse.pde.internal.core.ischema.ISchemaCompositor;
36
import org.eclipse.pde.internal.core.ischema.ISchemaDescriptor;
37
import org.eclipse.pde.internal.core.ischema.ISchemaElement;
38
import org.eclipse.pde.internal.core.ischema.ISchemaEnumeration;
39
import org.eclipse.pde.internal.core.ischema.ISchemaInclude;
40
import org.eclipse.pde.internal.core.ischema.ISchemaObject;
41
import org.eclipse.pde.internal.core.ischema.ISchemaObjectReference;
42
import org.eclipse.pde.internal.core.ischema.ISchemaRootElement;
43
import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType;
44
import org.eclipse.pde.internal.core.ischema.ISchemaType;
45
import org.eclipse.pde.internal.core.util.PDEXMLHelper;
46
import org.eclipse.pde.internal.core.util.SAXParserWrapper;
47
import org.eclipse.pde.internal.core.util.SchemaUtil;
48
import org.w3c.dom.NamedNodeMap;
49
import org.w3c.dom.Node;
50
import org.w3c.dom.NodeList;
51
import org.xml.sax.SAXException;
24
import org.xml.sax.SAXException;
52
25
53
public class Schema extends PlatformObject implements ISchema {
26
public class Schema extends PlatformObject implements ISchema {
Lines 716-721 Link Here
716
				return IMetaAttribute.JAVA;
689
				return IMetaAttribute.JAVA;
717
			if (name.equals("resource")) //$NON-NLS-1$
690
			if (name.equals("resource")) //$NON-NLS-1$
718
				return IMetaAttribute.RESOURCE;
691
				return IMetaAttribute.RESOURCE;
692
			if (name.equals("xml_path")) //$NON-NLS-1$
693
				return IMetaAttribute.XML_PATH;
719
		}
694
		}
720
		return IMetaAttribute.STRING;
695
		return IMetaAttribute.STRING;
721
	}
696
	}
(-)src/org/eclipse/pde/internal/core/schema/SchemaAttribute.java (-7 / +4 lines)
Lines 12-23 Link Here
12
package org.eclipse.pde.internal.core.schema;
12
package org.eclipse.pde.internal.core.schema;
13
13
14
import java.io.PrintWriter;
14
import java.io.PrintWriter;
15
15
import org.eclipse.pde.internal.core.ischema.*;
16
import org.eclipse.pde.internal.core.ischema.ISchema;
17
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
18
import org.eclipse.pde.internal.core.ischema.ISchemaElement;
19
import org.eclipse.pde.internal.core.ischema.ISchemaObject;
20
import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType;
21
import org.eclipse.pde.internal.core.util.SchemaUtil;
16
import org.eclipse.pde.internal.core.util.SchemaUtil;
22
import org.eclipse.pde.internal.core.util.XMLComponentRegistry;
17
import org.eclipse.pde.internal.core.util.XMLComponentRegistry;
23
18
Lines 67-73 Link Here
67
	}
62
	}
68
63
69
	public String getBasedOn() {
64
	public String getBasedOn() {
70
		return getKind() == JAVA ? basedOn : null;
65
		if (getKind() == JAVA || getKind() == XML_PATH)
66
			return basedOn;
67
		return null;
71
	}
68
	}
72
69
73
	public int getKind() {
70
	public int getKind() {
(-)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

Return to bug 181515