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

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/editor/schema/SchemaAttributeDetails.java (-25 / +73 lines)
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();
(-)src/org/eclipse/pde/internal/ui/editor/schema/SchemaElementDetails.java (-1 / +4 lines)
Lines 26-31 Link Here
26
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionAdapter;
27
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.events.SelectionEvent;
28
import org.eclipse.swt.graphics.Color;
28
import org.eclipse.swt.graphics.Color;
29
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.swt.widgets.Label;
Lines 50-56 Link Here
50
		Color foreground = toolkit.getColors().getColor(IFormColors.TITLE);
51
		Color foreground = toolkit.getColors().getColor(IFormColors.TITLE);
51
		
52
		
52
		fName = new FormEntry(parent, toolkit, PDEUIMessages.SchemaDetails_name, SWT.NONE);
53
		fName = new FormEntry(parent, toolkit, PDEUIMessages.SchemaDetails_name, SWT.NONE);
53
		
54
		// Ensures label columns on every detail page are same width
55
		((GridData)fName.getLabel().getLayoutData()).widthHint = minLabelWeight;
56
54
		Label label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_deprecated);
57
		Label label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_deprecated);
55
		label.setForeground(foreground);
58
		label.setForeground(foreground);
56
		Button[] buttons = createTrueFalseButtons(parent, toolkit, 2);
59
		Button[] buttons = createTrueFalseButtons(parent, toolkit, 2);
(-)src/org/eclipse/pde/internal/ui/editor/schema/SchemaRootElementDetails.java (+3 lines)
Lines 22-27 Link Here
22
import org.eclipse.swt.events.SelectionAdapter;
22
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionEvent;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.graphics.Color;
24
import org.eclipse.swt.graphics.Color;
25
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Label;
Lines 45-50 Link Here
45
		Color foreground = toolkit.getColors().getColor(IFormColors.TITLE);
46
		Color foreground = toolkit.getColors().getColor(IFormColors.TITLE);
46
		
47
		
47
		fName = new FormEntry(parent, toolkit, PDEUIMessages.SchemaDetails_name, SWT.READ_ONLY);
48
		fName = new FormEntry(parent, toolkit, PDEUIMessages.SchemaDetails_name, SWT.READ_ONLY);
49
		// Ensures label columns on every detail page are same width
50
		((GridData)fName.getLabel().getLayoutData()).widthHint = minLabelWeight;
48
51
49
		Label label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_deprecated);
52
		Label label = toolkit.createLabel(parent, PDEUIMessages.SchemaDetails_deprecated);
50
		label.setForeground(foreground);
53
		label.setForeground(foreground);
(-)src/org/eclipse/pde/internal/ui/editor/schema/AbstractSchemaDetails.java (-3 / +19 lines)
Lines 30-35 Link Here
30
import org.eclipse.swt.events.ModifyListener;
30
import org.eclipse.swt.events.ModifyListener;
31
import org.eclipse.swt.events.SelectionAdapter;
31
import org.eclipse.swt.events.SelectionAdapter;
32
import org.eclipse.swt.events.SelectionEvent;
32
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.graphics.GC;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Button;
Lines 47-52 Link Here
47
	protected static final String[] BOOLS = 
48
	protected static final String[] BOOLS = 
48
		new String[] { Boolean.toString(true), Boolean.toString(false) };
49
		new String[] { Boolean.toString(true), Boolean.toString(false) };
49
	
50
	
51
	protected int minLabelWeight;
52
	
50
	private Section fSection;
53
	private Section fSection;
51
	private SchemaDtdDetailsSection fDtdSection = null;
54
	private SchemaDtdDetailsSection fDtdSection = null;
52
	private ElementSection fElementSection;
55
	private ElementSection fElementSection;
Lines 81-87 Link Here
81
	}
84
	}
82
	
85
	
83
	public final void createContents(Composite parent) {
86
	public final void createContents(Composite parent) {
84
87
		// This is a hacked fix to ensure that the label columns on every details
88
		// page have the same width. SchemaDetails_translatable plus 11 pixels
89
		// represents the longest label on any field on any details page. This
90
		// occurs on SchemaStringAttributeDetails and 11 is the size of the
91
		// horizontal indent that contributes to the label's width.
92
		GC gc = new GC(parent);
93
		minLabelWeight = gc.textExtent(PDEUIMessages.SchemaDetails_translatable).x + 11;
94
		gc.dispose();
95
		gc = null;
96
		
85
		parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
97
		parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
86
		FormToolkit toolkit = getManagedForm().getToolkit();
98
		FormToolkit toolkit = getManagedForm().getToolkit();
87
		fSection = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
99
		fSection = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
Lines 242-251 Link Here
242
		fElementSection.fireSelection(selection);
254
		fElementSection.fireSelection(selection);
243
	}
255
	}
244
	
256
	
245
	protected ComboPart createComboPart(Composite parent, FormToolkit toolkit, String[] items, int colspan) {
257
	protected ComboPart createComboPart(Composite parent, FormToolkit toolkit, String[] items, int colspan, int style) {
246
		ComboPart cp = new ComboPart();
258
		ComboPart cp = new ComboPart();
247
		cp.createControl(parent, toolkit, SWT.READ_ONLY);
259
		cp.createControl(parent, toolkit, SWT.READ_ONLY);
248
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
260
		GridData gd = new GridData(style);
249
		gd.horizontalSpan = colspan;
261
		gd.horizontalSpan = colspan;
250
		gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
262
		gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
251
		cp.getControl().setLayoutData(gd);
263
		cp.getControl().setLayoutData(gd);
Lines 254-259 Link Here
254
		return cp;
266
		return cp;
255
	}
267
	}
256
	
268
	
269
	protected ComboPart createComboPart(Composite parent, FormToolkit toolkit, String[] items, int colspan) {
270
		return createComboPart(parent, toolkit, items, colspan, GridData.FILL_HORIZONTAL);
271
	}
272
	
257
	protected Button[] createTrueFalseButtons(Composite parent, FormToolkit toolkit, int colSpan) {
273
	protected Button[] createTrueFalseButtons(Composite parent, FormToolkit toolkit, int colSpan) {
258
		Composite comp = toolkit.createComposite(parent, SWT.NONE);
274
		Composite comp = toolkit.createComposite(parent, SWT.NONE);
259
		GridLayout gl = new GridLayout(2, false);
275
		GridLayout gl = new GridLayout(2, false);
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-1 / +1 lines)
Lines 377-383 Link Here
377
SchemaEditor_ElementSection_newChoice=New Choice
377
SchemaEditor_ElementSection_newChoice=New Choice
378
SchemaEditor_ElementSection_newAttribute = New Attribute
378
SchemaEditor_ElementSection_newAttribute = New Attribute
379
SchemaEditor_ElementSection_newSequence=New Sequence
379
SchemaEditor_ElementSection_newSequence=New Sequence
380
SchemaAttributeDetails_defaultDefaultValue=(ENTER DEFAULT)
380
SchemaAttributeDetails_defaultDefaultValue=Enter default value
381
381
382
ReviewPage_noSampleFound=No sample has been selected.
382
ReviewPage_noSampleFound=No sample has been selected.
383
383

Return to bug 197056