blob: 5a2a6b15116a56c94f7afe656165d068fe51dff5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
}
}
|