[yocto] [PATCHv2 4/5] Moved nature-related utils in own class
Atanas Gegov
atanas.gegov.oss at gmail.com
Wed Mar 6 08:11:55 PST 2013
From: Atanas Gegov <atanas.gegov at bmw-carit.de>
Created a nature specific utils class and moved
a method that is only relevant in the natures context.
---
.../ide/natures/YoctoSDKEmptyProjectNature.java | 3 +-
.../yocto/sdk/ide/natures/YoctoSDKNatureUtils.java | 39 ++++++++++++++++++++
.../sdk/ide/natures/YoctoSDKProjectNature.java | 2 +-
.../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 20 ----------
4 files changed, 41 insertions(+), 23 deletions(-)
create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java
index 9057b8e..6c9a5ac 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java
@@ -5,7 +5,6 @@ import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.yocto.sdk.ide.YoctoSDKPlugin;
-import org.yocto.sdk.ide.utils.YoctoSDKUtils;
public class YoctoSDKEmptyProjectNature implements IProjectNature {
@@ -34,7 +33,7 @@ public class YoctoSDKEmptyProjectNature implements IProjectNature {
}
public static void addYoctoSDKEmptyNature(IProject project, IProgressMonitor monitor) throws CoreException {
- YoctoSDKUtils.addNature(project, YoctoSDK_EMPTY_NATURE_ID, monitor);
+ YoctoSDKNatureUtils.addNature(project, YoctoSDK_EMPTY_NATURE_ID, monitor);
}
}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java
new file mode 100644
index 0000000..5a2a6b1
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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 API and implementation
+ * BMW Car IT - extracted in an own class
+ *******************************************************************************/
+package org.yocto.sdk.ide.natures;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class YoctoSDKNatureUtils {
+
+ public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException
+ {
+ IProjectDescription description = project.getDescription();
+ String[] natures = description.getNatureIds();
+
+ for (int i = 0; i < natures.length; ++i) {
+ if (natureId.equals(natures[i]))
+ return;
+ }
+
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = natureId;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, monitor);
+
+ }
+
+}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java
index 2c6a782..a299aa4 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java
@@ -60,7 +60,7 @@ public class YoctoSDKProjectNature implements IProjectNature {
}
public static void addYoctoSDKNature(IProject project, IProgressMonitor monitor) throws CoreException {
- YoctoSDKUtils.addNature(project, YoctoSDK_NATURE_ID, monitor);
+ YoctoSDKNatureUtils.addNature(project, YoctoSDK_NATURE_ID, monitor);
}
public static void configureAutotoolsOptions(IProject project) {
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 c37e4fe..621aabf 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
@@ -38,10 +38,8 @@ 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.IProjectDescription;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.debug.core.DebugPlugin;
@@ -631,24 +629,6 @@ public class YoctoSDKUtils {
}
- public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException
- {
- IProjectDescription description = project.getDescription();
- String[] natures = description.getNatureIds();
-
- for (int i = 0; i < natures.length; ++i) {
- if (natureId.equals(natures[i]))
- return;
- }
-
- String[] newNatures = new String[natures.length + 1];
- System.arraycopy(natures, 0, newNatures, 0, natures.length);
- newNatures[natures.length] = natureId;
- description.setNatureIds(newNatures);
- project.setDescription(description, monitor);
-
- }
-
public static String getPlatformArch()
{
String value = null;
--
1.7.9.5
More information about the yocto
mailing list