From 41ac47d732eed8392d60d0f6773e5a279d49b999 Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 12 Dec 2013 13:36:50 +0100 Subject: initial commit of Enea Linux 3.1 Migrated from the internal git server on the dora-enea branch Signed-off-by: Adrian Dudau --- .../sdk/ide/ProjectSpecificContributionItem.java | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java') diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java new file mode 100644 index 0000000..c29d278 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2013 BMW Car IT GmbH. + * 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: + * BMW Car IT - initial implementation + *******************************************************************************/ + +package org.yocto.sdk.ide; + +import java.util.ArrayList; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.ui.menus.CommandContributionItem; +import org.eclipse.ui.menus.CommandContributionItemParameter; +import org.eclipse.ui.services.IServiceLocator; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults; +import org.yocto.sdk.ide.actions.ProfileSwitchHandler; +import org.yocto.sdk.ide.utils.ProjectPreferenceUtils; + +public class ProjectSpecificContributionItem extends TargetProfileContributionItem { + private static final String PROJECT_SPECIFIC_PROFILE = + "Preferences.Profile.ProjectSpecific.Profile.Label"; //$NON-NLS-N$ + private static final String DISABLED_COMMAND_ID = "org.yocto.sdk.ide.command.disabled"; //$NON-NLS-N$ + + private IServiceLocator serviceLocator; + + public ProjectSpecificContributionItem() {} + + public ProjectSpecificContributionItem(String id) { + super(id); + } + + @Override + protected IContributionItem[] getContributionItems() { + ArrayList items = new ArrayList(); + + IProject project = getSelectedProject(serviceLocator); + YoctoUIElement yoctoUIElement = ProjectPreferenceUtils.getElem(project); + SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(yoctoUIElement); + + if ((result != SDKCheckResults.SDK_PASS)) { + CommandContributionItemParameter parameter = new CommandContributionItemParameter(serviceLocator, + null, + DISABLED_COMMAND_ID, + CommandContributionItem.STYLE_PUSH); + + parameter.label = YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE); + + items.add(new CommandContributionItem(parameter)); + } else { + items.add(super.createProfileItem(serviceLocator, ProfileSwitchHandler.PROJECT_SPECIFIC_PARAMETER, + YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE))); + } + + updateSelection(serviceLocator); + + return items.toArray(new IContributionItem[items.size()]); + } + + @Override + public void initialize(IServiceLocator serviceLocator) { + this.serviceLocator = serviceLocator; + } +} -- cgit v1.2.3-54-g00ecf