summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Hochstein2012-11-06 14:25:02 (EST)
committer John Cortell2012-11-06 14:25:02 (EST)
commitc1210c5d8b44253456c5b818e81d7aa5d91e592b (patch)
treeb52254bff7476cfcf36b8c43e0c841692cc6f27e
parent58c1312133beda50e27b7e5a72af57f2ca82ed5a (diff)
downloadorg.eclipse.cdt-c1210c5d8b44253456c5b818e81d7aa5d91e592b.zip
org.eclipse.cdt-c1210c5d8b44253456c5b818e81d7aa5d91e592b.tar.gz
org.eclipse.cdt-c1210c5d8b44253456c5b818e81d7aa5d91e592b.tar.bz2
Bug 392954 - Manage Working Sets dialog can be opened when all working
sets are empty
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java154
1 files changed, 84 insertions, 70 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
index 23980bb..5078610 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
@@ -1,70 +1,84 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Intel Corporation, QNX Software Systems, and others.
- * 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 Corporation - initial API and implementation
- * QNX Software Systems - [272416] Rework the config sets dialog
- *******************************************************************************/
-package org.eclipse.cdt.ui.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
-
-/**
- */
-public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
- private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
- private boolean enabled = true;
-
- private IWorkbenchWindow window;
-
- @Override
- public void run(IAction action) {
- new WorkingSetConfigurationDialog(window.getShell()).open();
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- checkWS();
- if (action.isEnabled() != enabled)
- action.setEnabled(enabled);
- }
- @Override
- public void dispose() {
- wsm.removePropertyChangeListener(this);
-
- }
- @Override
- public void init(IWorkbenchWindow window) {
- this.window = window;
- wsm.addPropertyChangeListener(this);
- checkWS();
- }
-
- private IWorkingSet[] checkWS() {
- IWorkingSet[] w = wsm.getWorkingSets();
- if (w == null)
- w = new IWorkingSet[0];
- enabled = w.length > 0;
- return w;
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- checkWS();
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008, 2009, 2012 Intel Corporation, QNX Software Systems, and others.
+ * 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 Corporation - initial API and implementation
+ * QNX Software Systems - [272416] Rework the config sets dialog
+ * Freescale Semiconductor - [392954] disable the action if only empty working sets exist
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
+
+/**
+ */
+public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
+
+ private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
+ private boolean enabled = true;
+ private IWorkbenchWindow window;
+ private IAction action;
+
+ @Override
+ public void run(IAction action) {
+ this.action = action;
+ checkWS();
+ if (enabled) {
+ new WorkingSetConfigurationDialog(window.getShell()).open();
+ }
+ }
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.action = action;
+ checkWS();
+ }
+
+ @Override
+ public void dispose() {
+ wsm.removePropertyChangeListener(this);
+ }
+
+ @Override
+ public void init(IWorkbenchWindow window) {
+ this.window = window;
+ wsm.addPropertyChangeListener(this);
+ checkWS();
+ }
+
+ private void checkWS() {
+ enabled = false;
+ IWorkingSet[] w = wsm.getWorkingSets();
+ if (w == null)
+ w = new IWorkingSet[0];
+ for (IWorkingSet ws : w) {
+ if (!ws.isEmpty()) {
+ enabled = true;
+ break;
+ }
+ }
+ if (action != null) {
+ action.setEnabled(enabled);
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ checkWS();
+ }
+}