1 /*******************************************************************************
2 * Copyright (c) 2008, 2009 Intel Corporation, QNX Software Systems, 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 * QNX Software Systems - [272416] Rework the config sets dialog
11 *******************************************************************************/
12 package org.eclipse.cdt.ui.actions;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.util.IPropertyChangeListener;
16 import org.eclipse.jface.util.PropertyChangeEvent;
17 import org.eclipse.jface.viewers.ISelection;
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
20 import org.eclipse.ui.IWorkingSet;
21 import org.eclipse.ui.IWorkingSetManager;
23 import org.eclipse.cdt.ui.CUIPlugin;
25 import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
29 public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
30 private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
31 private boolean enabled = true;
33 private IWorkbenchWindow window;
35 public void run(IAction action) {
36 new WorkingSetConfigurationDialog(window.getShell()).open();
39 public void selectionChanged(IAction action, ISelection selection) {
41 if (action.isEnabled() != enabled)
42 action.setEnabled(enabled);
44 public void dispose() {
45 wsm.removePropertyChangeListener(this);
48 public void init(IWorkbenchWindow window) {
50 wsm.addPropertyChangeListener(this);
54 private IWorkingSet[] checkWS() {
55 IWorkingSet[] w = wsm.getWorkingSets();
57 w = new IWorkingSet[0];
58 enabled = w.length > 0;
62 public void propertyChange(PropertyChangeEvent event) {