|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2001, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2001, 2008 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 16-22
Link Here
|
| 16 |
import java.util.Arrays; |
16 |
import java.util.Arrays; |
| 17 |
import java.util.Iterator; |
17 |
import java.util.Iterator; |
| 18 |
import java.util.List; |
18 |
import java.util.List; |
| 19 |
import java.util.Vector; |
|
|
| 20 |
|
19 |
|
| 21 |
import org.eclipse.core.runtime.Platform; |
20 |
import org.eclipse.core.runtime.Platform; |
| 22 |
import org.eclipse.core.runtime.Preferences; |
21 |
import org.eclipse.core.runtime.Preferences; |
|
Lines 41-48
Link Here
|
| 41 |
public class XMLFilesPreferencePage extends AbstractPreferencePage { |
40 |
public class XMLFilesPreferencePage extends AbstractPreferencePage { |
| 42 |
protected EncodingSettings fEncodingSettings = null; |
41 |
protected EncodingSettings fEncodingSettings = null; |
| 43 |
|
42 |
|
| 44 |
protected Combo fEndOfLineCode = null; |
|
|
| 45 |
private Vector fEOLCodes = null; |
| 46 |
private Combo fDefaultSuffix = null; |
43 |
private Combo fDefaultSuffix = null; |
| 47 |
private List fValidExtensions = null; |
44 |
private List fValidExtensions = null; |
| 48 |
private Button fWarnNoGrammar = null; |
45 |
private Button fWarnNoGrammar = null; |
|
Lines 50-56
Link Here
|
| 50 |
protected Control createContents(Composite parent) { |
47 |
protected Control createContents(Composite parent) { |
| 51 |
Composite composite = (Composite) super.createContents(parent); |
48 |
Composite composite = (Composite) super.createContents(parent); |
| 52 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID); |
49 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID); |
| 53 |
createContentsForCreatingOrSavingGroup(composite); |
|
|
| 54 |
createContentsForCreatingGroup(composite); |
50 |
createContentsForCreatingGroup(composite); |
| 55 |
createContentsForValidatingGroup(composite); |
51 |
createContentsForValidatingGroup(composite); |
| 56 |
|
52 |
|
|
Lines 78-96
Link Here
|
| 78 |
((GridData) fEncodingSettings.getLayoutData()).horizontalSpan = 2; |
74 |
((GridData) fEncodingSettings.getLayoutData()).horizontalSpan = 2; |
| 79 |
} |
75 |
} |
| 80 |
|
76 |
|
| 81 |
protected void createContentsForCreatingOrSavingGroup(Composite parent) { |
|
|
| 82 |
Group creatingOrSavingGroup = createGroup(parent, 2); |
| 83 |
creatingOrSavingGroup.setText(XMLUIMessages.Creating_or_saving_files); |
| 84 |
|
| 85 |
Label label = createLabel(creatingOrSavingGroup, XMLUIMessages.End_of_line_code_desc); |
| 86 |
((GridData) label.getLayoutData()).horizontalSpan = 2; |
| 87 |
((GridData) label.getLayoutData()).grabExcessHorizontalSpace = true; |
| 88 |
|
| 89 |
createLabel(creatingOrSavingGroup, XMLUIMessages.End_of_line_code); |
| 90 |
fEndOfLineCode = createDropDownBox(creatingOrSavingGroup); |
| 91 |
populateLineDelimiters(); |
| 92 |
} |
| 93 |
|
| 94 |
protected void createContentsForValidatingGroup(Composite parent) { |
77 |
protected void createContentsForValidatingGroup(Composite parent) { |
| 95 |
Group validatingGroup = createGroup(parent, 2); |
78 |
Group validatingGroup = createGroup(parent, 2); |
| 96 |
validatingGroup.setText(XMLUIMessages.Validating_files); |
79 |
validatingGroup.setText(XMLUIMessages.Validating_files); |
|
Lines 131-149
Link Here
|
| 131 |
return fValidExtensions; |
114 |
return fValidExtensions; |
| 132 |
} |
115 |
} |
| 133 |
|
116 |
|
| 134 |
/** |
|
|
| 135 |
* Return the currently selected line delimiter preference |
| 136 |
* |
| 137 |
* @return a line delimiter constant from CommonEncodingPreferenceNames |
| 138 |
*/ |
| 139 |
private String getCurrentEOLCode() { |
| 140 |
int i = fEndOfLineCode.getSelectionIndex(); |
| 141 |
if (i >= 0) { |
| 142 |
return (String) (fEOLCodes.elementAt(i)); |
| 143 |
} |
| 144 |
return ""; //$NON-NLS-1$ |
| 145 |
} |
| 146 |
|
| 147 |
/* |
117 |
/* |
| 148 |
* (non-Javadoc) |
118 |
* (non-Javadoc) |
| 149 |
* |
119 |
* |
|
Lines 154-160
Link Here
|
| 154 |
} |
124 |
} |
| 155 |
|
125 |
|
| 156 |
protected void initializeValues() { |
126 |
protected void initializeValues() { |
| 157 |
initializeValuesForCreatingOrSavingGroup(); |
|
|
| 158 |
initializeValuesForCreatingGroup(); |
127 |
initializeValuesForCreatingGroup(); |
| 159 |
initializeValuesForValidatingGroup(); |
128 |
initializeValuesForValidatingGroup(); |
| 160 |
} |
129 |
} |
|
Lines 168-184
Link Here
|
| 168 |
fEncodingSettings.setIANATag(encoding); |
137 |
fEncodingSettings.setIANATag(encoding); |
| 169 |
} |
138 |
} |
| 170 |
|
139 |
|
| 171 |
protected void initializeValuesForCreatingOrSavingGroup() { |
|
|
| 172 |
String endOfLineCode = getModelPreferences().getString(CommonEncodingPreferenceNames.END_OF_LINE_CODE); |
| 173 |
|
| 174 |
if (endOfLineCode.length() > 0) { |
| 175 |
setCurrentEOLCode(endOfLineCode); |
| 176 |
} |
| 177 |
else { |
| 178 |
setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
protected void initializeValuesForValidatingGroup() { |
140 |
protected void initializeValuesForValidatingGroup() { |
| 183 |
boolean warnNoGrammarButtonSelected = getModelPreferences().getBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR); |
141 |
boolean warnNoGrammarButtonSelected = getModelPreferences().getBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR); |
| 184 |
|
142 |
|
|
Lines 189-195
Link Here
|
| 189 |
} |
147 |
} |
| 190 |
|
148 |
|
| 191 |
protected void performDefaults() { |
149 |
protected void performDefaults() { |
| 192 |
performDefaultsForCreatingOrSavingGroup(); |
|
|
| 193 |
performDefaultsForCreatingGroup(); |
150 |
performDefaultsForCreatingGroup(); |
| 194 |
performDefaultsForValidatingGroup(); |
151 |
performDefaultsForValidatingGroup(); |
| 195 |
|
152 |
|
|
Lines 206-222
Link Here
|
| 206 |
// fEncodingSettings.resetToDefaultEncoding(); |
163 |
// fEncodingSettings.resetToDefaultEncoding(); |
| 207 |
} |
164 |
} |
| 208 |
|
165 |
|
| 209 |
protected void performDefaultsForCreatingOrSavingGroup() { |
|
|
| 210 |
String endOfLineCode = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.END_OF_LINE_CODE); |
| 211 |
|
| 212 |
if (endOfLineCode.length() > 0) { |
| 213 |
setCurrentEOLCode(endOfLineCode); |
| 214 |
} |
| 215 |
else { |
| 216 |
setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION); |
| 217 |
} |
| 218 |
} |
| 219 |
|
| 220 |
protected void performDefaultsForValidatingGroup() { |
166 |
protected void performDefaultsForValidatingGroup() { |
| 221 |
boolean warnNoGrammarButtonSelected = getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR); |
167 |
boolean warnNoGrammarButtonSelected = getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR); |
| 222 |
|
168 |
|
|
Lines 233-274
Link Here
|
| 233 |
return result; |
179 |
return result; |
| 234 |
} |
180 |
} |
| 235 |
|
181 |
|
| 236 |
/** |
|
|
| 237 |
* Populates the vector containing the line delimiter to display string |
| 238 |
* mapping and the combobox displaying line delimiters |
| 239 |
*/ |
| 240 |
private void populateLineDelimiters() { |
| 241 |
fEOLCodes = new Vector(); |
| 242 |
fEndOfLineCode.add(XMLUIMessages.EOL_Unix); |
| 243 |
fEOLCodes.add(CommonEncodingPreferenceNames.LF); |
| 244 |
|
| 245 |
fEndOfLineCode.add(XMLUIMessages.EOL_Mac); |
| 246 |
fEOLCodes.add(CommonEncodingPreferenceNames.CR); |
| 247 |
|
| 248 |
fEndOfLineCode.add(XMLUIMessages.EOL_Windows); |
| 249 |
fEOLCodes.add(CommonEncodingPreferenceNames.CRLF); |
| 250 |
|
| 251 |
fEndOfLineCode.add(XMLUIMessages.EOL_NoTranslation); |
| 252 |
fEOLCodes.add(CommonEncodingPreferenceNames.NO_TRANSLATION); |
| 253 |
} |
| 254 |
|
| 255 |
/** |
| 256 |
* Select the line delimiter in the eol combobox |
| 257 |
* |
| 258 |
*/ |
| 259 |
private void setCurrentEOLCode(String eolCode) { |
| 260 |
// Clear the current selection. |
| 261 |
fEndOfLineCode.clearSelection(); |
| 262 |
fEndOfLineCode.deselectAll(); |
| 263 |
|
| 264 |
int i = fEOLCodes.indexOf(eolCode); |
| 265 |
if (i >= 0) { |
| 266 |
fEndOfLineCode.select(i); |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
protected void storeValues() { |
182 |
protected void storeValues() { |
| 271 |
storeValuesForCreatingOrSavingGroup(); |
|
|
| 272 |
storeValuesForCreatingGroup(); |
183 |
storeValuesForCreatingGroup(); |
| 273 |
storeValuesForValidatingGroup(); |
184 |
storeValuesForValidatingGroup(); |
| 274 |
} |
185 |
} |
|
Lines 280-290
Link Here
|
| 280 |
getModelPreferences().setValue(CommonEncodingPreferenceNames.OUTPUT_CODESET, fEncodingSettings.getIANATag()); |
191 |
getModelPreferences().setValue(CommonEncodingPreferenceNames.OUTPUT_CODESET, fEncodingSettings.getIANATag()); |
| 281 |
} |
192 |
} |
| 282 |
|
193 |
|
| 283 |
protected void storeValuesForCreatingOrSavingGroup() { |
|
|
| 284 |
String eolCode = getCurrentEOLCode(); |
| 285 |
getModelPreferences().setValue(CommonEncodingPreferenceNames.END_OF_LINE_CODE, eolCode); |
| 286 |
} |
| 287 |
|
| 288 |
protected void storeValuesForValidatingGroup() { |
194 |
protected void storeValuesForValidatingGroup() { |
| 289 |
if (fWarnNoGrammar != null) { |
195 |
if (fWarnNoGrammar != null) { |
| 290 |
boolean warnNoGrammarButtonSelected = fWarnNoGrammar.getSelection(); |
196 |
boolean warnNoGrammarButtonSelected = fWarnNoGrammar.getSelection(); |