Return-Path: Received: from mail-bk0-f46.google.com (mail-bk0-f46.google.com [209.85.214.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by yocto-www.yoctoproject.org (Postfix) with ESMTPS id 97B69E0152B for ; Thu, 7 Mar 2013 06:09:27 -0800 (PST) Received: by mail-bk0-f46.google.com with SMTP id j5so236634bkw.5 for ; Thu, 07 Mar 2013 06:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=+qHpLshGygklZdi5muR5GOEb80oIO+0g1NOWE6NQqbA=; b=hY481JNPq5FPTKTTKb6KdidDjFmZqeQJFW581brTYiCZ43velXK+M0JxzA6CxUl4lL itfFjoZCQW/yIGwFuABeD1xHJ5rg8bjYULjjcpBmz/1bleTQrAuBvfEgLsMYH7subQLo tfa7EqEEJwKNtKdtYLsvve9qHvGj+mQG3IZ6zctMDNO2yVfc+5VsYkH8AO1Gs7R/vjcx P+wfCElBglNIjc5mkyf8LTeLK2stmRTINx8ifRcOlBs7+lpWgLvniqMASe0W8scLLxIc 5KmjKcjhl31H9MIVvH7MxvEVmNHr9n/cykUF2n7tVAmEchd7gPMfjsXfALkIWzk29yag MD0A== X-Received: by 10.204.153.1 with SMTP id i1mr13411773bkw.20.1362665365954; Thu, 07 Mar 2013 06:09:25 -0800 (PST) Received: from ubuntu.bmw-carit.intra (mail.bmw-carit.de. [62.245.222.98]) by mx.google.com with ESMTPS id v2sm742337bkw.5.2013.03.07.06.09.25 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Mar 2013 06:09:25 -0800 (PST) From: Atanas Gegov To: yocto@yoctoproject.org Date: Thu, 7 Mar 2013 15:09:10 +0100 Message-Id: <1362665352-8259-5-git-send-email-atanas.gegov.oss@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1362665352-8259-1-git-send-email-atanas.gegov.oss@gmail.com> References: <1362665352-8259-1-git-send-email-atanas.gegov.oss@gmail.com> Subject: [PATCHv3 4/6] Moved nature-related utils in own class X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Mar 2013 14:09:28 -0000 From: Atanas Gegov 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 5ccd6e2..2d3850f 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; @@ -616,24 +614,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