summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java')
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java39
1 files changed, 39 insertions, 0 deletions
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 @@
1/*******************************************************************************
2 * Copyright (c) 2010 Intel Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel - initial API and implementation
10 * BMW Car IT - extracted in an own class
11 *******************************************************************************/
12package org.yocto.sdk.ide.natures;
13
14import org.eclipse.core.resources.IProject;
15import org.eclipse.core.resources.IProjectDescription;
16import org.eclipse.core.runtime.CoreException;
17import org.eclipse.core.runtime.IProgressMonitor;
18
19public class YoctoSDKNatureUtils {
20
21 public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException
22 {
23 IProjectDescription description = project.getDescription();
24 String[] natures = description.getNatureIds();
25
26 for (int i = 0; i < natures.length; ++i) {
27 if (natureId.equals(natures[i]))
28 return;
29 }
30
31 String[] newNatures = new String[natures.length + 1];
32 System.arraycopy(natures, 0, newNatures, 0, natures.length);
33 newNatures[natures.length] = natureId;
34 description.setNatureIds(newNatures);
35 project.setDescription(description, monitor);
36
37 }
38
39}