[yocto] [RFC 16/17] plugins/sdk.ide: Use profiles for the preference page
Timo Mueller
mail at timomueller.eu
Thu Jan 24 07:12:40 PST 2013
From: Timo Mueller <timo.mueller at bmw-carit.de>
The preference page is now aware of profiles. By default the standard
profile is used and the values are stored to its preference store. If
a different profile is selected it's preferences store is used
instead.
Signed-off-by: Timo Mueller <timo.mueller at bmw-carit.de>
---
.../ide/preferences/YoctoSDKPreferencePage.java | 34 +++++++++++++++++-----
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java
index 8f6111b..eb7a393 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java
@@ -11,6 +11,7 @@
package org.yocto.sdk.ide.preferences;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
@@ -18,6 +19,8 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.yocto.sdk.ide.YoctoGeneralException;
+import org.yocto.sdk.ide.YoctoProfileElement;
+import org.yocto.sdk.ide.YoctoProfileSetting;
import org.yocto.sdk.ide.YoctoSDKPlugin;
import org.yocto.sdk.ide.YoctoSDKUtils;
import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom;
@@ -25,17 +28,30 @@ import org.yocto.sdk.ide.YoctoUIElement;
import org.yocto.sdk.ide.YoctoUISetting;
public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
+
+ private YoctoProfileSetting yoctoProfileSetting;
private YoctoUISetting yoctoUISetting;
public YoctoSDKPreferencePage() {
//super(GRID);
- setPreferenceStore(YoctoSDKPlugin.getDefault().getPreferenceStore());
- //setDescription(YoctoSDKMessages.getString(PREFERENCES_Yocto_CONFIG));
- YoctoUIElement elem = YoctoSDKUtils.getElemFromDefaultStore();
- this.yoctoUISetting = new YoctoUISetting(elem);
+ IPreferenceStore defaultStore = YoctoSDKPlugin.getDefault().getPreferenceStore();
+ String profiles = defaultStore.getString(PreferenceConstants.PROFILES);
+ String selectedProfile = defaultStore.getString(PreferenceConstants.SELECTED_PROFILE);
+
+ if (profiles.isEmpty()) {
+ profiles = defaultStore.getDefaultString(PreferenceConstants.PROFILES);
+ selectedProfile = defaultStore.getDefaultString(PreferenceConstants.SELECTED_PROFILE);
+ }
+
+ setPreferenceStore(YoctoSDKPlugin.getProfilePreferenceStore(selectedProfile));
+ //setDescription(YoctoSDKMessages.getString(PREFERENCES_Yocto_CONFIG));
+ YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(getPreferenceStore());
+ this.yoctoUISetting = new YoctoUISetting(elem);
+
+ YoctoProfileElement profileElement = new YoctoProfileElement(profiles, selectedProfile);
+ this.yoctoProfileSetting = new YoctoProfileSetting(profileElement, this);
}
-
+
/*
* @see IWorkbenchPreferencePage#init(IWorkbench)
*/
@@ -66,7 +82,10 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
yoctoUISetting.validateInput(SDKCheckRequestFrom.Preferences, true);
YoctoUIElement elem = yoctoUISetting.getCurrentInput();
- YoctoSDKUtils.saveElemToDefaultStore(elem);
+ YoctoSDKUtils.saveElemToStore(elem, getPreferenceStore());
+
+ YoctoProfileElement profileElement = yoctoProfileSetting.getCurrentInput();
+ YoctoSDKUtils.saveProfilesToDefaultStore(profileElement);
return super.performOk();
} catch (YoctoGeneralException e) {
@@ -76,6 +95,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
}
}
+
/*
* @see PreferencePage#performDefaults()
*/
--
1.7.11.7
More information about the yocto
mailing list