View | Details | Raw Unified | Return to bug 70410 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties (+1 lines)
Lines 732-737 Link Here
732
SpellingPreferencePage_group_dictionary=Dictionary
732
SpellingPreferencePage_group_dictionary=Dictionary
733
SpellingPreferencePage_group_dictionaries=Dictionaries
733
SpellingPreferencePage_group_dictionaries=Dictionaries
734
SpellingPreferencePage_group_advanced=Advanced
734
SpellingPreferencePage_group_advanced=Advanced
735
SpellingPreferencePage_variables=Variab&les...
735
SpellingPreferencePage_user_dictionary_description=The user dictionary is a text file with one word on each line
736
SpellingPreferencePage_user_dictionary_description=The user dictionary is a text file with one word on each line
736
737
737
BuildPathPreferencePage_title=Build Path
738
BuildPathPreferencePage_title=Build Path
(-)ui/org/eclipse/jdt/internal/ui/preferences/SpellingConfigurationBlock.java (-13 / +48 lines)
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
	 */
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java (+1 lines)
Lines 323-328 Link Here
323
	public static String CodeFormatterPreferencePage_description;
323
	public static String CodeFormatterPreferencePage_description;
324
	public static String SourceAttachmentPropertyPage_not_supported;
324
	public static String SourceAttachmentPropertyPage_not_supported;
325
	public static String SourceAttachmentPropertyPage_read_only;
325
	public static String SourceAttachmentPropertyPage_read_only;
326
	public static String SpellingPreferencePage_variables;
326
	public static String TodoTaskPreferencePage_title;
327
	public static String TodoTaskPreferencePage_title;
327
	public static String TodoTaskPreferencePage_description;
328
	public static String TodoTaskPreferencePage_description;
328
	public static String TodoTaskConfigurationBlock_markers_tasks_high_priority;
329
	public static String TodoTaskConfigurationBlock_markers_tasks_high_priority;
(-)ui/org/eclipse/jdt/internal/ui/text/spelling/SpellCheckEngine.java (-8 / +16 lines)
Lines 25-30 Link Here
25
import java.util.Set;
25
import java.util.Set;
26
import java.util.Map.Entry;
26
import java.util.Map.Entry;
27
27
28
import org.eclipse.core.variables.IStringVariableManager;
29
import org.eclipse.core.variables.VariablesPlugin;
30
31
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.FileLocator;
32
import org.eclipse.core.runtime.FileLocator;
29
33
30
import org.eclipse.jface.preference.IPreferenceStore;
34
import org.eclipse.jface.preference.IPreferenceStore;
Lines 358-370 Link Here
358
		}
362
		}
359
363
360
		IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
364
		IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
361
		final String filePath= store.getString(PreferenceConstants.SPELLING_USER_DICTIONARY);
365
		String filePath= store.getString(PreferenceConstants.SPELLING_USER_DICTIONARY);
362
		if (filePath.length() > 0) {
366
		IStringVariableManager variableManager= VariablesPlugin.getDefault().getStringVariableManager();
363
			try {
367
		try {
368
			filePath= variableManager.performStringSubstitution(filePath);
369
			if (filePath.length() > 0) {
364
				File file= new File(filePath);
370
				File file= new File(filePath);
365
				if (!file.exists() && !file.createNewFile())
371
				if (!file.exists() && !file.createNewFile())
366
					return;
372
					return;
367
				
373
368
				final URL url= new URL("file", null, filePath); //$NON-NLS-1$
374
				final URL url= new URL("file", null, filePath); //$NON-NLS-1$
369
				InputStream stream= url.openStream();
375
				InputStream stream= url.openStream();
370
				if (stream != null) {
376
				if (stream != null) {
Lines 375-385 Link Here
375
						stream.close();
381
						stream.close();
376
					}
382
					}
377
				}
383
				}
378
			} catch (MalformedURLException exception) {
379
				// Do nothing
380
			} catch (IOException exception) {
381
				// Do nothing
382
			}
384
			}
385
		} catch (MalformedURLException exception) {
386
			// Do nothing
387
		} catch (IOException exception) {
388
			// Do nothing
389
		} catch (CoreException e) {
390
			// Do nothing
383
		}
391
		}
384
	}
392
	}
385
393

Return to bug 70410