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