Lines 9-14
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 org.eclipse.jface.layout.GridLayoutFactory; |
12 |
import org.eclipse.osgi.util.NLS; |
13 |
import org.eclipse.osgi.util.NLS; |
13 |
import org.eclipse.pde.core.IModelChangedEvent; |
14 |
import org.eclipse.pde.core.IModelChangedEvent; |
14 |
import org.eclipse.pde.internal.core.ischema.IMetaAttribute; |
15 |
import org.eclipse.pde.internal.core.ischema.IMetaAttribute; |
Lines 25-33
Link Here
|
25 |
import org.eclipse.pde.internal.ui.parts.ComboPart; |
26 |
import org.eclipse.pde.internal.ui.parts.ComboPart; |
26 |
import org.eclipse.pde.internal.ui.parts.FormEntry; |
27 |
import org.eclipse.pde.internal.ui.parts.FormEntry; |
27 |
import org.eclipse.swt.SWT; |
28 |
import org.eclipse.swt.SWT; |
|
|
29 |
import org.eclipse.swt.custom.StackLayout; |
28 |
import org.eclipse.swt.events.SelectionAdapter; |
30 |
import org.eclipse.swt.events.SelectionAdapter; |
29 |
import org.eclipse.swt.events.SelectionEvent; |
31 |
import org.eclipse.swt.events.SelectionEvent; |
30 |
import org.eclipse.swt.graphics.Color; |
32 |
import org.eclipse.swt.graphics.Color; |
|
|
33 |
import org.eclipse.swt.layout.GridData; |
31 |
import org.eclipse.swt.widgets.Button; |
34 |
import org.eclipse.swt.widgets.Button; |
32 |
import org.eclipse.swt.widgets.Composite; |
35 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.Label; |
36 |
import org.eclipse.swt.widgets.Label; |
Lines 42-48
Link Here
|
42 |
private Button fDepTrue; |
45 |
private Button fDepTrue; |
43 |
private Button fDepFalse; |
46 |
private Button fDepFalse; |
44 |
private ComboPart fType; |
47 |
private ComboPart fType; |
45 |
private ComboPart fUse; |
48 |
private ComboPart fUseDefault; |
|
|
49 |
private ComboPart fUseOther; |
50 |
private StackLayout fUseLayout; |
51 |
private Composite fUseComp; |
52 |
private Composite fUseCompDefault; |
53 |
private Composite fUseCompOther; |
46 |
|
54 |
|
47 |
public SchemaAttributeDetails(ElementSection section) { |
55 |
public SchemaAttributeDetails(ElementSection section) { |
48 |
super(section, false, true); |
56 |
super(section, false, true); |
Lines 63-68
Link Here
|
63 |
Color foreground = toolkit.getColors().getColor(IFormColors.TITLE); |
71 |
Color foreground = toolkit.getColors().getColor(IFormColors.TITLE); |
64 |
|
72 |
|
65 |
fName = new FormEntry(parent, toolkit, PDEUIMessages.SchemaDetails_name, SWT.NONE); |
73 |
fName = new FormEntry(parent, toolkit, PDEUIMessages.SchemaDetails_name, SWT.NONE); |
|
|
74 |
// Ensures label columns on every detail page are same width |
75 |
((GridData)fName.getLabel().getLayoutData()).widthHint = minLabelWeight; |
66 |
|
76 |
|
67 |
Label label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_deprecated); |
77 |
Label label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_deprecated); |
68 |
label.setForeground(foreground); |
78 |
label.setForeground(foreground); |
Lines 70-86
Link Here
|
70 |
fDepTrue = buttons[0]; |
80 |
fDepTrue = buttons[0]; |
71 |
fDepFalse = buttons[1]; |
81 |
fDepFalse = buttons[1]; |
72 |
|
82 |
|
73 |
label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_type); |
83 |
label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_use); |
74 |
label.setForeground(foreground); |
84 |
label.setForeground(foreground); |
75 |
fType = createComboPart(parent, toolkit, ISchemaAttribute.TYPES, 2); |
|
|
76 |
|
85 |
|
77 |
createTypeDetails(parent, toolkit); |
86 |
fUseComp = toolkit.createComposite(parent); |
|
|
87 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
88 |
gd.horizontalSpan = 2; |
89 |
fUseComp.setLayoutData(gd); |
90 |
fUseLayout = new StackLayout(); |
91 |
fUseComp.setLayout(fUseLayout); |
78 |
|
92 |
|
79 |
label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_use); |
93 |
fUseCompDefault = toolkit.createComposite(fUseComp); |
|
|
94 |
fUseCompDefault.setLayout(GridLayoutFactory.fillDefaults().margins(0,0).numColumns(2).create()); |
95 |
|
96 |
fUseDefault = createComboPart(fUseCompDefault, toolkit, ISchemaAttribute.USE_TABLE, 1, SWT.NONE); |
97 |
fValue = new FormEntry(fUseCompDefault, toolkit, null, 0, 1); |
98 |
|
99 |
fUseCompOther = toolkit.createComposite(fUseComp); |
100 |
fUseCompOther.setLayout(GridLayoutFactory.fillDefaults().margins(0,0).create()); |
101 |
|
102 |
fUseOther = createComboPart(fUseCompOther, toolkit, ISchemaAttribute.USE_TABLE, 1); |
103 |
|
104 |
label = toolkit.createLabel(parent, PDEUIMessages.SchemaAttributeDetails_type); |
80 |
label.setForeground(foreground); |
105 |
label.setForeground(foreground); |
81 |
fUse = createComboPart(parent, toolkit, ISchemaAttribute.USE_TABLE, 2); |
106 |
fType = createComboPart(parent, toolkit, ISchemaAttribute.TYPES, 2); |
82 |
|
107 |
|
83 |
fValue = new FormEntry(parent, toolkit, PDEUIMessages.SchemaAttributeDetails_defaultValue, null, false, 6); |
108 |
createTypeDetails(parent, toolkit); |
84 |
|
109 |
|
85 |
toolkit.paintBordersFor(parent); |
110 |
toolkit.paintBordersFor(parent); |
86 |
setText(PDEUIMessages.SchemaAttributeDetails_title); |
111 |
setText(PDEUIMessages.SchemaAttributeDetails_title); |
Lines 101-122
Link Here
|
101 |
int kind = fAttribute.getKind(); |
126 |
int kind = fAttribute.getKind(); |
102 |
fType.select(isStringType ? 1 + kind : 0); |
127 |
fType.select(isStringType ? 1 + kind : 0); |
103 |
|
128 |
|
104 |
fUse.select(fAttribute.getUse()); |
129 |
fUseDefault.select(fAttribute.getUse()); |
|
|
130 |
fUseOther.select(fAttribute.getUse()); |
105 |
Object value = fAttribute.getValue(); |
131 |
Object value = fAttribute.getValue(); |
106 |
fValue.setValue(value != null ? value.toString() : "", true); //$NON-NLS-1$ |
132 |
fValue.setValue(value != null ? value.toString() : PDEUIMessages.SchemaAttributeDetails_defaultDefaultValue, true); |
107 |
|
133 |
|
108 |
boolean editable = isEditableElement(); |
134 |
boolean editable = isEditableElement(); |
109 |
if (fAttribute.getUse() != 2) { |
135 |
if (fAttribute.getUse() != 2) { |
110 |
fValue.getLabel().setEnabled(false); |
136 |
fUseLayout.topControl = fUseCompOther; |
111 |
fValue.getText().setEditable(false); |
|
|
112 |
} else { |
137 |
} else { |
113 |
fValue.setEditable(editable); |
138 |
fUseLayout.topControl = fUseCompDefault; |
114 |
} |
139 |
} |
|
|
140 |
fUseComp.layout(); |
115 |
fName.setEditable(editable); |
141 |
fName.setEditable(editable); |
116 |
fDepTrue.setEnabled(editable); |
142 |
fDepTrue.setEnabled(editable); |
117 |
fDepFalse.setEnabled(editable); |
143 |
fDepFalse.setEnabled(editable); |
118 |
fType.setEnabled(editable); |
144 |
fType.setEnabled(editable); |
119 |
fUse.setEnabled(editable); |
145 |
fUseDefault.setEnabled(editable); |
|
|
146 |
fUseOther.setEnabled(editable); |
120 |
} |
147 |
} |
121 |
|
148 |
|
122 |
public void hookListeners() { |
149 |
public void hookListeners() { |
Lines 184-207
Link Here
|
184 |
fireSelectionChange(); |
211 |
fireSelectionChange(); |
185 |
} |
212 |
} |
186 |
}); |
213 |
}); |
187 |
fUse.addSelectionListener(new SelectionAdapter() { |
214 |
fUseDefault.addSelectionListener(new SelectionAdapter() { |
188 |
public void widgetSelected(SelectionEvent e) { |
215 |
public void widgetSelected(SelectionEvent e) { |
189 |
if (blockListeners()) |
216 |
if (blockListeners()) |
190 |
return; |
217 |
return; |
191 |
int use = fUse.getSelectionIndex(); |
218 |
int i = fUseDefault.getSelectionIndex(); |
192 |
fAttribute.setUse(use); |
219 |
setBlockListeners(true); |
193 |
fValue.getLabel().setEnabled(use == 2); |
220 |
fUseOther.select(i); |
194 |
fValue.getText().setEditable(use == 2); |
221 |
setBlockListeners(false); |
195 |
if (use == 2 && fValue.getValue().length() == 0) { |
222 |
doUseChange(i); |
196 |
fValue.setValue(PDEUIMessages.SchemaAttributeDetails_defaultDefaultValue); |
223 |
} |
197 |
fValue.getText().setSelection(0, fValue.getValue().length()); |
224 |
}); |
198 |
fValue.getText().setFocus(); |
225 |
fUseOther.addSelectionListener(new SelectionAdapter() { |
199 |
} else if (use != 2) |
226 |
public void widgetSelected(SelectionEvent e) { |
200 |
fValue.setValue(""); //$NON-NLS-1$ |
227 |
if (blockListeners()) |
201 |
|
228 |
return; |
|
|
229 |
int i = fUseOther.getSelectionIndex(); |
230 |
setBlockListeners(true); |
231 |
fUseDefault.select(i); |
232 |
setBlockListeners(false); |
233 |
doUseChange(i); |
202 |
} |
234 |
} |
203 |
}); |
235 |
}); |
204 |
} |
236 |
} |
|
|
237 |
|
238 |
private void doUseChange (int index) { |
239 |
fAttribute.setUse(index); |
240 |
if (index == 2) { |
241 |
fUseLayout.topControl = fUseCompDefault; |
242 |
fUseComp.layout(); |
243 |
if (fValue.getValue().equals(PDEUIMessages.SchemaAttributeDetails_defaultDefaultValue)) |
244 |
fValue.getText().setSelection(0, fValue.getValue().length()); |
245 |
fValue.getText().setFocus(); |
246 |
} else if (index != 2) { |
247 |
fUseLayout.topControl = fUseCompOther; |
248 |
fUseComp.layout(); |
249 |
fValue.setValue(PDEUIMessages.SchemaAttributeDetails_defaultDefaultValue); |
250 |
fUseCompOther.setFocus(); |
251 |
} |
252 |
} |
205 |
|
253 |
|
206 |
public void modelChanged(IModelChangedEvent event) { |
254 |
public void modelChanged(IModelChangedEvent event) { |
207 |
Object[] changedObjs = event.getChangedObjects(); |
255 |
Object[] changedObjs = event.getChangedObjects(); |