1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
/*****************************************************************************
* Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and
* is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
****************************************************************************/
package org.eclipse.wst.css.ui.internal.edit.ui;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy;
import org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategyImpl;
import org.eclipse.wst.css.ui.internal.CSSUIMessages;
import org.eclipse.wst.css.ui.internal.editor.IHelpContextIds;
public class CleanupDialogCSS extends Dialog {
private boolean embeddedCSS;
protected Button fRadioButtonIdentCaseAsis;
protected Button fRadioButtonIdentCaseLower;
protected Button fRadioButtonIdentCaseUpper;
protected Button fRadioButtonPropNameCaseAsis;
protected Button fRadioButtonPropNameCaseLower;
protected Button fRadioButtonPropNameCaseUpper;
protected Button fRadioButtonPropValueCaseAsis;
protected Button fRadioButtonPropValueCaseLower;
protected Button fRadioButtonPropValueCaseUpper;
protected Button fRadioButtonSelectorTagCaseAsis;
protected Button fRadioButtonSelectorTagCaseLower;
protected Button fRadioButtonSelectorTagCaseUpper;
protected Button fCheckBoxQuoteValues;
protected Button fCheckBoxFormatSource;
/**
* CSSCleanupDialog constructor comment.
*
* @param parentShell
* org.eclipse.swt.widgets.Shell
*/
public CleanupDialogCSS(Shell parentShell) {
super(parentShell);
}
/**
*
* @return org.eclipse.swt.widgets.Control
* @param parent
* org.eclipse.swt.widgets.Composite
*/
public Control createDialogArea(Composite parent) {
if (isEmbeddedCSS())
getShell().setText(CSSUIMessages.CSS_Cleanup_UI_);
else
getShell().setText(CSSUIMessages.Cleanup_UI_);
Composite panel = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.makeColumnsEqualWidth = true;
panel.setLayout(layout);
WorkbenchHelp.setHelp(panel, IHelpContextIds.CSS_CLEANUP_HELPID);
// Convert ident case
// ACC: Group radio buttons together so associated label is read
// Label identCaseLabel = new Label(panel, SWT.NULL);
// identCaseLabel.setText(ResourceHandler.getString("Identifier_case__UI_"));
// //$NON-NLS-1$ = "Identifier case:"
// Canvas identCase = new Canvas(panel, SWT.NULL);
Group identCase = new Group(panel, SWT.NULL);
identCase.setText(CSSUIMessages.Identifier_case__UI_);
GridLayout hLayout = new GridLayout();
hLayout.numColumns = 3;
identCase.setLayout(hLayout);
fRadioButtonIdentCaseAsis = new Button(identCase, SWT.RADIO);
fRadioButtonIdentCaseAsis.setText(CSSUIMessages.As_is_UI_);
fRadioButtonIdentCaseLower = new Button(identCase, SWT.RADIO);
fRadioButtonIdentCaseLower.setText(CSSUIMessages.Lower_UI_);
fRadioButtonIdentCaseUpper = new Button(identCase, SWT.RADIO);
fRadioButtonIdentCaseUpper.setText(CSSUIMessages.Upper_UI_);
// Convert property name case
// ACC: Group radio buttons together so associated label is read
// Label propNameCaseLabel = new Label(panel, SWT.NULL);
// propNameCaseLabel.setText(ResourceHandler.getString("Property_name_case__UI_"));
// //$NON-NLS-1$ = "Property name case:"
// Canvas propNameCase = new Canvas(panel, SWT.NULL);
Group propNameCase = new Group(panel, SWT.NULL);
propNameCase.setText(CSSUIMessages.Property_name_case__UI_);
hLayout = new GridLayout();
hLayout.numColumns = 3;
propNameCase.setLayout(hLayout);
fRadioButtonPropNameCaseAsis = new Button(propNameCase, SWT.RADIO);
fRadioButtonPropNameCaseAsis.setText(CSSUIMessages.As_is_UI_);
fRadioButtonPropNameCaseLower = new Button(propNameCase, SWT.RADIO);
fRadioButtonPropNameCaseLower.setText(CSSUIMessages.Lower_UI_);
fRadioButtonPropNameCaseUpper = new Button(propNameCase, SWT.RADIO);
fRadioButtonPropNameCaseUpper.setText(CSSUIMessages.Upper_UI_);
// Convert property Value case
// ACC: Group radio buttons together so associated label is read
// Label propValueCaseLabel = new Label(panel, SWT.NULL);
// propValueCaseLabel.setText(ResourceHandler.getString("Property_value_case__UI_"));
// //$NON-NLS-1$ = "Property value case:"
// Canvas propValueCase = new Canvas(panel, SWT.NULL);
Group propValueCase = new Group(panel, SWT.NULL);
propValueCase.setText(CSSUIMessages.Property_value_case__UI_);
hLayout = new GridLayout();
hLayout.numColumns = 3;
propValueCase.setLayout(hLayout);
fRadioButtonPropValueCaseAsis = new Button(propValueCase, SWT.RADIO);
fRadioButtonPropValueCaseAsis.setText(CSSUIMessages.As_is_UI_);
fRadioButtonPropValueCaseLower = new Button(propValueCase, SWT.RADIO);
fRadioButtonPropValueCaseLower.setText(CSSUIMessages.Lower_UI_);
fRadioButtonPropValueCaseUpper = new Button(propValueCase, SWT.RADIO);
fRadioButtonPropValueCaseUpper.setText(CSSUIMessages.Upper_UI_);
if (!isEmbeddedCSS()) {
// Convert selector tag case
// ACC: Group radio buttons together so associated label is read
// Label selectorTagCaseLabel = new Label(panel, SWT.NULL);
// selectorTagCaseLabel.setText(ResourceHandler.getString("Selector_tag_name_case__UI_"));
// //$NON-NLS-1$ = "Selector tag name case:"
// Canvas selectorTagCase = new Canvas(panel, SWT.NULL);
Group selectorTagCase = new Group(panel, SWT.NULL);
selectorTagCase.setText(CSSUIMessages.Selector_tag_name_case__UI_);
hLayout = new GridLayout();
hLayout.numColumns = 3;
selectorTagCase.setLayout(hLayout);
fRadioButtonSelectorTagCaseAsis = new Button(selectorTagCase, SWT.RADIO);
fRadioButtonSelectorTagCaseAsis.setText(CSSUIMessages.As_is_UI_);
fRadioButtonSelectorTagCaseLower = new Button(selectorTagCase, SWT.RADIO);
fRadioButtonSelectorTagCaseLower.setText(CSSUIMessages.Lower_UI_);
fRadioButtonSelectorTagCaseUpper = new Button(selectorTagCase, SWT.RADIO);
fRadioButtonSelectorTagCaseUpper.setText(CSSUIMessages.Upper_UI_);
}
// Quote attribute values
fCheckBoxQuoteValues = new Button(panel, SWT.CHECK);
fCheckBoxQuoteValues.setText(CSSUIMessages.Quote_values_UI_);
if (!isEmbeddedCSS()) {
// Format source
fCheckBoxFormatSource = new Button(panel, SWT.CHECK);
fCheckBoxFormatSource.setText(CSSUIMessages.Format_source_UI_);
}
setCleanupOptions();
return panel;
}
/**
* Insert the method's description here.
*
* @return boolean
*/
public boolean isEmbeddedCSS() {
return embeddedCSS;
}
/**
*
*/
protected void okPressed() {
updateCleanupOptions();
super.okPressed();
}
/**
*
*/
protected void setCleanupOptions() {
CSSCleanupStrategy stgy = CSSCleanupStrategyImpl.getInstance();
if (fRadioButtonIdentCaseAsis != null) {
if (stgy.getIdentCase() == CSSCleanupStrategy.UPPER)
fRadioButtonIdentCaseUpper.setSelection(true);
else if (stgy.getIdentCase() == CSSCleanupStrategy.LOWER)
fRadioButtonIdentCaseLower.setSelection(true);
else
fRadioButtonIdentCaseAsis.setSelection(true);
}
if (fRadioButtonPropNameCaseAsis != null) {
if (stgy.getPropNameCase() == CSSCleanupStrategy.UPPER)
fRadioButtonPropNameCaseUpper.setSelection(true);
else if (stgy.getPropNameCase() == CSSCleanupStrategy.LOWER)
fRadioButtonPropNameCaseLower.setSelection(true);
else
fRadioButtonPropNameCaseAsis.setSelection(true);
}
if (fRadioButtonPropValueCaseAsis != null) {
if (stgy.getPropValueCase() == CSSCleanupStrategy.UPPER)
fRadioButtonPropValueCaseUpper.setSelection(true);
else if (stgy.getPropValueCase() == CSSCleanupStrategy.LOWER)
fRadioButtonPropValueCaseLower.setSelection(true);
else
fRadioButtonPropValueCaseAsis.setSelection(true);
}
if (fRadioButtonSelectorTagCaseAsis != null) {
if (stgy.getSelectorTagCase() == CSSCleanupStrategy.UPPER)
fRadioButtonSelectorTagCaseUpper.setSelection(true);
else if (stgy.getSelectorTagCase() == CSSCleanupStrategy.LOWER)
fRadioButtonSelectorTagCaseLower.setSelection(true);
else
fRadioButtonSelectorTagCaseAsis.setSelection(true);
}
if (fCheckBoxQuoteValues != null)
fCheckBoxQuoteValues.setSelection(stgy.isQuoteValues());
if (fCheckBoxFormatSource != null)
fCheckBoxFormatSource.setSelection(stgy.isFormatSource());
}
/**
* Insert the method's description here.
*
* @param newEmbeddedCSS
* boolean
*/
public void setEmbeddedCSS(boolean newEmbeddedCSS) {
embeddedCSS = newEmbeddedCSS;
}
/**
*
*/
protected void updateCleanupOptions() {
CSSCleanupStrategy stgy = CSSCleanupStrategyImpl.getInstance();
if (fRadioButtonIdentCaseAsis != null) {
if (fRadioButtonIdentCaseUpper.getSelection())
stgy.setIdentCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonIdentCaseLower.getSelection())
stgy.setIdentCase(CSSCleanupStrategy.LOWER);
else
stgy.setIdentCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonPropNameCaseAsis != null) {
if (fRadioButtonPropNameCaseUpper.getSelection())
stgy.setPropNameCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonPropNameCaseLower.getSelection())
stgy.setPropNameCase(CSSCleanupStrategy.LOWER);
else
stgy.setPropNameCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonPropValueCaseAsis != null) {
if (fRadioButtonPropValueCaseUpper.getSelection())
stgy.setPropValueCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonPropValueCaseLower.getSelection())
stgy.setPropValueCase(CSSCleanupStrategy.LOWER);
else
stgy.setPropValueCase(CSSCleanupStrategy.ASIS);
}
if (fRadioButtonSelectorTagCaseAsis != null) {
if (fRadioButtonSelectorTagCaseUpper.getSelection())
stgy.setSelectorTagCase(CSSCleanupStrategy.UPPER);
else if (fRadioButtonSelectorTagCaseLower.getSelection())
stgy.setSelectorTagCase(CSSCleanupStrategy.LOWER);
else
stgy.setSelectorTagCase(CSSCleanupStrategy.ASIS);
}
if (fCheckBoxQuoteValues != null)
stgy.setQuoteValues(fCheckBoxQuoteValues.getSelection());
if (fCheckBoxFormatSource != null)
stgy.setFormatSource(fCheckBoxFormatSource.getSelection());
// save these values to preferences
((CSSCleanupStrategyImpl) stgy).saveOptions();
}
}
|