All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
@ 2013-06-21 12:44 Timo Mueller
  2013-06-21 12:44 ` [PATCHv2 1/8] plugins/sdk.ide: Use an internationalized dialog title Timo Mueller
  2013-06-21 21:47 ` [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Zhang, Jessica
  0 siblings, 2 replies; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

Changes in v2:
Handle error when project specific profile is not configured more
gracefully. Instead of showing an error message the button is now
greyed out.

Patches 01..07 contain the implementation with the greyed out menu
button.

After playing around with the two options discussed in the first patch
series, I started to prefer inserting a different button in the menu
allowing the user to quickly navigate to the project preferences
instead of just greying it out. I've added this in the last patch of
the series, so you can compare yourself.

From original cover letter
<snip>
if a user wants to change the used target profile of a project he
currently has to open the project preferences. This can be tedious if
he has to switch the profile often.

This is a small addition which allows the user to quickly switch the
used target profile of a project. Instead of having to open the
project preferences the user can select the project in the navigator
and then choose the desired target profile from a drop-down menu in
the toolbar or from the project menu.
</snip>

01: Small i18n fix
02..04: Refactoring the project specific utils
05..06: Introduce the target profile toolbar switch
07: Adds the target profile switch to the project menu
08: Experimental: Add button to open project preferences

Best regards,
Timo

Timo Mueller (8):
  plugins/sdk.ide: Use an internationalized dialog title
  plugins/sdk.ide: Extract project specific util methods
  plugins/sdk.ide: Move project specific util methods
  plugins/sdk.ide: Remove project context from method names
  plugins/sdk.ide: Add command to switch the target profile
  plugins/sdk.ide: Add profile switch menu to the toolbar
  plugins/sdk.ide: Add profile switch menu to the project menu
  plugins/sdk.ide: Add project configuration button

 .../OSGI-INF/l10n/bundle.properties                |   4 +
 plugins/org.yocto.sdk.ide/plugin.xml               |  96 ++++++++-
 .../sdk/ide/ProjectSpecificContributionItem.java   |  91 ++++++++
 .../sdk/ide/TargetProfileContributionItem.java     | 125 +++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |   5 +
 .../src/org/yocto/sdk/ide/YoctoUISetting.java      |   3 +-
 .../sdk/ide/actions/ProfileSwitchHandler.java      | 134 ++++++++++++
 .../natures/YoctoSDKAutotoolsProjectNature.java    |   3 +-
 .../ide/preferences/YoctoSDKPreferencePage.java    |  11 +-
 .../preferences/YoctoSDKProjectPropertyPage.java   | 130 ++---------
 .../sdk/ide/utils/ProjectPreferenceUtils.java      | 240 +++++++++++++++++++++
 .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 118 ----------
 .../ide/wizard/NewYoctoProjectTemplateProcess.java |   3 +-
 13 files changed, 717 insertions(+), 246 deletions(-)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/TargetProfileContributionItem.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java

-- 
1.8.1.4



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCHv2 1/8] plugins/sdk.ide: Use an internationalized dialog title
  2013-06-21 12:44 [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Timo Mueller
@ 2013-06-21 12:44 ` Timo Mueller
  2013-06-21 12:44   ` [PATCHv2 2/8] plugins/sdk.ide: Extract project specific util methods Timo Mueller
  2013-06-21 21:47 ` [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Zhang, Jessica
  1 sibling, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>


Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
index e5a7897..d192538 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
@@ -42,7 +42,6 @@ import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
 import org.yocto.sdk.ide.preferences.PreferenceConstants;
 
 public class YoctoUISetting {
-
 	private static final String ENV_SCRIPT_FILE_PREFIX = "environment-setup-";
 
 	private SelectionListener fSelectionListener;
@@ -375,7 +374,7 @@ public class YoctoUISetting {
 		if ((result != SDKCheckResults.SDK_PASS) && showErrorDialog) {
 			Display display = Display.getCurrent();
 			ErrorDialog.openError(display.getActiveShell(),
-									"Yocto Project Configuration Error",
+									YoctoSDKChecker.SDKCheckRequestFrom.Other.getErrorMessage(),
 									YoctoSDKChecker.getErrorMessage(result, from),
 									new Status(Status.ERROR, YoctoSDKPlugin.PLUGIN_ID, result.getMessage()));
 
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 2/8] plugins/sdk.ide: Extract project specific util methods
  2013-06-21 12:44 ` [PATCHv2 1/8] plugins/sdk.ide: Use an internationalized dialog title Timo Mueller
@ 2013-06-21 12:44   ` Timo Mueller
  2013-06-21 12:44     ` [PATCHv2 3/8] plugins/sdk.ide: Move " Timo Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

Project specific util methods are moved to a separate util class. This
way the general util class will get more concise and other project
specific methods can be move to this new util class later.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 .../natures/YoctoSDKAutotoolsProjectNature.java    |   3 +-
 .../ide/preferences/YoctoSDKPreferencePage.java    |  11 +-
 .../preferences/YoctoSDKProjectPropertyPage.java   |  13 +-
 .../sdk/ide/utils/ProjectPreferenceUtils.java      | 138 +++++++++++++++++++++
 .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 118 ------------------
 .../ide/wizard/NewYoctoProjectTemplateProcess.java |   3 +-
 6 files changed, 155 insertions(+), 131 deletions(-)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java
index fb53c53..ce80d77 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java
@@ -18,6 +18,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
 import org.eclipse.core.resources.IProject;
 import org.yocto.sdk.ide.YoctoSDKPlugin;
 import org.yocto.sdk.ide.YoctoUIElement;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
 
 public class YoctoSDKAutotoolsProjectNature extends YoctoSDKProjectNature {
@@ -35,7 +36,7 @@ public class YoctoSDKAutotoolsProjectNature extends YoctoSDKProjectNature {
 	public static void configureAutotoolsOptions(IProject project) {
 		IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
 		IConfiguration icfg = info.getDefaultConfiguration();
-		YoctoUIElement elem = YoctoSDKUtils.getElemFromProjectEnv(project);
+		YoctoUIElement elem = ProjectPreferenceUtils.getElemFromProjectEnv(project);
 		String sysroot_str = elem.getStrSysrootLoc();
 		String id = icfg.getId();
 		String CFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CFLAGS");
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 211c4f9..e8123e2 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
@@ -34,6 +34,7 @@ import org.yocto.sdk.ide.YoctoProfileSetting;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
 import org.yocto.sdk.ide.YoctoSDKMessages;
 import org.yocto.sdk.ide.YoctoSDKPlugin;
@@ -240,10 +241,10 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 
 		for (IProject project : yoctoProjects)
 		{
-			YoctoSDKUtils.saveProfilesToProjectPreferences(profileElement, project);
+			ProjectPreferenceUtils.saveProfilesToProjectPreferences(profileElement, project);
 			YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(
 											YoctoSDKPlugin.getProfilePreferenceStore(PreferenceConstants.STANDARD_PROFILE_NAME));
-			YoctoSDKUtils.saveElemToProjectEnv(elem, project);
+			ProjectPreferenceUtils.saveElemToProjectEnv(elem, project);
 		}
 	}
 
@@ -254,14 +255,14 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 
 		for (IProject project : yoctoProjects)
 		{
-			YoctoSDKUtils.saveProfilesToProjectPreferences(profileElement, project);
+			ProjectPreferenceUtils.saveProfilesToProjectPreferences(profileElement, project);
 		}
 	}
 
 	private void updateProjects(HashSet<IProject> yoctoProjects, YoctoUIElement elem) {
 		for (IProject project : yoctoProjects)
 		{
-			YoctoSDKUtils.saveElemToProjectEnv(elem, project);
+			ProjectPreferenceUtils.saveElemToProjectEnv(elem, project);
 		}
 	}
 
@@ -295,7 +296,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 
 	private boolean projectUsesProfile(IProject project, String profile)
 	{
-		YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromProjectPreferences(project);
+		YoctoProfileElement profileElement = ProjectPreferenceUtils.getProfilesFromProjectPreferences(project);
 
 		if (!profileElement.getSelectedProfile().equals(profile)) {
 			return false;
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
index 9f99caf..f075c5b 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
@@ -34,6 +34,7 @@ import org.yocto.sdk.ide.YoctoProjectSpecificSetting;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
 import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
 import org.yocto.sdk.ide.utils.YoctoSDKUtilsConstants;
 import org.yocto.sdk.ide.YoctoSDKPlugin;
@@ -69,7 +70,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 		IProject project = getProject();
 
 		YoctoProfileElement globalProfileElement= YoctoSDKUtils.getProfilesFromDefaultStore();
-		YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromProjectPreferences(project);
+		YoctoProfileElement profileElement = ProjectPreferenceUtils.getProfilesFromProjectPreferences(project);
 
 		String selectedProfile = profileElement.getSelectedProfile();
 		if (!globalProfileElement.contains(selectedProfile)) {
@@ -160,14 +161,14 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 			}
 
 			saveUseProjectSpecificOptionToProjectPreferences(project, true);
-			YoctoSDKUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
+			ProjectPreferenceUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
 			saveElemToProjectPreferences(yoctoUISetting.getCurrentInput(), project);
 		} else {
 			saveUseProjectSpecificOptionToProjectPreferences(project, false);
-			YoctoSDKUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
+			ProjectPreferenceUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
 		}
 
-		YoctoSDKUtils.saveElemToProjectEnv(yoctoUISetting.getCurrentInput(), getProject());
+		ProjectPreferenceUtils.saveElemToProjectEnv(yoctoUISetting.getCurrentInput(), getProject());
 
 		return super.performOk();
 	}
@@ -245,7 +246,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 		if (projectNode == null) {
-			return YoctoSDKUtils.getElemFromProjectEnv(project);
+			return ProjectPreferenceUtils.getElemFromProjectEnv(project);
 		}
 
 		YoctoUIElement elem = new YoctoUIElement();
@@ -287,7 +288,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 
 	public void switchToProjectSpecificProfile()
 	{
-		YoctoUIElement profileElement = getElemFromProjectPreferences(getProject());
+		YoctoUIElement profileElement = ProjectPreferenceUtils.getElemFromProjectEnv(getProject());
 		yoctoUISetting.setCurrentInput(profileElement);
 	}
 
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
new file mode 100644
index 0000000..0f84912
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BMW Car IT GmbH.
+ * Copyright (c) 2010 Intel Corporation.
+ * 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:
+ * Intel - initial implementation
+ * BMW Car IT - initial implementation and refactoring
+ *******************************************************************************/
+package org.yocto.sdk.ide.utils;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.osgi.service.prefs.BackingStoreException;
+import org.yocto.sdk.ide.YoctoGeneralException;
+import org.yocto.sdk.ide.YoctoProfileElement;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.YoctoUIElement;
+import org.yocto.sdk.ide.natures.YoctoSDKAutotoolsProjectNature;
+import org.yocto.sdk.ide.natures.YoctoSDKCMakeProjectNature;
+import org.yocto.sdk.ide.preferences.PreferenceConstants;
+
+public class ProjectPreferenceUtils {
+	private static final String CONSOLE_MESSAGE  = "Menu.SDK.Console.Configure.Message";
+
+	/* Get POKY Preference settings from project's environment */
+	public static YoctoUIElement getElemFromProjectEnv(IProject project) {
+		YoctoUIElement elem = new YoctoUIElement();
+		elem.setStrToolChainRoot(YoctoSDKUtils.getEnvValue(project, PreferenceConstants.TOOLCHAIN_ROOT));
+		elem.setStrTarget(YoctoSDKUtils.getEnvValue(project, PreferenceConstants.TOOLCHAIN_TRIPLET));
+		elem.setStrQemuKernelLoc(YoctoSDKUtils.getEnvValue(project, PreferenceConstants.QEMU_KERNEL));
+		elem.setStrSysrootLoc(YoctoSDKUtils.getEnvValue(project, PreferenceConstants.SYSROOT));
+		elem.setStrQemuOption(YoctoSDKUtils.getEnvValue(project, PreferenceConstants.QEMU_OPTION));
+		String sTemp = YoctoSDKUtils.getEnvValue(project, PreferenceConstants.TARGET_ARCH_INDEX);
+
+		if (!sTemp.isEmpty()) {
+			elem.setIntTargetIndex(Integer.valueOf(sTemp).intValue());
+		}
+
+		if (YoctoSDKUtils.getEnvValue(project, PreferenceConstants.SDK_MODE).equalsIgnoreCase(IPreferenceStore.TRUE)) {
+			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
+		} else {
+			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
+		}
+
+		if(YoctoSDKUtils.getEnvValue(project, PreferenceConstants.TARGET_MODE).equalsIgnoreCase(IPreferenceStore.TRUE)) {
+			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
+		} else {
+			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
+		}
+
+		return elem;
+	}
+
+	/* Get profiles and selected profile from the project's preference store */
+	public static YoctoProfileElement getProfilesFromProjectPreferences(IProject project) {
+		IScopeContext projectScope = new ProjectScope(project);
+		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
+
+		if (projectNode == null) {
+			return YoctoSDKUtils.getProfilesFromDefaultStore();
+		}
+
+		String profiles = projectNode.get(PreferenceConstants.PROFILES, "");
+		String selectedProfile = projectNode.get(PreferenceConstants.SELECTED_PROFILE, "");
+
+		return new YoctoProfileElement(profiles, selectedProfile);
+	}
+
+	/* Save POKY Preference settings to project's environment */
+	public static void saveElemToProjectEnv(YoctoUIElement elem, IProject project) {
+		ConsoleOutputStream consoleOutStream = null;
+
+		try {
+			YoctoSDKUtils.setEnvironmentVariables(project, elem);
+			YoctoSDKUtils.createRemoteDebugAndQemuLaunchers(project, elem);
+
+			if (project.hasNature(YoctoSDKAutotoolsProjectNature.YoctoSDK_AUTOTOOLS_NATURE_ID)) {
+				YoctoSDKAutotoolsProjectNature.configureAutotoolsOptions(project);
+			} else if (project.hasNature(YoctoSDKCMakeProjectNature.YoctoSDK_CMAKE_NATURE_ID)) {
+				YoctoSDKCMakeProjectNature.extendProjectEnvironmentForCMake(project);
+			}
+
+			IConsole console = CCorePlugin.getDefault().getConsole("org.yocto.sdk.ide.YoctoConsole");
+			console.start(project);
+			consoleOutStream = console.getOutputStream();
+			String messages = YoctoSDKMessages.getString(CONSOLE_MESSAGE);
+			consoleOutStream.write(messages.getBytes());
+		} catch (CoreException e) {
+			System.out.println(e.getMessage());
+		} catch (IOException e) {
+			System.out.println(e.getMessage());
+		} catch (YoctoGeneralException e) {
+			System.out.println(e.getMessage());
+		} finally {
+			if (consoleOutStream != null) {
+				try {
+					consoleOutStream.flush();
+					consoleOutStream.close();
+				} catch (IOException e) {
+					// ignore
+				}
+			}
+		}
+	}
+
+	/* Save profiles and selected profile to the project's preference store */
+	public static void saveProfilesToProjectPreferences(YoctoProfileElement profileElement, IProject project) {
+		IScopeContext projectScope = new ProjectScope(project);
+		IEclipsePreferences projectPreferences = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
+
+		if (projectPreferences == null) {
+			return;
+		}
+
+		projectPreferences.put(PreferenceConstants.PROFILES, profileElement.getProfilesAsString());
+		projectPreferences.put(PreferenceConstants.SELECTED_PROFILE, profileElement.getSelectedProfile());
+
+		try {
+			projectPreferences.flush();
+		} catch (BackingStoreException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
index 99a9884..2ac48f8 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
@@ -25,34 +25,26 @@ import java.util.Set;
 import java.util.StringTokenizer;
 
 import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ConsoleOutputStream;
 import org.eclipse.cdt.core.envvar.IContributedEnvironment;
 import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
 import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
 import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.resources.IConsole;
 import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
 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.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
 import org.eclipse.debug.core.DebugPlugin;
 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.jface.preference.IPreferenceStore;
-import org.osgi.service.prefs.BackingStoreException;
 import org.yocto.sdk.ide.YoctoGeneralException;
 import org.yocto.sdk.ide.YoctoProfileElement;
-import org.yocto.sdk.ide.YoctoSDKMessages;
 import org.yocto.sdk.ide.YoctoSDKPlugin;
 import org.yocto.sdk.ide.YoctoUIElement;
-import org.yocto.sdk.ide.natures.YoctoSDKAutotoolsProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKCMakeProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.preferences.PreferenceConstants;
@@ -61,7 +53,6 @@ public class YoctoSDKUtils {
 
 	private static final String DEFAULT_SYSROOT_PREFIX = "--sysroot=";
 	private static final String LIBTOOL_SYSROOT_PREFIX = "--with-libtool-sysroot=";
-	private static final String CONSOLE_MESSAGE  = "Menu.SDK.Console.Configure.Message";
 
 	private static final String DEFAULT_USR_BIN = "/usr/bin/";
 	private static final String NATIVE_SYSROOT = "OECORE_NATIVE_SYSROOT";
@@ -395,78 +386,6 @@ public class YoctoSDKUtils {
 		return qemu_target;
 	}
 
-	/* Get POKY Preference settings from project's environment */
-	public static YoctoUIElement getElemFromProjectEnv(IProject project)
-	{
-		YoctoUIElement elem = new YoctoUIElement();
-		elem.setStrToolChainRoot(getEnvValue(project, PreferenceConstants.TOOLCHAIN_ROOT));
-		elem.setStrTarget(getEnvValue(project, PreferenceConstants.TOOLCHAIN_TRIPLET));
-		elem.setStrQemuKernelLoc(getEnvValue(project, PreferenceConstants.QEMU_KERNEL));
-		elem.setStrSysrootLoc(getEnvValue(project, PreferenceConstants.SYSROOT));
-		elem.setStrQemuOption(getEnvValue(project, PreferenceConstants.QEMU_OPTION));
-		String sTemp = getEnvValue(project, PreferenceConstants.TARGET_ARCH_INDEX);
-		if (!sTemp.isEmpty())
-			elem.setIntTargetIndex(Integer.valueOf(sTemp).intValue());
-		if (getEnvValue(project, PreferenceConstants.SDK_MODE).equalsIgnoreCase(IPreferenceStore.TRUE))
-		{
-			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
-		}
-		else
-			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
-
-		if(getEnvValue(project, PreferenceConstants.TARGET_MODE).equalsIgnoreCase(IPreferenceStore.TRUE))
-			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
-		else
-			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
-		return elem;
-	}
-
-	/* Save POKY Preference settings to project's environment */
-	public static void saveElemToProjectEnv(YoctoUIElement elem, IProject project)
-	{
-		ConsoleOutputStream consoleOutStream = null;
-
-		try {
-			setEnvironmentVariables(project, elem);
-			createRemoteDebugAndQemuLaunchers(project, elem);
-
-			if (project.hasNature(YoctoSDKAutotoolsProjectNature.YoctoSDK_AUTOTOOLS_NATURE_ID)) {
-				YoctoSDKAutotoolsProjectNature.configureAutotoolsOptions(project);
-			} else if (project.hasNature(YoctoSDKCMakeProjectNature.YoctoSDK_CMAKE_NATURE_ID)) {
-				YoctoSDKCMakeProjectNature.extendProjectEnvironmentForCMake(project);
-			}
-
-			IConsole console = CCorePlugin.getDefault().getConsole("org.yocto.sdk.ide.YoctoConsole");
-			console.start(project);
-			consoleOutStream = console.getOutputStream();
-			String messages = YoctoSDKMessages.getString(CONSOLE_MESSAGE);
-			consoleOutStream.write(messages.getBytes());
-		}
-		catch (CoreException e)
-		{
-			System.out.println(e.getMessage());
-		}
-		catch (IOException e)
-		{
-			System.out.println(e.getMessage());
-		}
-		catch (YoctoGeneralException e)
-		{
-			System.out.println(e.getMessage());
-		}
-		finally {
-			if (consoleOutStream != null) {
-				try {
-					consoleOutStream.flush();
-					consoleOutStream.close();
-				}
-				catch (IOException e) {
-					// ignore
-				}
-			}
-		}
-	}
-
 	/* Get IDE wide POKY Preference settings from a specific preference store */
 	public static YoctoUIElement getElemFromStore(IPreferenceStore store) {
 		YoctoUIElement elem = new YoctoUIElement();
@@ -520,27 +439,6 @@ public class YoctoSDKUtils {
 		saveProfilesToStore(profileElement, YoctoSDKPlugin.getDefault().getPreferenceStore());
 	}
 
-	/* Save profiles and selected profile to the project's preference store */
-	public static void saveProfilesToProjectPreferences(YoctoProfileElement profileElement, IProject project) {
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences projectPreferences = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
-		if (projectPreferences == null) {
-			return;
-		}
-
-		projectPreferences.put(PreferenceConstants.PROFILES, profileElement.getProfilesAsString());
-		projectPreferences.put(PreferenceConstants.SELECTED_PROFILE, profileElement.getSelectedProfile());
-
-		try
-		{
-			projectPreferences.flush();
-		} catch (BackingStoreException e)
-		{
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-
 	/* Save profiles and selected profile to a specific preference store */
 	private static void saveProfilesToStore(YoctoProfileElement profileElement, IPreferenceStore store) {
 		store.setValue(PreferenceConstants.PROFILES, profileElement.getProfilesAsString());
@@ -560,20 +458,4 @@ public class YoctoSDKUtils {
 
 		return new YoctoProfileElement(profiles, selectedProfile);
 	}
-
-	/* Get profiles and selected profile from the project's preference store */
-	public static YoctoProfileElement getProfilesFromProjectPreferences(IProject project)
-	{
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
-		if (projectNode == null)
-		{
-			return getProfilesFromDefaultStore();
-		}
-
-		String profiles = projectNode.get(PreferenceConstants.PROFILES, "");
-		String selectedProfile = projectNode.get(PreferenceConstants.SELECTED_PROFILE, "");
-
-		return new YoctoProfileElement(profiles, selectedProfile);
-	}
 }
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java
index 3ea7e33..f64043d 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java
@@ -60,6 +60,7 @@ import org.yocto.sdk.ide.natures.YoctoSDKCMakeProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
 import org.yocto.sdk.ide.natures.YoctoSDKNatureUtils;
 import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
 
 @SuppressWarnings("restriction")
@@ -205,7 +206,7 @@ public class NewYoctoProjectTemplateProcess extends ProcessRunner {
 		YoctoSDKChecker.checkIfGloballySelectedYoctoProfileIsValid();
 
 		YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromDefaultStore();
-		YoctoSDKUtils.saveProfilesToProjectPreferences(profileElement, project);
+		ProjectPreferenceUtils.saveProfilesToProjectPreferences(profileElement, project);
 
 		IPreferenceStore selecteProfileStore = YoctoSDKPlugin.getProfilePreferenceStore(profileElement.getSelectedProfile());
 		YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(selecteProfileStore);
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 3/8] plugins/sdk.ide: Move project specific util methods
  2013-06-21 12:44   ` [PATCHv2 2/8] plugins/sdk.ide: Extract project specific util methods Timo Mueller
@ 2013-06-21 12:44     ` Timo Mueller
  2013-06-21 12:44       ` [PATCHv2 4/8] plugins/sdk.ide: Remove project context from method names Timo Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

Move project specific methods to the new util class to allow public
usage of theses methods.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 .../preferences/YoctoSDKProjectPropertyPage.java   | 121 ++-------------------
 .../sdk/ide/utils/ProjectPreferenceUtils.java      | 102 +++++++++++++++++
 2 files changed, 109 insertions(+), 114 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
index f075c5b..1f82fe1 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
@@ -13,12 +13,8 @@
 package org.yocto.sdk.ide.preferences;
 
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
 import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
@@ -27,19 +23,17 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.ui.IWorkbenchPropertyPage;
 import org.eclipse.ui.dialogs.PropertyPage;
-import org.osgi.service.prefs.BackingStoreException;
 import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoProfileSetting;
 import org.yocto.sdk.ide.YoctoProjectSpecificSetting;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
 import org.yocto.sdk.ide.YoctoSDKMessages;
-import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
-import org.yocto.sdk.ide.utils.YoctoSDKUtils;
-import org.yocto.sdk.ide.utils.YoctoSDKUtilsConstants;
 import org.yocto.sdk.ide.YoctoSDKPlugin;
 import org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.YoctoUISetting;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
+import org.yocto.sdk.ide.utils.YoctoSDKUtils;
 
 public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 		IWorkbenchPropertyPage {
@@ -79,10 +73,10 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 
 		yoctoProfileSetting = new YoctoProfileSetting(
 				new YoctoProfileElement(globalProfileElement.getProfilesAsString(), selectedProfile), this, false);
-		boolean useProjectSpecificSetting = getUseProjectSpecificOptionFromProjectPreferences(project);
+		boolean useProjectSpecificSetting = ProjectPreferenceUtils.getUseProjectSpecificOptionFromProjectPreferences(project);
 
 		if (useProjectSpecificSetting) {
-			yoctoUISetting = new YoctoUISetting(getElemFromProjectPreferences(project));
+			yoctoUISetting = new YoctoUISetting(ProjectPreferenceUtils.getElemFromProjectPreferences(project));
 		} else {
 			yoctoUISetting = new YoctoUISetting(YoctoSDKUtils.getElemFromStore(YoctoSDKPlugin.getProfilePreferenceStore(selectedProfile)));
 		}
@@ -160,11 +154,11 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 				return false;
 			}
 
-			saveUseProjectSpecificOptionToProjectPreferences(project, true);
+			ProjectPreferenceUtils.saveUseProjectSpecificOptionToProjectPreferences(project, true);
 			ProjectPreferenceUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
-			saveElemToProjectPreferences(yoctoUISetting.getCurrentInput(), project);
+			ProjectPreferenceUtils.saveElemToProjectPreferences(yoctoUISetting.getCurrentInput(), project);
 		} else {
-			saveUseProjectSpecificOptionToProjectPreferences(project, false);
+			ProjectPreferenceUtils.saveUseProjectSpecificOptionToProjectPreferences(project, false);
 			ProjectPreferenceUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
 		}
 
@@ -173,107 +167,6 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 		return super.performOk();
 	}
 
-	private void saveUseProjectSpecificOptionToProjectPreferences(IProject project, boolean useProjectSpecificSetting) {
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
-		if (projectNode == null) {
-			return;
-		}
-
-		if (useProjectSpecificSetting) {
-			projectNode.put(PreferenceConstants.PROJECT_SPECIFIC_PROFILE, IPreferenceStore.TRUE);
-		} else {
-			projectNode.put(PreferenceConstants.PROJECT_SPECIFIC_PROFILE, IPreferenceStore.FALSE);
-		}
-
-		try {
-			projectNode.flush();
-		} catch (BackingStoreException e) {
-			e.printStackTrace();
-		}
-	}
-
-	private boolean getUseProjectSpecificOptionFromProjectPreferences(IProject project) {
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
-		if (projectNode == null) {
-			return false;
-		}
-
-		String useProjectSpecificSettingString = projectNode.get(PreferenceConstants.PROJECT_SPECIFIC_PROFILE, IPreferenceStore.FALSE);
-
-		if (useProjectSpecificSettingString.equals(IPreferenceStore.FALSE)) {
-			return false;
-		}
-		return true;
-	}
-
-	/* Save POKY Preference settings to project's preference store */
-	private void saveElemToProjectPreferences(YoctoUIElement elem, IProject project) {
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
-		if (projectNode == null) {
-			return;
-		}
-
-		projectNode.putInt(PreferenceConstants.TARGET_ARCH_INDEX, elem.getIntTargetIndex());
-		if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) {
-			projectNode.put(PreferenceConstants.SDK_MODE, IPreferenceStore.TRUE);
-		} else {
-			projectNode.put(PreferenceConstants.SDK_MODE, IPreferenceStore.FALSE);
-		}
-		projectNode.put(PreferenceConstants.QEMU_KERNEL, elem.getStrQemuKernelLoc());
-		projectNode.put(PreferenceConstants.QEMU_OPTION, elem.getStrQemuOption());
-		projectNode.put(PreferenceConstants.SYSROOT, elem.getStrSysrootLoc());
-
-		if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) {
-			projectNode.put(PreferenceConstants.TARGET_MODE, IPreferenceStore.TRUE);
-		} else {
-			projectNode.put(PreferenceConstants.TARGET_MODE, IPreferenceStore.FALSE);
-		}
-		projectNode.put(PreferenceConstants.TOOLCHAIN_ROOT, elem.getStrToolChainRoot());
-		projectNode.put(PreferenceConstants.TOOLCHAIN_TRIPLET, elem.getStrTarget());
-
-		try {
-			projectNode.flush();
-		} catch (BackingStoreException e) {
-			e.printStackTrace();
-		}
-	}
-
-	/* Get POKY Preference settings from project's preference store */
-	private YoctoUIElement getElemFromProjectPreferences(IProject project) {
-		IScopeContext projectScope = new ProjectScope(project);
-		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
-		if (projectNode == null) {
-			return ProjectPreferenceUtils.getElemFromProjectEnv(project);
-		}
-
-		YoctoUIElement elem = new YoctoUIElement();
-		elem.setStrToolChainRoot(projectNode.get(PreferenceConstants.TOOLCHAIN_ROOT,""));
-		elem.setStrTarget(projectNode.get(PreferenceConstants.TOOLCHAIN_TRIPLET,""));
-		elem.setStrQemuKernelLoc(projectNode.get(PreferenceConstants.QEMU_KERNEL,""));
-		elem.setStrSysrootLoc(projectNode.get(PreferenceConstants.SYSROOT,""));
-		elem.setStrQemuOption(projectNode.get(PreferenceConstants.QEMU_OPTION,""));
-		String sTemp = projectNode.get(PreferenceConstants.TARGET_ARCH_INDEX,"");
-		if (!sTemp.isEmpty()) {
-			elem.setIntTargetIndex(Integer.valueOf(sTemp).intValue());
-		}
-
-		if (projectNode.get(PreferenceConstants.SDK_MODE,"").equalsIgnoreCase(IPreferenceStore.TRUE)) {
-			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
-		} else {
-			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
-		}
-
-		if(projectNode.get(PreferenceConstants.TARGET_MODE,"").equalsIgnoreCase(IPreferenceStore.TRUE)) {
-			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
-		} else {
-			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
-		}
-		return elem;
-	}
-
 	private void clearMessages() {
 		setErrorMessage(null);
 		setMessage(null);
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
index 0f84912..50904c1 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
@@ -35,6 +35,39 @@ import org.yocto.sdk.ide.preferences.PreferenceConstants;
 public class ProjectPreferenceUtils {
 	private static final String CONSOLE_MESSAGE  = "Menu.SDK.Console.Configure.Message";
 
+	/* Get POKY Preference settings from project's preference store */
+	public static YoctoUIElement getElemFromProjectPreferences(IProject project) {
+		IScopeContext projectScope = new ProjectScope(project);
+		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
+		if (projectNode == null) {
+			return getElemFromProjectEnv(project);
+		}
+
+		YoctoUIElement elem = new YoctoUIElement();
+		elem.setStrToolChainRoot(projectNode.get(PreferenceConstants.TOOLCHAIN_ROOT,""));
+		elem.setStrTarget(projectNode.get(PreferenceConstants.TOOLCHAIN_TRIPLET,""));
+		elem.setStrQemuKernelLoc(projectNode.get(PreferenceConstants.QEMU_KERNEL,""));
+		elem.setStrSysrootLoc(projectNode.get(PreferenceConstants.SYSROOT,""));
+		elem.setStrQemuOption(projectNode.get(PreferenceConstants.QEMU_OPTION,""));
+		String sTemp = projectNode.get(PreferenceConstants.TARGET_ARCH_INDEX,"");
+		if (!sTemp.isEmpty()) {
+			elem.setIntTargetIndex(Integer.valueOf(sTemp).intValue());
+		}
+
+		if (projectNode.get(PreferenceConstants.SDK_MODE,"").equalsIgnoreCase(IPreferenceStore.TRUE)) {
+			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
+		} else {
+			elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
+		}
+
+		if(projectNode.get(PreferenceConstants.TARGET_MODE,"").equalsIgnoreCase(IPreferenceStore.TRUE)) {
+			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
+		} else {
+			elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
+		}
+		return elem;
+	}
+
 	/* Get POKY Preference settings from project's environment */
 	public static YoctoUIElement getElemFromProjectEnv(IProject project) {
 		YoctoUIElement elem = new YoctoUIElement();
@@ -79,6 +112,55 @@ public class ProjectPreferenceUtils {
 		return new YoctoProfileElement(profiles, selectedProfile);
 	}
 
+	public static boolean getUseProjectSpecificOptionFromProjectPreferences(IProject project) {
+		IScopeContext projectScope = new ProjectScope(project);
+		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
+		if (projectNode == null) {
+			return false;
+		}
+
+		String useProjectSpecificSettingString = projectNode.get(PreferenceConstants.PROJECT_SPECIFIC_PROFILE,
+																	IPreferenceStore.FALSE);
+
+		if (useProjectSpecificSettingString.equals(IPreferenceStore.FALSE)) {
+			return false;
+		}
+
+		return true;
+	}
+
+	/* Save POKY Preference settings to project's preference store */
+	public static void saveElemToProjectPreferences(YoctoUIElement elem, IProject project) {
+		IScopeContext projectScope = new ProjectScope(project);
+		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
+		if (projectNode == null) {
+			return;
+		}
+
+		projectNode.putInt(PreferenceConstants.TARGET_ARCH_INDEX, elem.getIntTargetIndex());
+		if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) {
+			projectNode.put(PreferenceConstants.SDK_MODE, IPreferenceStore.TRUE);
+		} else {
+			projectNode.put(PreferenceConstants.SDK_MODE, IPreferenceStore.FALSE);
+		}
+		projectNode.put(PreferenceConstants.QEMU_KERNEL, elem.getStrQemuKernelLoc());
+		projectNode.put(PreferenceConstants.QEMU_OPTION, elem.getStrQemuOption());
+		projectNode.put(PreferenceConstants.SYSROOT, elem.getStrSysrootLoc());
+		if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) {
+			projectNode.put(PreferenceConstants.TARGET_MODE, IPreferenceStore.TRUE);
+		} else {
+			projectNode.put(PreferenceConstants.TARGET_MODE, IPreferenceStore.FALSE);
+		}
+		projectNode.put(PreferenceConstants.TOOLCHAIN_ROOT, elem.getStrToolChainRoot());
+		projectNode.put(PreferenceConstants.TOOLCHAIN_TRIPLET, elem.getStrTarget());
+
+		try {
+			projectNode.flush();
+		} catch (BackingStoreException e) {
+			e.printStackTrace();
+		}
+	}
+
 	/* Save POKY Preference settings to project's environment */
 	public static void saveElemToProjectEnv(YoctoUIElement elem, IProject project) {
 		ConsoleOutputStream consoleOutStream = null;
@@ -135,4 +217,24 @@ public class ProjectPreferenceUtils {
 			e.printStackTrace();
 		}
 	}
+
+	public static void saveUseProjectSpecificOptionToProjectPreferences(IProject project, boolean useProjectSpecificSetting) {
+		IScopeContext projectScope = new ProjectScope(project);
+		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
+		if (projectNode == null) {
+			return;
+		}
+
+		if (useProjectSpecificSetting) {
+			projectNode.put(PreferenceConstants.PROJECT_SPECIFIC_PROFILE, IPreferenceStore.TRUE);
+		} else {
+			projectNode.put(PreferenceConstants.PROJECT_SPECIFIC_PROFILE, IPreferenceStore.FALSE);
+		}
+
+		try {
+			projectNode.flush();
+		} catch (BackingStoreException e) {
+			e.printStackTrace();
+		}
+	}
 }
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 4/8] plugins/sdk.ide: Remove project context from method names
  2013-06-21 12:44     ` [PATCHv2 3/8] plugins/sdk.ide: Move " Timo Mueller
@ 2013-06-21 12:44       ` Timo Mueller
  2013-06-21 12:44         ` [PATCHv2 5/8] plugins/sdk.ide: Add command to switch the target profile Timo Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

Through the context of the ProjectPreferenceUtil class we can infer
that all methods act on project preferences. Having this context
information duplicated in the method name is not needed anymore and
can be removed to get a cleaner API.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 .../sdk/ide/preferences/YoctoSDKPreferencePage.java      |  6 +++---
 .../sdk/ide/preferences/YoctoSDKProjectPropertyPage.java | 16 ++++++++--------
 .../org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java  | 12 ++++++------
 .../sdk/ide/wizard/NewYoctoProjectTemplateProcess.java   |  2 +-
 4 files changed, 18 insertions(+), 18 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 e8123e2..4e6ca2a 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
@@ -241,7 +241,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 
 		for (IProject project : yoctoProjects)
 		{
-			ProjectPreferenceUtils.saveProfilesToProjectPreferences(profileElement, project);
+			ProjectPreferenceUtils.saveProfiles(profileElement, project);
 			YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(
 											YoctoSDKPlugin.getProfilePreferenceStore(PreferenceConstants.STANDARD_PROFILE_NAME));
 			ProjectPreferenceUtils.saveElemToProjectEnv(elem, project);
@@ -255,7 +255,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 
 		for (IProject project : yoctoProjects)
 		{
-			ProjectPreferenceUtils.saveProfilesToProjectPreferences(profileElement, project);
+			ProjectPreferenceUtils.saveProfiles(profileElement, project);
 		}
 	}
 
@@ -296,7 +296,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
 
 	private boolean projectUsesProfile(IProject project, String profile)
 	{
-		YoctoProfileElement profileElement = ProjectPreferenceUtils.getProfilesFromProjectPreferences(project);
+		YoctoProfileElement profileElement = ProjectPreferenceUtils.getProfiles(project);
 
 		if (!profileElement.getSelectedProfile().equals(profile)) {
 			return false;
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
index 1f82fe1..f6026ee 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
@@ -64,7 +64,7 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 		IProject project = getProject();
 
 		YoctoProfileElement globalProfileElement= YoctoSDKUtils.getProfilesFromDefaultStore();
-		YoctoProfileElement profileElement = ProjectPreferenceUtils.getProfilesFromProjectPreferences(project);
+		YoctoProfileElement profileElement = ProjectPreferenceUtils.getProfiles(project);
 
 		String selectedProfile = profileElement.getSelectedProfile();
 		if (!globalProfileElement.contains(selectedProfile)) {
@@ -73,10 +73,10 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 
 		yoctoProfileSetting = new YoctoProfileSetting(
 				new YoctoProfileElement(globalProfileElement.getProfilesAsString(), selectedProfile), this, false);
-		boolean useProjectSpecificSetting = ProjectPreferenceUtils.getUseProjectSpecificOptionFromProjectPreferences(project);
+		boolean useProjectSpecificSetting = ProjectPreferenceUtils.getUseProjectSpecificOption(project);
 
 		if (useProjectSpecificSetting) {
-			yoctoUISetting = new YoctoUISetting(ProjectPreferenceUtils.getElemFromProjectPreferences(project));
+			yoctoUISetting = new YoctoUISetting(ProjectPreferenceUtils.getElem(project));
 		} else {
 			yoctoUISetting = new YoctoUISetting(YoctoSDKUtils.getElemFromStore(YoctoSDKPlugin.getProfilePreferenceStore(selectedProfile)));
 		}
@@ -154,12 +154,12 @@ public class YoctoSDKProjectPropertyPage extends PropertyPage implements
 				return false;
 			}
 
-			ProjectPreferenceUtils.saveUseProjectSpecificOptionToProjectPreferences(project, true);
-			ProjectPreferenceUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
-			ProjectPreferenceUtils.saveElemToProjectPreferences(yoctoUISetting.getCurrentInput(), project);
+			ProjectPreferenceUtils.saveUseProjectSpecificOption(project, true);
+			ProjectPreferenceUtils.saveProfiles(yoctoProfileSetting.getCurrentInput(), project);
+			ProjectPreferenceUtils.saveElem(yoctoUISetting.getCurrentInput(), project);
 		} else {
-			ProjectPreferenceUtils.saveUseProjectSpecificOptionToProjectPreferences(project, false);
-			ProjectPreferenceUtils.saveProfilesToProjectPreferences(yoctoProfileSetting.getCurrentInput(), project);
+			ProjectPreferenceUtils.saveUseProjectSpecificOption(project, false);
+			ProjectPreferenceUtils.saveProfiles(yoctoProfileSetting.getCurrentInput(), project);
 		}
 
 		ProjectPreferenceUtils.saveElemToProjectEnv(yoctoUISetting.getCurrentInput(), getProject());
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
index 50904c1..a06a03c 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java
@@ -36,7 +36,7 @@ public class ProjectPreferenceUtils {
 	private static final String CONSOLE_MESSAGE  = "Menu.SDK.Console.Configure.Message";
 
 	/* Get POKY Preference settings from project's preference store */
-	public static YoctoUIElement getElemFromProjectPreferences(IProject project) {
+	public static YoctoUIElement getElem(IProject project) {
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 		if (projectNode == null) {
@@ -98,7 +98,7 @@ public class ProjectPreferenceUtils {
 	}
 
 	/* Get profiles and selected profile from the project's preference store */
-	public static YoctoProfileElement getProfilesFromProjectPreferences(IProject project) {
+	public static YoctoProfileElement getProfiles(IProject project) {
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 
@@ -112,7 +112,7 @@ public class ProjectPreferenceUtils {
 		return new YoctoProfileElement(profiles, selectedProfile);
 	}
 
-	public static boolean getUseProjectSpecificOptionFromProjectPreferences(IProject project) {
+	public static boolean getUseProjectSpecificOption(IProject project) {
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 		if (projectNode == null) {
@@ -130,7 +130,7 @@ public class ProjectPreferenceUtils {
 	}
 
 	/* Save POKY Preference settings to project's preference store */
-	public static void saveElemToProjectPreferences(YoctoUIElement elem, IProject project) {
+	public static void saveElem(YoctoUIElement elem, IProject project) {
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 		if (projectNode == null) {
@@ -199,7 +199,7 @@ public class ProjectPreferenceUtils {
 	}
 
 	/* Save profiles and selected profile to the project's preference store */
-	public static void saveProfilesToProjectPreferences(YoctoProfileElement profileElement, IProject project) {
+	public static void saveProfiles(YoctoProfileElement profileElement, IProject project) {
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectPreferences = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 
@@ -218,7 +218,7 @@ public class ProjectPreferenceUtils {
 		}
 	}
 
-	public static void saveUseProjectSpecificOptionToProjectPreferences(IProject project, boolean useProjectSpecificSetting) {
+	public static void saveUseProjectSpecificOption(IProject project, boolean useProjectSpecificSetting) {
 		IScopeContext projectScope = new ProjectScope(project);
 		IEclipsePreferences projectNode = projectScope.getNode(YoctoSDKUtilsConstants.PROJECT_SCOPE);
 		if (projectNode == null) {
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java
index f64043d..d8c1232 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java
@@ -206,7 +206,7 @@ public class NewYoctoProjectTemplateProcess extends ProcessRunner {
 		YoctoSDKChecker.checkIfGloballySelectedYoctoProfileIsValid();
 
 		YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromDefaultStore();
-		ProjectPreferenceUtils.saveProfilesToProjectPreferences(profileElement, project);
+		ProjectPreferenceUtils.saveProfiles(profileElement, project);
 
 		IPreferenceStore selecteProfileStore = YoctoSDKPlugin.getProfilePreferenceStore(profileElement.getSelectedProfile());
 		YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(selecteProfileStore);
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 5/8] plugins/sdk.ide: Add command to switch the target profile
  2013-06-21 12:44       ` [PATCHv2 4/8] plugins/sdk.ide: Remove project context from method names Timo Mueller
@ 2013-06-21 12:44         ` Timo Mueller
  2013-06-21 12:44           ` [PATCHv2 6/8] plugins/sdk.ide: Add profile switch menu to the toolbar Timo Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

The command can be used in a radio group to switch the target profile
of a selected project.

Radio items should call this command handing over the name of the
target profile as the command's parameter.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 .../OSGI-INF/l10n/bundle.properties                |   3 +
 plugins/org.yocto.sdk.ide/plugin.xml               |  18 ++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |   3 +
 .../sdk/ide/actions/ProfileSwitchHandler.java      | 110 +++++++++++++++++++++
 4 files changed, 134 insertions(+)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java

diff --git a/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties b/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
index 48eb653..1191af6 100644
--- a/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
@@ -6,6 +6,9 @@ extension.name.2 = YoctoSDKCMakeNature
 command.name = ReconfigureYoctoProject
 command.label.0 = Change Yocto Project Settings
 command.mnemonic = C
+command.targetProfileSwitch.name = Change Target Profile
+command.targetProfileSwitch.description = Changes the target profile of a selected project
+command.targetProfileSwitch.parameter.name = Selected Target Profile
 projectType.name.0 = Yocto Project ADT Autotools Project
 projectProperties.label.0 = Yocto Project Settings
 Bundle-Vendor = yoctoproject.org
diff --git a/plugins/org.yocto.sdk.ide/plugin.xml b/plugins/org.yocto.sdk.ide/plugin.xml
index 7ea55c7..62f1297 100644
--- a/plugins/org.yocto.sdk.ide/plugin.xml
+++ b/plugins/org.yocto.sdk.ide/plugin.xml
@@ -225,5 +225,23 @@
          </filter>
       </page>
    </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            defaultHandler="org.yocto.sdk.ide.actions.ProfileSwitchHandler"
+            description="%command.targetProfileSwitch.description"
+            id="org.yocto.sdk.ide.targetProfile.switch"
+            name="%command.targetProfileSwitch.name">
+         <commandParameter
+               id="org.eclipse.ui.commands.radioStateParameter"
+               name="%command.targetProfileSwitch.parameter.name"
+               optional="false">
+         </commandParameter>
+         <state
+               class="org.eclipse.ui.handlers.RadioState:project-specific"
+               id="org.eclipse.ui.commands.radioState">
+         </state>
+      </command>
+   </extension>
 
 </plugin>
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index 4ff1574..d6b5cdb 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
@@ -89,6 +89,9 @@ Preferences.Profile.Standard.Modification.Message = Standard cross development p
 Preferences.Profile.ProjectSpecific.Title = Use project specific settings
 Preferences.Profile.ProjectSpecific.Group.Title = Project specific settings:
 
+Preferences.Profile.ProjectSpecific.Error.Title = Could not change to project specific target profile
+Preferences.Profile.ProjectSpecific.Error.Message = The project specific target profile is not defined for the project "{0}".\nYou can define it in the project's property page.  
+
 Console.SDK.Name = Yocto Project Console
 
 LaunchConfig.Type.Name = org.eclipse.ui.externaltools.ProgramLaunchConfigurationType
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
new file mode 100644
index 0000000..38e3e6d
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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 implementation
+ *******************************************************************************/
+package org.yocto.sdk.ide.actions;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.handlers.RadioState;
+import org.yocto.sdk.ide.YoctoProfileElement;
+import org.yocto.sdk.ide.YoctoSDKChecker;
+import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.YoctoSDKMessages;
+import org.yocto.sdk.ide.YoctoSDKPlugin;
+import org.yocto.sdk.ide.YoctoUIElement;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
+import org.yocto.sdk.ide.utils.YoctoSDKUtils;
+
+public class ProfileSwitchHandler extends AbstractHandler {
+	private static final String PROJECT_SPECIFIC_ERROR = "Preferences.Profile.ProjectSpecific.Error.Title";
+	private static final String PROJECT_SPECIFIC_ERROR_MESSAGE = "Preferences.Profile.ProjectSpecific.Error.Message";
+
+	public static final String PROFILE_SWITCH_COMMAND = "org.yocto.sdk.ide.targetProfile.switch"; //$NON-NLS-N$
+	public static final String PROJECT_SPECIFIC_PARAMETER = "project-specific"; //$NON-NLS-N$
+
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		if(HandlerUtil.matchesRadioState(event)) {
+			return null;
+		}
+
+		String currentState = event.getParameter(RadioState.PARAMETER_ID);
+		HandlerUtil.updateRadioState(event.getCommand(), currentState);
+
+		switchProfile(getSelectedProject(event), currentState);
+
+		return null;
+	}
+
+	public IProject getSelectedProject(ExecutionEvent event) {
+		ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+		if (selection instanceof ITreeSelection) {
+			Object selectedItem = ((ITreeSelection) selection).getFirstElement();
+			if (selectedItem instanceof IResource) {
+				return ((IResource) selectedItem).getProject();
+			} else if (selectedItem instanceof ICElement) {
+				ICProject cProject = ((ICElement) selectedItem).getCProject();
+				if (cProject != null) {
+					return cProject.getProject();
+				}
+			} else if (selectedItem instanceof IAdaptable) {
+				Object projectObject = ((IAdaptable) selectedItem).getAdapter(IProject.class);
+				if (projectObject != null && projectObject instanceof IProject) {
+					return ((IProject) projectObject);
+				}
+			}
+		}
+
+		return null;
+	}
+
+	private void switchProfile(IProject project, String selectedProfile) {
+		if (PROJECT_SPECIFIC_PARAMETER.equals(selectedProfile)) {
+			YoctoUIElement yoctoUIElement = ProjectPreferenceUtils.getElem(project);
+			SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(yoctoUIElement);
+
+			if ((result != SDKCheckResults.SDK_PASS)) {
+				Display display = Display.getCurrent();
+				ErrorDialog.openError(display.getActiveShell(),
+										YoctoSDKMessages.getString(PROJECT_SPECIFIC_ERROR),
+										YoctoSDKMessages.getFormattedString(PROJECT_SPECIFIC_ERROR_MESSAGE,
+															project.getName()),
+										new Status(Status.ERROR, YoctoSDKPlugin.PLUGIN_ID, result.getMessage()));
+				return;
+			}
+
+			ProjectPreferenceUtils.saveElemToProjectEnv(yoctoUIElement, project);
+			ProjectPreferenceUtils.saveUseProjectSpecificOption(project, true);
+		} else {
+			IPreferenceStore store = YoctoSDKPlugin.getProfilePreferenceStore(selectedProfile);
+			YoctoUIElement yoctoUIElement = YoctoSDKUtils.getElemFromStore(store);
+			ProjectPreferenceUtils.saveElemToProjectEnv(yoctoUIElement, project);
+			ProjectPreferenceUtils.saveUseProjectSpecificOption(project, false);
+
+			YoctoProfileElement profileSettings = ProjectPreferenceUtils.getProfiles(project);
+			profileSettings.setSelectedProfile(selectedProfile);
+			ProjectPreferenceUtils.saveProfiles(profileSettings, project);
+		}
+	}
+}
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 6/8] plugins/sdk.ide: Add profile switch menu to the toolbar
  2013-06-21 12:44         ` [PATCHv2 5/8] plugins/sdk.ide: Add command to switch the target profile Timo Mueller
@ 2013-06-21 12:44           ` Timo Mueller
  2013-06-21 12:44             ` [PATCHv2 7/8] plugins/sdk.ide: Add profile switch menu to the project menu Timo Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

If a project with a yocto nature is selected, the toolbar will show a
target profile menu which allows the user to switch the used target
profile of the project.

The content of this menu is dynamically created using the list of
globally defined target profiles. Additionally it will also contain
the project specific profile.

If the project specific profile is not yet defined for the selected
project, the button will be greyed out.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 .../OSGI-INF/l10n/bundle.properties                |   1 +
 plugins/org.yocto.sdk.ide/plugin.xml               |  57 +++++++++-
 .../sdk/ide/ProjectSpecificContributionItem.java   |  89 +++++++++++++++
 .../sdk/ide/TargetProfileContributionItem.java     | 125 +++++++++++++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |   1 +
 .../sdk/ide/actions/ProfileSwitchHandler.java      |  26 ++++-
 6 files changed, 297 insertions(+), 2 deletions(-)
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/TargetProfileContributionItem.java

diff --git a/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties b/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
index 1191af6..2031154 100644
--- a/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
@@ -7,6 +7,7 @@ command.name = ReconfigureYoctoProject
 command.label.0 = Change Yocto Project Settings
 command.mnemonic = C
 command.targetProfileSwitch.name = Change Target Profile
+command.targetProfileSwitch.label = Target Profiles
 command.targetProfileSwitch.description = Changes the target profile of a selected project
 command.targetProfileSwitch.parameter.name = Selected Target Profile
 projectType.name.0 = Yocto Project ADT Autotools Project
diff --git a/plugins/org.yocto.sdk.ide/plugin.xml b/plugins/org.yocto.sdk.ide/plugin.xml
index 62f1297..aaa0a35 100644
--- a/plugins/org.yocto.sdk.ide/plugin.xml
+++ b/plugins/org.yocto.sdk.ide/plugin.xml
@@ -81,6 +81,10 @@
             id="org.yocto.sdk.ide.command.reconfigYocto"
             name="%command.name">
       </command>
+      <command
+            id="org.yocto.sdk.ide.command.disabled"
+            name="DisabledCommand">
+      </command>
    </extension>
    <extension
          point="org.eclipse.ui.handlers">
@@ -243,5 +247,56 @@
          </state>
       </command>
    </extension>
-
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            allPopups="true"
+            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
+         <toolbar
+               id="org.yocto.sdk.ide.profiles.toolbar">
+            <command
+                  commandId="org.yocto.sdk.ide.command.reconfigYocto"
+                  id="org.yocto.sdk.ide.profiles.toolbar.dropdown"
+                  label="%command.targetProfileSwitch.label"
+                  mode="FORCE_TEXT"
+                  style="pulldown"
+                  tooltip="%command.targetProfileSwitch.description">
+               <visibleWhen
+                     checkEnabled="false">
+                  <and>
+	                  <count
+	                        value="1">
+	                  </count>
+	                  <iterate
+	                        operator="and">
+	                     <adapt
+	                           type="org.eclipse.core.resources.IResource">
+	                        <test
+	                              property="org.eclipse.core.resources.projectNature"
+	                              value="org.yocto.sdk.ide.YoctoSDKNature">
+	                        </test>
+	                     </adapt>
+	                  </iterate>
+	               </and>
+               </visibleWhen>
+            </command>
+         </toolbar>
+      </menuContribution>
+      <menuContribution
+            allPopups="false"
+            locationURI="menu:org.yocto.sdk.ide.profiles.toolbar.dropdown">
+         <dynamic
+               class="org.yocto.sdk.ide.ProjectSpecificContributionItem"
+               id="org.yocto.sdk.ide.dynamic.projectSpecific.targetProfile">
+         </dynamic>
+         <separator
+               name="org.yocto.sdk.ide.profiles.separator"
+               visible="true">
+         </separator>
+         <dynamic
+               class="org.yocto.sdk.ide.TargetProfileContributionItem"
+               id="org.yocto.sdk.ide.dynamic.targetProfile">
+         </dynamic>
+      </menuContribution>
+   </extension>
 </plugin>
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
new file mode 100644
index 0000000..41374a6
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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 implementation
+ *******************************************************************************/
+
+package org.yocto.sdk.ide;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.services.IServiceLocator;
+import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
+import org.yocto.sdk.ide.actions.ProfileSwitchHandler;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
+
+public class ProjectSpecificContributionItem extends TargetProfileContributionItem {
+	private static final String PROJECT_SPECIFIC_PROFILE =
+			"Preferences.Profile.ProjectSpecific.Profile.Label"; //$NON-NLS-N$
+	private static final String DISABLED_COMMAND_ID = "org.yocto.sdk.ide.command.disabled"; //$NON-NLS-N$
+
+	private IServiceLocator serviceLocator;
+
+	public ProjectSpecificContributionItem() {}
+
+	public ProjectSpecificContributionItem(String id) {
+		super(id);
+	}
+
+	@Override
+	protected IContributionItem[] getContributionItems() {
+		ArrayList<IContributionItem> items = new ArrayList<IContributionItem>();
+
+		IProject project = getSelectedProject(serviceLocator);
+		YoctoUIElement yoctoUIElement = ProjectPreferenceUtils.getElem(project);
+		SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(yoctoUIElement);
+
+		if ((result != SDKCheckResults.SDK_PASS)) {
+			CommandContributionItemParameter parameter = new CommandContributionItemParameter(serviceLocator,
+															null,
+															DISABLED_COMMAND_ID,
+															CommandContributionItem.STYLE_PUSH);
+
+			parameter.label = YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE);
+
+			items.add(new CommandContributionItem(parameter));
+		} else {
+			items.add(super.createProfileItem(serviceLocator, ProfileSwitchHandler.PROJECT_SPECIFIC_PARAMETER,
+												YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE)));
+		}
+
+		updateSelection();
+
+		return items.toArray(new IContributionItem[items.size()]);
+	}
+
+	@Override
+	public void initialize(IServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+	private void updateSelection() {
+		ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
+		Command command = commandService.getCommand(ProfileSwitchHandler.PROFILE_SWITCH_COMMAND);
+		IProject project = getSelectedProject(serviceLocator);
+
+		if (!ProjectPreferenceUtils.getUseProjectSpecificOption(project)) {
+			return;
+		}
+
+		try {
+			HandlerUtil.updateRadioState(command, ProfileSwitchHandler.PROJECT_SPECIFIC_PARAMETER);
+		} catch (ExecutionException e) {
+			// ignore
+		}
+	}
+}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/TargetProfileContributionItem.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/TargetProfileContributionItem.java
new file mode 100644
index 0000000..6e78e58
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/TargetProfileContributionItem.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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 implementation
+ *******************************************************************************/
+package org.yocto.sdk.ide;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.TreeSet;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.handlers.RadioState;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.menus.IWorkbenchContribution;
+import org.eclipse.ui.services.IServiceLocator;
+import org.yocto.sdk.ide.actions.ProfileSwitchHandler;
+import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
+import org.yocto.sdk.ide.utils.YoctoSDKUtils;
+
+public class TargetProfileContributionItem extends CompoundContributionItem implements IWorkbenchContribution {
+	private IServiceLocator serviceLocator;
+
+	public TargetProfileContributionItem() {}
+
+	public TargetProfileContributionItem(String id) {
+		super(id);
+	}
+
+	protected CommandContributionItem createProfileItem(IServiceLocator serviceLocator,
+														String parameter, String label) {
+		CommandContributionItemParameter itemParameter;
+		itemParameter = new CommandContributionItemParameter(serviceLocator,
+														null,
+														ProfileSwitchHandler.PROFILE_SWITCH_COMMAND,
+														CommandContributionItem.STYLE_RADIO);
+
+		HashMap<String, String> params = new HashMap<String, String>();
+		params.put(RadioState.PARAMETER_ID, parameter);
+
+		itemParameter.label = label;
+		itemParameter.parameters = params;
+
+		return new CommandContributionItem(itemParameter);
+	}
+
+	@Override
+	protected IContributionItem[] getContributionItems() {
+		TreeSet<String> profiles = YoctoSDKUtils.getProfilesFromDefaultStore().getProfiles();
+		ArrayList<IContributionItem> items = new ArrayList<IContributionItem>();
+
+		for (String profile : profiles) {
+			items.add(createProfileItem(serviceLocator, profile, profile));
+		}
+
+		updateSelection();
+
+		return items.toArray(new IContributionItem[profiles.size()]);
+	}
+
+	public IProject getSelectedProject(IServiceLocator serviceLocator) {
+		ISelectionService selectionService = (ISelectionService) serviceLocator.getService(ISelectionService.class);
+		ISelection selection = selectionService.getSelection();
+
+		if (selection instanceof ITreeSelection) {
+			Object selectedItem = ((ITreeSelection) selection).getFirstElement();
+			if (selectedItem instanceof IResource) {
+				return ((IResource) selectedItem).getProject();
+			} else if (selectedItem instanceof ICElement) {
+				ICProject cProject = ((ICElement) selectedItem).getCProject();
+				if (cProject != null) {
+					return cProject.getProject();
+				}
+			} else if (selectedItem instanceof IAdaptable) {
+				Object projectObject = ((IAdaptable) selectedItem).getAdapter(IProject.class);
+				if (projectObject != null && projectObject instanceof IProject) {
+					return ((IProject) projectObject);
+				}
+			}
+		}
+
+		return null;
+	}
+
+	@Override
+	public void initialize(IServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+	private void updateSelection() {
+		ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
+		Command command = commandService.getCommand(ProfileSwitchHandler.PROFILE_SWITCH_COMMAND);
+		IProject project = getSelectedProject(serviceLocator);
+
+		if (ProjectPreferenceUtils.getUseProjectSpecificOption(project)) {
+			return;
+		}
+
+		try {
+			String selectedProfile = ProjectPreferenceUtils.getProfiles(project).getSelectedProfile();
+			HandlerUtil.updateRadioState(command, selectedProfile);
+		} catch (ExecutionException e) {
+			// ignore
+		}
+	}
+}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index d6b5cdb..e71b7dd 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
@@ -88,6 +88,7 @@ Preferences.Profile.Standard.Modification.Message = Standard cross development p
 
 Preferences.Profile.ProjectSpecific.Title = Use project specific settings
 Preferences.Profile.ProjectSpecific.Group.Title = Project specific settings:
+Preferences.Profile.ProjectSpecific.Profile.Label = Project specific profile
 
 Preferences.Profile.ProjectSpecific.Error.Title = Could not change to project specific target profile
 Preferences.Profile.ProjectSpecific.Error.Message = The project specific target profile is not defined for the project "{0}".\nYou can define it in the project's property page.  
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
index 38e3e6d..bd16a0a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
@@ -10,11 +10,15 @@
  *******************************************************************************/
 package org.yocto.sdk.ide.actions;
 
+import java.util.Map;
+
 import org.eclipse.cdt.core.model.ICElement;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.State;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IAdaptable;
@@ -24,8 +28,11 @@ import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ITreeSelection;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.commands.IElementUpdater;
 import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.handlers.RadioState;
+import org.eclipse.ui.menus.UIElement;
 import org.yocto.sdk.ide.YoctoProfileElement;
 import org.yocto.sdk.ide.YoctoSDKChecker;
 import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults;
@@ -35,7 +42,7 @@ import org.yocto.sdk.ide.YoctoUIElement;
 import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
 import org.yocto.sdk.ide.utils.YoctoSDKUtils;
 
-public class ProfileSwitchHandler extends AbstractHandler {
+public class ProfileSwitchHandler extends AbstractHandler implements IElementUpdater {
 	private static final String PROJECT_SPECIFIC_ERROR = "Preferences.Profile.ProjectSpecific.Error.Title";
 	private static final String PROJECT_SPECIFIC_ERROR_MESSAGE = "Preferences.Profile.ProjectSpecific.Error.Message";
 
@@ -107,4 +114,21 @@ public class ProfileSwitchHandler extends AbstractHandler {
 			ProjectPreferenceUtils.saveProfiles(profileSettings, project);
 		}
 	}
+
+	/*
+	 * Workaround for BUG 398647 to allow checking radio items
+	 * in a dynamic contribution
+	 *
+	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=398647
+	 */
+	@Override
+	public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
+			ICommandService service = (ICommandService) element.getServiceLocator().getService(ICommandService.class);
+			String state = (String) parameters.get(RadioState.PARAMETER_ID);
+			Command command = service.getCommand(PROFILE_SWITCH_COMMAND);
+			State commandState = command.getState(RadioState.STATE_ID);
+			if (commandState.getValue().equals(state)) {
+				element.setChecked(true);
+			}
+	}
 }
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 7/8] plugins/sdk.ide: Add profile switch menu to the project menu
  2013-06-21 12:44           ` [PATCHv2 6/8] plugins/sdk.ide: Add profile switch menu to the toolbar Timo Mueller
@ 2013-06-21 12:44             ` Timo Mueller
  2013-06-21 12:44               ` [PATCHv2 8/8] plugins/sdk.ide: Add project configuration button Timo Mueller
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

If a project with a yocto nature is selected, the project menu will
show a target profile menu which allows the user to switch the used
target profile of the project.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 plugins/org.yocto.sdk.ide/plugin.xml | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/plugins/org.yocto.sdk.ide/plugin.xml b/plugins/org.yocto.sdk.ide/plugin.xml
index aaa0a35..c082c3a 100644
--- a/plugins/org.yocto.sdk.ide/plugin.xml
+++ b/plugins/org.yocto.sdk.ide/plugin.xml
@@ -251,6 +251,15 @@
          point="org.eclipse.ui.menus">
       <menuContribution
             allPopups="true"
+            locationURI="menu:project">
+         <menu
+               id="org.yocto.sdk.ide.profiles.menu"
+               label="%command.targetProfileSwitch.label"
+               tooltip="%command.targetProfileSwitch.description">
+         </menu>
+      </menuContribution>
+      <menuContribution
+            allPopups="true"
             locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
          <toolbar
                id="org.yocto.sdk.ide.profiles.toolbar">
@@ -284,6 +293,22 @@
       </menuContribution>
       <menuContribution
             allPopups="false"
+            locationURI="menu:org.yocto.sdk.ide.profiles.menu">
+         <dynamic
+               class="org.yocto.sdk.ide.ProjectSpecificContributionItem"
+               id="org.yocto.sdk.ide.dynamic.projectSpecific.targetProfile">
+         </dynamic>
+         <separator
+               name="org.yocto.sdk.ide.profiles.separator"
+               visible="true">
+         </separator>
+         <dynamic
+               class="org.yocto.sdk.ide.TargetProfileContributionItem"
+               id="org.yocto.sdk.ide.dynamic.targetProfile">
+         </dynamic>
+      </menuContribution>
+      <menuContribution
+            allPopups="false"
             locationURI="menu:org.yocto.sdk.ide.profiles.toolbar.dropdown">
          <dynamic
                class="org.yocto.sdk.ide.ProjectSpecificContributionItem"
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCHv2 8/8] plugins/sdk.ide: Add project configuration button
  2013-06-21 12:44             ` [PATCHv2 7/8] plugins/sdk.ide: Add profile switch menu to the project menu Timo Mueller
@ 2013-06-21 12:44               ` Timo Mueller
  0 siblings, 0 replies; 14+ messages in thread
From: Timo Mueller @ 2013-06-21 12:44 UTC (permalink / raw)
  To: yocto; +Cc: Timo Mueller

From: Timo Mueller <timo.mueller@bmw-carit.de>

This changes the behaviour of the project specific profile button. If
the project specific profile is not yet defined for the selected
project, the list will contain a button to open the project
preferences instead of the greying out the button.

Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
 plugins/org.yocto.sdk.ide/plugin.xml                              | 4 ----
 .../src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java    | 8 +++++---
 .../src/org/yocto/sdk/ide/YoctoSDKMessages.properties             | 1 +
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/plugin.xml b/plugins/org.yocto.sdk.ide/plugin.xml
index c082c3a..04ed40e 100644
--- a/plugins/org.yocto.sdk.ide/plugin.xml
+++ b/plugins/org.yocto.sdk.ide/plugin.xml
@@ -81,10 +81,6 @@
             id="org.yocto.sdk.ide.command.reconfigYocto"
             name="%command.name">
       </command>
-      <command
-            id="org.yocto.sdk.ide.command.disabled"
-            name="DisabledCommand">
-      </command>
    </extension>
    <extension
          point="org.eclipse.ui.handlers">
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
index 41374a6..13e0e7a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
@@ -27,9 +27,11 @@ import org.yocto.sdk.ide.actions.ProfileSwitchHandler;
 import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
 
 public class ProjectSpecificContributionItem extends TargetProfileContributionItem {
+	private static final String CONFIGURE_PROJECT_SPECIFIC_PROFILE =
+								"Preferences.Profile.ProjectSpecific.Configure.Label"; //$NON-NLS-N$
 	private static final String PROJECT_SPECIFIC_PROFILE =
 			"Preferences.Profile.ProjectSpecific.Profile.Label"; //$NON-NLS-N$
-	private static final String DISABLED_COMMAND_ID = "org.yocto.sdk.ide.command.disabled"; //$NON-NLS-N$
+	private static final String RECONFIG_YOCTO_COMMAND_ID = "org.yocto.sdk.ide.command.reconfigYocto"; //$NON-NLS-N$
 
 	private IServiceLocator serviceLocator;
 
@@ -50,10 +52,10 @@ public class ProjectSpecificContributionItem extends TargetProfileContributionIt
 		if ((result != SDKCheckResults.SDK_PASS)) {
 			CommandContributionItemParameter parameter = new CommandContributionItemParameter(serviceLocator,
 															null,
-															DISABLED_COMMAND_ID,
+															RECONFIG_YOCTO_COMMAND_ID,
 															CommandContributionItem.STYLE_PUSH);
 
-			parameter.label = YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE);
+			parameter.label = YoctoSDKMessages.getString(CONFIGURE_PROJECT_SPECIFIC_PROFILE);
 
 			items.add(new CommandContributionItem(parameter));
 		} else {
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
index e71b7dd..f545c2b 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties
@@ -89,6 +89,7 @@ Preferences.Profile.Standard.Modification.Message = Standard cross development p
 Preferences.Profile.ProjectSpecific.Title = Use project specific settings
 Preferences.Profile.ProjectSpecific.Group.Title = Project specific settings:
 Preferences.Profile.ProjectSpecific.Profile.Label = Project specific profile
+Preferences.Profile.ProjectSpecific.Configure.Label = Configure project specific profile ...
 
 Preferences.Profile.ProjectSpecific.Error.Title = Could not change to project specific target profile
 Preferences.Profile.ProjectSpecific.Error.Message = The project specific target profile is not defined for the project "{0}".\nYou can define it in the project's property page.  
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
  2013-06-21 12:44 [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Timo Mueller
  2013-06-21 12:44 ` [PATCHv2 1/8] plugins/sdk.ide: Use an internationalized dialog title Timo Mueller
@ 2013-06-21 21:47 ` Zhang, Jessica
  2013-06-23  8:36   ` Timo Mueller
  1 sibling, 1 reply; 14+ messages in thread
From: Zhang, Jessica @ 2013-06-21 21:47 UTC (permalink / raw)
  To: Timo Mueller, yocto; +Cc: Timo Mueller

Hi Timo,

So what's the purpose of "Project Specific Settings", my understanding is it's something that only local to project instead of global name space, e.g. profile?  OK, I've played a little bit of toggling between profiles, and project specific setting and notice the following behaviors that can be confusing:

1. As your preference that user can specify "project specific settings".  I've noticed for this case, if I haven't entered any project specific settings via the preference wizard, it'll always copy the profile settings prior to its selection, then in this case I don't think it makes much sense since we already have the profiles to cover all the settings

2.  OK, now let's move to the case of that I do have explicit setup a project specific settings in the project property view apply it and exit the window.  After that, in the drop down list, when I toggle between the options, e.g. I have two profiles besides the project specific settings, then every time after I made the selection and check in the project properties view, the settings matches my selection.  So this is good and consistent behavior.

3. If  inside the project properties window, I uncheck the "Use project specific settings" box, and select a profile then apply the changes close the window.  Now in the drop down list I will see both the "project specific setting" and the selected profile are selected. Then next time when I go back, and re-check "Use project specific settings" box, my project specific setting will be gone, instead the settings will show as my previous profile settings.

Overall, I think we still need to play a little bit more of different setting selections via different approaches, some of the inconsistent behavior can get user lost.

Thanks,
Jessica
-----Original Message-----
From: yocto-bounces@yoctoproject.org [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Timo Mueller
Sent: Friday, June 21, 2013 5:45 AM
To: yocto@yoctoproject.org
Cc: Timo Mueller
Subject: [yocto] [PATCHv2 0/8][eclipse-poky] Add target profile quick switch

From: Timo Mueller <timo.mueller@bmw-carit.de>

Changes in v2:
Handle error when project specific profile is not configured more gracefully. Instead of showing an error message the button is now greyed out.

Patches 01..07 contain the implementation with the greyed out menu button.

After playing around with the two options discussed in the first patch series, I started to prefer inserting a different button in the menu allowing the user to quickly navigate to the project preferences instead of just greying it out. I've added this in the last patch of the series, so you can compare yourself.

From original cover letter
<snip>
if a user wants to change the used target profile of a project he currently has to open the project preferences. This can be tedious if he has to switch the profile often.

This is a small addition which allows the user to quickly switch the used target profile of a project. Instead of having to open the project preferences the user can select the project in the navigator and then choose the desired target profile from a drop-down menu in the toolbar or from the project menu.
</snip>

01: Small i18n fix
02..04: Refactoring the project specific utils
05..06: Introduce the target profile toolbar switch
07: Adds the target profile switch to the project menu
08: Experimental: Add button to open project preferences

Best regards,
Timo

Timo Mueller (8):
  plugins/sdk.ide: Use an internationalized dialog title
  plugins/sdk.ide: Extract project specific util methods
  plugins/sdk.ide: Move project specific util methods
  plugins/sdk.ide: Remove project context from method names
  plugins/sdk.ide: Add command to switch the target profile
  plugins/sdk.ide: Add profile switch menu to the toolbar
  plugins/sdk.ide: Add profile switch menu to the project menu
  plugins/sdk.ide: Add project configuration button

 .../OSGI-INF/l10n/bundle.properties                |   4 +
 plugins/org.yocto.sdk.ide/plugin.xml               |  96 ++++++++-
 .../sdk/ide/ProjectSpecificContributionItem.java   |  91 ++++++++
 .../sdk/ide/TargetProfileContributionItem.java     | 125 +++++++++++
 .../org/yocto/sdk/ide/YoctoSDKMessages.properties  |   5 +
 .../src/org/yocto/sdk/ide/YoctoUISetting.java      |   3 +-
 .../sdk/ide/actions/ProfileSwitchHandler.java      | 134 ++++++++++++
 .../natures/YoctoSDKAutotoolsProjectNature.java    |   3 +-
 .../ide/preferences/YoctoSDKPreferencePage.java    |  11 +-
 .../preferences/YoctoSDKProjectPropertyPage.java   | 130 ++---------
 .../sdk/ide/utils/ProjectPreferenceUtils.java      | 240 +++++++++++++++++++++
 .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 118 ----------
 .../ide/wizard/NewYoctoProjectTemplateProcess.java |   3 +-
 13 files changed, 717 insertions(+), 246 deletions(-)  create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/TargetProfileContributionItem.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ProfileSwitchHandler.java
 create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/ProjectPreferenceUtils.java

--
1.8.1.4

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
  2013-06-21 21:47 ` [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Zhang, Jessica
@ 2013-06-23  8:36   ` Timo Mueller
  2013-06-24  5:25     ` Zhang, Jessica
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Mueller @ 2013-06-23  8:36 UTC (permalink / raw)
  To: Zhang, Jessica; +Cc: yocto, Timo Mueller

Hi Jessica,

Am 21.06.2013 23:47, schrieb Zhang, Jessica:
> Hi Timo,
 >
 > So what's the purpose of "Project Specific Settings", my
 > understanding is it's something that only local to project instead of
 > global name space, e.g. profile?

Yes, that's the main idea.

>  OK, I've played a little bit  of
 > toggling between profiles, and project specific setting and notice
 > the following behaviors that can be confusing:
 >
 > 1. As your preference that user can specify "project specific
 > settings".  I've noticed for this case, if I haven't entered any
 > project specific settings via the preference wizard, it'll always
 > copy the profile settings prior to its selection, then in this case I
 > don't think it makes much sense since we already have the profiles to
 > cover all the settings

That's independent of this patch set, right?

The original idea behind copying the settings of the currently selected
profile was to give the user a starting point for creating the project
specific settings. The assumption was that the user most of the times
only does small modifications to an existing profile.

Sure, if the user doesn't alter the settings, the project specific ones
match an already defined target profile. One difference remains, if
he changes the target profile it will update all projects that use this
profile. The project that is using it's own configuration won't be
changed, although the settings are similar.

An alternative to copying the inital settings would be to blank out
the form, when the checkbox is checked. If the assumption is not
correct and we think that this is easier to understand for the user,
I'll provide a patch set changing this behaviour.

>
 > 2.  OK, now let's move to the case of that I do have explicit setup a
 > project specific settings in the project property view apply it and
 > exit the window.  After that, in the drop down list, when I toggle
 > between the options, e.g. I have two profiles besides the project
 > specific settings, then every time after I made the selection and
 > check in the project properties view, the settings matches my
 > selection.  So this is good and consistent behavior.
 >
 > 3. If  inside the project properties window, I uncheck the "Use
 > project specific settings" box, and select a profile then apply the
 > changes close the window.  Now in the drop down list I will see both
 > the "project specific setting" and the selected profile are selected.
 > Then next time when I go back, and re-check "Use project specific
 > settings" box, my project specific setting will be gone, instead the
 > settings will show as my previous profile settings.

That's a bug in my implementation. They should always be in sink as
you explained in your second point.

>
 > Overall, I think we still need to play a little bit more of different
 > setting selections via different approaches, some of the inconsistent
 > behavior can get user lost.
 >
 > Thanks, Jessica -----Original Message----- From:
 > yocto-bounces@yoctoproject.org
 > [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Timo Mueller
 > Sent: Friday, June 21, 2013 5:45 AM To: yocto@yoctoproject.org Cc:
 > Timo Mueller Subject: [yocto] [PATCHv2 0/8][eclipse-poky] Add target
 > profile quick switch
 >
 > From: Timo Mueller <timo.mueller@bmw-carit.de>
 >
 > Changes in v2: Handle error when project specific profile is not
 > configured more gracefully. Instead of showing an error message the
 > button is now greyed out.
 >
 > Patches 01..07 contain the implementation with the greyed out menu
 > button.
 >
 > After playing around with the two options discussed in the first
 > patch series, I started to prefer inserting a different button in the
 > menu allowing the user to quickly navigate to the project preferences
 > instead of just greying it out. I've added this in the last patch of
 > the series, so you can compare yourself.
 >
 > From original cover letter <snip> if a user wants to change the used
 > target profile of a project he currently has to open the project
 > preferences. This can be tedious if he has to switch the profile
 > often.
 >
 > This is a small addition which allows the user to quickly switch the
 > used target profile of a project. Instead of having to open the
 > project preferences the user can select the project in the navigator
 > and then choose the desired target profile from a drop-down menu in
 > the toolbar or from the project menu. </snip>
 >
 > 01: Small i18n fix 02..04: Refactoring the project specific utils
 > 05..06: Introduce the target profile toolbar switch 07: Adds the
 > target profile switch to the project menu 08: Experimental: Add
 > button to open project preferences
 >
 > Best regards, Timo

Thanks, for the input. I'll fix the bug and send a v3.

Best regards,
Timo



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
  2013-06-23  8:36   ` Timo Mueller
@ 2013-06-24  5:25     ` Zhang, Jessica
  2013-06-24  6:52       ` Timo Müller
  0 siblings, 1 reply; 14+ messages in thread
From: Zhang, Jessica @ 2013-06-24  5:25 UTC (permalink / raw)
  To: Timo Mueller; +Cc: yocto, Timo Mueller

Hi Timo,

For case 1, I think we probably should bring back the grey out option.  In my opinion, it's more consistent.  The property window should be the centralized place for user to setup the settings.  The drop down list is for user to quickly toggle between the different settings.  So the behavior should be:

If there's no project specific settings, that option will be greyed out.  I don't think it'll make it secondary as long as it's still visible.  Once user 1st time check the project specific setting in the project properties window, we copy the prior profile settings as start point then the user can further customize if there's the need.  Once a project has its own specific settings, the option will be enabled in the drop down list and the selection will be consistent between the drop down list selection and project properties settings.

What do you think?

Jessica
-----Original Message-----
From: Timo Mueller [mailto:mail@timomueller.eu]
Sent: Sunday, June 23, 2013 1:36 AM
To: Zhang, Jessica
Cc: yocto@yoctoproject.org; Timo Mueller
Subject: Re: [yocto] [PATCHv2 0/8][eclipse-poky] Add target profile quick switch

Hi Jessica,

Am 21.06.2013 23:47, schrieb Zhang, Jessica:
> Hi Timo,
 >
 > So what's the purpose of "Project Specific Settings", my  > understanding is it's something that only local to project instead of  > global name space, e.g. profile?

Yes, that's the main idea.

>  OK, I've played a little bit  of
 > toggling between profiles, and project specific setting and notice  > the following behaviors that can be confusing:
 >
 > 1. As your preference that user can specify "project specific  > settings".  I've noticed for this case, if I haven't entered any  > project specific settings via the preference wizard, it'll always  > copy the profile settings prior to its selection, then in this case I  > don't think it makes much sense since we already have the profiles to  > cover all the settings

That's independent of this patch set, right?

The original idea behind copying the settings of the currently selected profile was to give the user a starting point for creating the project specific settings. The assumption was that the user most of the times only does small modifications to an existing profile.

Sure, if the user doesn't alter the settings, the project specific ones match an already defined target profile. One difference remains, if he changes the target profile it will update all projects that use this profile. The project that is using it's own configuration won't be changed, although the settings are similar.

An alternative to copying the inital settings would be to blank out the form, when the checkbox is checked. If the assumption is not correct and we think that this is easier to understand for the user, I'll provide a patch set changing this behaviour.

>
 > 2.  OK, now let's move to the case of that I do have explicit setup a  > project specific settings in the project property view apply it and  > exit the window.  After that, in the drop down list, when I toggle  > between the options, e.g. I have two profiles besides the project  > specific settings, then every time after I made the selection and  > check in the project properties view, the settings matches my  > selection.  So this is good and consistent behavior.
 >
 > 3. If  inside the project properties window, I uncheck the "Use  > project specific settings" box, and select a profile then apply the  > changes close the window.  Now in the drop down list I will see both  > the "project specific setting" and the selected profile are selected.
 > Then next time when I go back, and re-check "Use project specific  > settings" box, my project specific setting will be gone, instead the  > settings will show as my previous profile settings.

That's a bug in my implementation. They should always be in sink as you explained in your second point.

>
 > Overall, I think we still need to play a little bit more of different  > setting selections via different approaches, some of the inconsistent  > behavior can get user lost.
 >
 > Thanks, Jessica -----Original Message----- From:
 > yocto-bounces@yoctoproject.org
 > [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Timo Mueller  > Sent: Friday, June 21, 2013 5:45 AM To: yocto@yoctoproject.org Cc:
 > Timo Mueller Subject: [yocto] [PATCHv2 0/8][eclipse-poky] Add target  > profile quick switch  >  > From: Timo Mueller <timo.mueller@bmw-carit.de>  >  > Changes in v2: Handle error when project specific profile is not  > configured more gracefully. Instead of showing an error message the  > button is now greyed out.
 >
 > Patches 01..07 contain the implementation with the greyed out menu  > button.
 >
 > After playing around with the two options discussed in the first  > patch series, I started to prefer inserting a different button in the  > menu allowing the user to quickly navigate to the project preferences  > instead of just greying it out. I've added this in the last patch of  > the series, so you can compare yourself.
 >
 > From original cover letter <snip> if a user wants to change the used  > target profile of a project he currently has to open the project  > preferences. This can be tedious if he has to switch the profile  > often.
 >
 > This is a small addition which allows the user to quickly switch the  > used target profile of a project. Instead of having to open the  > project preferences the user can select the project in the navigator  > and then choose the desired target profile from a drop-down menu in  > the toolbar or from the project menu. </snip>  >  > 01: Small i18n fix 02..04: Refactoring the project specific utils  > 05..06: Introduce the target profile toolbar switch 07: Adds the  > target profile switch to the project menu 08: Experimental: Add  > button to open project preferences  >  > Best regards, Timo

Thanks, for the input. I'll fix the bug and send a v3.

Best regards,
Timo



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
  2013-06-24  5:25     ` Zhang, Jessica
@ 2013-06-24  6:52       ` Timo Müller
  2013-06-24 16:16         ` Zhang, Jessica
  0 siblings, 1 reply; 14+ messages in thread
From: Timo Müller @ 2013-06-24  6:52 UTC (permalink / raw)
  To: Zhang, Jessica; +Cc: yocto, Timo Mueller

Hi Jessica

Zhang, Jessica wrote, On 24.06.2013 07:25:
> Hi Timo,
>
> For case 1, I think we probably should bring back the grey out
> option.  In my opinion, it's more consistent.  The property window
> should be the centralized place for user to setup the settings.  The
> drop down list is for user to quickly toggle between the different
> settings.  So the behavior should be:
>
> If there's no project specific settings, that option will be greyed
> out.  I don't think it'll make it secondary as long as it's still
> visible.  Once user 1st time check the project specific setting in
> the project properties window, we copy the prior profile settings as
> start point then the user can further customize if there's the need.
> Once a project has its own specific settings, the option will be
> enabled in the drop down list and the selection will be consistent
> between the drop down list selection and project properties
> settings.
>
> What do you think?

I get your point. I'll kick out the last patch to restore the greyed out
version.

I tried to reproduce case 3. And I haven't been able to bring the menu
to a state where two menu items are checked. I tried all sorts of
combinations without success. Could you maybe tell me the exact steps
on how you get this behaviour?

However, when trying the different options I realized that there's a
bug in the project preferences. Maybe you've already pointed it out
and I didn't get it. But if you've configured a project specific profile
and change to a target profile, when you enable the project
specific profile again, your settings are lost. Instead the selected
profile is copied all of the time, instead of only at the first time of
configuration.

I'll send a fix and a v3 of the menu with the greyed out menu item.

>
> Jessica -----Original Message----- From: Timo Mueller
> [mailto:mail@timomueller.eu] Sent: Sunday, June 23, 2013 1:36 AM To:
> Zhang, Jessica Cc: yocto@yoctoproject.org; Timo Mueller Subject: Re:
> [yocto] [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
>
> Hi Jessica,
>
> Am 21.06.2013 23:47, schrieb Zhang, Jessica:
>> Hi Timo,
>>
>> So what's the purpose of "Project Specific Settings", my  >
>> understanding is it's something that only local to project instead
>> of  > global name space, e.g. profile?
>
> Yes, that's the main idea.
>
>> OK, I've played a little bit  of toggling between profiles, and
>> project specific setting and notice  > the following behaviors that
>> can be confusing:
>>
>> 1. As your preference that user can specify "project specific  >
>> settings".  I've noticed for this case, if I haven't entered any  >
>> project specific settings via the preference wizard, it'll always
>> > copy the profile settings prior to its selection, then in this
>> case I  > don't think it makes much sense since we already have the
>> profiles to  > cover all the settings
>
> That's independent of this patch set, right?
>
> The original idea behind copying the settings of the currently
> selected profile was to give the user a starting point for creating
> the project specific settings. The assumption was that the user most
> of the times only does small modifications to an existing profile.
>
> Sure, if the user doesn't alter the settings, the project specific
> ones match an already defined target profile. One difference remains,
> if he changes the target profile it will update all projects that use
> this profile. The project that is using it's own configuration won't
> be changed, although the settings are similar.
>
> An alternative to copying the inital settings would be to blank out
> the form, when the checkbox is checked. If the assumption is not
> correct and we think that this is easier to understand for the user,
> I'll provide a patch set changing this behaviour.
>
>>
>> 2.  OK, now let's move to the case of that I do have explicit setup
>> a  > project specific settings in the project property view apply
>> it and  > exit the window.  After that, in the drop down list, when
>> I toggle  > between the options, e.g. I have two profiles besides
>> the project  > specific settings, then every time after I made the
>> selection and  > check in the project properties view, the settings
>> matches my  > selection.  So this is good and consistent behavior.
>>
>> 3. If  inside the project properties window, I uncheck the "Use  >
>> project specific settings" box, and select a profile then apply the
>> > changes close the window.  Now in the drop down list I will see
>> both  > the "project specific setting" and the selected profile are
>> selected. Then next time when I go back, and re-check "Use project
>> specific  > settings" box, my project specific setting will be
>> gone, instead the  > settings will show as my previous profile
>> settings.
>
> That's a bug in my implementation. They should always be in sink as
> you explained in your second point.
>
>>
>> Overall, I think we still need to play a little bit more of
>> different  > setting selections via different approaches, some of
>> the inconsistent  > behavior can get user lost.
>>
>> Thanks, Jessica -----Original Message----- From:
>> yocto-bounces@yoctoproject.org
>> [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Timo Mueller
>> > Sent: Friday, June 21, 2013 5:45 AM To: yocto@yoctoproject.org
>> Cc: Timo Mueller Subject: [yocto] [PATCHv2 0/8][eclipse-poky] Add
>> target  > profile quick switch  >  > From: Timo Mueller
>> <timo.mueller@bmw-carit.de>  >  > Changes in v2: Handle error when
>> project specific profile is not  > configured more gracefully.
>> Instead of showing an error message the  > button is now greyed
>> out.
>>
>> Patches 01..07 contain the implementation with the greyed out menu
>> > button.
>>
>> After playing around with the two options discussed in the first  >
>> patch series, I started to prefer inserting a different button in
>> the  > menu allowing the user to quickly navigate to the project
>> preferences  > instead of just greying it out. I've added this in
>> the last patch of  > the series, so you can compare yourself.
>>
>> From original cover letter <snip> if a user wants to change the
>> used  > target profile of a project he currently has to open the
>> project  > preferences. This can be tedious if he has to switch the
>> profile  > often.
>>
>> This is a small addition which allows the user to quickly switch
>> the  > used target profile of a project. Instead of having to open
>> the  > project preferences the user can select the project in the
>> navigator  > and then choose the desired target profile from a
>> drop-down menu in  > the toolbar or from the project menu. </snip>
>> >  > 01: Small i18n fix 02..04: Refactoring the project specific
>> utils  > 05..06: Introduce the target profile toolbar switch 07:
>> Adds the  > target profile switch to the project menu 08:
>> Experimental: Add  > button to open project preferences  >  > Best
>> regards, Timo
>
> Thanks, for the input. I'll fix the bug and send a v3.
>
> Best regards, Timo
>

Best regards,
Timo


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
  2013-06-24  6:52       ` Timo Müller
@ 2013-06-24 16:16         ` Zhang, Jessica
  0 siblings, 0 replies; 14+ messages in thread
From: Zhang, Jessica @ 2013-06-24 16:16 UTC (permalink / raw)
  To: Timo Müller; +Cc: yocto, Timo Mueller

Hi Timo,

Your finding is described in my case 3.  For reproduce the double selection, you need to select "project specific" apply exit the property window.  Then go back to property window, deselect "project specific" apply, exit the window. Then check the drop down list, I can consistently reproduce the case this way.  Give it a try.

Thanks,
Jessica

-----Original Message-----
From: Timo Müller [mailto:mail@timomueller.eu]
Sent: Sunday, June 23, 2013 11:52 PM
To: Zhang, Jessica
Cc: yocto@yoctoproject.org; Timo Mueller
Subject: Re: [yocto] [PATCHv2 0/8][eclipse-poky] Add target profile quick switch

Hi Jessica

Zhang, Jessica wrote, On 24.06.2013 07:25:
> Hi Timo,
>
> For case 1, I think we probably should bring back the grey out option.
> In my opinion, it's more consistent.  The property window should be
> the centralized place for user to setup the settings.  The drop down
> list is for user to quickly toggle between the different settings.  So
> the behavior should be:
>
> If there's no project specific settings, that option will be greyed
> out.  I don't think it'll make it secondary as long as it's still
> visible.  Once user 1st time check the project specific setting in the
> project properties window, we copy the prior profile settings as start
> point then the user can further customize if there's the need.
> Once a project has its own specific settings, the option will be
> enabled in the drop down list and the selection will be consistent
> between the drop down list selection and project properties settings.
>
> What do you think?

I get your point. I'll kick out the last patch to restore the greyed out version.

I tried to reproduce case 3. And I haven't been able to bring the menu to a state where two menu items are checked. I tried all sorts of combinations without success. Could you maybe tell me the exact steps on how you get this behaviour?

However, when trying the different options I realized that there's a bug in the project preferences. Maybe you've already pointed it out and I didn't get it. But if you've configured a project specific profile and change to a target profile, when you enable the project specific profile again, your settings are lost. Instead the selected profile is copied all of the time, instead of only at the first time of configuration.

I'll send a fix and a v3 of the menu with the greyed out menu item.

>
> Jessica -----Original Message----- From: Timo Mueller
> [mailto:mail@timomueller.eu] Sent: Sunday, June 23, 2013 1:36 AM To:
> Zhang, Jessica Cc: yocto@yoctoproject.org; Timo Mueller Subject: Re:
> [yocto] [PATCHv2 0/8][eclipse-poky] Add target profile quick switch
>
> Hi Jessica,
>
> Am 21.06.2013 23:47, schrieb Zhang, Jessica:
>> Hi Timo,
>>
>> So what's the purpose of "Project Specific Settings", my  >
>> understanding is it's something that only local to project instead of
>> > global name space, e.g. profile?
>
> Yes, that's the main idea.
>
>> OK, I've played a little bit  of toggling between profiles, and
>> project specific setting and notice  > the following behaviors that
>> can be confusing:
>>
>> 1. As your preference that user can specify "project specific  >
>> settings".  I've noticed for this case, if I haven't entered any  >
>> project specific settings via the preference wizard, it'll always
>> > copy the profile settings prior to its selection, then in this
>> case I  > don't think it makes much sense since we already have the
>> profiles to  > cover all the settings
>
> That's independent of this patch set, right?
>
> The original idea behind copying the settings of the currently
> selected profile was to give the user a starting point for creating
> the project specific settings. The assumption was that the user most
> of the times only does small modifications to an existing profile.
>
> Sure, if the user doesn't alter the settings, the project specific
> ones match an already defined target profile. One difference remains,
> if he changes the target profile it will update all projects that use
> this profile. The project that is using it's own configuration won't
> be changed, although the settings are similar.
>
> An alternative to copying the inital settings would be to blank out
> the form, when the checkbox is checked. If the assumption is not
> correct and we think that this is easier to understand for the user,
> I'll provide a patch set changing this behaviour.
>
>>
>> 2.  OK, now let's move to the case of that I do have explicit setup a
>> > project specific settings in the project property view apply it and
>> > exit the window.  After that, in the drop down list, when I toggle
>> > between the options, e.g. I have two profiles besides the project
>> > specific settings, then every time after I made the selection and
>> > check in the project properties view, the settings matches my  >
>> selection.  So this is good and consistent behavior.
>>
>> 3. If  inside the project properties window, I uncheck the "Use  >
>> project specific settings" box, and select a profile then apply the
>> > changes close the window.  Now in the drop down list I will see
>> both  > the "project specific setting" and the selected profile are
>> selected. Then next time when I go back, and re-check "Use project
>> specific  > settings" box, my project specific setting will be gone,
>> instead the  > settings will show as my previous profile settings.
>
> That's a bug in my implementation. They should always be in sink as
> you explained in your second point.
>
>>
>> Overall, I think we still need to play a little bit more of different
>> > setting selections via different approaches, some of the
>> inconsistent  > behavior can get user lost.
>>
>> Thanks, Jessica -----Original Message----- From:
>> yocto-bounces@yoctoproject.org
>> [mailto:yocto-bounces@yoctoproject.org] On Behalf Of Timo Mueller
>> > Sent: Friday, June 21, 2013 5:45 AM To: yocto@yoctoproject.org
>> Cc: Timo Mueller Subject: [yocto] [PATCHv2 0/8][eclipse-poky] Add
>> target  > profile quick switch  >  > From: Timo Mueller
>> <timo.mueller@bmw-carit.de>  >  > Changes in v2: Handle error when
>> project specific profile is not  > configured more gracefully.
>> Instead of showing an error message the  > button is now greyed out.
>>
>> Patches 01..07 contain the implementation with the greyed out menu
>> > button.
>>
>> After playing around with the two options discussed in the first  >
>> patch series, I started to prefer inserting a different button in the
>> > menu allowing the user to quickly navigate to the project
>> preferences  > instead of just greying it out. I've added this in the
>> last patch of  > the series, so you can compare yourself.
>>
>> From original cover letter <snip> if a user wants to change the used
>> > target profile of a project he currently has to open the project  >
>> preferences. This can be tedious if he has to switch the profile  >
>> often.
>>
>> This is a small addition which allows the user to quickly switch the
>> > used target profile of a project. Instead of having to open the  >
>> project preferences the user can select the project in the navigator
>> > and then choose the desired target profile from a drop-down menu in
>> > the toolbar or from the project menu. </snip>
>> >  > 01: Small i18n fix 02..04: Refactoring the project specific
>> utils  > 05..06: Introduce the target profile toolbar switch 07:
>> Adds the  > target profile switch to the project menu 08:
>> Experimental: Add  > button to open project preferences  >  > Best
>> regards, Timo
>
> Thanks, for the input. I'll fix the bug and send a v3.
>
> Best regards, Timo
>

Best regards,
Timo


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-06-24 16:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-21 12:44 [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Timo Mueller
2013-06-21 12:44 ` [PATCHv2 1/8] plugins/sdk.ide: Use an internationalized dialog title Timo Mueller
2013-06-21 12:44   ` [PATCHv2 2/8] plugins/sdk.ide: Extract project specific util methods Timo Mueller
2013-06-21 12:44     ` [PATCHv2 3/8] plugins/sdk.ide: Move " Timo Mueller
2013-06-21 12:44       ` [PATCHv2 4/8] plugins/sdk.ide: Remove project context from method names Timo Mueller
2013-06-21 12:44         ` [PATCHv2 5/8] plugins/sdk.ide: Add command to switch the target profile Timo Mueller
2013-06-21 12:44           ` [PATCHv2 6/8] plugins/sdk.ide: Add profile switch menu to the toolbar Timo Mueller
2013-06-21 12:44             ` [PATCHv2 7/8] plugins/sdk.ide: Add profile switch menu to the project menu Timo Mueller
2013-06-21 12:44               ` [PATCHv2 8/8] plugins/sdk.ide: Add project configuration button Timo Mueller
2013-06-21 21:47 ` [PATCHv2 0/8][eclipse-poky] Add target profile quick switch Zhang, Jessica
2013-06-23  8:36   ` Timo Mueller
2013-06-24  5:25     ` Zhang, Jessica
2013-06-24  6:52       ` Timo Müller
2013-06-24 16:16         ` Zhang, Jessica

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.