1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Intel Corporation and others.
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
9 * Intel Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.cdt.ui.actions;
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.viewers.ISelection;
16 import org.eclipse.jface.viewers.StructuredSelection;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.swt.widgets.Menu;
19 import org.eclipse.ui.IObjectActionDelegate;
20 import org.eclipse.ui.IWorkbenchPart;
21 import org.eclipse.ui.IWorkbenchWindow;
22 import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
24 import org.eclipse.cdt.ui.newui.IConfigManager;
25 import org.eclipse.cdt.ui.newui.ManageConfigSelector;
28 * Action which lets to manage (add/remove etc.) build configurations of the project.
30 public class ManageConfigsAction
31 implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
32 IProject[] obs = null;
34 public void selectionChanged(IAction action, ISelection selection) {
35 if (!selection.isEmpty()) {
36 // case for context menu
37 if (selection instanceof StructuredSelection) {
38 obs = ManageConfigSelector.getProjects(((StructuredSelection)selection).toArray());
39 action.setEnabled(ManageConfigSelector.getManager(obs) != null);
43 action.setEnabled(false);
46 public void run(IAction action) {
47 IConfigManager cm = ManageConfigSelector.getManager(obs);
48 if (cm != null && obs != null)
52 public void dispose() { obs = null; }
55 public void init(IWorkbenchWindow window) { }
56 public Menu getMenu(Menu parent) { return null; }
57 public Menu getMenu(Control parent) { return null; }
58 public void setActivePart(IAction action, IWorkbenchPart targetPart) {}