mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Fixed bugzilla 260595. Disable the Show Full Paths action when not applicable
This commit is contained in:
parent
fb0cf15e02
commit
89b260739c
3 changed files with 67 additions and 4 deletions
|
@ -910,6 +910,12 @@
|
|||
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
|
||||
menubarPath="cDebugActions"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
|
||||
<enablement>
|
||||
<pluginState
|
||||
value="activated"
|
||||
id="org.eclipse.cdt.debug.ui">
|
||||
</pluginState>
|
||||
</enablement>
|
||||
</action>
|
||||
</viewContribution>
|
||||
<viewContribution
|
||||
|
@ -928,6 +934,12 @@
|
|||
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
|
||||
menubarPath="cDebugActions"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
|
||||
<enablement>
|
||||
<pluginState
|
||||
value="activated"
|
||||
id="org.eclipse.cdt.debug.ui">
|
||||
</pluginState>
|
||||
</enablement>
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.AddEventBreakpointActionDelegate"
|
||||
|
|
|
@ -24,7 +24,10 @@ import org.eclipse.jface.viewers.Viewer;
|
|||
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 {
|
||||
|
||||
|
|
|
@ -10,7 +10,13 @@
|
|||
*******************************************************************************/
|
||||
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.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugElement;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
@ -24,7 +30,8 @@ import org.eclipse.ui.IViewActionDelegate;
|
|||
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 {
|
||||
|
||||
|
@ -87,10 +94,51 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi
|
|||
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) {
|
||||
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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue