Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Refresh Action to Command/Handler framework and support visibility only whne CDT debug is active. #1035

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,44 @@
/*******************************************************************************
* Copyright (c) 2025 Advantest Europe GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Raghunandana Murthappa
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions;
raghucssit marked this conversation as resolved.
Show resolved Hide resolved

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 instanceof IViewPart view) {
IVMProvider provider = VMHandlerUtils.getVMProviderForPart(view);
if (provider instanceof ICachingVMProvider cachingVmProvider) {
cachingVmProvider.refresh();
}
}
return IStatus.OK;
}
}
Loading