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) { |