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 141106 | Differences between
and this patch

Collapse All | Expand All

(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/NotationSection.java (-16 / +49 lines)
Lines 11-21 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.GC;
16
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
17
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
18
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Text;
24
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 32-37 Link Here
32
36
33
	private CLabel publicIdLabel;
37
	private CLabel publicIdLabel;
34
	private CLabel systemIdLabel;
38
	private CLabel systemIdLabel;
39
	private FontMetrics fFontMetrics;
35
40
36
	public void doHandleEvent(Event event) {
41
	public void doHandleEvent(Event event) {
37
		if (event.widget == publicIdText) {
42
		if (event.widget == publicIdText) {
Lines 61-97 Link Here
61
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
66
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
62
		FormData data;
67
		FormData data;
63
68
69
		// Create label first then attach other control to it
70
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
71
		initializeFontMetrics(publicIdLabel);
72
		int labelWidth = getLabelWidth(publicIdLabel.getText());
73
		data = new FormData(labelWidth, SWT.DEFAULT);
74
		data.left = new FormAttachment(0, 0);
75
		data.top = new FormAttachment(0, 0);
76
		publicIdLabel.setLayoutData(data);
77
64
		// Public ID
78
		// Public ID
65
		publicIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
79
		publicIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
66
		data = new FormData();
80
		data = new FormData();
67
		data.left = new FormAttachment(0, 100);
81
		data.left = new FormAttachment(publicIdLabel, -ITabbedPropertyConstants.HSPACE);
68
		data.right = new FormAttachment(100, 0);
82
		data.right = new FormAttachment(100, 0);
69
		data.top = new FormAttachment(0, 0);
83
		data.top = new FormAttachment(publicIdLabel, 0, SWT.CENTER);
70
		publicIdText.setLayoutData(data);
84
		publicIdText.setLayoutData(data);
71
		publicIdText.addListener(SWT.Modify, this);
85
		publicIdText.addListener(SWT.Modify, this);
72
86
73
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
87
		// Create label first then attach other control to it
74
		data = new FormData();
88
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
89
		labelWidth = getLabelWidth(systemIdLabel.getText());
90
		data = new FormData(labelWidth, SWT.DEFAULT);
75
		data.left = new FormAttachment(0, 0);
91
		data.left = new FormAttachment(0, 0);
76
		data.right = new FormAttachment(publicIdText, -ITabbedPropertyConstants.HSPACE);
92
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
77
		data.top = new FormAttachment(publicIdText, 0, SWT.CENTER);
93
		systemIdLabel.setLayoutData(data);
78
		publicIdLabel.setLayoutData(data);
79
94
80
		// System ID
95
		// System ID
81
		systemIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
96
		systemIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
82
		data = new FormData();
97
		data = new FormData();
83
		data.left = new FormAttachment(0, 100);
98
		data.left = new FormAttachment(systemIdLabel, -ITabbedPropertyConstants.HSPACE);
84
		data.right = new FormAttachment(100, 0);
99
		data.right = new FormAttachment(100, 0);
85
		data.top = new FormAttachment(publicIdText, +ITabbedPropertyConstants.VSPACE);
100
		data.top = new FormAttachment(systemIdLabel, 0, SWT.CENTER);
86
		systemIdText.setLayoutData(data);
101
		systemIdText.setLayoutData(data);
87
		systemIdText.addListener(SWT.Modify, this);
102
		systemIdText.addListener(SWT.Modify, this);
88
89
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
90
		data = new FormData();
91
		data.left = new FormAttachment(0, 0);
92
		data.right = new FormAttachment(systemIdText, -ITabbedPropertyConstants.HSPACE);
93
		data.top = new FormAttachment(systemIdText, 0, SWT.CENTER);
94
		systemIdLabel.setLayoutData(data);
95
	}
103
	}
96
104
97
	/*
105
	/*
Lines 121-124 Link Here
121
		return false;
129
		return false;
122
	}
130
	}
123
131
132
	/**
133
	 * Initilize font metrics
134
	 * 
135
	 * @param control
136
	 */
137
	private void initializeFontMetrics(Control control) {
138
		GC gc = new GC(control);
139
		gc.setFont(control.getFont());
140
		fFontMetrics = gc.getFontMetrics();
141
		gc.dispose();
142
	}
143
144
	/**
145
	 * Determine appropriate label width
146
	 * 
147
	 * @param labelText
148
	 * @return
149
	 */
150
	private int getLabelWidth(String labelText) {
151
		int labelWidth = 98;
152
153
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
154
		labelWidth = Math.max(pixels, labelWidth);
155
		return labelWidth;
156
	}
124
}
157
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/ContentModelTypeSection.java (-14 / +42 lines)
Lines 13-25 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
15
16
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.custom.CCombo;
18
import org.eclipse.swt.custom.CCombo;
18
import org.eclipse.swt.custom.CLabel;
19
import org.eclipse.swt.custom.CLabel;
19
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.graphics.FontMetrics;
22
import org.eclipse.swt.graphics.GC;
20
import org.eclipse.swt.layout.FormAttachment;
23
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormData;
24
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
27
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
24
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
28
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
25
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
29
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
Lines 35-40 Link Here
35
39
36
	private CCombo typeCombo;
40
	private CCombo typeCombo;
37
	private String[] typeComboValues = {CMNode.ANY, CMNode.EMPTY, CMNode.PCDATA, CMNode.CHILDREN, CMNode.MIXED};
41
	private String[] typeComboValues = {CMNode.ANY, CMNode.EMPTY, CMNode.PCDATA, CMNode.CHILDREN, CMNode.MIXED};
42
	private FontMetrics fFontMetrics;
38
43
39
	/**
44
	/**
40
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
45
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 43-70 Link Here
43
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
48
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
44
		super.createControls(parent, factory);
49
		super.createControls(parent, factory);
45
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
50
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
46
		FormData data = new FormData();
51
		FormData data;
52
53
		// Create label first then attach other control to it
54
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_TYPE);
55
		initializeFontMetrics(cLabel);
56
		int labelWidth = getLabelWidth(cLabel.getText());
57
		data = new FormData(labelWidth, SWT.DEFAULT);
47
		data.left = new FormAttachment(0, 0);
58
		data.left = new FormAttachment(0, 0);
48
		data.right = new FormAttachment(100, 0);
49
		data.top = new FormAttachment(0, 0);
59
		data.top = new FormAttachment(0, 0);
50
		data.bottom = new FormAttachment(100, 0);
60
		cLabel.setLayoutData(data);
51
61
52
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
62
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
53
		data = new FormData();
63
		data = new FormData();
54
		data.left = new FormAttachment(0, 100);
64
		data.left = new FormAttachment(cLabel, -ITabbedPropertyConstants.HSPACE);
55
		data.right = new FormAttachment(100, 0);
65
		data.right = new FormAttachment(100);
56
		data.top = new FormAttachment(0, 0);
66
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
57
		typeCombo.setLayoutData(data);
67
		typeCombo.setLayoutData(data);
58
		typeCombo.addSelectionListener(this);
68
		typeCombo.addSelectionListener(this);
59
		typeCombo.setItems(typeComboValues);
69
		typeCombo.setItems(typeComboValues);
60
61
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_TYPE);
62
		data = new FormData();
63
		data.left = new FormAttachment(0, 0);
64
		data.right = new FormAttachment(typeCombo, -ITabbedPropertyConstants.HSPACE);
65
		data.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
66
		cLabel.setLayoutData(data);
67
68
	}
70
	}
69
71
70
	/*
72
	/*
Lines 121-124 Link Here
121
	public boolean shouldUseExtraSpace() {
123
	public boolean shouldUseExtraSpace() {
122
		return false;
124
		return false;
123
	}
125
	}
126
127
	/**
128
	 * Initilize font metrics
129
	 * 
130
	 * @param control
131
	 */
132
	private void initializeFontMetrics(Control control) {
133
		GC gc = new GC(control);
134
		gc.setFont(control.getFont());
135
		fFontMetrics = gc.getFontMetrics();
136
		gc.dispose();
137
	}
138
139
	/**
140
	 * Determine appropriate label width
141
	 * 
142
	 * @param labelText
143
	 * @return
144
	 */
145
	private int getLabelWidth(String labelText) {
146
		int labelWidth = 98;
147
148
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
149
		labelWidth = Math.max(pixels, labelWidth);
150
		return labelWidth;
151
	}
124
}
152
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/OccurrenceSection.java (-10 / +42 lines)
Lines 11-23 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
26
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
23
import org.eclipse.wst.dtd.core.internal.CMRepeatableNode;
27
import org.eclipse.wst.dtd.core.internal.CMRepeatableNode;
Lines 32-37 Link Here
32
36
33
	private CCombo occurrenceCombo;
37
	private CCombo occurrenceCombo;
34
	private String[] occurrenceComboValues = {ONCE, ONE_OR_MORE, OPTIONAL, ZERO_OR_MORE};
38
	private String[] occurrenceComboValues = {ONCE, ONE_OR_MORE, OPTIONAL, ZERO_OR_MORE};
39
	private FontMetrics fFontMetrics;
35
40
36
	/**
41
	/**
37
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
42
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 41-61 Link Here
41
		super.createControls(parent, factory);
46
		super.createControls(parent, factory);
42
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
47
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
43
48
49
		// Create label first then attach other control to it
50
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, OCCURENCE);
51
		initializeFontMetrics(usageLabel);
52
		int labelWidth = getLabelWidth(usageLabel.getText());
53
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
54
		data.left = new FormAttachment(0, 0);
55
		data.top = new FormAttachment(0, 0);
56
		usageLabel.setLayoutData(data);
57
44
		occurrenceCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
58
		occurrenceCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
45
		FormData data = new FormData();
59
		data = new FormData();
46
		data.left = new FormAttachment(0, 100);
60
		data.left = new FormAttachment(usageLabel, -ITabbedPropertyConstants.HSPACE);
47
		data.right = new FormAttachment(100, 0);
61
		data.right = new FormAttachment(100, 0);
48
		data.top = new FormAttachment(0, 0);
62
		data.top = new FormAttachment(usageLabel, 0, SWT.CENTER);
49
		occurrenceCombo.setLayoutData(data);
63
		occurrenceCombo.setLayoutData(data);
50
		occurrenceCombo.addSelectionListener(this);
64
		occurrenceCombo.addSelectionListener(this);
51
		occurrenceCombo.setItems(occurrenceComboValues);
65
		occurrenceCombo.setItems(occurrenceComboValues);
52
53
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, OCCURENCE);
54
		data = new FormData();
55
		data.left = new FormAttachment(0, 0);
56
		data.right = new FormAttachment(occurrenceCombo, -ITabbedPropertyConstants.HSPACE);
57
		data.top = new FormAttachment(occurrenceCombo, 0, SWT.CENTER);
58
		usageLabel.setLayoutData(data);
59
	}
66
	}
60
67
61
	/*
68
	/*
Lines 98-101 Link Here
98
		}
105
		}
99
	}
106
	}
100
107
108
	/**
109
	 * Initilize font metrics
110
	 * 
111
	 * @param control
112
	 */
113
	private void initializeFontMetrics(Control control) {
114
		GC gc = new GC(control);
115
		gc.setFont(control.getFont());
116
		fFontMetrics = gc.getFontMetrics();
117
		gc.dispose();
118
	}
119
120
	/**
121
	 * Determine appropriate label width
122
	 * 
123
	 * @param labelText
124
	 * @return
125
	 */
126
	private int getLabelWidth(String labelText) {
127
		int labelWidth = 98;
128
129
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
130
		labelWidth = Math.max(pixels, labelWidth);
131
		return labelWidth;
132
	}
101
}
133
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/EntityTypeSection.java (-13 / +47 lines)
Lines 11-24 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
26
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
23
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
27
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
24
import org.eclipse.wst.dtd.core.internal.Entity;
28
import org.eclipse.wst.dtd.core.internal.Entity;
Lines 33-38 Link Here
33
	private CCombo typeCombo;
37
	private CCombo typeCombo;
34
	private String[] typeComboValues = {PARAMETER, GENERAL};
38
	private String[] typeComboValues = {PARAMETER, GENERAL};
35
	private Button checkBox;
39
	private Button checkBox;
40
	private FontMetrics fFontMetrics;
36
41
37
	public static boolean isExternalEntity = false;
42
	public static boolean isExternalEntity = false;
38
43
Lines 44-70 Link Here
44
		super.createControls(parent, factory);
49
		super.createControls(parent, factory);
45
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
50
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
46
51
52
		// Create label first then attach other control to it
53
		CLabel cLabel = getWidgetFactory().createCLabel(composite, ENTITY_TYPE);
54
		initializeFontMetrics(cLabel);
55
		int labelWidth = getLabelWidth(cLabel.getText());
56
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
57
		data.left = new FormAttachment(0, 0);
58
		data.top = new FormAttachment(0, 0);
59
		cLabel.setLayoutData(data);
60
47
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
61
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
48
		FormData data = new FormData();
62
		data = new FormData();
49
		data.left = new FormAttachment(0, 100);
63
		data.left = new FormAttachment(cLabel, -ITabbedPropertyConstants.HSPACE);
50
		data.right = new FormAttachment(100, 0);
64
		data.right = new FormAttachment(100, 0);
51
		data.top = new FormAttachment(0, 0);
65
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
52
		typeCombo.setLayoutData(data);
66
		typeCombo.setLayoutData(data);
53
		typeCombo.addSelectionListener(this);
67
		typeCombo.addSelectionListener(this);
54
		typeCombo.setItems(typeComboValues);
68
		typeCombo.setItems(typeComboValues);
55
69
56
		CLabel cLabel = getWidgetFactory().createCLabel(composite, ENTITY_TYPE);
57
		data = new FormData();
58
		data.left = new FormAttachment(0, 0);
59
		data.right = new FormAttachment(typeCombo, -ITabbedPropertyConstants.HSPACE);
60
		data.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
61
		cLabel.setLayoutData(data);
62
63
		checkBox = getWidgetFactory().createButton(composite, EXTERNAL_ENTITY, SWT.CHECK);
70
		checkBox = getWidgetFactory().createButton(composite, EXTERNAL_ENTITY, SWT.CHECK);
64
		data = new FormData();
71
		labelWidth = getLabelWidth(checkBox.getText());
65
		data.left = new FormAttachment(0, 100);
72
		data = new FormData(labelWidth, SWT.DEFAULT);
73
		data.left = new FormAttachment(0, 0);
66
		data.right = new FormAttachment(95, 0);
74
		data.right = new FormAttachment(95, 0);
67
		data.top = new FormAttachment(typeCombo, +ITabbedPropertyConstants.VSPACE);
75
		data.top = new FormAttachment(cLabel, +ITabbedPropertyConstants.VSPACE);
68
		checkBox.setLayoutData(data);
76
		checkBox.setLayoutData(data);
69
		checkBox.addSelectionListener(this);
77
		checkBox.addSelectionListener(this);
70
	}
78
	}
Lines 129-132 Link Here
129
	public boolean shouldUseExtraSpace() {
137
	public boolean shouldUseExtraSpace() {
130
		return false;
138
		return false;
131
	}
139
	}
140
141
	/**
142
	 * Initilize font metrics
143
	 * 
144
	 * @param control
145
	 */
146
	private void initializeFontMetrics(Control control) {
147
		GC gc = new GC(control);
148
		gc.setFont(control.getFont());
149
		fFontMetrics = gc.getFontMetrics();
150
		gc.dispose();
151
	}
152
153
	/**
154
	 * Determine appropriate label width
155
	 * 
156
	 * @param labelText
157
	 * @return
158
	 */
159
	private int getLabelWidth(String labelText) {
160
		int labelWidth = 98;
161
162
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
163
		labelWidth = Math.max(pixels, labelWidth);
164
		return labelWidth;
165
	}
132
}
166
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/ContentModelNameSection.java (-12 / +44 lines)
Lines 13-25 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
15
16
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.custom.CCombo;
18
import org.eclipse.swt.custom.CCombo;
18
import org.eclipse.swt.custom.CLabel;
19
import org.eclipse.swt.custom.CLabel;
19
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.graphics.FontMetrics;
22
import org.eclipse.swt.graphics.GC;
20
import org.eclipse.swt.layout.FormAttachment;
23
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormData;
24
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
27
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
24
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
28
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
25
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
29
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
Lines 34-39 Link Here
34
38
35
	private CCombo typeCombo;
39
	private CCombo typeCombo;
36
	private String[] typeComboValues = {CMNode.PCDATA};
40
	private String[] typeComboValues = {CMNode.PCDATA};
41
	private FontMetrics fFontMetrics;
37
42
38
	/**
43
	/**
39
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
44
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 43-64 Link Here
43
		super.createControls(parent, factory);
48
		super.createControls(parent, factory);
44
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
49
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
45
50
46
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT | SWT.READ_ONLY);
51
		// Create label first then attach other control to it
47
		FormData data = new FormData();
48
		data.left = new FormAttachment(0, 100);
49
		data.right = new FormAttachment(100, 0);
50
		data.top = new FormAttachment(0, 0);
51
		typeCombo.setLayoutData(data);
52
		typeCombo.addSelectionListener(this);
53
		typeCombo.setItems(typeComboValues);
54
55
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_MODEL);
52
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_MODEL);
56
		data = new FormData();
53
		initializeFontMetrics(cLabel);
54
		int labelWidth = getLabelWidth(cLabel.getText());
55
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
57
		data.left = new FormAttachment(0, 0);
56
		data.left = new FormAttachment(0, 0);
58
		data.right = new FormAttachment(typeCombo, -ITabbedPropertyConstants.HSPACE);
57
		data.top = new FormAttachment(0, 0);
59
		data.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
60
		cLabel.setLayoutData(data);
58
		cLabel.setLayoutData(data);
61
59
60
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT | SWT.READ_ONLY);
61
		data = new FormData();
62
		data.left = new FormAttachment(cLabel, -ITabbedPropertyConstants.HSPACE);
63
		data.right = new FormAttachment(100);
64
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
65
		typeCombo.setLayoutData(data);
66
		typeCombo.addSelectionListener(this);
67
		typeCombo.setItems(typeComboValues);
62
	}
68
	}
63
69
64
	/*
70
	/*
Lines 103-106 Link Here
103
	public boolean shouldUseExtraSpace() {
109
	public boolean shouldUseExtraSpace() {
104
		return false;
110
		return false;
105
	}
111
	}
112
113
	/**
114
	 * Initilize font metrics
115
	 * 
116
	 * @param control
117
	 */
118
	private void initializeFontMetrics(Control control) {
119
		GC gc = new GC(control);
120
		gc.setFont(control.getFont());
121
		fFontMetrics = gc.getFontMetrics();
122
		gc.dispose();
123
	}
124
125
	/**
126
	 * Determine appropriate label width
127
	 * 
128
	 * @param labelText
129
	 * @return
130
	 */
131
	private int getLabelWidth(String labelText) {
132
		int labelWidth = 98;
133
134
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
135
		labelWidth = Math.max(pixels, labelWidth);
136
		return labelWidth;
137
	}
106
}
138
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/AttributeDefaultSection.java (-17 / +54 lines)
Lines 11-23 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Event;
25
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Text;
26
import org.eclipse.swt.widgets.Text;
23
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
27
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 35-40 Link Here
35
	private String[] usageComboValues = {IMPLIED, REQUIRED, FIXED, DTDPropertiesMessages._UI_DEFAULT};
39
	private String[] usageComboValues = {IMPLIED, REQUIRED, FIXED, DTDPropertiesMessages._UI_DEFAULT};
36
	private Text defaultValueText;
40
	private Text defaultValueText;
37
	private CLabel defaultValueLabel;
41
	private CLabel defaultValueLabel;
42
	private FontMetrics fFontMetrics;
38
43
39
	/**
44
	/**
40
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
45
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 44-79 Link Here
44
		super.createControls(parent, factory);
49
		super.createControls(parent, factory);
45
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
50
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
46
51
52
		// Create label first then attach other control to it
53
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_USAGE);
54
		initializeFontMetrics(usageLabel);
55
		int labelWidth = getLabelWidth(usageLabel.getText());
56
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
57
		data.left = new FormAttachment(0, 0);
58
		data.top = new FormAttachment(0, 0);
59
		usageLabel.setLayoutData(data);
60
47
		usageCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
61
		usageCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
48
		FormData data = new FormData();
62
		data = new FormData();
49
		data.left = new FormAttachment(0, 100);
63
		data.left = new FormAttachment(usageLabel, -ITabbedPropertyConstants.HSPACE);
50
		data.right = new FormAttachment(100, 0);
64
		data.right = new FormAttachment(100, 0);
51
		data.top = new FormAttachment(0, 0);
65
		data.top = new FormAttachment(usageLabel, 0, SWT.CENTER);
52
		usageCombo.setLayoutData(data);
66
		usageCombo.setLayoutData(data);
53
		usageCombo.addSelectionListener(this);
67
		usageCombo.addSelectionListener(this);
54
		usageCombo.setItems(usageComboValues);
68
		usageCombo.setItems(usageComboValues);
55
69
56
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_USAGE);
70
		// Create label first then attach other control to it
57
		data = new FormData();
71
		defaultValueLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_DEFAULT_VALUE);
72
		labelWidth = getLabelWidth(defaultValueLabel.getText());
73
		data = new FormData(labelWidth, SWT.DEFAULT);
58
		data.left = new FormAttachment(0, 0);
74
		data.left = new FormAttachment(0, 0);
59
		data.right = new FormAttachment(usageCombo, -ITabbedPropertyConstants.HSPACE);
75
		data.top = new FormAttachment(usageLabel, +ITabbedPropertyConstants.VSPACE);
60
		data.top = new FormAttachment(usageCombo, 0, SWT.CENTER);
76
		defaultValueLabel.setLayoutData(data);
61
		usageLabel.setLayoutData(data);
62
77
63
		defaultValueText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
78
		defaultValueText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
64
		data = new FormData();
79
		data = new FormData();
65
		data.left = new FormAttachment(0, 100);
80
		data.left = new FormAttachment(defaultValueLabel, -ITabbedPropertyConstants.HSPACE);
66
		data.right = new FormAttachment(100, 0);
81
		data.right = new FormAttachment(100, 0);
67
		data.top = new FormAttachment(usageCombo, +ITabbedPropertyConstants.VSPACE);
82
		data.top = new FormAttachment(defaultValueLabel, 0, SWT.CENTER);
68
		defaultValueText.setLayoutData(data);
83
		defaultValueText.setLayoutData(data);
69
		defaultValueText.addListener(SWT.Modify, this);
84
		defaultValueText.addListener(SWT.Modify, this);
70
71
		defaultValueLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_DEFAULT_VALUE);
72
		data = new FormData();
73
		data.left = new FormAttachment(0, 0);
74
		data.right = new FormAttachment(defaultValueText, -ITabbedPropertyConstants.HSPACE);
75
		data.top = new FormAttachment(defaultValueText, 0, SWT.CENTER);
76
		defaultValueLabel.setLayoutData(data);
77
	}
85
	}
78
86
79
	/*
87
	/*
Lines 92-103 Link Here
92
100
93
				if ("".equals(kind) || FIXED.equals(kind)) { //$NON-NLS-1$
101
				if ("".equals(kind) || FIXED.equals(kind)) { //$NON-NLS-1$
94
					defaultValueLabel.setVisible(true);
102
					defaultValueLabel.setVisible(true);
103
					defaultValueText.setVisible(true);
95
					defaultValueText.setEnabled(true);
104
					defaultValueText.setEnabled(true);
96
					defaultValueText.setText(((Attribute) input).getDefaultValue());
105
					defaultValueText.setText(((Attribute) input).getDefaultValue());
97
				}
106
				}
98
				else {
107
				else {
99
					defaultValueText.setText(""); //$NON-NLS-1$
108
					defaultValueText.setText(""); //$NON-NLS-1$
100
					defaultValueLabel.setVisible(false);
109
					defaultValueLabel.setVisible(false);
110
					defaultValueText.setVisible(false);
101
					defaultValueText.setEnabled(false);
111
					defaultValueText.setEnabled(false);
102
				}
112
				}
103
			}
113
			}
Lines 118-127 Link Here
118
128
119
				if (DTDPropertiesMessages._UI_DEFAULT.equals(usage) || FIXED.equals(usage)) {
129
				if (DTDPropertiesMessages._UI_DEFAULT.equals(usage) || FIXED.equals(usage)) {
120
					defaultValueLabel.setVisible(true);
130
					defaultValueLabel.setVisible(true);
131
					defaultValueText.setVisible(true);
121
					defaultValueText.setEnabled(true);
132
					defaultValueText.setEnabled(true);
122
				}
133
				}
123
				else {
134
				else {
124
					defaultValueLabel.setVisible(false);
135
					defaultValueLabel.setVisible(false);
136
					defaultValueText.setVisible(false);
125
					defaultValueText.setEnabled(false);
137
					defaultValueText.setEnabled(false);
126
				}
138
				}
127
			}
139
			}
Lines 138-141 Link Here
138
		}
150
		}
139
	}
151
	}
140
152
153
	/**
154
	 * Initilize font metrics
155
	 * 
156
	 * @param control
157
	 */
158
	private void initializeFontMetrics(Control control) {
159
		GC gc = new GC(control);
160
		gc.setFont(control.getFont());
161
		fFontMetrics = gc.getFontMetrics();
162
		gc.dispose();
163
	}
164
165
	/**
166
	 * Determine appropriate label width
167
	 * 
168
	 * @param labelText
169
	 * @return
170
	 */
171
	private int getLabelWidth(String labelText) {
172
		int labelWidth = 98;
173
174
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
175
		labelWidth = Math.max(pixels, labelWidth);
176
		return labelWidth;
177
	}
141
}
178
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/ContentModelGroupSection.java (-12 / +44 lines)
Lines 11-23 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
26
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
23
import org.eclipse.wst.dtd.core.internal.CMGroupNode;
27
import org.eclipse.wst.dtd.core.internal.CMGroupNode;
Lines 30-35 Link Here
30
34
31
	private CCombo modelGroupCombo;
35
	private CCombo modelGroupCombo;
32
	private String[] modelGroupComboValues = {SEQUENCE, CHOICE};
36
	private String[] modelGroupComboValues = {SEQUENCE, CHOICE};
37
	private FontMetrics fFontMetrics;
33
38
34
	/**
39
	/**
35
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
40
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 39-60 Link Here
39
		super.createControls(parent, factory);
44
		super.createControls(parent, factory);
40
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
45
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
41
46
42
		modelGroupCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
47
		// Create label first then attach other control to it
43
		FormData data = new FormData();
44
		data.left = new FormAttachment(0, 100);
45
		data.right = new FormAttachment(100, 0);
46
		data.top = new FormAttachment(0, 0);
47
		modelGroupCombo.setLayoutData(data);
48
		modelGroupCombo.addSelectionListener(this);
49
		modelGroupCombo.setItems(modelGroupComboValues);
50
51
		CLabel cLabel = getWidgetFactory().createCLabel(composite, MODEL_GROUP);
48
		CLabel cLabel = getWidgetFactory().createCLabel(composite, MODEL_GROUP);
52
		data = new FormData();
49
		initializeFontMetrics(cLabel);
50
		int labelWidth = getLabelWidth(cLabel.getText());
51
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
53
		data.left = new FormAttachment(0, 0);
52
		data.left = new FormAttachment(0, 0);
54
		data.right = new FormAttachment(modelGroupCombo, -ITabbedPropertyConstants.HSPACE);
53
		data.top = new FormAttachment(0, 0);
55
		data.top = new FormAttachment(modelGroupCombo, 0, SWT.CENTER);
56
		cLabel.setLayoutData(data);
54
		cLabel.setLayoutData(data);
57
55
56
		modelGroupCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
57
		data = new FormData();
58
		data.left = new FormAttachment(cLabel, -ITabbedPropertyConstants.HSPACE);
59
		data.right = new FormAttachment(100);
60
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
61
		modelGroupCombo.setLayoutData(data);
62
		modelGroupCombo.addSelectionListener(this);
63
		modelGroupCombo.setItems(modelGroupComboValues);
58
	}
64
	}
59
65
60
	/*
66
	/*
Lines 89-92 Link Here
89
		}
95
		}
90
	}
96
	}
91
97
98
	/**
99
	 * Initilize font metrics
100
	 * 
101
	 * @param control
102
	 */
103
	private void initializeFontMetrics(Control control) {
104
		GC gc = new GC(control);
105
		gc.setFont(control.getFont());
106
		fFontMetrics = gc.getFontMetrics();
107
		gc.dispose();
108
	}
109
110
	/**
111
	 * Determine appropriate label width
112
	 * 
113
	 * @param labelText
114
	 * @return
115
	 */
116
	private int getLabelWidth(String labelText) {
117
		int labelWidth = 98;
118
119
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
120
		labelWidth = Math.max(pixels, labelWidth);
121
		return labelWidth;
122
	}
123
92
}
124
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/EmptySection.java (+4 lines)
Lines 43-46 Link Here
43
	public boolean shouldUseExtraSpace() {
43
	public boolean shouldUseExtraSpace() {
44
		return false;
44
		return false;
45
	}
45
	}
46
	
47
	public int getMinimumHeight() {
48
		return 0;
49
	}
46
}
50
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/NewEntitySection.java (-75 / +102 lines)
Lines 12-17 Link Here
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.jface.viewers.IStructuredSelection;
16
import org.eclipse.jface.viewers.ViewerFilter;
17
import org.eclipse.jface.viewers.ViewerFilter;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.window.Window;
Lines 20-29 Link Here
20
import org.eclipse.swt.custom.CCombo;
21
import org.eclipse.swt.custom.CCombo;
21
import org.eclipse.swt.custom.CLabel;
22
import org.eclipse.swt.custom.CLabel;
22
import org.eclipse.swt.events.SelectionEvent;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.graphics.FontMetrics;
25
import org.eclipse.swt.graphics.GC;
23
import org.eclipse.swt.layout.FormAttachment;
26
import org.eclipse.swt.layout.FormAttachment;
24
import org.eclipse.swt.layout.FormData;
27
import org.eclipse.swt.layout.FormData;
25
import org.eclipse.swt.widgets.Button;
28
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Composite;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.swt.widgets.Display;
28
import org.eclipse.swt.widgets.Event;
32
import org.eclipse.swt.widgets.Event;
29
import org.eclipse.swt.widgets.Shell;
33
import org.eclipse.swt.widgets.Shell;
Lines 60-65 Link Here
60
	private CCombo typeCombo;
64
	private CCombo typeCombo;
61
	private String[] typeComboValues = {PARAMETER, GENERAL};
65
	private String[] typeComboValues = {PARAMETER, GENERAL};
62
	private PageBook pageBook;
66
	private PageBook pageBook;
67
	private FontMetrics fFontMetrics;
63
68
64
	/**
69
	/**
65
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
70
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 95-144 Link Here
95
		data.top = new FormAttachment(0, 0);
100
		data.top = new FormAttachment(0, 0);
96
		entityCommonComposite.setLayoutData(data);
101
		entityCommonComposite.setLayoutData(data);
97
102
103
		// Create label first then attach other control to it
104
		CLabel nameLabel = getWidgetFactory().createCLabel(entityCommonComposite, NAME); //$NON-NLS-1$
105
		initializeFontMetrics(nameLabel);
106
		int labelWidth = getLabelWidth(nameLabel.getText());
107
		data = new FormData(labelWidth, SWT.DEFAULT);
108
		data.left = new FormAttachment(0, 0);
109
		data.top = new FormAttachment(0, 0);
110
		nameLabel.setLayoutData(data);
111
98
		nameText = getWidgetFactory().createText(entityCommonComposite, "", SWT.NONE); //$NON-NLS-1$    
112
		nameText = getWidgetFactory().createText(entityCommonComposite, "", SWT.NONE); //$NON-NLS-1$    
99
		data = new FormData();
113
		data = new FormData();
100
		data.left = new FormAttachment(0, 100);
114
		data.left = new FormAttachment(nameLabel, -ITabbedPropertyConstants.HSPACE);
101
		data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
115
		data.right = new FormAttachment(100, 0);
102
		data.top = new FormAttachment(0, 0);
116
		data.top = new FormAttachment(nameLabel, 0, SWT.CENTER);
103
		nameText.setLayoutData(data);
117
		nameText.setLayoutData(data);
104
		nameText.addListener(SWT.Modify, this);
118
		nameText.addListener(SWT.Modify, this);
105
119
106
		CLabel nameLabel = getWidgetFactory().createCLabel(entityCommonComposite, NAME); //$NON-NLS-1$
120
		// Create label first then attach other control to it
107
		data = new FormData();
121
		CLabel cLabel = getWidgetFactory().createCLabel(entityCommonComposite, ENTITY_TYPE);
122
		labelWidth = getLabelWidth(cLabel.getText());
123
		data = new FormData(labelWidth, SWT.DEFAULT);
108
		data.left = new FormAttachment(0, 0);
124
		data.left = new FormAttachment(0, 0);
109
		data.right = new FormAttachment(nameText, +ITabbedPropertyConstants.HSPACE);
125
		data.top = new FormAttachment(nameLabel, +ITabbedPropertyConstants.VSPACE);
110
		data.top = new FormAttachment(nameText, 0, SWT.CENTER);
126
		cLabel.setLayoutData(data);
111
		nameLabel.setLayoutData(data);
112
127
113
		// Create Checkbox
128
		// Create Checkbox
114
		checkBox = getWidgetFactory().createButton(entityCommonComposite, EXTERNAL_ENTITY, SWT.CHECK); //$NON-NLS-1$
129
		checkBox = getWidgetFactory().createButton(entityCommonComposite, EXTERNAL_ENTITY, SWT.CHECK); //$NON-NLS-1$
130
		data = new FormData();
131
		data.right = new FormAttachment(100, 0);
132
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
133
		checkBox.setLayoutData(data);
115
		checkBox.addSelectionListener(this);
134
		checkBox.addSelectionListener(this);
116
135
117
		// Create CCombo
136
		// Create CCombo
118
		typeCombo = getWidgetFactory().createCCombo(entityCommonComposite, SWT.FLAT | SWT.READ_ONLY);
137
		typeCombo = getWidgetFactory().createCCombo(entityCommonComposite, SWT.FLAT | SWT.READ_ONLY);
138
		data = new FormData();
139
		data.left = new FormAttachment(cLabel, -ITabbedPropertyConstants.HSPACE - 2);
140
		data.right = new FormAttachment(checkBox, -ITabbedPropertyConstants.HSPACE);
141
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
142
		typeCombo.setLayoutData(data);
119
		typeCombo.addSelectionListener(this);
143
		typeCombo.addSelectionListener(this);
120
		typeCombo.setItems(typeComboValues);
144
		typeCombo.setItems(typeComboValues);
121
		typeCombo.setText(PARAMETER);
145
		typeCombo.setText(PARAMETER);
122
146
123
		FormData checkBoxFormData = new FormData();
124
		checkBoxFormData.left = new FormAttachment(90, -rightMarginSpace + 2);
125
		checkBoxFormData.right = new FormAttachment(100, 0);
126
		checkBoxFormData.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
127
		checkBox.setLayoutData(checkBoxFormData);
128
129
		FormData typeComboFormData = new FormData();
130
		typeComboFormData.left = new FormAttachment(0, 100);
131
		typeComboFormData.right = new FormAttachment(checkBox, 0);
132
		typeComboFormData.top = new FormAttachment(nameText, +ITabbedPropertyConstants.VSPACE);
133
		typeCombo.setLayoutData(typeComboFormData);
134
135
		CLabel cLabel = getWidgetFactory().createCLabel(entityCommonComposite, ENTITY_TYPE);
136
		data = new FormData();
137
		data.left = new FormAttachment(0, 0);
138
		data.right = new FormAttachment(typeCombo, -ITabbedPropertyConstants.HSPACE);
139
		data.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
140
		cLabel.setLayoutData(data);
141
142
		return entityCommonComposite;
147
		return entityCommonComposite;
143
	}
148
	}
144
149
Lines 149-174 Link Here
149
		FormData data = new FormData();
154
		FormData data = new FormData();
150
		data.left = new FormAttachment(0, 0);
155
		data.left = new FormAttachment(0, 0);
151
		data.right = new FormAttachment(100, 0);
156
		data.right = new FormAttachment(100, 0);
152
		data.top = new FormAttachment(entityCommonComposite, +ITabbedPropertyConstants.VSPACE);
157
		data.top = new FormAttachment(entityCommonComposite, -ITabbedPropertyConstants.VSPACE);
153
		// data.bottom = new FormAttachment(100,0);
154
		internalEntityComposite.setLayoutData(data);
158
		internalEntityComposite.setLayoutData(data);
155
159
156
		entityValueText = getWidgetFactory().createText(internalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
160
		// Create label first then attach other control to it
157
		entityValueText.setEditable(true);
158
		entityValueText.addListener(SWT.Modify, this);
159
		data = new FormData();
160
		data.left = new FormAttachment(0, 100);
161
		data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
162
		data.top = new FormAttachment(0, 0);
163
		entityValueText.setLayoutData(data);
164
165
		CLabel entityValueLabel = getWidgetFactory().createCLabel(internalEntityComposite, VALUE); //$NON-NLS-1$
161
		CLabel entityValueLabel = getWidgetFactory().createCLabel(internalEntityComposite, VALUE); //$NON-NLS-1$
166
		data = new FormData();
162
		int labelWidth = getLabelWidth(entityValueLabel.getText());
163
		data = new FormData(labelWidth, SWT.DEFAULT);
167
		data.left = new FormAttachment(0, 0);
164
		data.left = new FormAttachment(0, 0);
168
		data.right = new FormAttachment(entityValueText, 0);
165
		data.top = new FormAttachment(0, 0);
169
		data.top = new FormAttachment(entityValueText, 0, SWT.CENTER);
170
		entityValueLabel.setLayoutData(data);
166
		entityValueLabel.setLayoutData(data);
171
167
168
		entityValueText = getWidgetFactory().createText(internalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
169
		data = new FormData();
170
		data.left = new FormAttachment(entityValueLabel, -ITabbedPropertyConstants.HSPACE);
171
		data.right = new FormAttachment(100, 0);
172
		data.top = new FormAttachment(entityValueLabel, 0, SWT.CENTER);
173
		entityValueText.setLayoutData(data);
174
		entityValueText.setEditable(true);
175
		entityValueText.addListener(SWT.Modify, this);
176
172
		return internalEntityComposite;
177
		return internalEntityComposite;
173
	}
178
	}
174
179
Lines 179-235 Link Here
179
		FormData data = new FormData();
184
		FormData data = new FormData();
180
		data.left = new FormAttachment(0, 0);
185
		data.left = new FormAttachment(0, 0);
181
		data.right = new FormAttachment(100, 0);
186
		data.right = new FormAttachment(100, 0);
182
		data.top = new FormAttachment(entityCommonComposite, +ITabbedPropertyConstants.VSPACE);
187
		data.top = new FormAttachment(entityCommonComposite, -ITabbedPropertyConstants.VSPACE);
183
		// data.bottom = new FormAttachment(100,0);
184
		externalEntityComposite.setLayoutData(data);
188
		externalEntityComposite.setLayoutData(data);
185
189
190
		// Create label first then attach other control to it
191
		CLabel publicIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, PUBLIC_ID); //$NON-NLS-1$
192
		int labelWidth = getLabelWidth(publicIdLabel.getText());
193
		data = new FormData(labelWidth, SWT.DEFAULT);
194
		data.left = new FormAttachment(0, 0);
195
		data.top = new FormAttachment(0, 0);
196
		publicIdLabel.setLayoutData(data);
197
186
		publicIdText = getWidgetFactory().createText(externalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
198
		publicIdText = getWidgetFactory().createText(externalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
187
		publicIdText.setEditable(true);
199
		publicIdText.setEditable(true);
188
		publicIdText.addListener(SWT.Modify, this);
189
		data = new FormData();
200
		data = new FormData();
190
		data.left = new FormAttachment(0, 100);
201
		data.left = new FormAttachment(publicIdLabel, -ITabbedPropertyConstants.HSPACE);
191
		data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
202
		data.right = new FormAttachment(100, 0);
192
		// data.top = new FormAttachment(nameText,
203
		data.top = new FormAttachment(publicIdLabel, 0, SWT.CENTER);
193
		// +ITabbedPropertyConstants.VSPACE);
194
		data.top = new FormAttachment(0, 0);
195
		publicIdText.setLayoutData(data);
204
		publicIdText.setLayoutData(data);
205
		publicIdText.addListener(SWT.Modify, this);
196
206
197
		CLabel publicIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, PUBLIC_ID); //$NON-NLS-1$
207
		// Create label first then attach other control to it
198
		data = new FormData();
208
		// Create System ID Label
209
		CLabel systemIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, SYSTEM_ID); //$NON-NLS-1$
210
		labelWidth = getLabelWidth(systemIdLabel.getText());
211
		data = new FormData(labelWidth, SWT.DEFAULT);
199
		data.left = new FormAttachment(0, 0);
212
		data.left = new FormAttachment(0, 0);
200
		data.right = new FormAttachment(publicIdText, 0);
213
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
201
		data.top = new FormAttachment(publicIdText, 0, SWT.CENTER);
214
		systemIdLabel.setLayoutData(data);
202
		publicIdLabel.setLayoutData(data);
203
215
204
		// Create Wizard Button
216
		// Create Wizard Button
205
		wizardButton = getWidgetFactory().createButton(externalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
217
		wizardButton = getWidgetFactory().createButton(externalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
206
		wizardButton.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(DTDUIPlugin.getDefault().getBundle().getSymbolicName(), "icons/browsebutton.gif").createImage()); //$NON-NLS-1$
218
		wizardButton.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(DTDUIPlugin.getDefault().getBundle().getSymbolicName(), "icons/browsebutton.gif").createImage()); //$NON-NLS-1$
219
		data = new FormData();
220
		data.right = new FormAttachment(100, 0);
221
		data.top = new FormAttachment(systemIdLabel, 0, SWT.CENTER);
222
		wizardButton.setLayoutData(data);
223
		wizardButton.addSelectionListener(this);
207
224
208
		// Create System ID Text
225
		// Create System ID Text
209
		systemIdText = getWidgetFactory().createText(externalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
226
		systemIdText = getWidgetFactory().createText(externalEntityComposite, "", SWT.NONE); //$NON-NLS-1$
210
		// systemIdText.setEditable(false);
227
		// systemIdText.setEditable(false);
211
212
		FormData buttonFormData = new FormData();
213
		buttonFormData.left = new FormAttachment(100, -rightMarginSpace + 2);
214
		buttonFormData.right = new FormAttachment(100, 0);
215
		buttonFormData.top = new FormAttachment(systemIdText, 0, SWT.CENTER);
216
		wizardButton.setLayoutData(buttonFormData);
217
		wizardButton.addSelectionListener(this);
218
219
		FormData systemIdData = new FormData();
220
		systemIdData.left = new FormAttachment(0, 100);
221
		systemIdData.right = new FormAttachment(wizardButton, 0);
222
		systemIdData.top = new FormAttachment(publicIdText, +ITabbedPropertyConstants.VSPACE);
223
		systemIdText.setLayoutData(systemIdData);
224
		systemIdText.addListener(SWT.Modify, this);
225
226
		// Create System ID Label
227
		CLabel systemIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, SYSTEM_ID); //$NON-NLS-1$
228
		data = new FormData();
228
		data = new FormData();
229
		data.left = new FormAttachment(0, 0);
229
		data.left = new FormAttachment(systemIdLabel, -ITabbedPropertyConstants.HSPACE);
230
		data.right = new FormAttachment(systemIdText, 0);
230
		data.right = new FormAttachment(wizardButton, -ITabbedPropertyConstants.HSPACE);
231
		data.top = new FormAttachment(systemIdText, 0, SWT.CENTER);
231
		data.top = new FormAttachment(systemIdLabel, 0, SWT.CENTER);
232
		systemIdLabel.setLayoutData(data);
232
		systemIdText.setLayoutData(data);
233
		systemIdText.addListener(SWT.Modify, this);
233
234
234
		return externalEntityComposite;
235
		return externalEntityComposite;
235
	}
236
	}
Lines 362-365 Link Here
362
		}
363
		}
363
364
364
	}
365
	}
366
367
	/**
368
	 * Initilize font metrics
369
	 * 
370
	 * @param control
371
	 */
372
	private void initializeFontMetrics(Control control) {
373
		GC gc = new GC(control);
374
		gc.setFont(control.getFont());
375
		fFontMetrics = gc.getFontMetrics();
376
		gc.dispose();
377
	}
378
379
	/**
380
	 * Determine appropriate label width
381
	 * 
382
	 * @param labelText
383
	 * @return
384
	 */
385
	private int getLabelWidth(String labelText) {
386
		int labelWidth = 98;
387
388
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
389
		labelWidth = Math.max(pixels, labelWidth);
390
		return labelWidth;
391
	}
365
}
392
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/TypeSection.java (-13 / +40 lines)
Lines 11-23 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CCombo;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
26
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
23
import org.eclipse.wst.dtd.core.internal.Attribute;
27
import org.eclipse.wst.dtd.core.internal.Attribute;
Lines 28-33 Link Here
28
32
29
	private CCombo typeCombo;
33
	private CCombo typeCombo;
30
	private String[] typeComboValues = {Attribute.CDATA, Attribute.ID, Attribute.IDREF, Attribute.IDREFS, Attribute.ENTITY, Attribute.ENTITIES, Attribute.NMTOKEN, Attribute.NMTOKENS, Attribute.ENUMERATED_NAME, Attribute.ENUMERATED_NOTATION};
34
	private String[] typeComboValues = {Attribute.CDATA, Attribute.ID, Attribute.IDREF, Attribute.IDREFS, Attribute.ENTITY, Attribute.ENTITIES, Attribute.NMTOKEN, Attribute.NMTOKENS, Attribute.ENUMERATED_NAME, Attribute.ENUMERATED_NOTATION};
35
	private FontMetrics fFontMetrics;
31
36
32
	/**
37
	/**
33
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
38
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 36-63 Link Here
36
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
41
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
37
		super.createControls(parent, factory);
42
		super.createControls(parent, factory);
38
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
43
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
39
		FormData data = new FormData();
44
		FormData data;
45
46
		// Create label first then attach other control to it
47
		CLabel cLabel = getWidgetFactory().createCLabel(composite, TYPE);
48
		initializeFontMetrics(cLabel);
49
		int labelWidth = getLabelWidth(cLabel.getText());
50
		data = new FormData(labelWidth, SWT.DEFAULT);
40
		data.left = new FormAttachment(0, 0);
51
		data.left = new FormAttachment(0, 0);
41
		data.right = new FormAttachment(100, 0);
42
		data.top = new FormAttachment(0, 0);
52
		data.top = new FormAttachment(0, 0);
43
		data.bottom = new FormAttachment(100, 0);
53
		cLabel.setLayoutData(data);
44
54
45
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
55
		typeCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
46
		data = new FormData();
56
		data = new FormData();
47
		data.left = new FormAttachment(0, 100);
57
		data.left = new FormAttachment(cLabel, -ITabbedPropertyConstants.HSPACE);
48
		data.right = new FormAttachment(100, 0);
58
		data.right = new FormAttachment(100, 0);
49
		data.top = new FormAttachment(0, 0);
59
		data.top = new FormAttachment(cLabel, 0, SWT.CENTER);
50
		typeCombo.setLayoutData(data);
60
		typeCombo.setLayoutData(data);
51
		typeCombo.addSelectionListener(this);
61
		typeCombo.addSelectionListener(this);
52
		typeCombo.setItems(typeComboValues);
62
		typeCombo.setItems(typeComboValues);
53
54
		CLabel cLabel = getWidgetFactory().createCLabel(composite, TYPE);
55
		data = new FormData();
56
		data.left = new FormAttachment(0, 0);
57
		data.right = new FormAttachment(typeCombo, -ITabbedPropertyConstants.HSPACE);
58
		data.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
59
		cLabel.setLayoutData(data);
60
61
	}
63
	}
62
64
63
	/*
65
	/*
Lines 90-93 Link Here
90
		return false;
92
		return false;
91
	}
93
	}
92
94
95
	/**
96
	 * Initilize font metrics
97
	 * 
98
	 * @param control
99
	 */
100
	private void initializeFontMetrics(Control control) {
101
		GC gc = new GC(control);
102
		gc.setFont(control.getFont());
103
		fFontMetrics = gc.getFontMetrics();
104
		gc.dispose();
105
	}
106
107
	/**
108
	 * Determine appropriate label width
109
	 * 
110
	 * @param labelText
111
	 * @return
112
	 */
113
	private int getLabelWidth(String labelText) {
114
		int labelWidth = 98;
115
116
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
117
		labelWidth = Math.max(pixels, labelWidth);
118
		return labelWidth;
119
	}
93
}
120
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/NameSection.java (-10 / +43 lines)
Lines 11-21 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.GC;
16
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
17
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
18
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Text;
24
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 26-31 Link Here
26
public class NameSection extends AbstractSection {
30
public class NameSection extends AbstractSection {
27
	private final String NAME = DTDPropertiesMessages._UI_LABEL_NAME;
31
	private final String NAME = DTDPropertiesMessages._UI_LABEL_NAME;
28
	private Text nameText;
32
	private Text nameText;
33
	private FontMetrics fFontMetrics;
29
34
30
	public void doHandleEvent(Event event) {
35
	public void doHandleEvent(Event event) {
31
		if (event.widget == nameText) {
36
		if (event.widget == nameText) {
Lines 45-67 Link Here
45
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
50
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
46
		super.createControls(parent, factory);
51
		super.createControls(parent, factory);
47
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
52
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
53
48
		FormData data;
54
		FormData data;
55
		// Create label first then attach other control to it
56
		CLabel nameLabel = getWidgetFactory().createCLabel(composite, NAME);
57
		initializeFontMetrics(nameLabel);
58
		int labelWidth = getLabelWidth(nameLabel.getText());
59
		data = new FormData(labelWidth, SWT.DEFAULT);
60
		data.left = new FormAttachment(0, 0);
61
		data.top = new FormAttachment(0, 0);
62
		nameLabel.setLayoutData(data);
49
63
50
		nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
64
		nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
51
		data = new FormData();
65
		data = new FormData();
52
		data.left = new FormAttachment(0, 100);
66
		data.left = new FormAttachment(nameLabel, -ITabbedPropertyConstants.HSPACE);
53
		data.right = new FormAttachment(100, 0);
67
		data.right = new FormAttachment(100);
54
		data.top = new FormAttachment(0, 0);
68
		data.top = new FormAttachment(nameLabel, 0, SWT.CENTER);
55
		nameText.setLayoutData(data);
69
		nameText.setLayoutData(data);
56
		nameText.addListener(SWT.Modify, this);
70
		nameText.addListener(SWT.Modify, this);
57
71
58
		CLabel nameLabel = getWidgetFactory().createCLabel(composite, NAME);
59
		data = new FormData();
60
		data.left = new FormAttachment(0, 0);
61
		data.right = new FormAttachment(nameText, -ITabbedPropertyConstants.HSPACE);
62
		data.top = new FormAttachment(nameText, 0, SWT.CENTER);
63
		nameLabel.setLayoutData(data);
64
65
		// listener.startListeningForEnter(nameText);
72
		// listener.startListeningForEnter(nameText);
66
		// listener.startListeningTo(nameText);
73
		// listener.startListeningTo(nameText);
67
	}
74
	}
Lines 89-92 Link Here
89
	public boolean shouldUseExtraSpace() {
96
	public boolean shouldUseExtraSpace() {
90
		return false;
97
		return false;
91
	}
98
	}
99
100
	/**
101
	 * Initilize font metrics
102
	 * 
103
	 * @param control
104
	 */
105
	private void initializeFontMetrics(Control control) {
106
		GC gc = new GC(control);
107
		gc.setFont(control.getFont());
108
		fFontMetrics = gc.getFontMetrics();
109
		gc.dispose();
110
	}
111
112
	/**
113
	 * Determine appropriate label width
114
	 * 
115
	 * @param labelText
116
	 * @return
117
	 */
118
	private int getLabelWidth(String labelText) {
119
		int labelWidth = 98;
120
121
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
122
		labelWidth = Math.max(pixels, labelWidth);
123
		return labelWidth;
124
	}
92
}
125
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/EntityValueSection.java (-23 / +58 lines)
Lines 11-21 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
12
package org.eclipse.wst.dtd.ui.internal.properties.section;
13
13
14
import org.eclipse.jface.dialogs.Dialog;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.GC;
16
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
17
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
18
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Text;
24
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 35-40 Link Here
35
	private CLabel valueLabel;
39
	private CLabel valueLabel;
36
	private CLabel publicIdLabel;
40
	private CLabel publicIdLabel;
37
	private CLabel systemIdLabel;
41
	private CLabel systemIdLabel;
42
	private FontMetrics fFontMetrics;
38
43
39
	public void doHandleEvent(Event event) {
44
	public void doHandleEvent(Event event) {
40
		if (event.widget == valueText) {
45
		if (event.widget == valueText) {
Lines 72-124 Link Here
72
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
77
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
73
		FormData data;
78
		FormData data;
74
79
80
		// Create label first then attach other control to it
81
		valueLabel = getWidgetFactory().createCLabel(composite, VALUE);
82
		initializeFontMetrics(valueLabel);
83
		int labelWidth = getLabelWidth(valueLabel.getText());
84
		data = new FormData(labelWidth, SWT.DEFAULT);
85
		data.left = new FormAttachment(0, 0);
86
		data.top = new FormAttachment(0, 0);
87
		valueLabel.setLayoutData(data);
88
75
		// Entity Value
89
		// Entity Value
76
		valueText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
90
		valueText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
77
		data = new FormData();
91
		data = new FormData();
78
		data.left = new FormAttachment(0, 100);
92
		data.left = new FormAttachment(valueLabel, -ITabbedPropertyConstants.HSPACE);
79
		data.right = new FormAttachment(100, 0);
93
		data.right = new FormAttachment(100, 0);
80
		data.top = new FormAttachment(0, 0);
94
		data.top = new FormAttachment(valueLabel, 0, SWT.CENTER);
81
		valueText.setLayoutData(data);
95
		valueText.setLayoutData(data);
82
		valueText.addListener(SWT.Modify, this);
96
		valueText.addListener(SWT.Modify, this);
83
97
84
		valueLabel = getWidgetFactory().createCLabel(composite, VALUE);
98
		// Create label first then attach other control to it
85
		data = new FormData();
99
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
100
		labelWidth = getLabelWidth(publicIdLabel.getText());
101
		data = new FormData(labelWidth, SWT.DEFAULT);
86
		data.left = new FormAttachment(0, 0);
102
		data.left = new FormAttachment(0, 0);
87
		data.right = new FormAttachment(valueText, -ITabbedPropertyConstants.HSPACE);
103
		data.top = new FormAttachment(valueLabel, +ITabbedPropertyConstants.VSPACE);
88
		data.top = new FormAttachment(valueText, 0, SWT.CENTER);
104
		publicIdLabel.setLayoutData(data);
89
		valueLabel.setLayoutData(data);
90
105
91
		// Public ID
106
		// Public ID
92
		publicIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
107
		publicIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
93
		data = new FormData();
108
		data = new FormData();
94
		data.left = new FormAttachment(0, 100);
109
		data.left = new FormAttachment(publicIdLabel, -ITabbedPropertyConstants.HSPACE);
95
		data.right = new FormAttachment(100, 0);
110
		data.right = new FormAttachment(100, 0);
96
		data.top = new FormAttachment(valueText, +ITabbedPropertyConstants.VSPACE);
111
		data.top = new FormAttachment(publicIdLabel, 0, SWT.CENTER);
97
		publicIdText.setLayoutData(data);
112
		publicIdText.setLayoutData(data);
98
		publicIdText.addListener(SWT.Modify, this);
113
		publicIdText.addListener(SWT.Modify, this);
99
114
100
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
115
		// Create label first then attach other control to it
101
		data = new FormData();
116
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
117
		labelWidth = getLabelWidth(systemIdLabel.getText());
118
		data = new FormData(labelWidth, SWT.DEFAULT);
102
		data.left = new FormAttachment(0, 0);
119
		data.left = new FormAttachment(0, 0);
103
		data.right = new FormAttachment(publicIdText, -ITabbedPropertyConstants.HSPACE);
120
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
104
		data.top = new FormAttachment(publicIdText, 0, SWT.CENTER);
121
		systemIdLabel.setLayoutData(data);
105
		publicIdLabel.setLayoutData(data);
106
122
107
		// System ID
123
		// System ID
108
		systemIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
124
		systemIdText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
109
		data = new FormData();
125
		data = new FormData();
110
		data.left = new FormAttachment(0, 100);
126
		data.left = new FormAttachment(systemIdLabel, -ITabbedPropertyConstants.HSPACE);
111
		data.right = new FormAttachment(100, 0);
127
		data.right = new FormAttachment(100, 0);
112
		data.top = new FormAttachment(publicIdText, +ITabbedPropertyConstants.VSPACE);
128
		data.top = new FormAttachment(systemIdLabel, 0, SWT.CENTER);
113
		systemIdText.setLayoutData(data);
129
		systemIdText.setLayoutData(data);
114
		systemIdText.addListener(SWT.Modify, this);
130
		systemIdText.addListener(SWT.Modify, this);
115
116
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
117
		data = new FormData();
118
		data.left = new FormAttachment(0, 0);
119
		data.right = new FormAttachment(systemIdText, -ITabbedPropertyConstants.HSPACE);
120
		data.top = new FormAttachment(systemIdText, 0, SWT.CENTER);
121
		systemIdLabel.setLayoutData(data);
122
	}
131
	}
123
132
124
	/*
133
	/*
Lines 170-173 Link Here
170
	private boolean isExternalEntity() {
179
	private boolean isExternalEntity() {
171
		return EntityTypeSection.isExternalEntity;
180
		return EntityTypeSection.isExternalEntity;
172
	}
181
	}
182
183
	/**
184
	 * Initilize font metrics
185
	 * 
186
	 * @param control
187
	 */
188
	private void initializeFontMetrics(Control control) {
189
		GC gc = new GC(control);
190
		gc.setFont(control.getFont());
191
		fFontMetrics = gc.getFontMetrics();
192
		gc.dispose();
193
	}
194
195
	/**
196
	 * Determine appropriate label width
197
	 * 
198
	 * @param labelText
199
	 * @return
200
	 */
201
	private int getLabelWidth(String labelText) {
202
		int labelWidth = 98;
203
204
		int pixels = Dialog.convertWidthInCharsToPixels(fFontMetrics, labelText.length() + 5);
205
		labelWidth = Math.max(pixels, labelWidth);
206
		return labelWidth;
207
	}
173
}
208
}

Return to bug 141106