mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Bug 392954 - Manage Working Sets dialog can be opened when all working
sets are empty
This commit is contained in:
parent
58c1312133
commit
c1210c5d8b
1 changed files with 84 additions and 70 deletions
|
@ -1,70 +1,84 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Intel Corporation, QNX Software Systems, and others.
|
* Copyright (c) 2008, 2009, 2012 Intel Corporation, QNX Software Systems, and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - initial API and implementation
|
* Intel Corporation - initial API and implementation
|
||||||
* QNX Software Systems - [272416] Rework the config sets dialog
|
* 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;
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.ui.actions;
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.IWorkingSet;
|
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||||
import org.eclipse.ui.IWorkingSetManager;
|
import org.eclipse.ui.IWorkingSet;
|
||||||
|
import org.eclipse.ui.IWorkingSetManager;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
|
|
||||||
|
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
|
||||||
/**
|
|
||||||
*/
|
/**
|
||||||
public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
|
*/
|
||||||
private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
|
public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
|
||||||
private boolean enabled = true;
|
|
||||||
|
private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
|
||||||
private IWorkbenchWindow window;
|
private boolean enabled = true;
|
||||||
|
private IWorkbenchWindow window;
|
||||||
@Override
|
private IAction action;
|
||||||
public void run(IAction action) {
|
|
||||||
new WorkingSetConfigurationDialog(window.getShell()).open();
|
@Override
|
||||||
}
|
public void run(IAction action) {
|
||||||
|
this.action = action;
|
||||||
@Override
|
checkWS();
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
if (enabled) {
|
||||||
checkWS();
|
new WorkingSetConfigurationDialog(window.getShell()).open();
|
||||||
if (action.isEnabled() != enabled)
|
}
|
||||||
action.setEnabled(enabled);
|
}
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
wsm.removePropertyChangeListener(this);
|
this.action = action;
|
||||||
|
checkWS();
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void init(IWorkbenchWindow window) {
|
@Override
|
||||||
this.window = window;
|
public void dispose() {
|
||||||
wsm.addPropertyChangeListener(this);
|
wsm.removePropertyChangeListener(this);
|
||||||
checkWS();
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
private IWorkingSet[] checkWS() {
|
public void init(IWorkbenchWindow window) {
|
||||||
IWorkingSet[] w = wsm.getWorkingSets();
|
this.window = window;
|
||||||
if (w == null)
|
wsm.addPropertyChangeListener(this);
|
||||||
w = new IWorkingSet[0];
|
checkWS();
|
||||||
enabled = w.length > 0;
|
}
|
||||||
return w;
|
|
||||||
}
|
private void checkWS() {
|
||||||
|
enabled = false;
|
||||||
@Override
|
IWorkingSet[] w = wsm.getWorkingSets();
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
if (w == null)
|
||||||
checkWS();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue