From: Timo Mueller <[email protected]>
Saving yocto project settings is currently only used by the "Change
Yocto Project Settings" command. To allow other UI elements
(e.g. project property pages) to modify the yocto settings of a
project the functionality has been extraced to a separate method and
moved to the utils class.
---
.../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 42 ++++++++++++++++++++
.../yocto/sdk/ide/actions/ReconfigYoctoAction.java | 41 ++-----------------
2 files changed, 46 insertions(+), 37 deletions(-)
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
index 16035fd..7ea4262 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
@@ -22,10 +22,12 @@ import java.util.HashMap;
import java.util.Iterator;
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.core.resources.IProject;
@@ -75,6 +77,7 @@ 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 SYSROOTS_DIR = "sysroots";
+ private static final String CONSOLE_MESSAGE =
"Menu.SDK.Console.Configure.Message";
public static SDKCheckResults checkYoctoSDK(YoctoUIElement elem) {
@@ -418,6 +421,45 @@ public class YoctoSDKUtils {
elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
return elem;
}
+
+ /* Save YoctoUIElement to project settings */
+ public static void saveElemToProjectEnv(IProject project,
YoctoUIElement elem)
+ {
+ ConsoleOutputStream consoleOutStream = null;
+
+ try {
+ YoctoSDKProjectNature.setEnvironmentVariables(project,
elem);
+
YoctoSDKProjectNature.configureAutotoolsOptions(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
+ }
+ }
+ }
+ }
/* Load IDE wide POKY Preference settings into Preference Store */
public static void saveElemToStore(YoctoUIElement elem)
diff --git
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
index f68b552..d7021be 100644
---
a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
+++
b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
@@ -10,29 +10,19 @@
*******************************************************************************/
package org.yocto.sdk.ide.actions;
-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.cdt.internal.autotools.ui.actions.InvokeAction;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
-import org.eclipse.cdt.internal.autotools.ui.actions.InvokeAction;
import org.eclipse.swt.widgets.Shell;
-
-import org.yocto.sdk.ide.YoctoGeneralException;
-import org.yocto.sdk.ide.YoctoSDKUtils;
import org.yocto.sdk.ide.YoctoSDKMessages;
-import org.yocto.sdk.ide.YoctoSDKProjectNature;
+import org.yocto.sdk.ide.YoctoSDKUtils;
import org.yocto.sdk.ide.YoctoUIElement;
@SuppressWarnings("restriction")
public class ReconfigYoctoAction extends InvokeAction {
private static final String DIALOG_TITLE = "Menu.SDK.Dialog.Title";
- private static final String CONSOLE_MESSAGE =
"Menu.SDK.Console.Configure.Message";
public void run(IAction action) {
@@ -52,31 +42,8 @@ public class ReconfigYoctoAction extends InvokeAction {
SDKLocationDialog optionDialog = new SDKLocationDialog(new
Shell(), YoctoSDKMessages.getString(DIALOG_TITLE), elem);
optionDialog.open();
elem = optionDialog.getElem();
- if (elem.getStrToolChainRoot() != null) {
- try {
-
YoctoSDKProjectNature.setEnvironmentVariables(project, elem);
-
YoctoSDKProjectNature.configureAutotoolsOptions(project);
- IConsole console =
CCorePlugin.getDefault().getConsole("org.yocto.sdk.ide.YoctoConsole");
- console.start(project);
- ConsoleOutputStream consoleOutStream;
- consoleOutStream = console.getOutputStream();
- String messages =
YoctoSDKMessages.getString(CONSOLE_MESSAGE);
- consoleOutStream.write(messages.getBytes());
- consoleOutStream.flush();
- consoleOutStream.close();
- }
- catch (CoreException e)
- {
- System.out.println(e.getMessage());
- }
- catch (IOException e)
- {
- System.out.println(e.getMessage());
- }
- catch (YoctoGeneralException e)
- {
- System.out.println(e.getMessage());
- }
+ if (elem.getStrToolChainRoot() != null) {
+ YoctoSDKUtils.saveElemToProjectEnv(project, elem);
}
}
--
1.7.7.6
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto