Lines 17-22
Link Here
|
17 |
import java.util.Locale; |
17 |
import java.util.Locale; |
18 |
import java.util.Set; |
18 |
import java.util.Set; |
19 |
|
19 |
|
|
|
20 |
import org.eclipse.core.variables.IStringVariableManager; |
21 |
import org.eclipse.core.variables.VariablesPlugin; |
22 |
|
23 |
import org.eclipse.core.runtime.CoreException; |
20 |
import org.eclipse.core.runtime.IStatus; |
24 |
import org.eclipse.core.runtime.IStatus; |
21 |
|
25 |
|
22 |
import org.eclipse.core.resources.IProject; |
26 |
import org.eclipse.core.resources.IProject; |
Lines 41-52
Link Here
|
41 |
import org.eclipse.jface.dialogs.DialogPage; |
45 |
import org.eclipse.jface.dialogs.DialogPage; |
42 |
import org.eclipse.jface.preference.IPreferenceStore; |
46 |
import org.eclipse.jface.preference.IPreferenceStore; |
43 |
import org.eclipse.jface.preference.PreferenceStore; |
47 |
import org.eclipse.jface.preference.PreferenceStore; |
|
|
48 |
import org.eclipse.jface.window.Window; |
44 |
|
49 |
|
45 |
import org.eclipse.ui.PlatformUI; |
50 |
import org.eclipse.ui.PlatformUI; |
46 |
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; |
51 |
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; |
47 |
|
52 |
|
48 |
import org.eclipse.ui.ide.dialogs.EncodingFieldEditor; |
53 |
import org.eclipse.ui.ide.dialogs.EncodingFieldEditor; |
49 |
|
54 |
|
|
|
55 |
import org.eclipse.debug.ui.StringVariableSelectionDialog; |
56 |
|
50 |
import org.eclipse.jdt.internal.corext.util.Messages; |
57 |
import org.eclipse.jdt.internal.corext.util.Messages; |
51 |
|
58 |
|
52 |
import org.eclipse.jdt.ui.PreferenceConstants; |
59 |
import org.eclipse.jdt.ui.PreferenceConstants; |
Lines 173-192
Link Here
|
173 |
* |
180 |
* |
174 |
* @param path |
181 |
* @param path |
175 |
* The path of the file to validate |
182 |
* The path of the file to validate |
176 |
* @return <code>true</code> iff the file exists and can be opened, |
183 |
* @return a status without error if the path is valid |
177 |
* <code>false</code> otherwise |
|
|
178 |
*/ |
184 |
*/ |
179 |
protected static IStatus validateAbsoluteFilePath(final String path) { |
185 |
protected static IStatus validateAbsoluteFilePath(String path) { |
180 |
|
186 |
|
181 |
final StatusInfo status= new StatusInfo(); |
187 |
final StatusInfo status= new StatusInfo(); |
182 |
if (path.length() > 0) { |
188 |
IStringVariableManager variableManager= VariablesPlugin.getDefault().getStringVariableManager(); |
183 |
|
189 |
try { |
184 |
final File file= new File(path); |
190 |
path= variableManager.performStringSubstitution(path); |
185 |
if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite())) |
191 |
if (path.length() > 0) { |
186 |
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error); |
192 |
|
187 |
else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite())) |
193 |
final File file= new File(path); |
188 |
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error); |
194 |
if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite())) |
189 |
|
195 |
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error); |
|
|
196 |
else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite())) |
197 |
status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error); |
198 |
} |
199 |
} catch (CoreException e) { |
200 |
status.setError(e.getLocalizedMessage()); |
190 |
} |
201 |
} |
191 |
return status; |
202 |
return status; |
192 |
} |
203 |
} |
Lines 400-407
Link Here
|
400 |
allControls.add(fDictionaryPath); |
411 |
allControls.add(fDictionaryPath); |
401 |
allControls.add(fLabels.get(fDictionaryPath)); |
412 |
allControls.add(fLabels.get(fDictionaryPath)); |
402 |
|
413 |
|
|
|
414 |
Composite buttons=new Composite(engine, SWT.NONE); |
415 |
buttons.setLayout(new GridLayout(2,true)); |
416 |
buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); |
403 |
|
417 |
|
404 |
Button button= new Button(engine, SWT.PUSH); |
418 |
Button button= new Button(buttons, SWT.PUSH); |
405 |
button.setText(PreferencesMessages.SpellingPreferencePage_browse_label); |
419 |
button.setText(PreferencesMessages.SpellingPreferencePage_browse_label); |
406 |
button.addSelectionListener(new SelectionAdapter() { |
420 |
button.addSelectionListener(new SelectionAdapter() { |
407 |
|
421 |
|
Lines 409-416
Link Here
|
409 |
handleBrowseButtonSelected(); |
423 |
handleBrowseButtonSelected(); |
410 |
} |
424 |
} |
411 |
}); |
425 |
}); |
412 |
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); |
|
|
413 |
SWTUtil.setButtonDimensionHint(button); |
426 |
SWTUtil.setButtonDimensionHint(button); |
|
|
427 |
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); |
428 |
allControls.add(button); |
429 |
|
430 |
button=new Button(buttons, SWT.PUSH); |
431 |
button.setText(PreferencesMessages.SpellingPreferencePage_variables); |
432 |
button.addSelectionListener(new SelectionAdapter() { |
433 |
|
434 |
public void widgetSelected(SelectionEvent e) { |
435 |
handleVariablesButtonSelected(); |
436 |
} |
437 |
|
438 |
}); |
439 |
SWTUtil.setButtonDimensionHint(button); |
440 |
button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); |
414 |
allControls.add(button); |
441 |
allControls.add(button); |
415 |
|
442 |
|
416 |
// Description for user dictionary |
443 |
// Description for user dictionary |
Lines 565-570
Link Here
|
565 |
fEncodingEditor.loadDefault(); |
592 |
fEncodingEditor.loadDefault(); |
566 |
} |
593 |
} |
567 |
|
594 |
|
|
|
595 |
|
596 |
protected void handleVariablesButtonSelected() { |
597 |
StringVariableSelectionDialog dialog= new StringVariableSelectionDialog(fDictionaryPath.getShell()); |
598 |
if (dialog.open() == Window.OK) { |
599 |
fDictionaryPath.setText(fDictionaryPath.getText() + dialog.getVariableExpression()); |
600 |
} |
601 |
} |
602 |
|
568 |
/** |
603 |
/** |
569 |
* Handles selections of the browse button. |
604 |
* Handles selections of the browse button. |
570 |
*/ |
605 |
*/ |