1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

Fixed bugzilla 260595. Disable the Show Full Paths action when not applicable

This commit is contained in:
John Cortell 2009-01-09 21:33:39 +00:00
parent fb0cf15e02
commit 89b260739c
3 changed files with 67 additions and 4 deletions

View file

@ -910,6 +910,12 @@
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction" class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
menubarPath="cDebugActions" menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"> id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action> </action>
</viewContribution> </viewContribution>
<viewContribution <viewContribution
@ -928,6 +934,12 @@
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction" class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
menubarPath="cDebugActions" menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"> id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action> </action>
<action <action
class="org.eclipse.cdt.debug.internal.ui.actions.AddEventBreakpointActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.AddEventBreakpointActionDelegate"

View file

@ -24,7 +24,10 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.BusyIndicator;
/** /**
* An action delegate that toggles the state of its viewer to show/hide full paths. * An action delegate that toggles the state of its viewer to show/hide full
* paths. Note that we are not a filtering action (thus we unconditionally
* return true in {@link #select(Viewer, Object, Object)}), but we extend
* ViewFilterAction to get some basic, useful action behavior.
*/ */
public class ShowFullPathsAction extends ViewFilterAction { public class ShowFullPathsAction extends ViewFilterAction {

View file

@ -10,7 +10,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.ui.IDebugView; import org.eclipse.debug.ui.IDebugView;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
@ -24,7 +30,8 @@ import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
/** /**
* A base class for the view filtering actions. * A base class for the CDT filtering actions added to views. We disable the action if
* the view has no CDT content.
*/ */
public abstract class ViewFilterAction extends ViewerFilter implements IViewActionDelegate, IActionDelegate2 { public abstract class ViewFilterAction extends ViewerFilter implements IViewActionDelegate, IActionDelegate2 {
@ -87,10 +94,51 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi
CDebugUIPlugin.getDefault().savePluginPreferences(); CDebugUIPlugin.getDefault().savePluginPreferences();
} }
/* (non-Javadoc) /**
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) * Disable the action if there is no CDT content in the view. There is no
* practical generic way to test that so we have to use view specific tests.
* Currently, we support the Debug and Breakpoints view. Support for other
* views should be added as needed.
*
* Note that because we do this test on a view selection change, there can
* be some edge cases where we'll be enabled even though there is no CDT
* content. Closing those gaps would not be easy, and thus not worth the
* effort as no harm is done by an unintentional enablement.
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* org.eclipse.jface.viewers.ISelection)
*/ */
public void selectionChanged(IAction action, ISelection selection) { public void selectionChanged(IAction action, ISelection selection) {
boolean enable = false;
Object input = getStructuredViewer().getInput();
// Debug view
if (input instanceof ILaunchManager) {
ILaunchManager launchmgr = (ILaunchManager)input;
IDebugTarget[] debugTargets = launchmgr.getDebugTargets();
for (IDebugTarget debugTarget : debugTargets) {
if (debugTarget instanceof ICDebugElement) {
enable = true;
break;
}
}
}
// Breakpoints view
else if (input instanceof IBreakpointManager) {
IBreakpointManager bkptmgr = (IBreakpointManager)input;
IBreakpoint[] bkpts = bkptmgr.getBreakpoints();
for (IBreakpoint bkpt : bkpts) {
if (bkpt instanceof ICBreakpoint) {
enable = true;
break;
}
}
}
// unsupported view; action will always be enabled.
else {
enable = true;
}
fAction.setEnabled(enable);
} }
protected IPreferenceStore getPreferenceStore() { protected IPreferenceStore getPreferenceStore() {