|
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 |
} |