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 (-37 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-25 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CLabel;
15
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.graphics.FontMetrics;
16
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.GC;
19
import org.eclipse.swt.layout.FormAttachment;
17
import org.eclipse.swt.layout.FormAttachment;
20
import org.eclipse.swt.layout.FormData;
18
import org.eclipse.swt.layout.FormData;
21
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 36-42 Link Here
36
33
37
	private CLabel publicIdLabel;
34
	private CLabel publicIdLabel;
38
	private CLabel systemIdLabel;
35
	private CLabel systemIdLabel;
39
	private FontMetrics fFontMetrics;
40
36
41
	public void doHandleEvent(Event event) {
37
	public void doHandleEvent(Event event) {
42
		if (event.widget == publicIdText) {
38
		if (event.widget == publicIdText) {
Lines 64-76 Link Here
64
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
60
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
65
		super.createControls(parent, factory);
61
		super.createControls(parent, factory);
66
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
62
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
67
		FormData data;
68
63
69
		// Create label first then attach other control to it
64
		// Create label first then attach other control to it
70
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
65
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
71
		initializeFontMetrics(publicIdLabel);
66
72
		int labelWidth = getLabelWidth(publicIdLabel.getText());
67
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
73
		data = new FormData(labelWidth, SWT.DEFAULT);
68
		Point p = publicIdLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
69
		int labelWidth = Math.max(p.x, 98);
70
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
74
		data.left = new FormAttachment(0, 0);
71
		data.left = new FormAttachment(0, 0);
75
		data.top = new FormAttachment(0, 0);
72
		data.top = new FormAttachment(0, 0);
76
		publicIdLabel.setLayoutData(data);
73
		publicIdLabel.setLayoutData(data);
Lines 86-92 Link Here
86
83
87
		// Create label first then attach other control to it
84
		// Create label first then attach other control to it
88
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
85
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
89
		labelWidth = getLabelWidth(systemIdLabel.getText());
86
87
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
88
		p = systemIdLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
89
		labelWidth = Math.max(p.x, 98);
90
		data = new FormData(labelWidth, SWT.DEFAULT);
90
		data = new FormData(labelWidth, SWT.DEFAULT);
91
		data.left = new FormAttachment(0, 0);
91
		data.left = new FormAttachment(0, 0);
92
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
92
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
Lines 128-157 Link Here
128
	public boolean shouldUseExtraSpace() {
128
	public boolean shouldUseExtraSpace() {
129
		return false;
129
		return false;
130
	}
130
	}
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
	}
157
}
131
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/ContentModelTypeSection.java (-36 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-29 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
15
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CCombo;
19
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.custom.CLabel;
20
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.graphics.GC;
23
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
24
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
25
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
24
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
28
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
25
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
29
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
26
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
Lines 39-45 Link Here
39
36
40
	private CCombo typeCombo;
37
	private CCombo typeCombo;
41
	private String[] typeComboValues = {CMNode.ANY, CMNode.EMPTY, CMNode.PCDATA, CMNode.CHILDREN, CMNode.MIXED};
38
	private String[] typeComboValues = {CMNode.ANY, CMNode.EMPTY, CMNode.PCDATA, CMNode.CHILDREN, CMNode.MIXED};
42
	private FontMetrics fFontMetrics;
43
39
44
	/**
40
	/**
45
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
41
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 48-60 Link Here
48
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
44
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
49
		super.createControls(parent, factory);
45
		super.createControls(parent, factory);
50
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
46
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
51
		FormData data;
52
47
53
		// Create label first then attach other control to it
48
		// Create label first then attach other control to it
54
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_TYPE);
49
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_TYPE);
55
		initializeFontMetrics(cLabel);
50
56
		int labelWidth = getLabelWidth(cLabel.getText());
51
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
57
		data = new FormData(labelWidth, SWT.DEFAULT);
52
		Point p = cLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
53
		int labelWidth = Math.max(p.x, 98);
54
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
58
		data.left = new FormAttachment(0, 0);
55
		data.left = new FormAttachment(0, 0);
59
		data.top = new FormAttachment(0, 0);
56
		data.top = new FormAttachment(0, 0);
60
		cLabel.setLayoutData(data);
57
		cLabel.setLayoutData(data);
Lines 123-152 Link Here
123
	public boolean shouldUseExtraSpace() {
120
	public boolean shouldUseExtraSpace() {
124
		return false;
121
		return false;
125
	}
122
	}
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
	}
152
}
123
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/OccurrenceSection.java (-34 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-27 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CCombo;
15
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
23
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
26
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
23
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
27
import org.eclipse.wst.dtd.core.internal.CMRepeatableNode;
24
import org.eclipse.wst.dtd.core.internal.CMRepeatableNode;
Lines 36-42 Link Here
36
33
37
	private CCombo occurrenceCombo;
34
	private CCombo occurrenceCombo;
38
	private String[] occurrenceComboValues = {ONCE, ONE_OR_MORE, OPTIONAL, ZERO_OR_MORE};
35
	private String[] occurrenceComboValues = {ONCE, ONE_OR_MORE, OPTIONAL, ZERO_OR_MORE};
39
	private FontMetrics fFontMetrics;
40
36
41
	/**
37
	/**
42
	 * @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 48-55 Link Here
48
44
49
		// Create label first then attach other control to it
45
		// Create label first then attach other control to it
50
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, OCCURENCE);
46
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, OCCURENCE);
51
		initializeFontMetrics(usageLabel);
47
52
		int labelWidth = getLabelWidth(usageLabel.getText());
48
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
49
		Point p = usageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
50
		int labelWidth = Math.max(p.x, 98);
53
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
51
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
54
		data.left = new FormAttachment(0, 0);
52
		data.left = new FormAttachment(0, 0);
55
		data.top = new FormAttachment(0, 0);
53
		data.top = new FormAttachment(0, 0);
Lines 104-133 Link Here
104
			setListenerEnabled(true);
102
			setListenerEnabled(true);
105
		}
103
		}
106
	}
104
	}
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
	}
133
}
105
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/EntityTypeSection.java (-35 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-28 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CCombo;
15
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
23
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
23
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
27
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
24
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
28
import org.eclipse.wst.dtd.core.internal.Entity;
25
import org.eclipse.wst.dtd.core.internal.Entity;
Lines 37-43 Link Here
37
	private CCombo typeCombo;
34
	private CCombo typeCombo;
38
	private String[] typeComboValues = {PARAMETER, GENERAL};
35
	private String[] typeComboValues = {PARAMETER, GENERAL};
39
	private Button checkBox;
36
	private Button checkBox;
40
	private FontMetrics fFontMetrics;
41
37
42
	public static boolean isExternalEntity = false;
38
	public static boolean isExternalEntity = false;
43
39
Lines 51-58 Link Here
51
47
52
		// Create label first then attach other control to it
48
		// Create label first then attach other control to it
53
		CLabel cLabel = getWidgetFactory().createCLabel(composite, ENTITY_TYPE);
49
		CLabel cLabel = getWidgetFactory().createCLabel(composite, ENTITY_TYPE);
54
		initializeFontMetrics(cLabel);
50
55
		int labelWidth = getLabelWidth(cLabel.getText());
51
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
52
		Point p = cLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
53
		int labelWidth = Math.max(p.x, 98);
56
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
54
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
57
		data.left = new FormAttachment(0, 0);
55
		data.left = new FormAttachment(0, 0);
58
		data.top = new FormAttachment(0, 0);
56
		data.top = new FormAttachment(0, 0);
Lines 68-74 Link Here
68
		typeCombo.setItems(typeComboValues);
66
		typeCombo.setItems(typeComboValues);
69
67
70
		checkBox = getWidgetFactory().createButton(composite, EXTERNAL_ENTITY, SWT.CHECK);
68
		checkBox = getWidgetFactory().createButton(composite, EXTERNAL_ENTITY, SWT.CHECK);
71
		labelWidth = getLabelWidth(checkBox.getText());
69
70
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
71
		p = checkBox.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
72
		labelWidth = Math.max(p.x, 98);
72
		data = new FormData(labelWidth, SWT.DEFAULT);
73
		data = new FormData(labelWidth, SWT.DEFAULT);
73
		data.left = new FormAttachment(0, 0);
74
		data.left = new FormAttachment(0, 0);
74
		data.right = new FormAttachment(95, 0);
75
		data.right = new FormAttachment(95, 0);
Lines 137-166 Link Here
137
	public boolean shouldUseExtraSpace() {
138
	public boolean shouldUseExtraSpace() {
138
		return false;
139
		return false;
139
	}
140
	}
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
	}
166
}
141
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/ContentModelNameSection.java (-34 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-29 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
15
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CCombo;
19
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.custom.CLabel;
20
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.graphics.FontMetrics;
20
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.graphics.GC;
23
import org.eclipse.swt.layout.FormAttachment;
21
import org.eclipse.swt.layout.FormAttachment;
24
import org.eclipse.swt.layout.FormData;
22
import org.eclipse.swt.layout.FormData;
25
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
24
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
28
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
25
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
29
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
26
import org.eclipse.wst.dtd.core.internal.CMBasicNode;
Lines 38-44 Link Here
38
35
39
	private CCombo typeCombo;
36
	private CCombo typeCombo;
40
	private String[] typeComboValues = {CMNode.PCDATA};
37
	private String[] typeComboValues = {CMNode.PCDATA};
41
	private FontMetrics fFontMetrics;
42
38
43
	/**
39
	/**
44
	 * @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 50-57 Link Here
50
46
51
		// Create label first then attach other control to it
47
		// Create label first then attach other control to it
52
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_MODEL);
48
		CLabel cLabel = getWidgetFactory().createCLabel(composite, CONTENT_MODEL);
53
		initializeFontMetrics(cLabel);
49
54
		int labelWidth = getLabelWidth(cLabel.getText());
50
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
51
		Point p = cLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
52
		int labelWidth = Math.max(p.x, 98);
55
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
53
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
56
		data.left = new FormAttachment(0, 0);
54
		data.left = new FormAttachment(0, 0);
57
		data.top = new FormAttachment(0, 0);
55
		data.top = new FormAttachment(0, 0);
Lines 109-138 Link Here
109
	public boolean shouldUseExtraSpace() {
107
	public boolean shouldUseExtraSpace() {
110
		return false;
108
		return false;
111
	}
109
	}
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
	}
138
}
110
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/AttributeDefaultSection.java (-35 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-27 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CCombo;
15
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
23
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Event;
26
import org.eclipse.swt.widgets.Text;
23
import org.eclipse.swt.widgets.Text;
27
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
24
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 39-45 Link Here
39
	private String[] usageComboValues = {IMPLIED, REQUIRED, FIXED, DTDPropertiesMessages._UI_DEFAULT};
36
	private String[] usageComboValues = {IMPLIED, REQUIRED, FIXED, DTDPropertiesMessages._UI_DEFAULT};
40
	private Text defaultValueText;
37
	private Text defaultValueText;
41
	private CLabel defaultValueLabel;
38
	private CLabel defaultValueLabel;
42
	private FontMetrics fFontMetrics;
43
39
44
	/**
40
	/**
45
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
41
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 51-58 Link Here
51
47
52
		// Create label first then attach other control to it
48
		// Create label first then attach other control to it
53
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_USAGE);
49
		CLabel usageLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_USAGE);
54
		initializeFontMetrics(usageLabel);
50
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
55
		int labelWidth = getLabelWidth(usageLabel.getText());
51
		Point p = usageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
52
		int labelWidth = Math.max(p.x, 98);
56
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
53
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
57
		data.left = new FormAttachment(0, 0);
54
		data.left = new FormAttachment(0, 0);
58
		data.top = new FormAttachment(0, 0);
55
		data.top = new FormAttachment(0, 0);
Lines 69-75 Link Here
69
66
70
		// Create label first then attach other control to it
67
		// Create label first then attach other control to it
71
		defaultValueLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_DEFAULT_VALUE);
68
		defaultValueLabel = getWidgetFactory().createCLabel(composite, DTDPropertiesMessages._UI_LABEL_DEFAULT_VALUE);
72
		labelWidth = getLabelWidth(defaultValueLabel.getText());
69
70
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
71
		p = defaultValueLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
72
		labelWidth = Math.max(p.x, 98);
73
		data = new FormData(labelWidth, SWT.DEFAULT);
73
		data = new FormData(labelWidth, SWT.DEFAULT);
74
		data.left = new FormAttachment(0, 0);
74
		data.left = new FormAttachment(0, 0);
75
		data.top = new FormAttachment(usageLabel, +ITabbedPropertyConstants.VSPACE);
75
		data.top = new FormAttachment(usageLabel, +ITabbedPropertyConstants.VSPACE);
Lines 149-178 Link Here
149
			}
149
			}
150
		}
150
		}
151
	}
151
	}
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
	}
178
}
152
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/ContentModelGroupSection.java (-35 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-27 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CCombo;
15
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
23
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
26
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
23
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
27
import org.eclipse.wst.dtd.core.internal.CMGroupNode;
24
import org.eclipse.wst.dtd.core.internal.CMGroupNode;
Lines 34-40 Link Here
34
31
35
	private CCombo modelGroupCombo;
32
	private CCombo modelGroupCombo;
36
	private String[] modelGroupComboValues = {SEQUENCE, CHOICE};
33
	private String[] modelGroupComboValues = {SEQUENCE, CHOICE};
37
	private FontMetrics fFontMetrics;
38
34
39
	/**
35
	/**
40
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
36
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 46-53 Link Here
46
42
47
		// Create label first then attach other control to it
43
		// Create label first then attach other control to it
48
		CLabel cLabel = getWidgetFactory().createCLabel(composite, MODEL_GROUP);
44
		CLabel cLabel = getWidgetFactory().createCLabel(composite, MODEL_GROUP);
49
		initializeFontMetrics(cLabel);
45
50
		int labelWidth = getLabelWidth(cLabel.getText());
46
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
47
		Point p = cLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
48
		int labelWidth = Math.max(p.x, 98);
51
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
49
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
52
		data.left = new FormAttachment(0, 0);
50
		data.left = new FormAttachment(0, 0);
53
		data.top = new FormAttachment(0, 0);
51
		data.top = new FormAttachment(0, 0);
Lines 94-124 Link Here
94
			}
92
			}
95
		}
93
		}
96
	}
94
	}
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
124
}
95
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/NewEntitySection.java (-38 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-18 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;
16
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.jface.viewers.ViewerFilter;
16
import org.eclipse.jface.viewers.ViewerFilter;
18
import org.eclipse.jface.window.Window;
17
import org.eclipse.jface.window.Window;
Lines 21-33 Link Here
21
import org.eclipse.swt.custom.CCombo;
20
import org.eclipse.swt.custom.CCombo;
22
import org.eclipse.swt.custom.CLabel;
21
import org.eclipse.swt.custom.CLabel;
23
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.graphics.FontMetrics;
23
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.graphics.GC;
26
import org.eclipse.swt.layout.FormAttachment;
24
import org.eclipse.swt.layout.FormAttachment;
27
import org.eclipse.swt.layout.FormData;
25
import org.eclipse.swt.layout.FormData;
28
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Button;
29
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Display;
28
import org.eclipse.swt.widgets.Display;
32
import org.eclipse.swt.widgets.Event;
29
import org.eclipse.swt.widgets.Event;
33
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Shell;
Lines 64-70 Link Here
64
	private CCombo typeCombo;
61
	private CCombo typeCombo;
65
	private String[] typeComboValues = {PARAMETER, GENERAL};
62
	private String[] typeComboValues = {PARAMETER, GENERAL};
66
	private PageBook pageBook;
63
	private PageBook pageBook;
67
	private FontMetrics fFontMetrics;
68
64
69
	/**
65
	/**
70
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
66
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 102-109 Link Here
102
98
103
		// Create label first then attach other control to it
99
		// Create label first then attach other control to it
104
		CLabel nameLabel = getWidgetFactory().createCLabel(entityCommonComposite, NAME); //$NON-NLS-1$
100
		CLabel nameLabel = getWidgetFactory().createCLabel(entityCommonComposite, NAME); //$NON-NLS-1$
105
		initializeFontMetrics(nameLabel);
101
106
		int labelWidth = getLabelWidth(nameLabel.getText());
102
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
103
		Point p = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
104
		int labelWidth = Math.max(p.x, 98);
107
		data = new FormData(labelWidth, SWT.DEFAULT);
105
		data = new FormData(labelWidth, SWT.DEFAULT);
108
		data.left = new FormAttachment(0, 0);
106
		data.left = new FormAttachment(0, 0);
109
		data.top = new FormAttachment(0, 0);
107
		data.top = new FormAttachment(0, 0);
Lines 119-125 Link Here
119
117
120
		// Create label first then attach other control to it
118
		// Create label first then attach other control to it
121
		CLabel cLabel = getWidgetFactory().createCLabel(entityCommonComposite, ENTITY_TYPE);
119
		CLabel cLabel = getWidgetFactory().createCLabel(entityCommonComposite, ENTITY_TYPE);
122
		labelWidth = getLabelWidth(cLabel.getText());
120
121
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
122
		p = cLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
123
		labelWidth = Math.max(p.x, 98);
123
		data = new FormData(labelWidth, SWT.DEFAULT);
124
		data = new FormData(labelWidth, SWT.DEFAULT);
124
		data.left = new FormAttachment(0, 0);
125
		data.left = new FormAttachment(0, 0);
125
		data.top = new FormAttachment(nameLabel, +ITabbedPropertyConstants.VSPACE);
126
		data.top = new FormAttachment(nameLabel, +ITabbedPropertyConstants.VSPACE);
Lines 159-165 Link Here
159
160
160
		// Create label first then attach other control to it
161
		// Create label first then attach other control to it
161
		CLabel entityValueLabel = getWidgetFactory().createCLabel(internalEntityComposite, VALUE); //$NON-NLS-1$
162
		CLabel entityValueLabel = getWidgetFactory().createCLabel(internalEntityComposite, VALUE); //$NON-NLS-1$
162
		int labelWidth = getLabelWidth(entityValueLabel.getText());
163
164
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
165
		Point p = entityValueLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
166
		int labelWidth = Math.max(p.x, 98);
163
		data = new FormData(labelWidth, SWT.DEFAULT);
167
		data = new FormData(labelWidth, SWT.DEFAULT);
164
		data.left = new FormAttachment(0, 0);
168
		data.left = new FormAttachment(0, 0);
165
		data.top = new FormAttachment(0, 0);
169
		data.top = new FormAttachment(0, 0);
Lines 189-195 Link Here
189
193
190
		// Create label first then attach other control to it
194
		// Create label first then attach other control to it
191
		CLabel publicIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, PUBLIC_ID); //$NON-NLS-1$
195
		CLabel publicIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, PUBLIC_ID); //$NON-NLS-1$
192
		int labelWidth = getLabelWidth(publicIdLabel.getText());
196
197
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
198
		Point p = publicIdLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
199
		int labelWidth = Math.max(p.x, 98);
193
		data = new FormData(labelWidth, SWT.DEFAULT);
200
		data = new FormData(labelWidth, SWT.DEFAULT);
194
		data.left = new FormAttachment(0, 0);
201
		data.left = new FormAttachment(0, 0);
195
		data.top = new FormAttachment(0, 0);
202
		data.top = new FormAttachment(0, 0);
Lines 207-213 Link Here
207
		// Create label first then attach other control to it
214
		// Create label first then attach other control to it
208
		// Create System ID Label
215
		// Create System ID Label
209
		CLabel systemIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, SYSTEM_ID); //$NON-NLS-1$
216
		CLabel systemIdLabel = getWidgetFactory().createCLabel(externalEntityComposite, SYSTEM_ID); //$NON-NLS-1$
210
		labelWidth = getLabelWidth(systemIdLabel.getText());
217
218
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
219
		p = systemIdLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
220
		labelWidth = Math.max(p.x, 98);
211
		data = new FormData(labelWidth, SWT.DEFAULT);
221
		data = new FormData(labelWidth, SWT.DEFAULT);
212
		data.left = new FormAttachment(0, 0);
222
		data.left = new FormAttachment(0, 0);
213
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
223
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
Lines 363-392 Link Here
363
		}
373
		}
364
374
365
	}
375
	}
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
	}
392
}
376
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/TypeSection.java (-35 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-27 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CCombo;
15
import org.eclipse.swt.custom.CCombo;
17
import org.eclipse.swt.custom.CLabel;
16
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.FontMetrics;
18
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.GC;
21
import org.eclipse.swt.layout.FormAttachment;
19
import org.eclipse.swt.layout.FormAttachment;
22
import org.eclipse.swt.layout.FormData;
20
import org.eclipse.swt.layout.FormData;
23
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
26
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
23
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
27
import org.eclipse.wst.dtd.core.internal.Attribute;
24
import org.eclipse.wst.dtd.core.internal.Attribute;
Lines 32-38 Link Here
32
29
33
	private CCombo typeCombo;
30
	private CCombo typeCombo;
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};
31
	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;
36
32
37
	/**
33
	/**
38
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
34
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite,
Lines 41-52 Link Here
41
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
37
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
42
		super.createControls(parent, factory);
38
		super.createControls(parent, factory);
43
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
39
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
44
		FormData data;
45
40
46
		// Create label first then attach other control to it
41
		// Create label first then attach other control to it
47
		CLabel cLabel = getWidgetFactory().createCLabel(composite, TYPE);
42
		CLabel cLabel = getWidgetFactory().createCLabel(composite, TYPE);
48
		initializeFontMetrics(cLabel);
43
49
		int labelWidth = getLabelWidth(cLabel.getText());
44
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
45
		Point p = cLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
46
		int labelWidth = Math.max(p.x, 98);
47
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
50
		data = new FormData(labelWidth, SWT.DEFAULT);
48
		data = new FormData(labelWidth, SWT.DEFAULT);
51
		data.left = new FormAttachment(0, 0);
49
		data.left = new FormAttachment(0, 0);
52
		data.top = new FormAttachment(0, 0);
50
		data.top = new FormAttachment(0, 0);
Lines 91-120 Link Here
91
	public boolean shouldUseExtraSpace() {
89
	public boolean shouldUseExtraSpace() {
92
		return false;
90
		return false;
93
	}
91
	}
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
	}
120
}
92
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/EntityValueSection.java (-38 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-25 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CLabel;
15
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.graphics.FontMetrics;
16
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.GC;
19
import org.eclipse.swt.layout.FormAttachment;
17
import org.eclipse.swt.layout.FormAttachment;
20
import org.eclipse.swt.layout.FormData;
18
import org.eclipse.swt.layout.FormData;
21
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 39-45 Link Here
39
	private CLabel valueLabel;
36
	private CLabel valueLabel;
40
	private CLabel publicIdLabel;
37
	private CLabel publicIdLabel;
41
	private CLabel systemIdLabel;
38
	private CLabel systemIdLabel;
42
	private FontMetrics fFontMetrics;
43
39
44
	public void doHandleEvent(Event event) {
40
	public void doHandleEvent(Event event) {
45
		if (event.widget == valueText) {
41
		if (event.widget == valueText) {
Lines 75-87 Link Here
75
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
71
	public void createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
76
		super.createControls(parent, factory);
72
		super.createControls(parent, factory);
77
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
73
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
78
		FormData data;
79
74
80
		// Create label first then attach other control to it
75
		// Create label first then attach other control to it
81
		valueLabel = getWidgetFactory().createCLabel(composite, VALUE);
76
		valueLabel = getWidgetFactory().createCLabel(composite, VALUE);
82
		initializeFontMetrics(valueLabel);
77
83
		int labelWidth = getLabelWidth(valueLabel.getText());
78
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
84
		data = new FormData(labelWidth, SWT.DEFAULT);
79
		Point p = valueLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
80
		int labelWidth = Math.max(p.x, 98);
81
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
85
		data.left = new FormAttachment(0, 0);
82
		data.left = new FormAttachment(0, 0);
86
		data.top = new FormAttachment(0, 0);
83
		data.top = new FormAttachment(0, 0);
87
		valueLabel.setLayoutData(data);
84
		valueLabel.setLayoutData(data);
Lines 97-103 Link Here
97
94
98
		// Create label first then attach other control to it
95
		// Create label first then attach other control to it
99
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
96
		publicIdLabel = getWidgetFactory().createCLabel(composite, PUBLIC_ID);
100
		labelWidth = getLabelWidth(publicIdLabel.getText());
97
98
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
99
		p = publicIdLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
100
		labelWidth = Math.max(p.x, 98);
101
		data = new FormData(labelWidth, SWT.DEFAULT);
101
		data = new FormData(labelWidth, SWT.DEFAULT);
102
		data.left = new FormAttachment(0, 0);
102
		data.left = new FormAttachment(0, 0);
103
		data.top = new FormAttachment(valueLabel, +ITabbedPropertyConstants.VSPACE);
103
		data.top = new FormAttachment(valueLabel, +ITabbedPropertyConstants.VSPACE);
Lines 114-120 Link Here
114
114
115
		// Create label first then attach other control to it
115
		// Create label first then attach other control to it
116
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
116
		systemIdLabel = getWidgetFactory().createCLabel(composite, SYSTEM_ID);
117
		labelWidth = getLabelWidth(systemIdLabel.getText());
117
118
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
119
		p = systemIdLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
120
		labelWidth = Math.max(p.x, 98);
118
		data = new FormData(labelWidth, SWT.DEFAULT);
121
		data = new FormData(labelWidth, SWT.DEFAULT);
119
		data.left = new FormAttachment(0, 0);
122
		data.left = new FormAttachment(0, 0);
120
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
123
		data.top = new FormAttachment(publicIdLabel, +ITabbedPropertyConstants.VSPACE);
Lines 179-208 Link Here
179
	private boolean isExternalEntity() {
182
	private boolean isExternalEntity() {
180
		return EntityTypeSection.isExternalEntity;
183
		return EntityTypeSection.isExternalEntity;
181
	}
184
	}
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
	}
208
}
185
}
(-)src-properties/org/eclipse/wst/dtd/ui/internal/properties/section/NameSection.java (-36 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-25 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;
15
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CLabel;
15
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.graphics.FontMetrics;
16
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.graphics.GC;
19
import org.eclipse.swt.layout.FormAttachment;
17
import org.eclipse.swt.layout.FormAttachment;
20
import org.eclipse.swt.layout.FormData;
18
import org.eclipse.swt.layout.FormData;
21
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
22
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
Lines 30-36 Link Here
30
public class NameSection extends AbstractSection {
27
public class NameSection extends AbstractSection {
31
	private final String NAME = DTDPropertiesMessages._UI_LABEL_NAME;
28
	private final String NAME = DTDPropertiesMessages._UI_LABEL_NAME;
32
	private Text nameText;
29
	private Text nameText;
33
	private FontMetrics fFontMetrics;
34
30
35
	public void doHandleEvent(Event event) {
31
	public void doHandleEvent(Event event) {
36
		if (event.widget == nameText) {
32
		if (event.widget == nameText) {
Lines 51-62 Link Here
51
		super.createControls(parent, factory);
47
		super.createControls(parent, factory);
52
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
48
		Composite composite = getWidgetFactory().createFlatFormComposite(parent);
53
49
54
		FormData data;
55
		// Create label first then attach other control to it
50
		// Create label first then attach other control to it
56
		CLabel nameLabel = getWidgetFactory().createCLabel(composite, NAME);
51
		CLabel nameLabel = getWidgetFactory().createCLabel(composite, NAME);
57
		initializeFontMetrics(nameLabel);
52
58
		int labelWidth = getLabelWidth(nameLabel.getText());
53
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141106
59
		data = new FormData(labelWidth, SWT.DEFAULT);
54
		Point p = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
55
		int labelWidth = Math.max(p.x, 98);
56
		FormData data = new FormData(labelWidth, SWT.DEFAULT);
60
		data.left = new FormAttachment(0, 0);
57
		data.left = new FormAttachment(0, 0);
61
		data.top = new FormAttachment(0, 0);
58
		data.top = new FormAttachment(0, 0);
62
		nameLabel.setLayoutData(data);
59
		nameLabel.setLayoutData(data);
Lines 96-125 Link Here
96
	public boolean shouldUseExtraSpace() {
93
	public boolean shouldUseExtraSpace() {
97
		return false;
94
		return false;
98
	}
95
	}
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
	}
125
}
96
}

Return to bug 141106