Skip to content

Commit

Permalink
Migrate Refresh Action to Command/Handler framework and support
Browse files Browse the repository at this point in the history
visibility only whne CDT debug is active.

See eclipse-cdt#1034
  • Loading branch information
raghucssit committed Jan 16, 2025
1 parent 8d06425 commit 10b0148
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 124 deletions.
2 changes: 1 addition & 1 deletion debug/org.eclipse.cdt.debug.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=additions">
locationURI="toolbar:org.eclipse.debug.ui.DebugView?endof=togInstStepModeGroup">
<command
commandId="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand"
disabledIcon="icons/dlcl16/instr_step.gif"
Expand Down
172 changes: 108 additions & 64 deletions dsf/org.eclipse.cdt.dsf.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,6 @@
</extension>

<extension point="org.eclipse.ui.viewActions">
<!-- Breakpoints View menu contributions -->
<viewContribution
id="org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.update.Refresh"
targetID="org.eclipse.debug.ui.BreakpointView">
<action
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.RefreshActionDelegate"
icon="icons/refresh.gif"
id="org.eclipse.cdt.dsf.debug.ui.breakpoints.viewmodel.update.actions.refresh"
label="%action.refresh.label"
toolbarPath="additions">
</action>
</viewContribution>

<!-- Variables View menu contributions -->
<viewContribution
id="org.eclipse.cdt.dsf.debug.ui.viewmodel.variables.update.Refresh"
targetID="org.eclipse.debug.ui.VariableView">
<action
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.RefreshActionDelegate"
icon="icons/refresh.gif"
id="org.eclipse.cdt.dsf.debug.ui.variables.viewmodel.update.actions.refresh"
label="%action.refresh.label"
toolbarPath="additions">
</action>
</viewContribution>

<!-- Registers View menu contributions -->
<viewContribution
id="org.eclipse.cdt.dsf.debug.ui.viewmodel.registers.update.Refresh"
targetID="org.eclipse.debug.ui.RegisterView">
<action
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.RefreshActionDelegate"
icon="icons/refresh.gif"
id="org.eclipse.cdt.dsf.debug.ui.registers.viewmodel.update.actions.refresh"
label="%action.refresh.label"
toolbarPath="additions">
</action>
</viewContribution>

<!-- Expressions View menu contributions -->
<viewContribution
id="org.eclipse.cdt.dsf.debug.ui.viewmodel.expressions.update.Refresh"
targetID="org.eclipse.debug.ui.ExpressionView">
<action
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.RefreshActionDelegate"
icon="icons/refresh.gif"
id="org.eclipse.cdt.dsf.debug.ui.expressions.viewmodel.update.actions.refresh"
label="%action.refresh.label"
toolbarPath="additions">
</action>
</viewContribution>

<!-- Debug View menu contributions -->
<viewContribution
id="org.eclipse.cdt.dsf.debug.ui.viewmodel.debugview.update.Refresh"
targetID="org.eclipse.debug.ui.DebugView">
<action
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.RefreshActionDelegate"
icon="icons/refresh.gif"
id="org.eclipse.cdt.dsf.debug.ui.debugview.viewmodel.update.actions.refresh"
label="%action.refresh.label"
toolbarPath="additions">
</action>
</viewContribution>
<viewContribution
id="org.eclipse.cdt.debug.ui.disassembly.toolbar"
targetID="org.eclipse.cdt.dsf.debug.ui.disassembly.view">
Expand Down Expand Up @@ -355,6 +291,106 @@
</dynamic>
</menu>
</menuContribution>
<!-- Refresh command for view toolbar -->
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.BreakpointView?after=additions">
<separator
name="refreshGroup"
visible="true">
</separator>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.BreakpointView?after=refreshGroup">
<command
commandId="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh"
icon="icons/refresh.gif"
label="%action.refresh.label"
style="push">
<visibleWhen
checkEnabled="false">
<test
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
</test>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.VariableView?after=additions">
<command
commandId="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh"
icon="icons/refresh.gif"
label="%action.refresh.label"
style="push">
<visibleWhen
checkEnabled="false">
<test
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
</test>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.ExpressionView?after=additions">
<command
commandId="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh"
icon="icons/refresh.gif"
label="%action.refresh.label"
style="push">
<visibleWhen
checkEnabled="false">
<test
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
</test>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.RegisterView?after=additions">
<command
commandId="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh"
icon="icons/refresh.gif"
label="%action.refresh.label"
style="push">
<visibleWhen
checkEnabled="false">
<test
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
</test>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=additions">
<separator
name="placeholder"
visible="true">
</separator>
<separator
name="togInstStepModeGroup">
</separator>
<separator
name="refreshGroup"
visible="true">
</separator>
<command
commandId="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh"
icon="icons/refresh.gif"
label="%action.refresh.label"
style="push">
<visibleWhen
checkEnabled="false">
<test
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
</test>
</visibleWhen>
</command>
</menuContribution>
</extension>

<extension point="org.eclipse.ui.handlers">
Expand Down Expand Up @@ -444,6 +480,10 @@
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.ViewRefreshHandler"
commandId="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh">
</handler>
</extension>
<extension point="org.eclipse.core.expressions.definitions">
<definition id="org.eclipse.cdt.dsf.debug.ui.testIsUpdateModesActionSetActive">
Expand Down Expand Up @@ -635,6 +675,10 @@
description="%command.jumpToMemory.description"
id="org.eclipse.cdt.debug.ui.memory.memorybrowser.jumpToMemory"
name="%command.jumpToMemory.name"/>
<command
id="org.eclipse.cdt.dsf.debug.ui.viewmodel.refresh"
name="%action.refresh.label">
</command>
</extension>

<extension point="org.eclipse.ui.bindings">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions;

import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.VMHandlerUtils;
import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.update.ICachingVMProvider;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;

/**
* Handler that handles the 'Refresh' toolbar contribution item that is present on all debug views.
*
* @author Raghunandana Murthappa
*/
public class ViewRefreshHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart != null && activePart instanceof IViewPart view) {
IVMProvider provider = VMHandlerUtils.getVMProviderForPart(view);
if (provider instanceof ICachingVMProvider) {
((ICachingVMProvider) provider).refresh();
}
}
return IStatus.OK;
}
}

0 comments on commit 10b0148

Please sign in to comment.