diff options
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java')
-rw-r--r-- | plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java | 71 |
1 files changed, 71 insertions, 0 deletions
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..7ba7df1 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/ProjectSpecificContributionItem.java | |||
@@ -0,0 +1,71 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2013 BMW Car IT GmbH. | ||
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 | * BMW Car IT - initial implementation | ||
10 | *******************************************************************************/ | ||
11 | |||
12 | package org.yocto.sdk.ide; | ||
13 | |||
14 | import java.util.ArrayList; | ||
15 | |||
16 | import org.eclipse.core.resources.IProject; | ||
17 | import org.eclipse.jface.action.IContributionItem; | ||
18 | import org.eclipse.ui.menus.CommandContributionItem; | ||
19 | import org.eclipse.ui.menus.CommandContributionItemParameter; | ||
20 | import org.eclipse.ui.services.IServiceLocator; | ||
21 | import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults; | ||
22 | import org.yocto.sdk.ide.actions.ProfileSwitchHandler; | ||
23 | import org.yocto.sdk.ide.utils.ProjectPreferenceUtils; | ||
24 | |||
25 | public class ProjectSpecificContributionItem extends TargetProfileContributionItem { | ||
26 | private static final String PROJECT_SPECIFIC_PROFILE = | ||
27 | "Preferences.Profile.ProjectSpecific.Profile.Label"; //$NON-NLS-N$ | ||
28 | private static final String DISABLED_COMMAND_ID = "org.yocto.sdk.ide.command.disabled"; //$NON-NLS-N$ | ||
29 | |||
30 | private IServiceLocator serviceLocator; | ||
31 | |||
32 | public ProjectSpecificContributionItem() {} | ||
33 | |||
34 | public ProjectSpecificContributionItem(String id) { | ||
35 | super(id); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | protected IContributionItem[] getContributionItems() { | ||
40 | ArrayList<IContributionItem> items = new ArrayList<IContributionItem>(); | ||
41 | |||
42 | IProject project = getSelectedProject(serviceLocator); | ||
43 | if (project != null) { | ||
44 | YoctoUIElement yoctoUIElement = ProjectPreferenceUtils.getElem(project); | ||
45 | SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(yoctoUIElement); | ||
46 | |||
47 | if ((result != SDKCheckResults.SDK_PASS)) { | ||
48 | CommandContributionItemParameter parameter = new CommandContributionItemParameter(serviceLocator, | ||
49 | null, | ||
50 | DISABLED_COMMAND_ID, | ||
51 | CommandContributionItem.STYLE_PUSH); | ||
52 | |||
53 | parameter.label = YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE); | ||
54 | |||
55 | items.add(new CommandContributionItem(parameter)); | ||
56 | } else { | ||
57 | items.add(super.createProfileItem(serviceLocator, ProfileSwitchHandler.PROJECT_SPECIFIC_PARAMETER, | ||
58 | YoctoSDKMessages.getString(PROJECT_SPECIFIC_PROFILE))); | ||
59 | } | ||
60 | |||
61 | updateSelection(serviceLocator); | ||
62 | } | ||
63 | |||
64 | return items.toArray(new IContributionItem[items.size()]); | ||
65 | } | ||
66 | |||
67 | @Override | ||
68 | public void initialize(IServiceLocator serviceLocator) { | ||
69 | this.serviceLocator = serviceLocator; | ||
70 | } | ||
71 | } | ||