mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Fixed tools unable to restore Console location information
This commit is contained in:
parent
0792417979
commit
7b5b1fb542
5 changed files with 52 additions and 27 deletions
|
@ -27,8 +27,7 @@ import javax.swing.*;
|
|||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.WindowPosition;
|
||||
import docking.*;
|
||||
import docking.action.*;
|
||||
import docking.dnd.*;
|
||||
import docking.widgets.EventTrigger;
|
||||
|
@ -60,7 +59,9 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
|
|||
implements ProgramLocationListener, ProgramSelectionListener, Draggable, Droppable,
|
||||
ChangeListener, StringSelectionListener, PopupListener {
|
||||
|
||||
private static final String TITLE = "Listing: ";
|
||||
private static final String OLD_NAME = "CodeBrowserPlugin";
|
||||
private static final String NAME = "Listing";
|
||||
private static final String TITLE = NAME + ": ";
|
||||
|
||||
private static final Icon LISTING_FORMAT_EXPAND_ICON =
|
||||
ResourceManager.loadImage("images/field.header.down.png");
|
||||
|
@ -113,11 +114,15 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
|
|||
|
||||
public CodeViewerProvider(CodeBrowserPluginInterface plugin, FormatManager formatMgr,
|
||||
boolean isConnected) {
|
||||
super(plugin.getTool(), "Listing", plugin.getName(), CodeViewerActionContext.class);
|
||||
super(plugin.getTool(), NAME, plugin.getName(), CodeViewerActionContext.class);
|
||||
|
||||
this.plugin = plugin;
|
||||
this.formatMgr = formatMgr;
|
||||
|
||||
// note: the owner has not changed, just the name; remove sometime after version 10
|
||||
String owner = plugin.getName();
|
||||
ComponentProvider.registerProviderNameOwnerChange(OLD_NAME, owner, NAME, owner);
|
||||
|
||||
setConnected(isConnected);
|
||||
setIcon(ResourceManager.loadImage("images/Browser.gif"));
|
||||
if (!isConnected) {
|
||||
|
|
|
@ -23,8 +23,7 @@ import javax.swing.*;
|
|||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.WindowPosition;
|
||||
import docking.*;
|
||||
import docking.action.*;
|
||||
import ghidra.app.services.*;
|
||||
import ghidra.framework.main.ConsoleTextPane;
|
||||
|
@ -42,6 +41,9 @@ import resources.ResourceManager;
|
|||
public class ConsoleComponentProvider extends ComponentProviderAdapter
|
||||
implements ConsoleService, OptionsChangeListener {
|
||||
|
||||
private static final String OLD_NAME = "ConsolePlugin";
|
||||
private static final String NAME = "Console";
|
||||
|
||||
private static final String CONSOLE_GIF = "images/monitor.png";
|
||||
private static final String CLEAR_GIF = "images/erase16.png";
|
||||
private static final String SCROLL_LOCK_GIF = "images/lock.png";
|
||||
|
@ -67,6 +69,9 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
|
|||
public ConsoleComponentProvider(PluginTool tool, String owner) {
|
||||
super(tool, "Console", owner);
|
||||
|
||||
// note: the owner has not changed, just the name; remove sometime after version 10
|
||||
ComponentProvider.registerProviderNameOwnerChange(OLD_NAME, owner, NAME, owner);
|
||||
|
||||
setDefaultWindowPosition(WindowPosition.BOTTOM);
|
||||
setHelpLocation(new HelpLocation(owner, owner));
|
||||
setIcon(ResourceManager.loadImage(CONSOLE_GIF));
|
||||
|
@ -216,7 +221,7 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
|
|||
}
|
||||
|
||||
private ConsoleWord getWordSeparatedByWhitespace(Point p) {
|
||||
int pos = textPane.viewToModel(p);
|
||||
int pos = textPane.viewToModel2D(p);
|
||||
Document doc = textPane.getDocument();
|
||||
int startIndex = pos;
|
||||
int endIndex = pos;
|
||||
|
|
|
@ -34,6 +34,10 @@ import ghidra.util.HelpLocation;
|
|||
|
||||
public class ViewManagerComponentProvider extends ComponentProviderAdapter
|
||||
implements ViewManagerService, ViewChangeListener {
|
||||
|
||||
private static final String OLD_NAME = "ProgramTreePlugin";
|
||||
private static final String NAME = "Program Tree";
|
||||
|
||||
public static final String CURRENT_VIEW = "Current Viewname";
|
||||
|
||||
private ViewPanel viewPanel;
|
||||
|
@ -42,7 +46,7 @@ public class ViewManagerComponentProvider extends ComponentProviderAdapter
|
|||
private String restoredViewName;
|
||||
|
||||
public ViewManagerComponentProvider(PluginTool tool, String name) {
|
||||
super(tool, name, name, ProgramActionContext.class);
|
||||
super(tool, NAME, name, ProgramActionContext.class);
|
||||
viewPanel = new ViewPanel(tool, this);
|
||||
listeners = new ArrayList<>(3);
|
||||
|
||||
|
@ -50,9 +54,25 @@ public class ViewManagerComponentProvider extends ComponentProviderAdapter
|
|||
setHelpLocation(new HelpLocation(getName(), getName()));
|
||||
setDefaultWindowPosition(WindowPosition.LEFT);
|
||||
|
||||
// This provider used to be name ViewManagerPlugin and owned by ViewManagerPlugin so register owner/name change
|
||||
ComponentProvider.registerProviderNameOwnerChange("ViewManagerPlugin", "ViewManagerPlugin",
|
||||
"ProgramTreePlugin", "ProgramTreePlugin");
|
||||
//
|
||||
// Remove the 'name change' calls below some time after version 10. These calls map
|
||||
// this provider to the correct name and owner over the course of 2 renames.
|
||||
//
|
||||
|
||||
// This provider used to be name ViewManagerPlugin and owned by ViewManagerPlugin so
|
||||
// register owner/name change
|
||||
String oldOwner = "ViewManagerPlugin";
|
||||
String oldName = oldOwner;
|
||||
String currentOwner = "ProgramTreePlugin";
|
||||
String intermediateName = currentOwner;
|
||||
ComponentProvider.registerProviderNameOwnerChange(oldName, oldOwner, intermediateName,
|
||||
currentOwner);
|
||||
|
||||
// note: it was a mistake above to name the provider the same as the owner; this update
|
||||
// fixes that
|
||||
String currentName = NAME;
|
||||
ComponentProvider.registerProviderNameOwnerChange(intermediateName, currentOwner,
|
||||
currentName, currentOwner);
|
||||
}
|
||||
|
||||
void serviceAdded(ViewProviderService service) {
|
||||
|
@ -147,8 +167,7 @@ public class ViewManagerComponentProvider extends ComponentProviderAdapter
|
|||
/**
|
||||
* Get the object under the mouse location for the popup
|
||||
*
|
||||
* @param popupPoint point of where the popup will be placed relative to the
|
||||
* popup component.
|
||||
* @param event the mouse event that triggered the popup
|
||||
*/
|
||||
private Object getActivePopupObject(MouseEvent event) {
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import docking.help.HelpService;
|
|||
import docking.widgets.OptionDialog;
|
||||
import docking.widgets.tabbedpane.DockingTabRenderer;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import ghidra.util.Swing;
|
||||
|
||||
/**
|
||||
* Node object for managing one or more components. If more that one managed component
|
||||
|
@ -36,9 +36,6 @@ import ghidra.util.SystemUtilities;
|
|||
*/
|
||||
class ComponentNode extends Node {
|
||||
|
||||
private static final String OLD_LISTING_NAME = "CodeBrowserPlugin";
|
||||
private static final String NEW_LISTING_NAME = "Listing";
|
||||
|
||||
private ComponentPlaceholder top;
|
||||
private List<ComponentPlaceholder> windowPlaceholders;
|
||||
private JComponent comp;
|
||||
|
@ -52,7 +49,7 @@ class ComponentNode extends Node {
|
|||
break;
|
||||
}
|
||||
}
|
||||
SystemUtilities.runSwingLater(() -> {
|
||||
Swing.runLater(() -> {
|
||||
if (top != null) {
|
||||
top.requestFocus();
|
||||
}
|
||||
|
@ -95,12 +92,6 @@ class ComponentNode extends Node {
|
|||
group = ComponentProvider.DEFAULT_WINDOW_GROUP;
|
||||
}
|
||||
|
||||
// TODO remove this in a few major releases after 9.1; this prevents existing tools
|
||||
// from losing layout positioning information due to a recent rename
|
||||
if (OLD_LISTING_NAME.equals(name)) {
|
||||
name = NEW_LISTING_NAME;
|
||||
}
|
||||
|
||||
boolean isActive = Boolean.valueOf(e.getAttributeValue("ACTIVE")).booleanValue();
|
||||
|
||||
long uniqueID = getUniqueID(e, 0);
|
||||
|
|
|
@ -756,9 +756,14 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
|
|||
}
|
||||
|
||||
/**
|
||||
* Register a name and/or owner change to a provider so that old tools can restore those provider windows
|
||||
* to their old position and size. Note you must supply all four arguments. If the name or owner did not
|
||||
* change, use the name or owner that did not change for both the old and new values.
|
||||
* Register a name and/or owner change to a provider so that old tools can restore those
|
||||
* provider windows to their old position and size. Note you must supply all four
|
||||
* arguments. If the name or owner did not change, use the name or owner that did not change
|
||||
* for both the old and new values.
|
||||
*
|
||||
* <p>Note: when you make use of this method, please signal when it is safe to remove
|
||||
* its usage.
|
||||
*
|
||||
* @param oldName the old name of the provider.
|
||||
* @param oldOwner the old owner of the provider.
|
||||
* @param newName the new name of the provider. If the name did not change, use the old name here.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue