Skip to contentSkip to conversation

Storing yocto settings as target profiles

RFC Superseded Timo Mueller 2 participants 19 messages Jan 24, 2013 – Jan 25, 2013

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Storing yocto settings as target profiles

From: Timo Mueller <[email protected]>

Hi,

currently the yocto settings can be changed globally through eclipse's preferences or locally in the project properties. But the standard configuration stored in the global preferences sometimes changes, e.g. if a new version of the toolchain or the sysroot is released.
If you change the global settings to the updated toolchain or sysroot your old working configuration is gone. If you want to reuse this configuration at a later point in time you have to (remember and) re-enter everthing. This patch set introduces the possiblity to store a configuration under a unique name, a so called target profile, and be able to select the default target profile that is used for new projects.
Building upon this change the target profiles could later also be used in the project settings and be able to quickly build and debug your software for different hard- and software combinations.

Best regards,
Timo

Atanas Gegov (4):
plugins/sdk.ide: Extract labels to private members plugins/sdk.ide: Add method to enable and disable form plugins/sdk.ide: Set value of target array on input change plugins/sdk.ide: Create UI element for managing target profiles.

Timo Mueller (13):
plugins/sdk.ide: Removed unused message
plugins/sdk.ide: Changed method signature to be more consistent plugins/sdk.ide: Modified preferences storage to support profiles. plugins/sdk.ide: Set profile on selection change plugins/sdk.ide: Add method to allow storing the current settings plugins/sdk.ide: Add UI method to create a new profile plugins/sdk.ide: Add UI method to delete a profile plugins/sdk.ide: Add UI method to rename a profile plugins/sdk.ide: Add method to change values of the preference page plugins/sdk.ide: Add method to rename a profile and its preference
store
plugins/sdk.ide: Add method to delete a profile plugins/sdk.ide: Use profiles for the preference page plugins/sdk.ide: Added profile UI to the preference page

 .../src/org/yocto/sdk/ide/YoctoProfileElement.java | 105 +++++++++
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 244 +++++++++++++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |  19 +-
 .../src/org/yocto/sdk/ide/YoctoSDKPlugin.java      |  15 ++
 .../org/yocto/sdk/ide/YoctoSDKProjectNature.java   |  10 +-
 .../src/org/yocto/sdk/ide/YoctoSDKUtils.java       |  62 ++++--
 .../src/org/yocto/sdk/ide/YoctoUISetting.java      |  61 +++++-
 .../sdk/ide/preferences/PreferenceConstants.java   |   5 +
 .../sdk/ide/preferences/PreferenceInitializer.java |  22 +-
 .../ide/preferences/ProfileNameInputValidator.java |  73 ++++++
 .../ide/preferences/YoctoSDKPreferencePage.java    |  80 ++++---
 .../preferences/YoctoSDKProjectPropertyPage.java   |   6 +-
 12 files changed, 637 insertions(+), 65 deletions(-)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileElement.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/ProfileNameInputValidator.java
Signature · 1 line
1.7.11.7
#1 lore raw

RFC 1/17 plugins/sdk.ide: Removed unused message

From: Timo Mueller <[email protected]>

The dialog has been merged with the project settings. Therefor the message is no longer needed.

---
 .../org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties  | 1 -
 1 file changed, 1 deletion(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +0 -1
index b302524..17240e9 100644
@@ -22,7 +22,6 @@ Poky.Env.Script.Nonexist = Specified Build Tree Toolchain Root does not contain
 Poky.ADT.Sysroot.Wrongversion = OECORE related items are not found in envrionement setup files.\nThe ADT version you're using is too old.\n Please upgrade to our latest ADT Version!
 Poky.Toolchain.Host.Mismatch = Toolchain and host arch mismatch.\n Make sure you use 32bit toolchain for 32bit host and same for 64bit machines!
 Poky.Toolchain.No.Sysroot = There's no sysroots directory under your toolchain directory under /opt/poky!
-Menu.SDK.Dialog.Title       = Yocto Project Settings
 
 
 Menu.SDK.Console.Configure.Message    = The Yocto Project ADT has been successfully set up for this project.\nTo see the environment variables created during setup,\ngo to Project > Properties > C/C++ Build > Environment. 
Signature · 1 line
1.7.11.7
#2 lore raw

RFC 2/17 plugins/sdk.ide: Extract labels to private members

From: Atanas Gegov <[email protected]>

Extracting the labels as private members allows the modification of the label settings after creation. This is will allow disabling and enabling the labels after creation of the form.

---
 .../src/org/yocto/sdk/ide/YoctoUISetting.java             | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +8 -7
index 0fbfde0..a4a3c09 100644
@@ -63,6 +63,12 @@ public class YoctoUISetting {
 	private Text textRootLoc;
 	private Combo targetArchCombo;
 
+	private Label root_label;
+	private Label sysroot_label;
+	private Label targetArchLabel;
+	private Label kernel_label;
+	private Label option_label;
+
 	public YoctoUISetting(YoctoUIElement elem)
 	{
 		yoctoUIElement = elem;
@@ -140,10 +146,6 @@ public class YoctoUISetting {
 
 	private void createQemuSetup(final Group targetGroup) throws YoctoGeneralException
 	{
-		Label kernel_label;
-		Label option_label;
-		
-		
 		//QEMU Setup
 		kernel_label= new Label(targetGroup, SWT.NONE);
 		kernel_label.setText("Kernel: ");
@@ -180,8 +182,7 @@ public class YoctoUISetting {
 	}
 	public void createComposite(Composite composite) throws YoctoGeneralException
 	{
-		Label root_label, sysroot_label;
-		
+
 		GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
 		GridLayout layout = new GridLayout(2, false);
 		composite.setLayout(layout);
@@ -224,7 +225,7 @@ public class YoctoUISetting {
 		btnSysrootLoc = addFileSelectButton(textContainer, textSysrootLoc, PreferenceConstants.SYSROOT);
 
 		updateSDKControlState();
-		Label targetArchLabel= new Label(crossCompilerGroup, SWT.NONE);
+		targetArchLabel = new Label(crossCompilerGroup, SWT.NONE);
 		targetArchLabel.setText("Target Architecture: ");
 
 		targetArchCombo= new Combo(crossCompilerGroup, SWT.READ_ONLY);
Signature · 1 line
1.7.11.7
#3 lore raw

RFC 3/17 plugins/sdk.ide: Add method to enable and disable form

From: Atanas Gegov <[email protected]>

The YoctoUISetting form as a whole can be disabled and enabled using this method. A disabled form can for example show a read-only yocto configuration.

---
 .../src/org/yocto/sdk/ide/YoctoUISetting.java      | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +44 -0
index a4a3c09..d615956 100644
@@ -371,6 +371,50 @@ public class YoctoUISetting {
 		return pass;
 	}
 
+	public void setUIFormEnabledState(boolean isEnabled) {
+		btnSDKRoot.setEnabled(isEnabled);
+		btnPokyRoot.setEnabled(isEnabled);
+
+		root_label.setEnabled(isEnabled);
+		textRootLoc.setEnabled(isEnabled);
+		btnToolChainLoc.setEnabled(isEnabled);
+
+		sysroot_label.setEnabled(isEnabled);
+		textSysrootLoc.setEnabled(isEnabled);
+		btnSysrootLoc.setEnabled(isEnabled);
+
+		targetArchLabel.setEnabled(isEnabled);
+		targetArchCombo.setEnabled(isEnabled);
+
+		btnQemu.setEnabled(isEnabled);
+
+		if(isEnabled) {
+			/* enabling widgets regarding
+			 * Kernel and Custom Options
+			 * depends on the state of the QEMU button */
+			kernel_label.setEnabled(isEnabled);
+			option_label.setEnabled(isEnabled);
+			if(btnQemu.getSelection()) {
+				textKernelLoc.setEnabled(isEnabled);
+				btnKernelLoc.setEnabled(isEnabled);
+
+				textQemuOption.setEnabled(isEnabled);
+			}
+		}
+		else {
+			/* disable all widgets regarding
+			 * Kernel and Custom Options */
+			kernel_label.setEnabled(isEnabled);
+			textKernelLoc.setEnabled(isEnabled);
+			btnKernelLoc.setEnabled(isEnabled);
+
+			option_label.setEnabled(isEnabled);
+			textQemuOption.setEnabled(isEnabled);
+		}
+
+		btnDevice.setEnabled(isEnabled);
+	}
+
 	private void updateQemuControlState()
 	{
 		boolean bQemuMode = btnQemu.getSelection();
Signature · 1 line
1.7.11.7
#4 lore raw

RFC 4/17 plugins/sdk.ide: Set value of target array on input change

From: Atanas Gegov <[email protected]>

The value of the target array set in the constructor is now also affected when the input of the element is changed.

---
 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java | 2 ++
 1 file changed, 2 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +2 -0
index d615956..32f9fa1 100644
@@ -304,6 +304,8 @@ public class YoctoUISetting {
 	}
 
 	public void setCurrentInput(YoctoUIElement elem){
+		elem.setStrTargetsArray(getTargetArray(elem));
+
 		btnSDKRoot.setSelection(false);
 		btnPokyRoot.setSelection(false);
 		if(elem.getEnumPokyMode().equals(YoctoUIElement.PokyMode.POKY_SDK_MODE)){
Signature · 1 line
1.7.11.7
#5 lore raw

RFC 5/17 plugins/sdk.ide: Changed method signature to be more consistent

From: Timo Mueller <[email protected]>

YoctoUIElement should always be the first element, e.g. as in saveElemToStore().

---
 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java      | 2 +-
 .../src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java +1 -1
index 7ea4262..ab969ea 100644
@@ -423,7 +423,7 @@ public class YoctoSDKUtils {
 	}
 	
 	/* Save YoctoUIElement to project settings */
-	public static void saveElemToProjectEnv(IProject project, YoctoUIElement elem)
+	public static void saveElemToProjectEnv(YoctoUIElement elem, IProject project)
 	{
 		ConsoleOutputStream consoleOutStream = null;
 		
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java +1 -1
index 92d476a..f2247ca 100644
@@ -99,7 +99,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 			yoctoUISetting.validateInput(SDKCheckRequestFrom.Preferences, true);
 
 			YoctoUIElement elem = yoctoUISetting.getCurrentInput();
-			YoctoSDKUtils.saveElemToProjectEnv(getProject(), elem);
+			YoctoSDKUtils.saveElemToProjectEnv(elem, getProject());
 
 			return super.performOk();
 		} catch (YoctoGeneralException e) {
Signature · 1 line
1.7.11.7
#6 lore raw

RFC 6/17 plugins/sdk.ide: Create UI element for managing target profiles.

From: Atanas Gegov <[email protected]>

A target profile is a combination of yocto settings identified by a user-defined name. This UI element allows the user to add new profiles and to rename or delete existing ones.

---
 .../src/org/yocto/sdk/ide/YoctoProfileElement.java | 105 +++++++++++++++++++++
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 101 ++++++++++++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |   5 +
 .../sdk/ide/preferences/PreferenceConstants.java   |   1 +
 4 files changed, 212 insertions(+)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileElement.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileElement.java new file +105 -0
new file mode 100644
index 0000000..c75dfd2
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2012 BMW Car IT GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BMW Car IT - initial API and implementation
+ *******************************************************************************/
+package org.yocto.sdk.ide;
+
+import java.util.Comparator;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import org.yocto.sdk.ide.preferences.PreferenceConstants;
+
+public class YoctoProfileElement {
+	private TreeSet<String> profiles = new TreeSet<String>(new Comparator<String>() {
+
+		@Override
+		public int compare(String o1, String o2) {
+			int strcompare = o1.compareTo(o2);
+
+			if (strcompare == 0) {
+				return strcompare;
+			}
+
+			// Standard profile always less than anything else
+			if (o1.equals(PreferenceConstants.STANDARD_PROFILE_NAME)) {
+				return -1;
+			}
+
+			if (o2.equals(PreferenceConstants.STANDARD_PROFILE_NAME)) {
+				return 1;
+			}
+
+			return strcompare;
+		}
+
+	});
+
+	private String selectedProfile;
+
+	public YoctoProfileElement(String profilesString, String selectedProfile) {
+		setProfilesFromString(profilesString);
+		this.selectedProfile = selectedProfile;
+	}
+
+	public void addProfile(String profile) {
+		this.profiles.add(profile);
+	}
+
+	public boolean contains(String newText) {
+		return profiles.contains(newText);
+	}
+
+	public TreeSet<String> getProfiles() {
+		return profiles;
+	}
+
+	public String getProfilesAsString() {
+		String profileString = "";
+
+		for (String profile : profiles) {
+			profileString += "\"" + profile + "\",";
+		}
+		return profileString.substring(0, profileString.length() - 1);
+	}
+
+	public String getSelectedProfile() {
+		return selectedProfile;
+	}
+
+	public void remove(String profile) {
+		this.profiles.remove(profile);
+	}
+
+	public void rename(String oldProfileName, String newProfileName) {
+		this.remove(oldProfileName);
+		this.addProfile(newProfileName);
+
+		if (selectedProfile.equals(oldProfileName)) {
+			selectedProfile = newProfileName;
+		}
+	}
+
+	public void setProfiles(TreeSet<String> profiles) {
+		this.profiles = profiles;
+	}
+
+	public void setProfilesFromString(String profilesString) {
+		StringTokenizer tokenizer = new StringTokenizer(profilesString, ",");
+
+		while (tokenizer.hasMoreElements()) {
+			String config = (String) tokenizer.nextElement();
+			profiles.add(config.replace("\"", ""));
+		}
+	}
+
+	public void setSelectedProfile(String selectedProfile) {
+		this.selectedProfile = selectedProfile;
+	}
+}
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java new file +101 -0

101 lines not on this page · raw message

plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +5 -0
index 17240e9..f8c2e4b 100644
@@ -7,6 +7,7 @@
  *
  * Contributors:
  * Intel - initial API and implementation
+ * BMW Car IT - added keys for target profiles
  *******************************************************************************/
 Wizard.SDK.Warning.Title = Invalid Yocto Project ADT Location
 
@@ -45,6 +46,10 @@ Preferences.SDK.Target.name = Target Preferences:
 Preferences.SDK.Informing.Title   = Yocto Project ADT has been successfully set up. 
 Preferences.SDK.Informing.Message = You might need to reconfigure your existing Yocto Project Autotools Projects to use the Yocto Project ADT. Do this from Project > Reconfigure Project!
 
+Preferences.Profiles.Title = Target profiles:
+Preferences.Profile.New.Title = New ...
+Preferences.Profile.Rename.Title = Rename
+Preferences.Profile.Remove.Title = Remove
 
 Console.SDK.Name = Yocto Project Console
 
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/PreferenceConstants.java +1 -0
index cf79578..d6ca41f 100644
@@ -33,4 +33,5 @@ public class PreferenceConstants {
 		
 	public static final String IP_ADDR = "IPAddr";
 
+	public static final String STANDARD_PROFILE_NAME = "Standard Profile";
 }
Signature · 1 line
1.7.11.7
#7 lore raw

RFC 7/17 plugins/sdk.ide: Modified preferences storage to support profiles.

From: Timo Mueller <[email protected]>

Yocto preferences are now stored using a user-defined name that identifies a target profile. To store these preferences eclipse' scoped preferences provider is used. The filename in the eclipse configuration area is derived from the unique target profile name.

---
 .../src/org/yocto/sdk/ide/YoctoSDKPlugin.java      | 15 ++++++
 .../org/yocto/sdk/ide/YoctoSDKProjectNature.java   | 10 ++--
 .../src/org/yocto/sdk/ide/YoctoSDKUtils.java       | 60 +++++++++++++++++-----
 .../sdk/ide/preferences/PreferenceConstants.java   |  4 ++
 .../sdk/ide/preferences/PreferenceInitializer.java | 22 ++++----
 .../ide/preferences/YoctoSDKPreferencePage.java    | 36 ++++---------
 .../preferences/YoctoSDKProjectPropertyPage.java   |  4 +-
 7 files changed, 99 insertions(+), 52 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java +15 -0
index b0b5447..8956fea 100644
@@ -16,9 +16,12 @@ import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -65,6 +68,18 @@ public class YoctoSDKPlugin extends AbstractUIPlugin {
 		return plugin;
 	}
 
+	public static IPreferenceStore getProfilePreferenceStore(String profileName) {
+		int profileIdentifier = profileName.hashCode();
+
+		return new ScopedPreferenceStore(InstanceScope.INSTANCE,getUniqueIdentifier() + "." + profileIdentifier);
+	}
+
+	public static IPreferenceStore getProfilePreferenceStore(String profileName) {
+		int profileIdentifier = profileName.hashCode();
+
+		return new ScopedPreferenceStore(InstanceScope.INSTANCE,getUniqueIdentifier() + "." + profileIdentifier);
+	}
+
 	public static void log(IStatus status) {
 		ResourcesPlugin.getPlugin().getLog().log(status);
 	}
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKProjectNature.java +7 -3
index ec49dcc..6f16732 100644
@@ -18,10 +18,13 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.StringTokenizer;
+
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.settings.model.ICProjectDescription;
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
+import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager;
+import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
 import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@@ -34,8 +37,7 @@ import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager;
-import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom;
 
 
@@ -151,7 +153,9 @@ public class YoctoSDKProjectNature implements IProjectNature {
 	}
 
 	public static void configureAutotools(IProject project) throws YoctoGeneralException {
-		YoctoUIElement elem = YoctoSDKUtils.getElemFromStore();
+		YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromDefaultStore();
+		IPreferenceStore selecteProfileStore = YoctoSDKPlugin.getProfilePreferenceStore(profileElement.getSelectedProfile());
+		YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(selecteProfileStore);
 		YoctoSDKUtils.SDKCheckResults result = YoctoSDKUtils.checkYoctoSDK(elem);
 		if (result != YoctoSDKUtils.SDKCheckResults.SDK_PASS){		
 			String strErrorMsg =  YoctoSDKUtils.getErrorMessage(result, SDKCheckRequestFrom.Wizard);
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java +48 -12

115 lines not on this page · raw message

plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/PreferenceConstants.java +4 -0
index d6ca41f..814397a 100644
@@ -34,4 +34,8 @@ public class PreferenceConstants {
 	public static final String IP_ADDR = "IPAddr";
 
 	public static final String STANDARD_PROFILE_NAME = "Standard Profile";
+
+	public static final String PROFILES = "profiles";
+
+	public static final String SELECTED_PROFILE = "selectedProfile";
 }
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/PreferenceInitializer.java +13 -9
index 33c7117..40f37d0 100644
@@ -15,6 +15,8 @@ import org.eclipse.jface.preference.IPreferenceStore;
 
 import org.yocto.sdk.ide.YoctoSDKPlugin;
 
+import static org.yocto.sdk.ide.preferences.PreferenceConstants.*;
+
 /**
  * Class used to initialize default preference values.
  */
@@ -26,15 +28,17 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
 	 */
 	public void initializeDefaultPreferences() {
 		IPreferenceStore store = YoctoSDKPlugin.getDefault().getPreferenceStore();
-		store.setDefault(PreferenceConstants.TOOLCHAIN_ROOT, "");
-		store.setDefault(PreferenceConstants.SDK_MODE, true);
-		store.setDefault(PreferenceConstants.TARGET_MODE, false);
-		store.setDefault(PreferenceConstants.TARGET_ARCH_INDEX, -1);
-		store.setDefault(PreferenceConstants.IP_ADDR, "");
-		store.setDefault(PreferenceConstants.QEMU_KERNEL, "");
-		store.setDefault(PreferenceConstants.QEMU_OPTION, "");
-		store.setDefault(PreferenceConstants.SYSROOT, "");
-		store.setDefault(PreferenceConstants.TOOLCHAIN_TRIPLET, "");
+		store.setDefault(TOOLCHAIN_ROOT, "");
+		store.setDefault(SDK_MODE, true);
+		store.setDefault(TARGET_MODE, false);
+		store.setDefault(TARGET_ARCH_INDEX, -1);
+		store.setDefault(IP_ADDR, "");
+		store.setDefault(QEMU_KERNEL, "");
+		store.setDefault(QEMU_OPTION, "");
+		store.setDefault(SYSROOT, "");
+		store.setDefault(TOOLCHAIN_TRIPLET, "");
+		store.setDefault(PROFILES, "\"" + STANDARD_PROFILE_NAME + "\"");
+		store.setDefault(SELECTED_PROFILE, STANDARD_PROFILE_NAME);
 	}
 
 }
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +10 -26
index d1c1a72..64c9968 100644
@@ -10,32 +10,20 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.preferences;
 
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
 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;
+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.YoctoSDKUtils;
 import org.yocto.sdk.ide.YoctoSDKPlugin;
+import org.yocto.sdk.ide.YoctoSDKUtils;
 import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom;
-
 import org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.YoctoUISetting;
 
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-
-
-
 public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
     
 	private YoctoUISetting yoctoUISetting;
@@ -44,7 +32,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 		//super(GRID);
         setPreferenceStore(YoctoSDKPlugin.getDefault().getPreferenceStore());
         //setDescription(YoctoSDKMessages.getString(PREFERENCES_Yocto_CONFIG));
-        YoctoUIElement elem = YoctoSDKUtils.getElemFromStore();
+		YoctoUIElement elem = YoctoSDKUtils.getElemFromDefaultStore();
         this.yoctoUISetting = new YoctoUISetting(elem);
 	}
 	
@@ -74,30 +62,26 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 	 * @see IPreferencePage#performOk()
 	 */
 	public boolean performOk() {
-		
-		
 		try {
 			yoctoUISetting.validateInput(SDKCheckRequestFrom.Preferences, true);
 
 			YoctoUIElement elem = yoctoUISetting.getCurrentInput();
-			YoctoSDKUtils.saveElemToStore(elem);
+			YoctoSDKUtils.saveElemToDefaultStore(elem);
 
 			return super.performOk();
 		} catch (YoctoGeneralException e) {
 			// TODO Auto-generated catch block
 			System.out.println(e.getMessage());
 			return false;
-		}		
+		}
 	}
 
 	/*
 	 * @see PreferencePage#performDefaults()
 	 */
 	protected void performDefaults() {
-		YoctoUIElement defaultElement = YoctoSDKUtils.getDefaultElemFromStore();
+		YoctoUIElement defaultElement = YoctoSDKUtils.getDefaultElemFromDefaultStore();
 		yoctoUISetting.setCurrentInput(defaultElement);
 		super.performDefaults();
 	}
-
-
 }
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java +2 -2
index f2247ca..56cc4cb 100644
@@ -74,7 +74,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 				|| uiElement.getStrTarget().isEmpty()) {
 			// No project environment has been set yet, use the Preference
 			// values
-			uiElement = YoctoSDKUtils.getElemFromStore();
+			uiElement = YoctoSDKUtils.getElemFromDefaultStore();
 		}
 
 		return uiElement;
@@ -85,7 +85,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 	 */
 	@Override
 	protected void performDefaults() {
-		YoctoUIElement defaultElement = YoctoSDKUtils.getDefaultElemFromStore();
+		YoctoUIElement defaultElement = YoctoSDKUtils.getDefaultElemFromDefaultStore();
 		yoctoUISetting.setCurrentInput(defaultElement);
 		super.performDefaults();
 	}
Signature · 1 line
1.7.11.7
#8 lore raw

RFC 8/17 plugins/sdk.ide: Set profile on selection change

From: Timo Mueller <[email protected]>

When a profile is selected through the combo box the value of the profileElement changed to contain the selected profile.

---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +23 -0
index eecb4ef..f9cd7ce 100644
@@ -16,7 +16,9 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Listener;
 
 public class YoctoProfileSetting {
 	private static final String PROFILES_TITLE = "Preferences.Profiles.Title";
@@ -54,6 +56,27 @@ public class YoctoProfileSetting {
 		sdkConfigsCombo.setLayout(new GridLayout(2, false));
 		sdkConfigsCombo.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
 
+		Listener selectionListener = new Listener() {
+			@Override
+			public void handleEvent(Event event) {
+				Object source = event.widget;
+				if (!(source instanceof Combo)) {
+					return;
+				}
+
+				Combo sdkCombo = (Combo) source;
+				if (sdkCombo.getSelectionIndex() < 0) {
+					return;
+				}
+
+				String selectedItem = sdkCombo.getItem(sdkCombo.getSelectionIndex());
+				profileElement.setSelectedProfile(selectedItem);
+			}
+		};
+
+		sdkConfigsCombo.addListener(SWT.Selection, selectionListener);
+		sdkConfigsCombo.addListener(SWT.Modify, selectionListener);
+
 		createNewProfileButton(storeYoctoConfigurationsGroup);
 		createRenameButton(storeYoctoConfigurationsGroup);
 		createRemoveButton(storeYoctoConfigurationsGroup);
Signature · 1 line
1.7.11.7
#9 lore raw

RFC 9/17 plugins/sdk.ide: Add method to allow storing the current settings

From: Timo Mueller <[email protected]>

The added method calls the performOK method on the provided preference page to store the current content of the page.
This callback is needed so the profile UI is able to propagate changes to the preference page it is part of.

---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java               | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +8 -1
index f9cd7ce..7c2b8d4 100644
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.yocto.sdk.ide;
 
+import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -32,9 +33,11 @@ public class YoctoProfileSetting {
 	private Button btnConfigNew;
 
 	private YoctoProfileElement profileElement;
+	private PreferencePage preferencePage;
 
-	public YoctoProfileSetting(YoctoProfileElement profileElement){
+	public YoctoProfileSetting(YoctoProfileElement profileElement, PreferencePage preferencePage){
 		this.profileElement = profileElement;
+		this.preferencePage = preferencePage;
 	}
 
 	public void createComposite(Composite composite) {
@@ -101,6 +104,10 @@ public class YoctoProfileSetting {
 		btnConfigRename.setText(YoctoSDKMessages.getString(RENAME_PROFILE_TITLE));
 	}
 
+	private void saveChangesOnCurrentProfile() {
+		preferencePage.performOk();
+	}
+
 	private void addConfigs(Combo combo) {
 		for (String profile : profileElement.getProfiles()) {
 			combo.add(profile);
Signature · 1 line
1.7.11.7
#10 lore raw

RFC 10/17 plugins/sdk.ide: Add UI method to create a new profile

From: Timo Mueller <[email protected]>

When the new button is clicked a dialog shows up and the user has to provide the name of the new profile. The validity of the name is checked during input. If the name is valid and the users confirms the new profile is created.

---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 31 +++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |  7 +++
 .../ide/preferences/ProfileNameInputValidator.java | 73 ++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/ProfileNameInputValidator.java
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +31 -0
index 7c2b8d4..6a38fb1 100644
@@ -10,8 +10,12 @@
  *******************************************************************************/
 package org.yocto.sdk.ide;
 
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -20,10 +24,13 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Listener;
+import org.yocto.sdk.ide.preferences.ProfileNameInputValidator;
 
 public class YoctoProfileSetting {
 	private static final String PROFILES_TITLE = "Preferences.Profiles.Title";
 	private static final String NEW_PROFILE_TITLE = "Preferences.Profile.New.Title";
+	private static final String NEW_DIALOG_TITLE = "Preferences.Profile.New.Dialog.Title";
+	private static final String NEW_DIALOG_MESSAGE = "Preferences.Profile.New.Dialog.Message";
 	private static final String RENAME_PROFILE_TITLE = "Preferences.Profile.Rename.Title";
 	private static final String REMOVE_PROFILE_TITLE = "Preferences.Profile.Remove.Title";
 
@@ -89,6 +96,30 @@ public class YoctoProfileSetting {
 	{
 		btnConfigNew = new Button(storeYoctoConfigurationsGroup, SWT.PUSH | SWT.LEAD);
 		btnConfigNew.setText(YoctoSDKMessages.getString(NEW_PROFILE_TITLE));
+		btnConfigNew.addMouseListener(new MouseAdapter()
+		{
+			@Override
+			public void mouseDown(MouseEvent e)
+			{
+				saveChangesOnCurrentProfile();
+				InputDialog profileNameDialog =
+									new InputDialog(null,
+													YoctoSDKMessages.getString(NEW_DIALOG_TITLE),
+													YoctoSDKMessages.getString(NEW_DIALOG_MESSAGE),
+													null,
+													new ProfileNameInputValidator(profileElement));
+
+				int returnCode = profileNameDialog.open();
+				if (returnCode == IDialogConstants.CANCEL_ID) {
+					return;
+				}
+
+				profileElement.addProfile(profileNameDialog.getValue());
+				int index = sdkConfigsCombo.getItemCount();
+				sdkConfigsCombo.add(profileNameDialog.getValue(), index);
+				sdkConfigsCombo.select(index);
+			}
+		});
 	}
 
 	private void createRemoveButton(Group storeYoctoConfigurationsGroup)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +7 -0
index f8c2e4b..6876663 100644
@@ -46,8 +46,15 @@ Preferences.SDK.Target.name = Target Preferences:
 Preferences.SDK.Informing.Title   = Yocto Project ADT has been successfully set up. 
 Preferences.SDK.Informing.Message = You might need to reconfigure your existing Yocto Project Autotools Projects to use the Yocto Project ADT. Do this from Project > Reconfigure Project!
 
+Preferences.Profile.Validator.InvalidName.Comma = Warning: The profile name cannot contain a comma (,).
+Preferences.Profile.Validator.InvalidName.Quote = Warning: The profile name cannot contain a double quote (\").
+Preferences.Profile.Validator.InvalidName.Empty = Please provide a new profile name.
+Preferences.Profile.Validator.InvalidName.Exists = Warning: The profile already exists.
+
 Preferences.Profiles.Title = Target profiles:
 Preferences.Profile.New.Title = New ...
+Preferences.Profile.New.Dialog.Title = Create a new target profile
+Preferences.Profile.New.Dialog.Message = Please input a profile name.
 Preferences.Profile.Rename.Title = Rename
 Preferences.Profile.Remove.Title = Remove
 
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/ProfileNameInputValidator.java new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#11 lore raw

RFC 11/17 plugins/sdk.ide: Add UI method to delete a profile

From: Timo Mueller <[email protected]>

A profile is removed from the list, when the delete button is clicked. The deletion has to be confirmed by the user. Deleting the standard profile is not allowed.

---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 34 ++++++++++++++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |  4 +++
 2 files changed, 38 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +34 -0
index 6a38fb1..cd44b92 100644
@@ -12,6 +12,7 @@ package org.yocto.sdk.ide;
 
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.MouseAdapter;
@@ -24,6 +25,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Listener;
+import org.yocto.sdk.ide.preferences.PreferenceConstants;
 import org.yocto.sdk.ide.preferences.ProfileNameInputValidator;
 
 public class YoctoProfileSetting {
@@ -33,6 +35,10 @@ public class YoctoProfileSetting {
 	private static final String NEW_DIALOG_MESSAGE = "Preferences.Profile.New.Dialog.Message";
 	private static final String RENAME_PROFILE_TITLE = "Preferences.Profile.Rename.Title";
 	private static final String REMOVE_PROFILE_TITLE = "Preferences.Profile.Remove.Title";
+	private static final String REMOVE_DIALOG_TITLE = "Preferences.Profile.Remove.Dialog.Title";
+	private static final String REMOVE_DIALOG_MESSAGE = "Preferences.Profile.Remove.Dialog.Message";
+	private static final String MODIFY_STANDARD_TITLE = "Preferences.Profile.Standard.Modification.Title";
+	private static final String MODIFY_STANDARD_MESSAGE = "Preferences.Profile.Standard.Modification.Message";
 
 	private Combo sdkConfigsCombo;
 	private Button btnConfigRename;
@@ -127,6 +133,34 @@ public class YoctoProfileSetting {
 		btnConfigRemove = new Button(storeYoctoConfigurationsGroup, SWT.PUSH | SWT.LEAD);
 		btnConfigRemove.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false, 3, 1));
 		btnConfigRemove.setText(YoctoSDKMessages.getString(REMOVE_PROFILE_TITLE));
+		btnConfigRemove.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mouseDown(MouseEvent e) {
+				saveChangesOnCurrentProfile();
+				int selectionIndex = sdkConfigsCombo.getSelectionIndex();
+				String selectedItem = sdkConfigsCombo.getItem(selectionIndex);
+
+				if (selectedItem.equals(PreferenceConstants.STANDARD_PROFILE_NAME)) {
+					MessageDialog.openInformation(null,
+													YoctoSDKMessages.getString(MODIFY_STANDARD_TITLE),
+													YoctoSDKMessages.getString(MODIFY_STANDARD_MESSAGE));
+					return;
+				}
+
+				boolean deleteConfirmed =
+						MessageDialog.openConfirm(null,
+													YoctoSDKMessages.getString(REMOVE_DIALOG_TITLE),
+													YoctoSDKMessages.getFormattedString(REMOVE_DIALOG_MESSAGE, selectedItem));
+
+				if (!deleteConfirmed) {
+					return;
+				}
+
+				sdkConfigsCombo.select(0);
+				sdkConfigsCombo.remove(selectionIndex);
+				profileElement.remove(selectedItem);
+			}
+		});
 	}
 
 	private void createRenameButton(Group storeYoctoConfigurationsGroup)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +4 -0
index 6876663..cd52348 100644
@@ -57,6 +57,10 @@ Preferences.Profile.New.Dialog.Title = Create a new target profile
 Preferences.Profile.New.Dialog.Message = Please input a profile name.
 Preferences.Profile.Rename.Title = Rename
 Preferences.Profile.Remove.Title = Remove
+Preferences.Profile.Remove.Dialog.Title = Remove target profile
+Preferences.Profile.Remove.Dialog.Message = Do you really want to the remove the target profile "{0}"?\nProjects using this target profile will be reconfigured to use the standard profile.
+Preferences.Profile.Standard.Modification.Title = Modify standard target profile
+Preferences.Profile.Standard.Modification.Message = Standard target profile cannot be removed or renamed.
 
 Console.SDK.Name = Yocto Project Console
 
Signature · 1 line
1.7.11.7
#12 lore raw

RFC 12/17 plugins/sdk.ide: Add UI method to rename a profile

From: Timo Mueller <[email protected]>

When the rename button is clicked a dialog shows up and the user has to provide the new name for the profile. The validity of the name is checked during input. If the name is valid and the users confirms the profile is renamed. Renaming the standard profile is not allowed.

---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 35 ++++++++++++++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |  2 ++
 2 files changed, 37 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +35 -0
index cd44b92..309e1de 100644
@@ -34,6 +34,8 @@ public class YoctoProfileSetting {
 	private static final String NEW_DIALOG_TITLE = "Preferences.Profile.New.Dialog.Title";
 	private static final String NEW_DIALOG_MESSAGE = "Preferences.Profile.New.Dialog.Message";
 	private static final String RENAME_PROFILE_TITLE = "Preferences.Profile.Rename.Title";
+	private static final String RENAME_DIALOG_TITLE = "Preferences.Profile.Rename.Dialog.Title";
+	private static final String RENAME_DIALOG_MESSAGE = "Preferences.Profile.Rename.Dialog.Message";
 	private static final String REMOVE_PROFILE_TITLE = "Preferences.Profile.Remove.Title";
 	private static final String REMOVE_DIALOG_TITLE = "Preferences.Profile.Remove.Dialog.Title";
 	private static final String REMOVE_DIALOG_MESSAGE = "Preferences.Profile.Remove.Dialog.Message";
@@ -167,6 +169,39 @@ public class YoctoProfileSetting {
 	{
 		btnConfigRename = new Button(storeYoctoConfigurationsGroup, SWT.PUSH | SWT.LEAD);
 		btnConfigRename.setText(YoctoSDKMessages.getString(RENAME_PROFILE_TITLE));
+		btnConfigRename.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mouseDown(MouseEvent e) {
+				saveChangesOnCurrentProfile();
+				int selectedIndex = sdkConfigsCombo.getSelectionIndex();
+				final String selectedItem = sdkConfigsCombo.getItem(selectedIndex);
+
+				if (selectedItem.equals(PreferenceConstants.STANDARD_PROFILE_NAME)) {
+					MessageDialog.openInformation(null,
+							YoctoSDKMessages.getString(MODIFY_STANDARD_TITLE),
+							YoctoSDKMessages.getString(MODIFY_STANDARD_MESSAGE));
+					return;
+				}
+
+				InputDialog profileNameDialog =
+						new InputDialog(null,
+										YoctoSDKMessages.getString(RENAME_DIALOG_TITLE),
+										YoctoSDKMessages.getString(RENAME_DIALOG_MESSAGE),
+										null,
+										new ProfileNameInputValidator(profileElement, selectedItem));
+
+				int returnCode = profileNameDialog.open();
+				if (returnCode == IDialogConstants.CANCEL_ID) {
+					return;
+				}
+
+				String newProfileName = profileNameDialog.getValue();
+				profileElement.rename(selectedItem, profileNameDialog.getValue());
+
+				sdkConfigsCombo.setItem(selectedIndex, newProfileName);
+				sdkConfigsCombo.select(selectedIndex);
+			}
+		});
 	}
 
 	private void saveChangesOnCurrentProfile() {
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +2 -0
index cd52348..ff0946c 100644
@@ -56,6 +56,8 @@ Preferences.Profile.New.Title = New ...
 Preferences.Profile.New.Dialog.Title = Create a new target profile
 Preferences.Profile.New.Dialog.Message = Please input a profile name.
 Preferences.Profile.Rename.Title = Rename
+Preferences.Profile.Rename.Dialog.Title = Rename target profile
+Preferences.Profile.Rename.Dialog.Message = Please input a new profile name.
 Preferences.Profile.Remove.Title = Remove
 Preferences.Profile.Remove.Dialog.Title = Remove target profile
 Preferences.Profile.Remove.Dialog.Message = Do you really want to the remove the target profile "{0}"?\nProjects using this target profile will be reconfigured to use the standard profile.
Signature · 1 line
1.7.11.7
#13 lore raw

RFC 13/17 plugins/sdk.ide: Add method to change values of the preference page

From: Timo Mueller <[email protected]>

When switching profile the values of the profile are retrieved from the preference store. The UI is updated using the retrieved values.

---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java                  | 5 +++++
 .../src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java   | 6 ++++++
 2 files changed, 11 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +5 -0
index 309e1de..a28dce9 100644
@@ -27,6 +27,7 @@ import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Listener;
 import org.yocto.sdk.ide.preferences.PreferenceConstants;
 import org.yocto.sdk.ide.preferences.ProfileNameInputValidator;
+import org.yocto.sdk.ide.preferences.YoctoSDKPreferencePage;
 
 public class YoctoProfileSetting {
 	private static final String PROFILES_TITLE = "Preferences.Profiles.Title";
@@ -89,6 +90,10 @@ public class YoctoProfileSetting {
 
 				String selectedItem = sdkCombo.getItem(sdkCombo.getSelectionIndex());
 				profileElement.setSelectedProfile(selectedItem);
+
+				if (preferencePage instanceof YoctoSDKPreferencePage) {
+					((YoctoSDKPreferencePage) preferencePage).switchProfile(selectedItem);
+				}
 			}
 		};
 
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +6 -0
index 64c9968..cb4a993 100644
@@ -84,4 +84,10 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 		yoctoUISetting.setCurrentInput(defaultElement);
 		super.performDefaults();
 	}
+
+	public void switchProfile(String selectedProfile) {
+		setPreferenceStore(YoctoSDKPlugin.getProfilePreferenceStore(selectedProfile));
+		YoctoUIElement profileElement = YoctoSDKUtils.getElemFromStore(getPreferenceStore());
+		yoctoUISetting.setCurrentInput(profileElement);
+	}
 }
Signature · 1 line
1.7.11.7
#14 lore raw

RFC 14/17 plugins/sdk.ide: Add method to rename a profile and its preference store

From: Timo Mueller <[email protected]>

When renaming a profile the current values are stored in the profile's new preference store.

---
 .../org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java | 4 ++++
 .../src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java    | 5 +++++
 2 files changed, 9 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +4 -0
index a28dce9..47916c7 100644
@@ -203,6 +203,10 @@ public class YoctoProfileSetting {
 				String newProfileName = profileNameDialog.getValue();
 				profileElement.rename(selectedItem, profileNameDialog.getValue());
 
+				if (preferencePage instanceof YoctoSDKPreferencePage) {
+					((YoctoSDKPreferencePage) preferencePage).renameProfile(selectedItem, newProfileName);
+				}
+
 				sdkConfigsCombo.setItem(selectedIndex, newProfileName);
 				sdkConfigsCombo.select(selectedIndex);
 			}
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +5 -0
index cb4a993..0c5928e 100644
@@ -90,4 +90,9 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 		YoctoUIElement profileElement = YoctoSDKUtils.getElemFromStore(getPreferenceStore());
 		yoctoUISetting.setCurrentInput(profileElement);
 	}
+
+	public void renameProfile(String oldProfileName, String newProfileName) {
+		YoctoUIElement oldProfileElement = YoctoSDKUtils.getElemFromStore(YoctoSDKPlugin.getProfilePreferenceStore(oldProfileName));
+		YoctoSDKUtils.saveElemToStore(oldProfileElement, YoctoSDKPlugin.getProfilePreferenceStore(newProfileName));
+	}
 }
Signature · 1 line
1.7.11.7
#15 lore raw

RFC 15/17 plugins/sdk.ide: Add method to delete a profile

From: Timo Mueller <[email protected]>

Deletion of a profile currently has no effects on the preference page.

---
 .../org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java | 4 ++++
 .../src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java    | 5 +++++
 2 files changed, 9 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java +4 -0
index 47916c7..5ae3ab6 100644
@@ -166,6 +166,10 @@ public class YoctoProfileSetting {
 				sdkConfigsCombo.select(0);
 				sdkConfigsCombo.remove(selectionIndex);
 				profileElement.remove(selectedItem);
+
+				if (preferencePage instanceof YoctoSDKPreferencePage) {
+					((YoctoSDKPreferencePage) preferencePage).deleteProfile(selectedItem);
+				}
 			}
 		});
 	}
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +5 -0
index 0c5928e..8f6111b 100644
@@ -95,4 +95,9 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 		YoctoUIElement oldProfileElement = YoctoSDKUtils.getElemFromStore(YoctoSDKPlugin.getProfilePreferenceStore(oldProfileName));
 		YoctoSDKUtils.saveElemToStore(oldProfileElement, YoctoSDKPlugin.getProfilePreferenceStore(newProfileName));
 	}
+
+	public void deleteProfile(String selectedProfile)
+	{
+		// do nothing
+	}
 }
Signature · 1 line
1.7.11.7
#16 lore raw

RFC 16/17 plugins/sdk.ide: Use profiles for the preference page

From: Timo Mueller <[email protected]>

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.

---
 .../ide/preferences/YoctoSDKPreferencePage.java    | 34 +++++++++++++++++-----
 1 file changed, 27 insertions(+), 7 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +27 -7
index 8f6111b..eb7a393 100644
@@ -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()
 	 */
Signature · 1 line
1.7.11.7
#17 lore raw

RFC 17/17 plugins/sdk.ide: Added profile UI to the preference page

From: Timo Mueller <[email protected]>

Adds the UI elements that allow managing profiles to the preference page.

---
 .../src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +3 -1
index eb7a393..a4d6ce5 100644
@@ -61,7 +61,9 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 	protected Control createContents(Composite parent) {
 		initializeDialogUnits(parent);
 		final Composite result= new Composite(parent, SWT.NONE);
-		
+
+		yoctoProfileSetting.createComposite(result);
+
 		try {
 			yoctoUISetting.createComposite(result);
 			yoctoUISetting.validateInput(SDKCheckRequestFrom.Preferences, false);
Signature · 1 line
1.7.11.7
#18 lore raw
In reply to Timo Mueller

Hi Timo and Atanas,

Thanks for the contribution and I really think it's a great idea and nice feature enhancement by allowing save user customized preference configs via profiles. But I ran into couple issues when applying the patch series and playing with it.

1st. For patch 7/17, seems we're have following dup changes:

+ public static IPreferenceStore getProfilePreferenceStore(String profileName) {
+ int profileIdentifier = profileName.hashCode();
+
+ return new ScopedPreferenceStore(InstanceScope.INSTANCE,getUniqueIdentifier() + "." + profileIdentifier);
+ }
+
+ public static IPreferenceStore getProfilePreferenceStore(String profileName) {
+ int profileIdentifier = profileName.hashCode();
+
+ return new ScopedPreferenceStore(InstanceScope.INSTANCE,getUniqueIdentifier() + "." + profileIdentifier);
+ }
+

Also, we're missing the patch for NewYoctoCProjectTemplate.java since we're still calling YoctoSDKUtils.getElemFromStore() which should be getElemFromDefaultStore()?

2nd, some behavior exceptions:

When I first open the preference page, I can see the Standard profile, when after I made all my selections for toolchain, sysroot, etc. then I click on new and entered a profile name, e.g. pokytree. To my surprise, my changes went to the default profile, instead of the new profile which I'd expected. So now I have 2 profiles, standard (which contains my changes) and pokytree, which is empty. And if I leave my drop down box with pokytree and click on new button again, I'll get this pop window telling me I need to specify toolchain, etc. but after I dismiss the error message box, the "create a new target profile" dialog will show. IMHO this can be very confusing to people, esp. those new to the whole thing. So I'd suggest that we change the logic, instead of new button, can we change it to "Save as..." which brings up the dialog for entering the profile name. But we use the existing logic of validate the entries before it's allowed to be saved as new profile. So to that extend, the behavior is the same as "Apply" except Apply will apply all the changes to the selected Profile? And I'd also suggest we move the "Save as" button on the same line with Apply if possible.

Make sense?

Thanks,
Jessica

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Timo Mueller
Sent: Thursday, January 24, 2013 7:12 AM
To: [email protected]
Cc: Timo Mueller
Subject: [yocto] [RFC 00/17][eclipse-poky] Storing yocto settings as target profiles

From: Timo Mueller <[email protected]>

Hi,

currently the yocto settings can be changed globally through eclipse's preferences or locally in the project properties. But the standard configuration stored in the global preferences sometimes changes, e.g. if a new version of the toolchain or the sysroot is released. If you change the global settings to the updated toolchain or sysroot your old working configuration is gone. If you want to reuse this configuration at a later point in time you have to (remember and) re-enter everthing. This patch set introduces the possiblity to store a configuration under a unique name, a so called target profile, and be able to select the default target profile that is used for new projects.
Building upon this change the target profiles could later also be used in the project settings and be able to quickly build and debug your software for different hard- and software combinations.

Best regards,
Timo

Atanas Gegov (4):
plugins/sdk.ide: Extract labels to private members plugins/sdk.ide: Add method to enable and disable form plugins/sdk.ide: Set value of target array on input change plugins/sdk.ide: Create UI element for managing target profiles.

Timo Mueller (13):
plugins/sdk.ide: Removed unused message
plugins/sdk.ide: Changed method signature to be more consistent plugins/sdk.ide: Modified preferences storage to support profiles. plugins/sdk.ide: Set profile on selection change plugins/sdk.ide: Add method to allow storing the current settings plugins/sdk.ide: Add UI method to create a new profile plugins/sdk.ide: Add UI method to delete a profile plugins/sdk.ide: Add UI method to rename a profile plugins/sdk.ide: Add method to change values of the preference page plugins/sdk.ide: Add method to rename a profile and its preference
store
plugins/sdk.ide: Add method to delete a profile plugins/sdk.ide: Use profiles for the preference page plugins/sdk.ide: Added profile UI to the preference page

 .../src/org/yocto/sdk/ide/YoctoProfileElement.java | 105 +++++++++  .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 244 +++++++++++++++++++++  .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |  19 +-
 .../src/org/yocto/sdk/ide/YoctoSDKPlugin.java      |  15 ++
 .../org/yocto/sdk/ide/YoctoSDKProjectNature.java   |  10 +-
 .../src/org/yocto/sdk/ide/YoctoSDKUtils.java       |  62 ++++--
 .../src/org/yocto/sdk/ide/YoctoUISetting.java      |  61 +++++-
 .../sdk/ide/preferences/PreferenceConstants.java   |   5 +
 .../sdk/ide/preferences/PreferenceInitializer.java |  22 +-  .../ide/preferences/ProfileNameInputValidator.java |  73 ++++++
 .../ide/preferences/YoctoSDKPreferencePage.java    |  80 ++++---
 .../preferences/YoctoSDKProjectPropertyPage.java   |   6 +-
 12 files changed, 637 insertions(+), 65 deletions(-)  create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileElement.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/ProfileNameInputValidator.java

--
1.7.11.7

_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto