mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch 'origin/GP-6323-dragonmacher-program-tabs-focus--SQUASHED'
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -41,4 +41,6 @@ public interface DebuggerProgramLocationActionContext extends ActionContext {
|
||||
Address getAddress();
|
||||
|
||||
CodeUnit getCodeUnit();
|
||||
|
||||
boolean isActiveProgram();
|
||||
}
|
||||
|
||||
@@ -55,4 +55,18 @@ public class DebuggerListingActionContext extends ListingActionContext
|
||||
|
||||
return super.hasSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to signal that this navigatable's program may not be the same as the globally
|
||||
* active program. This is done to signal that this navigatable can supply default context.
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
@Override
|
||||
public boolean isActiveProgram() {
|
||||
// The active program for the debugger listing is the on in the 'main listing'. We cannot
|
||||
// use Navigatable.isConnected() here, since that always returns false for the debugger.
|
||||
DebuggerListingProvider dlp = (DebuggerListingProvider) getComponentProvider();
|
||||
return dlp.isMainListing();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ import javax.swing.event.ChangeListener;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jdom.Element;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.WindowPosition;
|
||||
import docking.*;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.ToggleDockingAction;
|
||||
import docking.action.builder.ToggleActionBuilder;
|
||||
@@ -173,15 +172,15 @@ public class DebuggerListingProvider extends CodeViewerProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void specChanged(LocationTrackingSpec spec) {
|
||||
protected void specChanged(LocationTrackingSpec lts) {
|
||||
if (isMainListing()) {
|
||||
plugin.firePluginEvent(new TrackingChangedPluginEvent(getName(), spec));
|
||||
plugin.firePluginEvent(new TrackingChangedPluginEvent(getName(), lts));
|
||||
}
|
||||
updateTitle();
|
||||
trackingLabel.setText("");
|
||||
trackingLabel.setToolTipText("");
|
||||
trackingLabel.setForeground(Colors.FOREGROUND);
|
||||
trackingSpecChangeListeners.invoke().locationTrackingSpecChanged(spec);
|
||||
trackingSpecChangeListeners.invoke().locationTrackingSpecChanged(lts);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -348,6 +347,8 @@ public class DebuggerListingProvider extends CodeViewerProvider {
|
||||
|
||||
private long countAddressesInIndex;
|
||||
|
||||
private TabContextListener contextListener;
|
||||
|
||||
public DebuggerListingProvider(DebuggerListingPlugin plugin, FormatManager formatManager,
|
||||
boolean isConnected) {
|
||||
super(plugin, formatManager, isConnected);
|
||||
@@ -379,6 +380,9 @@ public class DebuggerListingProvider extends CodeViewerProvider {
|
||||
|
||||
if (isConnected) {
|
||||
traceTabs = new DebuggerTraceTabPanel(plugin);
|
||||
contextListener = new TabContextListener();
|
||||
DockingWindowManager dwm = tool.getWindowManager();
|
||||
dwm.addContextListener(contextListener);
|
||||
}
|
||||
else {
|
||||
traceTabs = null;
|
||||
@@ -1049,4 +1053,44 @@ public class DebuggerListingProvider extends CodeViewerProvider {
|
||||
}
|
||||
return new DebuggerByteSource(tool, current.getView(), current.getTarget(), readsMemTrait);
|
||||
}
|
||||
|
||||
private class TabContextListener implements DockingContextListener {
|
||||
|
||||
@Override
|
||||
public void contextChanged(ActionContext localContext) {
|
||||
|
||||
DockingWindowManager dwm = tool.getWindowManager();
|
||||
DebuggerProgramLocationActionContext defaultContext =
|
||||
(DebuggerProgramLocationActionContext) dwm
|
||||
.getDefaultActionContext(DebuggerProgramLocationActionContext.class);
|
||||
Trace myTrace = null;
|
||||
if (defaultContext != null) {
|
||||
TraceProgramView tpv = defaultContext.getProgram();
|
||||
myTrace = tpv.getTrace();
|
||||
}
|
||||
|
||||
if (!(localContext instanceof DebuggerProgramLocationActionContext dlac)) {
|
||||
|
||||
// Future: We would like to make the debugger be the default context in this case,
|
||||
// but we need a way to have the static and dynamic views to decide who is in charge.
|
||||
// For now, assume it should always be the static non-debugger listing view, which
|
||||
// means making the trace tabs inactive.
|
||||
traceTabs.setActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
TraceProgramView localTraceProgramView = dlac.getProgram();
|
||||
Trace localTrace = localTraceProgramView.getTrace();
|
||||
if (myTrace != localTrace || !dlac.isActiveProgram()) {
|
||||
// A different trace is in the local context; deactivate out tabs.
|
||||
traceTabs.setActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Signal that the trace from our default context is the active trace.
|
||||
traceTabs.setActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user