View | Details | Raw Unified | Return to bug 246754
Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/wizards/preferences/messages.properties (+1 lines)
Lines 32-37 Link Here
32
WizardPreferencesImportPage1_file=From &preference file:
32
WizardPreferencesImportPage1_file=From &preference file:
33
WizardPreferencesImportPage1_title=Import from File
33
WizardPreferencesImportPage1_title=Import from File
34
WizardPreferencesImportPage1_invalidPrefFile=Preference file does not exist or is a directory.
34
WizardPreferencesImportPage1_invalidPrefFile=Preference file does not exist or is a directory.
35
WizardPreferencesImportPage1_RestoreDefaultSettingAndImportAll=Restore default settings, then import all.
35
36
36
PreferencesExport_error=Error
37
PreferencesExport_error=Error
37
PreferencesExport_browse=B&rowse...
38
PreferencesExport_browse=B&rowse...
(-)Eclipse UI/org/eclipse/ui/internal/wizards/preferences/WizardPreferencesImportPage1.java (-16 / +53 lines)
Lines 17-31 Link Here
17
17
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.preferences.ConfigurationScope;
20
import org.eclipse.core.runtime.preferences.IExportedPreferences;
21
import org.eclipse.core.runtime.preferences.IExportedPreferences;
21
import org.eclipse.core.runtime.preferences.IPreferenceFilter;
22
import org.eclipse.core.runtime.preferences.IPreferenceFilter;
22
import org.eclipse.core.runtime.preferences.IPreferencesService;
23
import org.eclipse.core.runtime.preferences.IPreferencesService;
24
import org.eclipse.core.runtime.preferences.InstanceScope;
23
import org.eclipse.jface.dialogs.MessageDialog;
25
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.widgets.Button;
25
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Event;
29
import org.eclipse.swt.widgets.Event;
27
import org.eclipse.ui.internal.WorkbenchPlugin;
30
import org.eclipse.ui.internal.WorkbenchPlugin;
28
import org.eclipse.ui.internal.preferences.PreferenceTransferElement;
31
import org.eclipse.ui.internal.preferences.PreferenceTransferElement;
32
import org.osgi.service.prefs.BackingStoreException;
29
33
30
/**
34
/**
31
 * Page 1 of the base preference import Wizard
35
 * Page 1 of the base preference import Wizard
Lines 35-44 Link Here
35
 */
39
 */
36
public class WizardPreferencesImportPage1 extends WizardPreferencesPage {
40
public class WizardPreferencesImportPage1 extends WizardPreferencesPage {
37
41
38
    /**
42
	private Button clearPriorToImportingButton;
39
     * Create a new instance of the receiver with name pageName.
43
40
     * @param pageName
44
	/**
41
     */
45
	 * Create a new instance of the receiver with name pageName.
46
	 * 
47
	 * @param pageName
48
	 */
42
    protected WizardPreferencesImportPage1(String pageName) {
49
    protected WizardPreferencesImportPage1(String pageName) {
43
        super(pageName);
50
        super(pageName);
44
        setTitle(PreferencesMessages.WizardPreferencesImportPage1_importTitle);
51
        setTitle(PreferencesMessages.WizardPreferencesImportPage1_importTitle);
Lines 149-159 Link Here
149
        createTransfersList(composite);
156
        createTransfersList(composite);
150
    }
157
    }
151
158
152
    /**
159
	protected Button hookAdditionalOptionsForImport(Composite composite) {
153
     * Answer the string to display in self as the destination type
160
		super.hookAdditionalOptionsForImport(composite);
154
     * 
161
		clearPriorToImportingButton = new Button(composite, SWT.RADIO);
155
     * @return java.lang.String
162
		clearPriorToImportingButton
156
     */
163
				.setText(getClearPriorToImportingButtonText());
164
		return clearPriorToImportingButton;
165
	}
166
167
	private String getClearPriorToImportingButtonText() {
168
		return PreferencesMessages.WizardPreferencesImportPage1_RestoreDefaultSettingAndImportAll;
169
	}
170
171
	/**
172
	 * Answer the string to display in self as the destination type
173
	 * 
174
	 * @return java.lang.String
175
	 */
157
    protected String getDestinationLabel() {
176
    protected String getDestinationLabel() {
158
        return PreferencesMessages.WizardPreferencesImportPage1_file;
177
        return PreferencesMessages.WizardPreferencesImportPage1_file;
159
    }
178
    }
Lines 179-184 Link Here
179
                }
198
                }
180
                IPreferencesService service = Platform.getPreferencesService();
199
                IPreferencesService service = Platform.getPreferencesService();
181
                try {
200
                try {
201
					if (shouldRestoreDefaultSettingsPriorToImport()) {
202
						// removing instance and configuration preferences
203
						// leaves only default settings
204
						service.getRootNode().node(InstanceScope.SCOPE)
205
								.removeNode();
206
						service.getRootNode().node(
207
								ConfigurationScope.SCOPE).removeNode();
208
					}
182
                    IExportedPreferences prefs = service.readPreferences(fis);
209
                    IExportedPreferences prefs = service.readPreferences(fis);
183
                    
210
                    
184
                    service.applyPreferences(prefs, filters);
211
                    service.applyPreferences(prefs, filters);
Lines 188-194 Link Here
188
							.getShell(), new String(), e.getLocalizedMessage(),
215
							.getShell(), new String(), e.getLocalizedMessage(),
189
							SWT.SHEET);
216
							SWT.SHEET);
190
                    return false;
217
                    return false;
191
                }
218
				} catch (BackingStoreException e) {
219
					WorkbenchPlugin.log(e.getMessage(), e);
220
					MessageDialog.open(MessageDialog.ERROR, getControl()
221
							.getShell(), new String(), e.getLocalizedMessage(),
222
							SWT.SHEET);
223
					return false;
224
				}
192
            }
225
            }
193
        } finally {
226
        } finally {
194
            if (fis != null) {
227
            if (fis != null) {
Lines 205-216 Link Here
205
        return true;
238
        return true;
206
    }
239
    }
207
240
208
    /**
241
	private boolean shouldRestoreDefaultSettingsPriorToImport() {
209
     * Handle events and enablements for widgets in this page
242
		return clearPriorToImportingButton.getSelection();
210
     * 
243
	}
211
     * @param e
244
212
     *            Event
245
	/**
213
     */
246
	 * Handle events and enablements for widgets in this page
247
	 * 
248
	 * @param e
249
	 *            Event
250
	 */
214
    public void handleEvent(Event e) {
251
    public void handleEvent(Event e) {
215
        if (e.widget == destinationNameField) {
252
        if (e.widget == destinationNameField) {
216
			setPreferenceTransfers();
253
			setPreferenceTransfers();
(-)Eclipse UI/org/eclipse/ui/internal/wizards/preferences/PreferencesMessages.java (+2 lines)
Lines 50-55 Link Here
50
	public static String WizardPreferencesImportPage1_file;
50
	public static String WizardPreferencesImportPage1_file;
51
	public static String WizardPreferencesImportPage1_title;
51
	public static String WizardPreferencesImportPage1_title;
52
	public static String WizardPreferencesImportPage1_invalidPrefFile;
52
	public static String WizardPreferencesImportPage1_invalidPrefFile;
53
54
	public static String WizardPreferencesImportPage1_RestoreDefaultSettingAndImportAll;
53
	
55
	
54
	public static String SelectionDialog_selectLabel;
56
	public static String SelectionDialog_selectLabel;
55
	public static String SelectionDialog_deselectLabel;
57
	public static String SelectionDialog_deselectLabel;
(-)Eclipse UI/org/eclipse/ui/internal/wizards/preferences/WizardPreferencesPage.java (-3 / +27 lines)
Lines 91-102 Link Here
91
91
92
	private static final String TRANSFER_ALL_PREFERENCES_ID = "WizardPreferencesExportPage1.EXPORT_ALL_PREFERENCES_ID"; //$NON-NLS-1$
92
	private static final String TRANSFER_ALL_PREFERENCES_ID = "WizardPreferencesExportPage1.EXPORT_ALL_PREFERENCES_ID"; //$NON-NLS-1$
93
93
94
	private static final String TRANSFER_ALL_BUT_CLEAR_PREFERENCES_ID = "WizardPreferencesExportPage1.EXPORT_ALL_BUT_CLEAR_PREFERENCES_ID"; //$NON-NLS-1$
95
94
	private Hashtable imageTable;
96
	private Hashtable imageTable;
95
97
96
	private PreferenceTransferElement[] transfers;
98
	private PreferenceTransferElement[] transfers;
97
99
98
	private String currentMessage;
100
	private String currentMessage;
99
101
102
	private Button allButClearButton;
103
100
	private static final String STORE_DESTINATION_ID = null;
104
	private static final String STORE_DESTINATION_ID = null;
101
105
102
    protected static final int COMBO_HISTORY_LENGTH = 5;
106
    protected static final int COMBO_HISTORY_LENGTH = 5;
Lines 281-286 Link Here
281
		return imageTable;
285
		return imageTable;
282
	}
286
	}
283
287
288
	protected Button hookAdditionalOptionsForImport(Composite composite) {
289
		return null;
290
	}
291
284
	/**
292
	/**
285
	 * @param composite
293
	 * @param composite
286
	 */
294
	 */
Lines 289-294 Link Here
289
		allButton = new Button(composite, SWT.RADIO);
297
		allButton = new Button(composite, SWT.RADIO);
290
		allButton.setText(getAllButtonText());
298
		allButton.setText(getAllButtonText());
291
		
299
		
300
		allButClearButton = hookAdditionalOptionsForImport(composite);
301
292
		chooseImportsButton = new Button(composite, SWT.RADIO);
302
		chooseImportsButton = new Button(composite, SWT.RADIO);
293
		chooseImportsButton.setText(getChooseButtonText());
303
		chooseImportsButton.setText(getChooseButtonText());
294
		
304
		
Lines 326-332 Link Here
326
336
327
			private void updateState(SelectionEvent e) {
337
			private void updateState(SelectionEvent e) {
328
				if (((TableItem)e.item).getChecked()) {
338
				if (((TableItem)e.item).getChecked()) {
329
					allButton.setSelection(false);
330
					chooseImportsButton.setSelection(true);
339
					chooseImportsButton.setSelection(true);
331
				}
340
				}
332
			}
341
			}
Lines 844-850 Link Here
844
						overwriteExistingFilesCheckbox.getSelection());
853
						overwriteExistingFilesCheckbox.getSelection());
845
			}
854
			}
846
			settings.put(TRANSFER_ALL_PREFERENCES_ID, allButton.getSelection());
855
			settings.put(TRANSFER_ALL_PREFERENCES_ID, allButton.getSelection());
847
856
			settings.put(TRANSFER_ALL_BUT_CLEAR_PREFERENCES_ID,
857
					getTransferAllButClear());
848
		}
858
		}
849
	}
859
	}
850
860
Lines 890-895 Link Here
890
	protected void restoreWidgetValues() {
900
	protected void restoreWidgetValues() {
891
		IDialogSettings settings = getDialogSettings();
901
		IDialogSettings settings = getDialogSettings();
892
		boolean all = true;
902
		boolean all = true;
903
		boolean clear = false;
893
		if (settings != null) {
904
		if (settings != null) {
894
			String[] directoryNames = settings
905
			String[] directoryNames = settings
895
					.getArray(STORE_DESTINATION_NAMES_ID);
906
					.getArray(STORE_DESTINATION_NAMES_ID);
Lines 910-919 Link Here
910
							.getBoolean(STORE_OVERWRITE_EXISTING_FILES_ID));
921
							.getBoolean(STORE_OVERWRITE_EXISTING_FILES_ID));
911
				}
922
				}
912
				all = settings.getBoolean(TRANSFER_ALL_PREFERENCES_ID);
923
				all = settings.getBoolean(TRANSFER_ALL_PREFERENCES_ID);
924
				clear = settings
925
						.getBoolean(TRANSFER_ALL_BUT_CLEAR_PREFERENCES_ID);
913
			}
926
			}
914
		}
927
		}
915
		if (all) {
928
		if (all) {
916
			allButton.setSelection(true);
929
			allButton.setSelection(true);
930
		} else if (clear) {
931
			if (allButClearButton != null) {
932
				allButClearButton.setSelection(true);
933
			}
917
		} else {
934
		} else {
918
			chooseImportsButton.setSelection(true);
935
			chooseImportsButton.setSelection(true);
919
		}
936
		}
Lines 925-931 Link Here
925
	}
942
	}
926
943
927
	private boolean getTransferAll() {
944
	private boolean getTransferAll() {
928
		return allButton.getSelection();
945
		return allButton.getSelection() || getTransferAllButClear();
946
	}
947
948
	private boolean getTransferAllButClear() {
949
		if (allButClearButton != null) {
950
			return allButClearButton.getSelection();
951
		}
952
		return false;
929
	}
953
	}
930
954
931
	/**
955
	/**

Return to bug 246754