View | Details | Raw Unified | Return to bug 196882 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java (-21 / +5 lines)
Lines 36-57 Link Here
36
36
37
public abstract class SchemaAttributeDetails extends AbstractSchemaDetails {
37
public abstract class SchemaAttributeDetails extends AbstractSchemaDetails {
38
	
38
	
39
	private static final String JAVA_TYPE = "java"; //$NON-NLS-1$
40
	private static final String RESOURCE_TYPE = "resource"; //$NON-NLS-1$
41
	protected static final int BOOL_IND = 0;
42
	protected static final int STR_IND = 1;
43
	protected static final int JAVA_IND = 2;
44
	protected static final int RES_IND = 3;
45
	protected static final String[] TYPES = new String[4];
46
	static {
47
		TYPES[BOOL_IND]= BOOLEAN_TYPE;
48
		TYPES[STR_IND] = STRING_TYPE;
49
		TYPES[JAVA_IND] = JAVA_TYPE;
50
		TYPES[RES_IND] = RESOURCE_TYPE;
51
	}
52
	private static final String[] USE = 
53
		new String[] {"optional", "required", "default"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
54
	
55
	private SchemaAttribute fAttribute;
39
	private SchemaAttribute fAttribute;
56
	private FormEntry fValue;
40
	private FormEntry fValue;
57
	private FormEntry fName;
41
	private FormEntry fName;
Lines 88-100 Link Here
88
72
89
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_type);
73
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_type);
90
		label.setForeground(foreground);
74
		label.setForeground(foreground);
91
		fType = createComboPart(parent, toolkit, TYPES, 2);
75
		fType = createComboPart(parent, toolkit, ISchemaAttribute.TYPES, 2);
92
		
76
		
93
		createTypeDetails(parent, toolkit);
77
		createTypeDetails(parent, toolkit);
94
		
78
		
95
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_use);
79
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_use);
96
		label.setForeground(foreground);
80
		label.setForeground(foreground);
97
		fUse = createComboPart(parent, toolkit, USE, 2);
81
		fUse = createComboPart(parent, toolkit, ISchemaAttribute.USE_TABLE, 2);
98
		
82
		
99
		fValue = new FormEntry(parent, toolkit, PDEUIMessages.SchemaAttributeDetails_defaultValue, null, false, 6);
83
		fValue = new FormEntry(parent, toolkit, PDEUIMessages.SchemaAttributeDetails_defaultValue, null, false, 6);
100
		
84
		
Lines 113-119 Link Here
113
		fDepTrue.setSelection(fAttribute.isDeprecated());
97
		fDepTrue.setSelection(fAttribute.isDeprecated());
114
		fDepFalse.setSelection(!fAttribute.isDeprecated());
98
		fDepFalse.setSelection(!fAttribute.isDeprecated());
115
		
99
		
116
		boolean isStringType = fAttribute.getType().getName().equals(STRING_TYPE);
100
		boolean isStringType = fAttribute.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND]);
117
		int kind = fAttribute.getKind();
101
		int kind = fAttribute.getKind();
118
		fType.select(isStringType ? 1 + kind : 0);
102
		fType.select(isStringType ? 1 + kind : 0);
119
		
103
		
Lines 183-190 Link Here
183
				if (blockListeners())
167
				if (blockListeners())
184
					return;
168
					return;
185
				String typeString = fType.getSelection();
169
				String typeString = fType.getSelection();
186
				if (!typeString.equals(BOOLEAN_TYPE))
170
				if (!typeString.equals(ISchemaAttribute.TYPES[ISchemaAttribute.BOOL_IND]))
187
					typeString = STRING_TYPE;
171
					typeString = ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND];
188
				
172
				
189
				fAttribute.setType(new SchemaSimpleType(fAttribute.getSchema(), typeString));
173
				fAttribute.setType(new SchemaSimpleType(fAttribute.getSchema(), typeString));
190
				
174
				
(-)src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java (-67 lines)
Lines 10-22 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.schema;
11
package org.eclipse.pde.internal.ui.editor.schema;
12
12
13
import java.util.ArrayList;
14
15
import org.eclipse.osgi.util.NLS;
13
import org.eclipse.osgi.util.NLS;
16
import org.eclipse.pde.core.IModelChangedEvent;
14
import org.eclipse.pde.core.IModelChangedEvent;
17
import org.eclipse.pde.internal.core.ischema.IMetaAttribute;
18
import org.eclipse.pde.internal.core.ischema.ISchema;
15
import org.eclipse.pde.internal.core.ischema.ISchema;
19
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
20
import org.eclipse.pde.internal.core.ischema.ISchemaComplexType;
16
import org.eclipse.pde.internal.core.ischema.ISchemaComplexType;
21
import org.eclipse.pde.internal.core.ischema.ISchemaElement;
17
import org.eclipse.pde.internal.core.ischema.ISchemaElement;
22
import org.eclipse.pde.internal.core.ischema.ISchemaObject;
18
import org.eclipse.pde.internal.core.ischema.ISchemaObject;
Lines 25-31 Link Here
25
import org.eclipse.pde.internal.core.schema.SchemaElementReference;
21
import org.eclipse.pde.internal.core.schema.SchemaElementReference;
26
import org.eclipse.pde.internal.ui.PDEUIMessages;
22
import org.eclipse.pde.internal.ui.PDEUIMessages;
27
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
23
import org.eclipse.pde.internal.ui.editor.FormEntryAdapter;
28
import org.eclipse.pde.internal.ui.parts.ComboPart;
29
import org.eclipse.pde.internal.ui.parts.FormEntry;
24
import org.eclipse.pde.internal.ui.parts.FormEntry;
30
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionAdapter;
Lines 41-48 Link Here
41
36
42
	private SchemaElement fElement;
37
	private SchemaElement fElement;
43
	private FormEntry fName;
38
	private FormEntry fName;
44
	private ComboPart fLabelProperty;
45
	private ComboPart fIcon;
46
	private Button fDepTrue;
39
	private Button fDepTrue;
47
	private Button fDepFalse;
40
	private Button fDepFalse;
48
	private Button fTransTrue;
41
	private Button fTransTrue;
Lines 63-76 Link Here
63
		Button[] buttons = createTrueFalseButtons(parent, toolkit, 2);
56
		Button[] buttons = createTrueFalseButtons(parent, toolkit, 2);
64
		fDepTrue = buttons[0];
57
		fDepTrue = buttons[0];
65
		fDepFalse = buttons[1];
58
		fDepFalse = buttons[1];
66
		
67
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaElementDetails_labelProperty);
68
		label.setForeground(foreground);
69
		fLabelProperty = createComboPart(parent, toolkit, new String[0], 2);
70
		
71
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaElementDetails_icon);
72
		label.setForeground(foreground);
73
		fIcon = createComboPart(parent, toolkit, new String[0], 2);
74
59
75
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_translatable);
60
		label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_translatable);
76
		label.setForeground(foreground);
61
		label.setForeground(foreground);
Lines 89-100 Link Here
89
			return;
74
			return;
90
		setDecription(NLS.bind(PDEUIMessages.SchemaElementDetails_description, fElement.getName()));
75
		setDecription(NLS.bind(PDEUIMessages.SchemaElementDetails_description, fElement.getName()));
91
		fName.setValue(fElement.getName(), true);
76
		fName.setValue(fElement.getName(), true);
92
		String labProp = fElement.getLabelProperty();
93
		fLabelProperty.setItems(getLabelItems());
94
		fLabelProperty.setText(labProp != null ? labProp : ""); //$NON-NLS-1$
95
		String icProp = fElement.getIconProperty();
96
		fIcon.setItems(getIconItems());
97
		fIcon.setText(icProp != null ? icProp : ""); //$NON-NLS-1$
98
		
77
		
99
		fDepTrue.setSelection(fElement.isDeprecated());
78
		fDepTrue.setSelection(fElement.isDeprecated());
100
		fDepFalse.setSelection(!fElement.isDeprecated());
79
		fDepFalse.setSelection(!fElement.isDeprecated());
Lines 109-116 Link Here
109
		fTransFalse.setSelection(!fElement.hasTranslatableContent());
88
		fTransFalse.setSelection(!fElement.hasTranslatableContent());
110
		
89
		
111
		boolean editable = isEditableElement();
90
		boolean editable = isEditableElement();
112
		fIcon.setEnabled(editable);
113
		fLabelProperty.setEnabled(editable);
114
		fName.setEditable(editable);
91
		fName.setEditable(editable);
115
		
92
		
116
		fDepTrue.setEnabled(editable);
93
		fDepTrue.setEnabled(editable);
Lines 120-147 Link Here
120
	}
97
	}
121
98
122
	public void hookListeners() {
99
	public void hookListeners() {
123
		fIcon.addSelectionListener(new SelectionAdapter() {
124
			public void widgetSelected(SelectionEvent e) {
125
				if (blockListeners())
126
					return;
127
				String icon = fIcon.getSelection();
128
				if (icon == null || icon.equals("")) //$NON-NLS-1$
129
					fElement.setIconProperty(null);
130
				else
131
					fElement.setIconProperty(icon);
132
			}
133
		});
134
		fLabelProperty.addSelectionListener(new SelectionAdapter() {
135
			public void widgetSelected(SelectionEvent e) {
136
				if (blockListeners())
137
					return;
138
				String label = fLabelProperty.getSelection();
139
				if (label == null || label.equals("")) //$NON-NLS-1$
140
					fElement.setLabelProperty(null);
141
				else
142
					fElement.setLabelProperty(label);
143
			}
144
		});
145
		fName.setFormEntryListener(new FormEntryAdapter(this) {
100
		fName.setFormEntryListener(new FormEntryAdapter(this) {
146
			public void textValueChanged(FormEntry entry) {
101
			public void textValueChanged(FormEntry entry) {
147
				if (blockListeners())
102
				if (blockListeners())
Lines 183-210 Link Here
183
		});
138
		});
184
	}
139
	}
185
	
140
	
186
	private String[] getIconItems() {
187
		ISchemaAttribute[] attribs = fElement.getAttributes();
188
		ArrayList list = new ArrayList();
189
		list.add(""); //$NON-NLS-1$
190
		for (int i = 0; i < attribs.length; i++) {
191
			if (attribs[i].getKind() == IMetaAttribute.RESOURCE) {
192
				list.add(attribs[i].getName());
193
			}
194
		}
195
		return (String[]) list.toArray(new String[list.size()]);
196
	}
197
	
198
	private String[] getLabelItems() {
199
		ISchemaAttribute[] attribs = fElement.getAttributes();
200
		String[] labels = new String[attribs.length + 1];
201
		labels[0] = ""; //$NON-NLS-1$
202
		for (int i = 0; i < attribs.length; i++) {
203
			labels[i + 1] = attribs[i].getName();
204
		}
205
		return labels;
206
	}
207
	
208
	public void modelChanged(IModelChangedEvent event) {
141
	public void modelChanged(IModelChangedEvent event) {
209
		Object[] changedObjs = event.getChangedObjects();
142
		Object[] changedObjs = event.getChangedObjects();
210
		if(event.getChangeType() == IModelChangedEvent.INSERT && changedObjs.length > 0) {
143
		if(event.getChangeType() == IModelChangedEvent.INSERT && changedObjs.length > 0) {
(-)src/org/eclipse/pde/internal/ui/editor/schema/SchemaFormPage.java (-5 / +1 lines)
Lines 9-16 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.schema;
11
package org.eclipse.pde.internal.ui.editor.schema;
12
import java.util.Arrays;
13
14
import org.eclipse.jface.action.ControlContribution;
12
import org.eclipse.jface.action.ControlContribution;
15
import org.eclipse.pde.core.IModelChangedEvent;
13
import org.eclipse.pde.core.IModelChangedEvent;
16
import org.eclipse.pde.core.IModelChangedListener;
14
import org.eclipse.pde.core.IModelChangedListener;
Lines 88-96 Link Here
88
					case IMetaAttribute.JAVA :
86
					case IMetaAttribute.JAVA :
89
						return SchemaJavaAttributeDetails.class;
87
						return SchemaJavaAttributeDetails.class;
90
					case IMetaAttribute.STRING :
88
					case IMetaAttribute.STRING :
91
						int typeIndex = Arrays.binarySearch(SchemaAttributeDetails.TYPES,
89
						if (att.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND]))
92
								att.getType().getName());
93
						if (typeIndex == SchemaAttributeDetails.STR_IND)
94
							return SchemaStringAttributeDetails.class;
90
							return SchemaStringAttributeDetails.class;
95
				}
91
				}
96
				return SchemaOtherAttributeDetails.class;
92
				return SchemaOtherAttributeDetails.class;
(-)src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java (-2 lines)
Lines 44-51 Link Here
44
44
45
public abstract class AbstractSchemaDetails extends PDEDetails {
45
public abstract class AbstractSchemaDetails extends PDEDetails {
46
46
47
	protected static final String STRING_TYPE = "string"; //$NON-NLS-1$
48
	protected static final String BOOLEAN_TYPE = "boolean"; //$NON-NLS-1$
49
	protected static final String[] BOOLS = 
47
	protected static final String[] BOOLS = 
50
		new String[] { Boolean.toString(true), Boolean.toString(false) };
48
		new String[] { Boolean.toString(true), Boolean.toString(false) };
51
	
49
	
(-)src/org/eclipse/pde/internal/ui/PDEUIMessages.java (-4 lines)
Lines 2396-2405 Link Here
2396
2396
2397
	public static String SchemaIncludesSection_dialogMessage;
2397
	public static String SchemaIncludesSection_dialogMessage;
2398
2398
2399
	public static String SchemaElementDetails_labelProperty;
2400
2401
	public static String SchemaElementDetails_icon;
2402
2403
	public static String SchemaDetails_translatable;
2399
	public static String SchemaDetails_translatable;
2404
2400
2405
	public static String SchemaElementDetails_title;
2401
	public static String SchemaElementDetails_title;
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-2 lines)
Lines 400-406 Link Here
400
SchemaIncludesSection_missingWarningMessage={0} could not be found.
400
SchemaIncludesSection_missingWarningMessage={0} could not be found.
401
401
402
SchemaEditor_NewCompositor_tooltip = New {0}
402
SchemaEditor_NewCompositor_tooltip = New {0}
403
SchemaElementDetails_labelProperty=Label Property:
404
SchemaElementReferenceDetails_reference=Reference:
403
SchemaElementReferenceDetails_reference=Reference:
405
SchemaAttributeDetails_removeRestButton=Remove
404
SchemaAttributeDetails_removeRestButton=Remove
406
SchemaElementReferenceDetails_title=Element Reference Details
405
SchemaElementReferenceDetails_title=Element Reference Details
Lines 415-421 Link Here
415
SchemaIncludesSection_title=Schema Inclusions
414
SchemaIncludesSection_title=Schema Inclusions
416
SchemaAttributeDetails_type=Type:
415
SchemaAttributeDetails_type=Type:
417
SchemaEditor_DocPage_title = Overview
416
SchemaEditor_DocPage_title = Overview
418
SchemaElementDetails_icon=Icon:
419
SchemaElementDetails_title=Element Details
417
SchemaElementDetails_title=Element Details
420
SchemaElementDetails_rootTitle=Extension Element Details
418
SchemaElementDetails_rootTitle=Extension Element Details
421
SchemaAttributeDetails_use=Use:
419
SchemaAttributeDetails_use=Use:
(-)src/org/eclipse/pde/internal/core/ischema/ISchemaAttribute.java (-1 / +12 lines)
Lines 34-42 Link Here
34
	/**
34
	/**
35
	 * Table of the 'use' clause choices.
35
	 * Table of the 'use' clause choices.
36
	 */
36
	 */
37
	public static final String[] useTable = {
37
	public static final String[] USE_TABLE = {
38
			"optional", "required", "default" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
38
			"optional", "required", "default" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
39
39
40
	public static final int BOOL_IND = 0;
41
	public static final int STR_IND = 1;
42
	public static final int JAVA_IND = 2;
43
	public static final int RES_IND = 3;
44
	public static final String[] TYPES = {
45
		"boolean", //$NON-NLS-1$
46
		"string", //$NON-NLS-1$
47
		"java", //$NON-NLS-1$
48
		"resource" //$NON-NLS-1$
49
	};
50
40
	/**
51
	/**
41
	 * Returns the type of this attribute. Attributes can only have simple
52
	 * Returns the type of this attribute. Attributes can only have simple
42
	 * types.
53
	 * types.
(-)src/org/eclipse/pde/internal/core/schema/SchemaElement.java (-2 / +28 lines)
Lines 12-17 Link Here
12
12
13
import java.io.PrintWriter;
13
import java.io.PrintWriter;
14
14
15
import org.eclipse.pde.internal.core.ischema.IMetaAttribute;
15
import org.eclipse.pde.internal.core.ischema.ISchema;
16
import org.eclipse.pde.internal.core.ischema.ISchema;
16
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
17
import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
17
import org.eclipse.pde.internal.core.ischema.ISchemaComplexType;
18
import org.eclipse.pde.internal.core.ischema.ISchemaComplexType;
Lines 158-168 Link Here
158
	}
159
	}
159
160
160
	public String getIconProperty() {
161
	public String getIconProperty() {
161
		return iconName;
162
		if (iconName != null)
163
			return iconName;
164
		String result = null;
165
		ISchemaAttribute[] attributes = getAttributes();
166
		for (int i = 0; i < attributes.length && result == null; i++) {
167
			if (isValidIconProperty(attributes[i]))
168
				result = attributes[i].getName();
169
		}
170
		return result;
162
	}
171
	}
163
172
164
	public String getLabelProperty() {
173
	public String getLabelProperty() {
165
		return labelProperty;
174
		if (labelProperty != null)
175
			return labelProperty;
176
		String result = null;
177
		ISchemaAttribute[] attributes = getAttributes();
178
		for (int i = 0; i < attributes.length && result == null; i++) {
179
			if (isValidLabelProperty(attributes[i]))
180
				result = attributes[i].getName();
181
		}
182
		return result;
183
	}
184
	
185
	private boolean isValidLabelProperty(ISchemaAttribute a) {
186
		return a.getKind() == IMetaAttribute.STRING &&
187
			a.getType().getName().equals(ISchemaAttribute.TYPES[ISchemaAttribute.STR_IND]) &&
188
			a.isTranslatable();
189
	}
190
	private boolean isValidIconProperty(ISchemaAttribute a) {
191
		return a.getKind() == IMetaAttribute.RESOURCE;
166
	}
192
	}
167
193
168
	public ISchemaType getType() {
194
	public ISchemaType getType() {

Return to bug 196882