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(); |