GT-3495 - Refactor tool hierarchy to remove old 'Tool'

GT-3495 - GT-3495 - Refactor tool hierarchy to rename DockingTool to
Tool
This commit is contained in:
dragonmacher 2020-01-24 18:17:48 -05:00
parent 5dc7df71b3
commit 0ff6578d2c
92 changed files with 966 additions and 1228 deletions

View file

@ -33,6 +33,7 @@ import ghidra.framework.client.ClientUtil;
import ghidra.framework.client.RepositoryAdapter;
import ghidra.framework.model.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.LockException;
import ghidra.util.*;
import ghidra.util.exception.NotFoundException;
@ -274,6 +275,8 @@ class FileActionManager {
/**
* Opens the given project in a task that will show a dialog to block input while opening
* the project in the swing thread.
* @param projectLocator the project locator
* @return true if the project was opened
*/
final boolean openProject(ProjectLocator projectLocator) {
OpenTaskRunnable openRunnable = new OpenTaskRunnable(projectLocator);
@ -285,6 +288,8 @@ class FileActionManager {
/**
* Open an existing project, using a file chooser to specify where the
* existing project folder is stored.
* @param projectLocator the project locator
* @return true if the project was opened
*/
final boolean doOpenProject(ProjectLocator projectLocator) {
String status = "Opened project: " + projectLocator.getName();
@ -346,7 +351,7 @@ class FileActionManager {
/**
* Obtain domain objects from files and lock. If unable to lock
* one or more of the files, none are locked and null is returned.
* @param files
* @param files the files
* @return locked domain objects, or null if unable to lock
* all domain objects.
*/
@ -414,8 +419,6 @@ class FileActionManager {
* This method will always save the FrontEndTool and project, but not the data unless
* <tt>confirmClose</tt> is called.
*
* @param confirmClose true if the confirmation dialog should be
* displayed
* @param isExiting true if we are closing the project because
* Ghidra is exiting
* @return false if user cancels the close operation
@ -428,9 +431,9 @@ class FileActionManager {
}
// check for any changes since last saved
Tool[] runningTools = activeProject.getToolManager().getRunningTools();
for (int i = 0; i < runningTools.length; i++) {
if (!runningTools[i].canClose(isExiting)) {
PluginTool[] runningTools = activeProject.getToolManager().getRunningTools();
for (PluginTool runningTool : runningTools) {
if (!runningTool.canClose(isExiting)) {
return false;
}
}
@ -655,7 +658,7 @@ class FileActionManager {
/**
* Checks the list for read-only files; if any are found, pops up
* a dialog for whether to save now or lose changes.
* @param files list of files which correspond to modified
* @param objs list of files which correspond to modified
* domain objects.
* @return true if there are no read only files OR if the user
* wants to lose his changes; false if the user wants to save the

View file

@ -660,9 +660,9 @@ public class FrontEndPlugin extends Plugin
private ToolTemplate getUpToDateTemplate(ToolTemplate template) {
ToolManager toolManager = activeProject.getToolManager();
Tool[] runningTools = toolManager.getRunningTools();
PluginTool[] runningTools = toolManager.getRunningTools();
String templateName = template.getName();
for (Tool runningTool : runningTools) {
for (PluginTool runningTool : runningTools) {
if (runningTool.getName().equals(templateName)) {
return runningTool.getToolTemplate(true);
}
@ -960,8 +960,8 @@ public class FrontEndPlugin extends Plugin
private boolean isToolRunning(ToolTemplate template) {
ToolManager toolManager = activeProject.getToolManager();
Tool[] runningTools = toolManager.getRunningTools();
for (Tool runningTool : runningTools) {
PluginTool[] runningTools = toolManager.getRunningTools();
for (PluginTool runningTool : runningTools) {
if (runningTool.getToolName().equals(template.getName())) {
return true;
}

View file

@ -745,8 +745,8 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
@Override
public boolean canCloseDomainFile(DomainFile df) {
Tool[] tools = getProject().getToolManager().getRunningTools();
for (Tool tool : tools) {
PluginTool[] tools = getProject().getToolManager().getRunningTools();
for (PluginTool tool : tools) {
DomainFile[] files = tool.getDomainFiles();
for (DomainFile domainFile : files) {
if (df == domainFile) {

View file

@ -34,6 +34,7 @@ import ghidra.app.util.GenericHelpTopics;
import ghidra.framework.client.*;
import ghidra.framework.data.ConvertFileSystem;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.remote.User;
import ghidra.framework.store.local.*;
import ghidra.util.*;
@ -456,10 +457,10 @@ public class ProjectInfoDialog extends DialogComponentProvider {
}
private boolean filesAreOpen() {
Tool[] tools = project.getToolManager().getRunningTools();
PluginTool[] tools = project.getToolManager().getRunningTools();
if (tools.length > 0) {
for (Tool tool : tools) {
for (PluginTool tool : tools) {
if (tool.getDomainFiles().length > 0) {
return true;
}

View file

@ -23,12 +23,14 @@ import java.util.Map;
import javax.swing.*;
import docking.DockingUtils;
import ghidra.framework.model.*;
import ghidra.framework.model.ToolTemplate;
import ghidra.framework.model.Workspace;
import ghidra.framework.plugintool.PluginTool;
class RunningToolsPanel extends JPanel {
private JToolBar runningToolbar;
private FrontEndPlugin plugin;
private Map<Tool, ToolButton> runningTools;
private Map<PluginTool, ToolButton> runningTools;
RunningToolsPanel(FrontEndPlugin plugin, Workspace ws) {
super(new BorderLayout(0, 0));
@ -55,12 +57,13 @@ class RunningToolsPanel extends JPanel {
// remove the default etched border
add(runningToolbar, BorderLayout.CENTER);
runningTools = new HashMap<Tool, ToolButton>(WorkspacePanel.TYPICAL_NUM_RUNNING_TOOLS);
runningTools =
new HashMap<PluginTool, ToolButton>(WorkspacePanel.TYPICAL_NUM_RUNNING_TOOLS);
// populate the toolbar if the workspace has running tools
if (ws != null) {
Tool[] tools = ws.getTools();
for (Tool element : tools) {
PluginTool[] tools = ws.getTools();
for (PluginTool element : tools) {
addTool(element);
}
}
@ -73,7 +76,7 @@ class RunningToolsPanel extends JPanel {
return runningToolbar.getPreferredSize();
}
void addTool(Tool runningTool) {
void addTool(PluginTool runningTool) {
ToolButton toolButton =
new ToolButton(plugin, runningTool, runningTool.getToolTemplate(true));
runningToolbar.add(toolButton);
@ -83,7 +86,7 @@ class RunningToolsPanel extends JPanel {
repaint();
}
void removeTool(Tool tool) {
void removeTool(PluginTool tool) {
ToolButton button = runningTools.get(tool);
if (button == null) {
return;
@ -97,13 +100,13 @@ class RunningToolsPanel extends JPanel {
}
// parameter not used
void toolNameChanged(Tool changedTool) {
void toolNameChanged(PluginTool changedTool) {
}
/**
* Update the tool template for the tool button.
*/
void updateToolButton(Tool tool, ToolTemplate template, Icon icon) {
void updateToolButton(PluginTool tool, ToolTemplate template, Icon icon) {
ToolButton button = runningTools.get(tool);
if (button != null) {

View file

@ -307,7 +307,7 @@ class ToolActionManager implements ToolChestChangeListener {
}
// only enable if project has more than 1 running tool
ToolManager tm = project.getToolManager();
Tool[] runningTools = tm.getRunningTools();
PluginTool[] runningTools = tm.getRunningTools();
connectToolsAction.setEnabled(runningTools.length > 1);
}

View file

@ -65,7 +65,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
private FrontEndPlugin plugin;
private ToolTemplate template;
private Tool associatedRunningTool;
private PluginTool associatedRunningTool;
private DefaultToolChangeListener toolChangeListener;
private ToolServices toolServices;
@ -83,7 +83,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
* Construct a tool label that represents a running tool, using the
* default RUNNING_TOOL icon.
*/
ToolButton(FrontEndPlugin plugin, Tool tool, ToolTemplate template) {
ToolButton(FrontEndPlugin plugin, PluginTool tool, ToolTemplate template) {
this(plugin, tool, template, tool.getIconURL());
setHelpLocation("Run_Tool");
}
@ -91,7 +91,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
/**
* Construct a tool label that represents a running tool.
*/
private ToolButton(FrontEndPlugin plugin, Tool tool, ToolTemplate template,
private ToolButton(FrontEndPlugin plugin, PluginTool tool, ToolTemplate template,
ToolIconURL iconURL) {
super(iconURL.getIcon());
this.plugin = plugin;
@ -298,9 +298,9 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
private void addFromToolButton(ToolButton toolButton) {
plugin.setToolButtonTransferable(null);
Tool tool = null;
PluginTool tool = null;
if (associatedRunningTool != null && toolButton.associatedRunningTool != null) {
final Tool t2 = toolButton.associatedRunningTool;
final PluginTool t2 = toolButton.associatedRunningTool;
SwingUtilities.invokeLater(() -> connectTools(associatedRunningTool, t2));
return;
}
@ -309,14 +309,14 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
if (toolButton.associatedRunningTool == null) {
tool = plugin.getActiveWorkspace().runTool(toolButton.template);
accepted = tool.acceptDomainFiles(associatedRunningTool.getDomainFiles());
final Tool t = tool;
final PluginTool t = tool;
SwingUtilities.invokeLater(() -> connectTools(t, associatedRunningTool));
}
else {
tool = plugin.getActiveWorkspace().runTool(template);
accepted = tool.acceptDomainFiles(toolButton.associatedRunningTool.getDomainFiles());
final Tool t = tool;
final Tool t2 = toolButton.associatedRunningTool;
final PluginTool t = tool;
final PluginTool t2 = toolButton.associatedRunningTool;
SwingUtilities.invokeLater(() -> connectTools(t, t2));
}
@ -328,7 +328,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
/**
* Connect the tools in both directions.
*/
private void connectTools(Tool t1, Tool t2) {
private void connectTools(PluginTool t1, PluginTool t2) {
ToolManager tm = plugin.getActiveProject().getToolManager();
ToolConnection tc = tm.getConnection(t1, t2);
connectAll(tc);
@ -514,7 +514,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
associatedRunningTool.close();
}
Tool getRunningTool() {
PluginTool getRunningTool() {
return associatedRunningTool;
}
@ -570,7 +570,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
Msg.debug(this, "Found root frame without a GhidraGlassPane registered!");
// try to recover without animation
Tool newTool = plugin.getActiveWorkspace().runTool(template);
PluginTool newTool = plugin.getActiveWorkspace().runTool(template);
openDomainFiles(newTool, domainFiles);
finishedCallback.run();
return;
@ -621,7 +621,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
try {
// cleanup any residual painting effects
toolGlassPane.paintImmediately(toolGlassPane.getBounds());
Tool newTool = plugin.getActiveWorkspace().runTool(template);
PluginTool newTool = plugin.getActiveWorkspace().runTool(template);
openDomainFiles(newTool, domainFiles);
}
finally {
@ -640,7 +640,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
zoomRunner.run();
}
private void openDomainFiles(Tool tool, DomainFile[] domainFiles) {
private void openDomainFiles(PluginTool tool, DomainFile[] domainFiles) {
if (domainFiles == null) {
return;
}

View file

@ -23,6 +23,7 @@ import javax.swing.JPanel;
import docking.DialogComponentProvider;
import ghidra.app.util.GenericHelpTopics;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
/**
@ -39,9 +40,6 @@ class ToolConnectionDialog extends DialogComponentProvider implements WorkspaceC
private JButton connectAllButton;
private JButton disconnectAllButton;
/**
* Constructor
*/
ToolConnectionDialog(FrontEndTool tool, ToolManager toolManager) {
super("Connect Tools", false);
this.frontEndTool = tool;
@ -59,9 +57,6 @@ class ToolConnectionDialog extends DialogComponentProvider implements WorkspaceC
toolManager.addWorkspaceChangeListener(this);
}
/**
* Set the dialog to be visible according to the v param.
*/
void setVisible(boolean v) {
if (v) {
@ -79,27 +74,16 @@ class ToolConnectionDialog extends DialogComponentProvider implements WorkspaceC
}
}
// WorkspaceChangedListener
/**
* Tool was added to the given workspace.
*/
@Override
public void toolAdded(Workspace ws, Tool tool) {
public void toolAdded(Workspace ws, PluginTool tool) {
panel.toolAdded(tool);
}
/**
* Tool was removed from the given workspace.
*/
@Override
public void toolRemoved(Workspace ws, Tool tool) {
public void toolRemoved(Workspace ws, PluginTool tool) {
panel.toolRemoved(tool);
}
/*
* (non-Javadoc)
* @see ghidra.util.bean.GhidraDialog#okCallback()
*/
@Override
protected void okCallback() {
setVisible(false);
@ -117,23 +101,15 @@ class ToolConnectionDialog extends DialogComponentProvider implements WorkspaceC
public void workspaceSetActive(Workspace ws) {
}
/**
* Property change on the workspace.
*/
@Override
public void propertyChange(PropertyChangeEvent event) {
Object eventSource = event.getSource();
if (eventSource instanceof Tool) {
if (eventSource instanceof PluginTool) {
// tool name might have changed
updateDisplay();
}
}
///////////////////////////////////////////////////////////////////
/**
* Update the tool manager object.
*/
void setToolManager(ToolManager tm) {
toolManager.removeWorkspaceChangeListener(this);
toolManager = tm;

View file

@ -27,7 +27,9 @@ import javax.swing.event.ListSelectionListener;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.label.GDLabel;
import docking.widgets.list.GListCellRenderer;
import ghidra.framework.model.*;
import ghidra.framework.model.ToolConnection;
import ghidra.framework.model.ToolManager;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg;
/**
@ -41,20 +43,16 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
private ToolConnectionDialog toolDialog;
private ToolManager toolManager;
private JList<Tool> consumerList; // list of receiver tools
private JList<Tool> producerList; // list of source (of events)
private JList<PluginTool> consumerList; // list of receiver tools
private JList<PluginTool> producerList; // list of source (of events)
private JList<JCheckBox> eventList; // names of events generated by source
private DefaultListModel<Tool> producerModel;
private DefaultListModel<Tool> consumerModel;
private DefaultListModel<PluginTool> producerModel;
private DefaultListModel<PluginTool> consumerModel;
private GCheckBox[] checkboxes;
private String[] eventNames;
private final static String msgSource = "Tool Connection";
/**
* Constructor
* @param myTool plugin tool associated with this connect panel
*/
ToolConnectionPanel(ToolConnectionDialog toolDialog, ToolManager toolManager) {
super();
this.toolDialog = toolDialog;
@ -62,9 +60,6 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
initialize();
}
/**
* ListSelectionListener method to process selection events.
*/
@Override
public void valueChanged(ListSelectionEvent e) {
toolDialog.setStatusText("");
@ -77,9 +72,6 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
processSelection();
}
/**
* Set the tool manager; need to do this if another project is opened.
*/
void setToolManager(ToolManager toolManager) {
this.toolManager = toolManager;
updateDisplay();
@ -91,8 +83,8 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
* added or removed.
*/
void updateDisplay() {
Tool producer = producerList.getSelectedValue();
Tool consumer = consumerList.getSelectedValue();
PluginTool producer = producerList.getSelectedValue();
PluginTool consumer = consumerList.getSelectedValue();
showData();
@ -138,7 +130,7 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
* Tool was added to the workspace; update the display.
* @param tool tool added
*/
void toolAdded(Tool tool) {
void toolAdded(PluginTool tool) {
String[] consumedEvents = tool.getConsumedToolEventNames();
String[] producedEvents = tool.getToolEventNames();
if (consumedEvents.length > 0) {
@ -154,7 +146,7 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
* Tool was removed from a workspace; update the display.
* @param tool tool removed
*/
void toolRemoved(Tool tool) {
void toolRemoved(PluginTool tool) {
int index = producerModel.indexOf(tool);
if (index >= 0) {
producerModel.remove(index);
@ -167,13 +159,10 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
validate();
}
/**
* Interconnect two producers and consumers
*/
void connectAll(boolean connect) {
Tool producer = producerList.getSelectedValue();
Tool consumer = consumerList.getSelectedValue();
PluginTool producer = producerList.getSelectedValue();
PluginTool consumer = consumerList.getSelectedValue();
// clear the event list
eventList.setModel(new DefaultListModel<>());
@ -237,8 +226,8 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
GListCellRenderer.createDefaultCellTextRenderer(tool -> tool.getName()));
consumerList.setCellRenderer(
GListCellRenderer.createDefaultCellTextRenderer(tool -> tool.getName()));
producerModel = (DefaultListModel<Tool>) producerList.getModel();
consumerModel = (DefaultListModel<Tool>) consumerList.getModel();
producerModel = (DefaultListModel<PluginTool>) producerList.getModel();
consumerModel = (DefaultListModel<PluginTool>) consumerList.getModel();
}
private void processMouseClicked(MouseEvent e) {
@ -256,8 +245,8 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
checkboxes[index].setSelected(!selected);
refreshList(checkboxes);
Tool producer = producerList.getSelectedValue();
Tool consumer = consumerList.getSelectedValue();
PluginTool producer = producerList.getSelectedValue();
PluginTool consumer = consumerList.getSelectedValue();
doConnect(producer, consumer, eventNames[index], !selected);
int connectedCount = 0;
@ -270,7 +259,8 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
}
}
private void doConnect(Tool producer, Tool consumer, String eventName, boolean connect) {
private void doConnect(PluginTool producer, PluginTool consumer, String eventName,
boolean connect) {
ToolConnection tc = toolManager.getConnection(producer, consumer);
if (tc.isConnected(eventName) == connect) {
// if already connected
@ -292,13 +282,13 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
private void populateConsumerList() {
consumerModel.removeAllElements();
Tool[] tools = toolManager.getConsumerTools();
PluginTool[] tools = toolManager.getConsumerTools();
Arrays.sort(tools, (t1, t2) -> {
return t1.getName().compareTo(t2.getName());
});
for (Tool tool : tools) {
for (PluginTool tool : tools) {
consumerModel.addElement(tool);
}
if (tools.length == 0) {
@ -309,13 +299,13 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
private void populateProducerList() {
producerModel.removeAllElements();
Tool[] tools = toolManager.getProducerTools();
PluginTool[] tools = toolManager.getProducerTools();
Arrays.sort(tools, (t1, t2) -> {
return t1.getName().compareTo(t2.getName());
});
for (Tool tool : tools) {
for (PluginTool tool : tools) {
producerModel.addElement(tool);
}
if (tools.length == 0) {
@ -327,13 +317,13 @@ class ToolConnectionPanel extends JPanel implements ListSelectionListener {
// clear the event list
eventList.setModel(new DefaultListModel<>());
Tool producer = producerList.getSelectedValue();
PluginTool producer = producerList.getSelectedValue();
if (producer == null) {
toolDialog.setStatusText("Please select an Event Producer");
return;
}
Tool consumer = consumerList.getSelectedValue();
PluginTool consumer = consumerList.getSelectedValue();
if (consumer == null) {
toolDialog.setStatusText("Please select an Event Consumer");
return;

View file

@ -28,6 +28,7 @@ import docking.help.HelpService;
import docking.widgets.combobox.GComboBox;
import docking.widgets.dialogs.InputDialog;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.exception.DuplicateNameException;
@ -87,7 +88,7 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
* Tool was removed from the given workspace.
*/
@Override
public void toolRemoved(Workspace ws, Tool tool) {
public void toolRemoved(Workspace ws, PluginTool tool) {
removeTool(ws.getName(), tool);
plugin.getToolActionManager().enableConnectTools();
}
@ -96,7 +97,7 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
* Tool was added to the given workspace.
*/
@Override
public void toolAdded(Workspace ws, Tool tool) {
public void toolAdded(Workspace ws, PluginTool tool) {
addTool(ws.getName(), tool);
plugin.getToolActionManager().enableConnectTools();
}
@ -192,13 +193,13 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
// if this is a change in a tool, update the running tools panel
// containing the tool
Object eventSource = event.getSource();
if (eventSource instanceof Tool) {
Tool tool = (Tool) eventSource;
if (eventSource instanceof PluginTool) {
PluginTool tool = (PluginTool) eventSource;
ToolTemplate template = tool.getToolTemplate(true);
Icon icon = tool.getIconURL().getIcon();
String workspaceName = activeWorkspace.getName();
RunningToolsPanel rtp = runningToolsMap.get(workspaceName);
if (eventPropertyName.equals(Tool.TOOL_NAME_PROPERTY)) {
if (eventPropertyName.equals(PluginTool.TOOL_NAME_PROPERTY)) {
rtp.toolNameChanged(tool);
}
else {
@ -210,6 +211,7 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
/**
* called whenever the active project changes or is being set for
* the first time
* @param project the project
*/
void setActiveProject(Project project) {
// clear state from previous project
@ -233,8 +235,8 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
ToolManager toolManager = project.getToolManager();
toolManager.addWorkspaceChangeListener(this);
Tool[] tools = toolManager.getRunningTools();
for (Tool tool : tools) {
PluginTool[] tools = toolManager.getRunningTools();
for (PluginTool tool : tools) {
tool.addPropertyChangeListener(this);
}
@ -247,10 +249,7 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
initProjectState(activeProject);
}
/**
* add a running tool to the panel
*/
void addTool(String workspaceName, Tool runningTool) {
void addTool(String workspaceName, PluginTool runningTool) {
RunningToolsPanel rtp = runningToolsMap.get(workspaceName);
if (rtp != null) {
rtp.addTool(runningTool);
@ -418,8 +417,9 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
}
/**
* cause the specified workspace to be the active one
* Cause the specified workspace to be the active one
* NOTE: this workspace must already be known to the ToolManager
* @param ws the workspace
*/
void setActiveWorkspace(Workspace ws) {
chooseWorkspace(ws.getName());
@ -452,7 +452,7 @@ class WorkspacePanel extends JPanel implements WorkspaceChangeListener {
setBorder(INACTIVE_BORDER);
}
private void removeTool(String workspaceName, Tool tool) {
private void removeTool(String workspaceName, PluginTool tool) {
RunningToolsPanel rtp = runningToolsMap.get(workspaceName);
if (rtp != null) {
rtp.removeTool(tool);

View file

@ -24,6 +24,7 @@ import ghidra.framework.main.AppInfo;
import ghidra.framework.main.datatable.ProjectDataActionContext;
import ghidra.framework.main.datatable.ProjectDataContextAction;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HTMLUtilities;
import ghidra.util.HelpLocation;
@ -58,7 +59,7 @@ public class ProjectDataOpenToolAction extends ProjectDataContextAction {
Workspace activeWorkspace = toolManager.getActiveWorkspace();
ToolTemplate template = toolChest.getToolTemplate(toolName);
Tool newTool = activeWorkspace.runTool(template);
PluginTool newTool = activeWorkspace.runTool(template);
DomainFile[] files = fileList.toArray(new DomainFile[fileList.size()]);
newTool.acceptDomainFiles(files);

View file

@ -122,8 +122,8 @@ public abstract class VersionControlAction extends DomainFileProviderContextActi
*/
boolean canCloseDomainFile(DomainFile df) {
Project project = tool.getProject();
Tool[] tools = project.getToolManager().getRunningTools();
for (Tool t : tools) {
PluginTool[] tools = project.getToolManager().getRunningTools();
for (PluginTool t : tools) {
DomainFile[] files = t.getDomainFiles();
for (DomainFile domainFile : files) {
if (df == domainFile) {

View file

@ -1,221 +0,0 @@
/* ###
* IP: GHIDRA
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.framework.model;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import org.jdom.Element;
import docking.DockingTool;
import docking.util.image.ToolIconURL;
import ghidra.framework.plugintool.PluginEvent;
/**
*
* A Tool represents a collection of Plugins that are the basic building
* blocks. The plugins cooperate with one another to achieve certain
* functionality. The tool interface defines methods called by the
* Project that manages the tools.
*/
public interface Tool extends DockingTool, ToolListener {
/**
* Name of the property for the tool name.
*/
public final static String TOOL_NAME_PROPERTY = "ToolName";
/**
* Name of the property for the tool icon.
*/
public final static String ICON_PROPERTY_NAME = "Icon";
/**
* Name of the property for the description of the tool.
*/
public final static String DESCRIPTION_PROPERTY_NAME = "Description";
/**
* Name of the property for the number of plugins the tool has.
*/
public final static String PLUGIN_COUNT_PROPERTY_NAME = "PluginCount";
/**
* Tells the tool to stop functioning and release its resources.
* The tool should dispose of all its windows and other resources.
*/
public void exit();
/**
* Can this tool be closed?
* @param isExiting true if all of Ghidra is closing, false if just this tool is closing.
* @return true if the tool is in a state that it can be closed.
*/
public boolean canClose(boolean isExiting);
/**
* Can the domain File be closed?
* <br>Note: This forces plugins to terminate any tasks they have running for the
* indicated domain object and apply any unsaved data to the domain object. If they can't do
* this or the user cancels then this returns false.
* @return false any of the plugins reports that the domain object
* should not be closed
*/
public boolean canCloseDomainFile(DomainFile domainFile);
/**
* Fire the plugin event by notifying the event manager which
* calls the listeners.
* @param event plugin event
*/
public void firePluginEvent(PluginEvent event);
/**
* Returns the name associated with the tool
*/
public String getToolName();
/**
* Sets the type name of the tool.
* @param toolName the basename to use when setting the tool's name
* @exception PropertyVetoException thrown if a VetoableChangeListener
* rejects the change
*/
public void setToolName(String toolName) throws PropertyVetoException;
/**
* Associates a unique(within the active project) name to a tool instance.
* @param instanceName unique tool instance name
*/
public void putInstanceName(String instanceName);
/**
* Returns the tool's unique name.
*/
public String getInstanceName();
/**
* Returns the names of all the possible ToolEvents that this
* tool might generate. Used by the ConnectionManager to connect
* tools together.
*/
public String[] getToolEventNames();
/**
* Returns a list of eventNames that this Tool is interested in.
*/
public String[] getConsumedToolEventNames();
/**
* When the user drags a data file onto a tool, an event will be fired
* that the tool will respond to by accepting the data.
*
* @param data the data to be used by the running tool
*/
public boolean acceptDomainFiles(DomainFile[] data);
/**
* Get the domain files that this tool currently has open.
*/
public DomainFile[] getDomainFiles();
/**
* Adds a ToolListener to be notified for any of a Tool's ToolEvents.
* The listener will be notified of any events that this tool generates.
*
* @param listener ToolListener to be added to receive all events
*/
public void addToolListener(ToolListener listener);
/**
* Removes a ToolListener from receiving any event generated by this Tool.
* The tool will still recieve specific events that it has registered for.
*
* @param listener The ToolListener to be removed from receiving all events.
*/
public void removeToolListener(ToolListener listener);
/**
* Add property change listener.
*/
public void addPropertyChangeListener(PropertyChangeListener l);
/**
* Remove property change listener.
*/
public void removePropertyChangeListener(PropertyChangeListener l);
/**
* Get the classes of the data types that this tool supports,
* i.e., what data types can be dropped onto this tool.
*/
public Class<?>[] getSupportedDataTypes();
/**
* Tells tool to write its data state from the given output stream.
* @param isTransactionState true if saving the toolstate is for a potential undo/redo
* (database transaction)
*/
public Element saveDataStateToXml(boolean isTransactionState);
/**
* Tells tool to read its data state from the given input stream.
* @param element XML data state
*/
public void restoreDataStateFromXml(Element element);
/**
* Set the icon for this tool.
* @param iconURL icon location
*/
public void setIconURL(ToolIconURL iconURL);
/**
* Get the url for the icon that this tool is using.
*/
public ToolIconURL getIconURL();
/**
* Returns a ToolTemplate for this Tool that describes the state of the tool.
* @return a ToolTemplate for this Tool that describes the state of the tool.
*/
public ToolTemplate getToolTemplate(boolean includeConfigState);
/**
* Save the tool and return its state as a ToolTemplate. Forces a complete
* regeneration of the tool template.
* @return a toolTemplate for this tool.
*/
public ToolTemplate saveToolToToolTemplate();
/**
* Saves the tool's Docking Window layout and positioning information to an XML element.
* @return the element containing the DockingWindow's layout information.
*/
public Element saveWindowingDataToXml();
/**
* Restores the tool's Docking Window layout and positioning information from an XML element.
* @param windowData the element containing the information.
*/
public void restoreWindowingDataFromXml(Element windowData);
/**
* Returns true if this tool should save its data, based upon its changed state and the state
* of Ghidra's saving method.
* @return true if this tool should save its data
*/
public boolean shouldSave();
public Element saveToXml(boolean includeConfigState);
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,60 +15,63 @@
*/
package ghidra.framework.model;
import ghidra.framework.plugintool.PluginTool;
/**
* Represents a connection between a producer tool and a
* consumer tool.
*/
public interface ToolConnection {
/**
* Get the tool that produces an event.
*/
public Tool getProducer();
/**
* Get the tool that consumes an event.
*/
public Tool getConsumer();
/**
* Get the tool that produces an event
* @return the tool
*/
public PluginTool getProducer();
/**
* Get the list of event names that is an intersection
* between what the producer produces and what the
* consumers consumes.
*
* @return an array of event names
*/
public String[] getEvents();
* Get the tool that consumes an event
* @return the tool
*/
public PluginTool getConsumer();
/**
* Connect the tools for the given event name.
*
* @param eventName name of event to connect
*
* @throws IllegalArgumentException if eventName is not valid for this
/**
* Get the list of event names that is an intersection
* between what the producer produces and what the
* consumers consumes.
*
* @return an array of event names
*/
public String[] getEvents();
/**
* Connect the tools for the given event name.
*
* @param eventName name of event to connect
*
* @throws IllegalArgumentException if eventName is not valid for this
* producer/consumer pair.
*/
public void connect(String eventName);
*/
public void connect(String eventName);
/**
* Break the connection between the tools for the
* given event name.
*
* @param eventName name of event to disconnect
*
* @throws IllegalArgumentException if eventName is not valid for this
* producer/consumer pair.
*/
public void disconnect(String eventName);
* Break the connection between the tools for the
* given event name.
*
* @param eventName name of event to disconnect
*
* @throws IllegalArgumentException if eventName is not valid for this
* producer/consumer pair.
*/
public void disconnect(String eventName);
/**
* Return whether the tools are connected for the
* given event name.
*
/**
* Return whether the tools are connected for the
* given event name.
*
* @param eventName name of event to check
* @return true if the tools are connected by eventName.
*/
public boolean isConnected(String eventName);
public boolean isConnected(String eventName);
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,7 @@
*/
package ghidra.framework.model;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.exception.DuplicateNameException;
/**
@ -29,106 +29,103 @@ import ghidra.util.exception.DuplicateNameException;
*/
public interface ToolManager {
/**
* The name to use for a new unnamed workspace; used by the Ghidra
* Project Window when the user creates a new workspace.
*/
public final static String DEFAULT_WORKSPACE_NAME = "Workspace";
/**
* Property used when sending the change event when a workspace name is
* changed.
*/
public final static String WORKSPACE_NAME_PROPERTY = "WorkspaceName";
/**
* Get the connection object for the producer and consumer
* tools.
*
* @param producer tool that is producing the tool event
* @param consumer tool that is consuming the tool event
*/
public ToolConnection getConnection(Tool producer, Tool consumer);
/**
* Get a list of tools that produce at least one tool event.
*
* @return zero-length array if no tool produces any events
*/
public Tool[] getProducerTools();
/**
* Get a list of tools that consume at least one tool event.
*
* @return zero-length array if no tool consumes any events
*/
public Tool[] getConsumerTools();
/**
* Get a list running tools across all workspaces.
*
* @return zero-length array if there are no running tools.
*/
public Tool[] getRunningTools();
/**
* Create a workspace with the given name.
*
* @param name name of workspace
*
* @throws DuplicateNameException if a workspace with this
* name already exists.
*/
public Workspace createWorkspace(String name) throws DuplicateNameException;
/**
* Remove the workspace.
*
* @param ws workspace to remove
*/
public void removeWorkspace(Workspace ws);
/**
* Get list of known workspaces.
*
* @return an array of known workspaces
*/
public Workspace[] getWorkspaces();
/**
* Get the active workspace
*
* @return the active workspace
*/
public Workspace getActiveWorkspace();
/**
* The name to use for a new unnamed workspace; used by the Ghidra
* Project Window when the user creates a new workspace.
*/
public final static String DEFAULT_WORKSPACE_NAME = "Workspace";
/**
* Add the listener that will be notified when a tool is added
* or removed.
*
* @param listener workspace listener to add
*/
public void addWorkspaceChangeListener(WorkspaceChangeListener listener);
/**
* Remove the workspace listener.
*
* @param l workspace listener to remove
*/
public void removeWorkspaceChangeListener(WorkspaceChangeListener l);
* Property used when sending the change event when a workspace name is
* changed.
*/
public final static String WORKSPACE_NAME_PROPERTY = "WorkspaceName";
/**
* Get the connection object for the producer and consumer tools
*
* @param producer tool that is producing the tool event
* @param consumer tool that is consuming the tool event
* @return the connection
*/
public ToolConnection getConnection(PluginTool producer, PluginTool consumer);
/**
* Get a list of tools that produce at least one tool event.
*
* @return zero-length array if no tool produces any events
*/
public PluginTool[] getProducerTools();
/**
* Get a list of tools that consume at least one tool event.
*
* @return zero-length array if no tool consumes any events
*/
public PluginTool[] getConsumerTools();
/**
* Get a list running tools across all workspaces.
*
* @return zero-length array if there are no running tools.
*/
public PluginTool[] getRunningTools();
/**
* Create a workspace with the given name.
*
* @param name name of workspace
* @return the workspace
* @throws DuplicateNameException if a workspace with this name already exists
*/
public Workspace createWorkspace(String name) throws DuplicateNameException;
/**
* Remove the workspace.
*
* @param ws workspace to remove
*/
public void removeWorkspace(Workspace ws);
/**
* Get list of known workspaces.
*
* @return an array of known workspaces
*/
public Workspace[] getWorkspaces();
/**
* Get the active workspace
*
* @return the active workspace
*/
public Workspace getActiveWorkspace();
/**
* Add the listener that will be notified when a tool is added
* or removed.
*
* @param listener workspace listener to add
*/
public void addWorkspaceChangeListener(WorkspaceChangeListener listener);
/**
* Remove the workspace listener.
*
* @param l workspace listener to remove
*/
public void removeWorkspaceChangeListener(WorkspaceChangeListener l);
/**
* Removes all connections involving tool
* @param tool tool for which to remove all connections
*/
public void disconnectTool(Tool tool);
public void disconnectTool(PluginTool tool);
/**
* A configuration change was made to the tool; a plugin was added
* or removed.
* @param tool tool that changed
*/
public void toolChanged(Tool tool);
public void toolChanged(PluginTool tool);
}

View file

@ -19,6 +19,7 @@ import java.io.*;
import java.util.Set;
import ghidra.framework.plugintool.PluginEvent;
import ghidra.framework.plugintool.PluginTool;
/**
* Services that the Tool uses.
@ -33,7 +34,7 @@ public interface ToolServices {
*
* @param tool tool that is closing
*/
public void closeTool(Tool tool);
public void closeTool(PluginTool tool);
/**
* Saves the tool's configuration in the standard
@ -41,7 +42,7 @@ public interface ToolServices {
*
* @param tool tool to save.
*/
public void saveTool(Tool tool);
public void saveTool(PluginTool tool);
/**
* Save the tool to the given location on the local file system.
@ -54,7 +55,8 @@ public interface ToolServices {
public File exportTool(ToolTemplate tool) throws FileNotFoundException, IOException;
/**
* Get the tool chest for the project.
* Get the tool chest for the project
* @return the tool chest
*/
public ToolChest getToolChest();
@ -68,7 +70,7 @@ public interface ToolServices {
* @param domainFile open this file in the found/created tool.
* @param event invoke this event on the found/created tool
*/
public void displaySimilarTool(Tool tool, DomainFile domainFile, PluginEvent event);
public void displaySimilarTool(PluginTool tool, DomainFile domainFile, PluginEvent event);
/**
* Returns the default tool template used to open the tool. Here <b>default</b> means the
@ -83,6 +85,7 @@ public interface ToolServices {
/**
* Returns a set of tools that can open the given domain file class.
* @param domainClass The domain file class type for which to get tools
* @return the tools
*/
public Set<ToolTemplate> getCompatibleTools(Class<? extends DomainObject> domainClass);
@ -90,6 +93,7 @@ public interface ToolServices {
* Returns the {@link ToolAssociationInfo associations}, which describe content
* types and the tools used to open them, for all content types known to the system.
*
* @return the associations
* @see #setContentTypeToolAssociations(Set)
*/
public Set<ToolAssociationInfo> getContentTypeToolAssociations();
@ -107,24 +111,27 @@ public interface ToolServices {
* Launch the default tool; if domainFile is not null, this file will
* be opened in the tool.
* @param domainFile the file to open; may be null
* @return the tool
*/
public Tool launchDefaultTool(DomainFile domainFile);
public PluginTool launchDefaultTool(DomainFile domainFile);
/**
* Launch the tool with the given name
* @param toolName name of the tool to launch
* @param domainFile the file to open; may be null
* @return the tool
*/
public Tool launchTool(String toolName, DomainFile domainFile);
public PluginTool launchTool(String toolName, DomainFile domainFile);
/**
* Add a listener that will be notified when the default tool
* specification changes.
* Add a listener that will be notified when the default tool specification changes
* @param listener the listener
*/
public void addDefaultToolChangeListener(DefaultToolChangeListener listener);
/**
* Remove the listener.
* Remove the listener
* @param listener the listener
*/
public void removeDefaultToolChangeListener(DefaultToolChangeListener listener);
@ -132,13 +139,13 @@ public interface ToolServices {
* Return array of running tools
* @return array of Tools
*/
public Tool[] getRunningTools();
public PluginTool[] getRunningTools();
/**
* Returns true if this tool should be saved base on the state of other runnings instances of
* Returns true if this tool should be saved base on the state of other running instances of
* the same tool
* @param tool the tool to check for saving
* @return true if the tool should be saved
*/
public boolean canAutoSave(Tool tool);
public boolean canAutoSave(PluginTool tool);
}

View file

@ -20,6 +20,7 @@ import javax.swing.ImageIcon;
import org.jdom.Element;
import docking.util.image.ToolIconURL;
import ghidra.framework.plugintool.PluginTool;
/**
* Configuration of a tool that knows how to create tools.
@ -51,7 +52,8 @@ public interface ToolTemplate {
void setName(String name);
/**
* Get the iconURL for this tool template.
* Get the iconURL for this tool template
* @return the iconURL for this tool template
*/
ToolIconURL getIconURL();
@ -88,7 +90,7 @@ public interface ToolTemplate {
* @param project the project in which the tool will be living.
* @return a new tool for this template implementation.
*/
public Tool createTool(Project project);
public PluginTool createTool(Project project);
/**
* This returns the XML element that represents the tool part of the overall XML hierarchy.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,7 @@
*/
package ghidra.framework.model;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.exception.DuplicateNameException;
/**
@ -24,47 +24,49 @@ import ghidra.util.exception.DuplicateNameException;
*/
public interface Workspace {
/**
* Get the workspace name.
*/
public String getName();
/**
* Get the workspace name
* @return the name
*/
public String getName();
/**
* Get the running tools in the workspace.
*
* @return list of running tools or zero-length array if there are no tools in the workspace
*/
public Tool[] getTools();
/**
* Get the running tools in the workspace.
*
* @return list of running tools or zero-length array if there are no tools in the workspace
*/
public PluginTool[] getTools();
/**
* Launch an empty tool.
* @return name of empty tool that is launched.
*/
public Tool createTool();
/**
* Launch an empty tool.
* @return name of empty tool that is launched.
*/
public PluginTool createTool();
/**
* Run the tool specified by the tool template object.
* @return launched tool that is now running.
*/
public Tool runTool(ToolTemplate template);
/**
* Run the tool specified by the tool template object.
* @param template the template
* @return launched tool that is now running.
*/
public PluginTool runTool(ToolTemplate template);
/**
* Rename this workspace.
*
* @param newName new workspace name
*
* @throws DuplicateNameException if newName is already the
* name of a workspace.
*/
public void setName(String newName)
throws DuplicateNameException;
/**
* Rename this workspace.
*
* @param newName new workspace name
*
* @throws DuplicateNameException if newName is already the
* name of a workspace.
*/
public void setName(String newName)
throws DuplicateNameException;
/**
* Set this workspace to be the active workspace, i.e.,
* all tools become visible.
* The currently active workspace becomes inactive, and
* this workspace becomes active.
*/
public void setActive();
/**
* Set this workspace to be the active workspace, i.e.,
* all tools become visible.
* The currently active workspace becomes inactive, and
* this workspace becomes active.
*/
public void setActive();
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,41 +17,43 @@ package ghidra.framework.model;
import java.beans.PropertyChangeListener;
import ghidra.framework.plugintool.PluginTool;
/**
* Listener that is notified when a tool is added or removed from a
* workspace, or when workspace properties change.
*/
public interface WorkspaceChangeListener extends PropertyChangeListener {
/**
* Notification that a tool was added to the given workspace.
* @param ws workspace the affected workspace
* @param tool tool that was added
*/
public void toolAdded(Workspace ws, Tool tool);
/**
* Notification that a tool was added to the given workspace.
* @param ws workspace the affected workspace
* @param tool tool that was added
*/
public void toolAdded(Workspace ws, PluginTool tool);
/**
* Notification that a tool was removed from the given workspace.
* @param ws workspace the affected workspace
* @param tool tool that was removed from the workspace
*/
public void toolRemoved(Workspace ws, Tool tool);
/**
* Notification that a tool was removed from the given workspace.
* @param ws workspace the affected workspace
* @param tool tool that was removed from the workspace
*/
public void toolRemoved(Workspace ws, PluginTool tool);
/**
* Notification that the given workspace was added by the ToolManager.
* @param ws workspace the affected workspace
*/
public void workspaceAdded(Workspace ws);
/**
* Notification that the given workspace was added by the ToolManager.
* @param ws workspace the affected workspace
*/
public void workspaceAdded(Workspace ws);
/**
* Notification that the given workspace was removed by the ToolManager.
* @param ws workspace the affected workspace
*/
public void workspaceRemoved(Workspace ws);
/**
* Notification that the given workspace was removed by the ToolManager.
* @param ws workspace the affected workspace
*/
public void workspaceRemoved(Workspace ws);
/**
* Notification that the given workspace is the current one.
* @param ws workspace the affected workspace
*/
public void workspaceSetActive(Workspace ws);
/**
* Notification that the given workspace is the current one.
* @param ws workspace the affected workspace
*/
public void workspaceSetActive(Workspace ws);
}

View file

@ -16,11 +16,11 @@
package ghidra.framework.plugintool;
import docking.ComponentProvider;
import docking.DockingTool;
import docking.Tool;
/**
* Extends the {@link ComponentProvider} to fit into the Plugin architecture by taking in a
* {@link PluginTool} which extends {@link DockingTool}. Most implementers will want to extend
* {@link PluginTool} which extends {@link Tool}. Most implementers will want to extend
* this class instead of the ComponentProvider class because they will want to access the extra
* methods provided by PluginTool over DockingTool without having to cast the dockingTool variable.
*/

View file

@ -73,7 +73,24 @@ import ghidra.util.task.*;
* <p>The PluginTool also manages tasks that run in the background, and options used by the plugins.
*
*/
public abstract class PluginTool extends AbstractDockingTool implements Tool {
public abstract class PluginTool extends AbstractDockingTool {
/**
* Name of the property for the tool name.
*/
public final static String TOOL_NAME_PROPERTY = "ToolName";
/**
* Name of the property for the tool icon.
*/
public final static String ICON_PROPERTY_NAME = "Icon";
/**
* Name of the property for the description of the tool.
*/
public final static String DESCRIPTION_PROPERTY_NAME = "Description";
/**
* Name of the property for the number of plugins the tool has.
*/
public final static String PLUGIN_COUNT_PROPERTY_NAME = "PluginCount";
private static final String DOCKING_WINDOWS_ON_TOP = "Docking Windows On Top";
@ -170,6 +187,10 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
installHomeButton();
}
protected PluginTool() {
// non-public constructor for stub subclasses
}
public abstract PluginClassManager getPluginClassManager();
/**
@ -368,43 +389,36 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
winMgr.setDefaultComponent(provider);
}
@Override
public ToolTemplate getToolTemplate(boolean includeConfigState) {
throw new UnsupportedOperationException(
"You cannot create templates for generic tools: " + getClass().getName());
}
@Override
public ToolTemplate saveToolToToolTemplate() {
setConfigChanged(false);
optionsMgr.removeUnusedOptions();
return getToolTemplate(true);
}
@Override
public Element saveWindowingDataToXml() {
throw new UnsupportedOperationException(
"You cannot persist generic tools: " + getClass().getName());
}
@Override
public void restoreWindowingDataFromXml(Element windowData) {
throw new UnsupportedOperationException(
"You cannot persist generic tools: " + getClass().getName());
}
@Override
public boolean acceptDomainFiles(DomainFile[] data) {
return pluginMgr.acceptData(data);
}
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
propertyChangeMgr.addPropertyChangeListener(l);
}
@Override
public void addToolListener(ToolListener listener) {
eventMgr.addToolListener(listener);
}
@ -417,7 +431,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
return eventMgr.hasToolListeners();
}
@Override
public void exit() {
dispose();
}
@ -458,17 +471,14 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
executingTaskListeners.clear();
}
@Override
public void firePluginEvent(PluginEvent event) {
eventMgr.fireEvent(event);
}
@Override
public String[] getConsumedToolEventNames() {
return eventMgr.getEventsConsumed();
}
@Override
public DomainFile[] getDomainFiles() {
return pluginMgr.getData();
}
@ -478,12 +488,10 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
return iconURL.getIcon();
}
@Override
public ToolIconURL getIconURL() {
return iconURL;
}
@Override
public String getInstanceName() {
return instanceName;
}
@ -493,22 +501,18 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
return fullName;
}
@Override
public Class<?>[] getSupportedDataTypes() {
return pluginMgr.getSupportedDataTypes();
}
@Override
public String[] getToolEventNames() {
return eventMgr.getEventsProduced();
}
@Override
public String getToolName() {
return toolName;
}
@Override
public void putInstanceName(String newInstanceName) {
this.instanceName = newInstanceName;
if (instanceName.length() == 0) {
@ -520,24 +524,20 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
updateTitle();
}
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
propertyChangeMgr.removePropertyChangeListener(l);
}
@Override
public void removeToolListener(ToolListener listener) {
eventMgr.removeToolListener(listener);
}
@Override
public void restoreDataStateFromXml(Element root) {
pluginMgr.restoreDataStateFromXml(root);
setConfigChanged(false);
}
@Override
public Element saveDataStateToXml(boolean savingProject) {
return pluginMgr.saveDataStateToXml(savingProject);
}
@ -570,7 +570,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
return hasErrors;
}
@Override
public Element saveToXml(boolean includeConfigState) {
Element root = new Element("TOOL");
@ -591,7 +590,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
}
}
@Override
public void setIconURL(ToolIconURL newIconURL) {
if (newIconURL == null) {
throw new NullPointerException("iconURL cannot be null.");
@ -609,7 +607,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
winMgr.setIcon(newValue);
}
@Override
public void setToolName(String name) {
String oldName = toolName;
toolName = name;
@ -623,7 +620,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
propertyChangeMgr.firePropertyChange(TOOL_NAME_PROPERTY, oldName, toolName);
}
@Override
public void processToolEvent(PluginEvent toolEvent) {
eventMgr.processToolEvent(toolEvent);
}
@ -718,6 +714,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
* Get the options for the given category name; if no options exist with
* the given name, then one is created.
*/
@Override
public ToolOptions getOptions(String categoryName) {
return optionsMgr.getOptions(categoryName);
@ -894,6 +891,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
protected void addExitAction() {
DockingAction exitAction = new DockingAction("Exit Ghidra", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
AppInfo.exitGhidra();
@ -918,6 +916,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
protected void addOptionsAction() {
DockingAction optionsAction = new DockingAction("Edit Options", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
optionsMgr.editOptions();
@ -943,6 +942,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
protected void addSaveToolAction() {
DockingAction saveAction = new DockingAction("Save Tool", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
saveTool();
@ -956,6 +956,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
saveAction.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Save Tool"));
DockingAction saveAsAction = new DockingAction("Save Tool As", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
saveToolAs();
@ -983,6 +984,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
int subGroup = 1;
DockingAction exportToolAction =
new DockingAction("Export Tool", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
dialogMgr.exportTool();
@ -998,6 +1000,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
DockingAction exportDefautToolAction =
new DockingAction("Export Default Tool", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext e) {
dialogMgr.exportDefaultTool();
@ -1016,6 +1019,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
protected void addHelpActions() {
DockingAction action = new DockingAction("About Ghidra", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
DockingWindowManager.showDialog(new AboutDialog());
@ -1035,6 +1039,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
DockingAction userAgreementAction = new DockingAction("User Agreement",
ToolConstants.TOOL_OWNER, KeyBindingType.UNSUPPORTED) {
@Override
public void actionPerformed(ActionContext context) {
DockingWindowManager.showDialog(new UserAgreementDialog(false, false));
@ -1057,6 +1062,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
final ErrorReporter reporter = ErrLogDialog.getErrorReporter();
if (reporter != null) {
action = new DockingAction("Report Bug", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
reporter.report(getToolFrame(), "User Bug Report", null);
@ -1077,6 +1083,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
HelpService help = Help.getHelpService();
action = new DockingAction("Contents", ToolConstants.TOOL_OWNER) {
@Override
public void actionPerformed(ActionContext context) {
help.showHelp(null, false, getToolFrame());
@ -1115,6 +1122,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
* <LI>notify the project tool services that this tool is going away.
* </OL>
*/
@Override
public void close() {
if (canClose(false) && pluginMgr.saveData()) {
@ -1141,7 +1149,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
toolServices.closeTool(this);
}
@Override
public boolean shouldSave() {
return configChangedFlag; // ignore the window layout changes
}
@ -1185,10 +1192,11 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
* <br>Note: This forces plugins to terminate any tasks they have running and
* apply any unsaved data to domain objects or files. If they can't do
* this or the user cancels then this returns false.
*
* @param isExiting whether the tool is exiting
* @return false if this tool has tasks in progress or can't be closed
* since the user has unfinished/unsaved changes.
*/
@Override
public boolean canClose(boolean isExiting) {
if (taskMgr.isBusy()) {
if (isExiting) {
@ -1236,7 +1244,6 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
return pluginMgr.canCloseDomainObject(domainObject);
}
@Override
public boolean canCloseDomainFile(DomainFile domainFile) {
Object consumer = new Object();
DomainObject domainObject = domainFile.getOpenedDomainObject(consumer);
@ -1469,6 +1476,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
//==================================================================================================
private class ToolOptionsListener implements OptionsChangeListener {
@Override
public void optionsChanged(ToolOptions options, String name, Object oldValue,
Object newValue) {
@ -1483,7 +1491,7 @@ public abstract class PluginTool extends AbstractDockingTool implements Tool {
private <T extends Throwable> void checkedRunSwingNow(CheckedRunnable<T> r,
Class<T> exceptionClass) throws T {
AtomicReference<Throwable> caughtException = new AtomicReference<>();
SystemUtilities.runSwingNow(() -> {
Swing.runNow(() -> {
try {
r.run();
}

View file

@ -29,7 +29,6 @@ import org.jdom.output.XMLOutputter;
import docking.framework.*;
import ghidra.framework.*;
import ghidra.framework.model.Tool;
import ghidra.framework.model.ToolServices;
import ghidra.util.Msg;
import ghidra.util.SystemUtilities;
@ -249,12 +248,12 @@ public abstract class StandAloneApplication implements GenericStandAloneApplicat
return new ToolServicesAdapter() {
@Override
public void closeTool(Tool t) {
public void closeTool(PluginTool t) {
System.exit(0);
}
@Override
public void saveTool(Tool saveTool) {
public void saveTool(PluginTool saveTool) {
Element toolElement = saveTool.saveToXml(true);
Element dataStateElement = saveTool.saveDataStateToXml(false);
Element rootElement = new Element("Root");

View file

@ -27,17 +27,17 @@ public class ToolServicesAdapter implements ToolServices {
}
@Override
public boolean canAutoSave(Tool tool) {
public boolean canAutoSave(PluginTool tool) {
return true;
}
@Override
public void closeTool(Tool tool) {
public void closeTool(PluginTool tool) {
// override
}
@Override
public void displaySimilarTool(Tool tool, DomainFile domainFile, PluginEvent event) {
public void displaySimilarTool(PluginTool tool, DomainFile domainFile, PluginEvent event) {
// override
}
@ -62,7 +62,7 @@ public class ToolServicesAdapter implements ToolServices {
}
@Override
public Tool[] getRunningTools() {
public PluginTool[] getRunningTools() {
return null;
}
@ -72,12 +72,12 @@ public class ToolServicesAdapter implements ToolServices {
}
@Override
public Tool launchDefaultTool(DomainFile domainFile) {
public PluginTool launchDefaultTool(DomainFile domainFile) {
return null;
}
@Override
public Tool launchTool(String toolName, DomainFile domainFile) {
public PluginTool launchTool(String toolName, DomainFile domainFile) {
return null;
}
@ -87,7 +87,7 @@ public class ToolServicesAdapter implements ToolServices {
}
@Override
public void saveTool(Tool tool) {
public void saveTool(PluginTool tool) {
// override
}

View file

@ -22,7 +22,9 @@ import javax.swing.ImageIcon;
import org.jdom.Element;
import docking.util.image.ToolIconURL;
import ghidra.framework.model.*;
import ghidra.framework.model.Project;
import ghidra.framework.model.ToolTemplate;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg;
import ghidra.util.NumericUtilities;
@ -46,6 +48,7 @@ public class GhidraToolTemplate implements ToolTemplate {
/**
* Constructor.
* @param root XML element that contains the tool template data
* @param path the path of the template
*/
public GhidraToolTemplate(Element root, String path) {
this.path = path;
@ -208,7 +211,7 @@ public class GhidraToolTemplate implements ToolTemplate {
}
@Override
public Tool createTool(Project project) {
public PluginTool createTool(Project project) {
return new GhidraTool(project, this);
}
}

View file

@ -27,18 +27,18 @@ import docking.DialogComponentProvider;
import docking.widgets.OptionDialog;
import docking.widgets.button.GRadioButton;
import docking.widgets.label.GHtmlLabel;
import ghidra.framework.model.Tool;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HTMLUtilities;
import ghidra.util.layout.VerticalLayout;
public class SelectChangedToolDialog extends DialogComponentProvider {
private final List<Tool> toolList;
private final List<PluginTool> toolList;
private boolean wasCancelled;
private Tool selectedTool;
private PluginTool selectedTool;
public SelectChangedToolDialog(List<Tool> toolList) {
public SelectChangedToolDialog(List<PluginTool> toolList) {
super("Save Tool Changes?", true, false, true, false);
this.toolList = toolList;
@ -87,7 +87,7 @@ public class SelectChangedToolDialog extends DialogComponentProvider {
buttonGroup.add(noneButton);
panel.add(noneButton);
for (final Tool tool : toolList) {
for (final PluginTool tool : toolList) {
GRadioButton radioButton = new GRadioButton(tool.getName());
radioButton.addItemListener(new ItemListener() {
@Override
@ -119,7 +119,7 @@ public class SelectChangedToolDialog extends DialogComponentProvider {
return wasCancelled;
}
Tool getSelectedTool() {
PluginTool getSelectedTool() {
return selectedTool;
}
}

View file

@ -19,8 +19,10 @@ import java.util.*;
import org.jdom.Element;
import ghidra.framework.model.*;
import ghidra.framework.model.ToolConnection;
import ghidra.framework.model.ToolListener;
import ghidra.framework.plugintool.PluginEvent;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg;
import ghidra.util.datastruct.StringIntHashtable;
import ghidra.util.exception.NoValueException;
@ -32,146 +34,149 @@ import ghidra.util.exception.NoValueException;
*/
class ToolConnectionImpl implements ToolConnection, ToolListener {
private Tool producerTool;
private Tool consumerTool;
private StringIntHashtable connectHt; // maps event -> int value 1 if
// tools are connected, int value 0 if tools are not connected
private PluginTool producerTool;
private PluginTool consumerTool;
private StringIntHashtable connectHt; // maps event -> int value 1 if
// tools are connected, int value 0 if tools are not connected
private final static int CONNECTED = 1;
private final static int DISCONNECTED = 0;
private final static int CONNECTED = 1;
private final static int DISCONNECTED = 0;
private boolean listenerAdded; // set to true the first time a
// connection is made for any event
private boolean changed; // flag for whether the connection was changed
private boolean listenerAdded; // set to true the first time a
// connection is made for any event
private boolean changed; // flag for whether the connection was changed
/**
* Constructor
*/
ToolConnectionImpl(Tool producerTool, Tool consumerTool) {
this.producerTool = producerTool;
this.consumerTool = consumerTool;
/**
* Constructor
*/
ToolConnectionImpl(PluginTool producerTool, PluginTool consumerTool) {
this.producerTool = producerTool;
this.consumerTool = consumerTool;
connectHt = new StringIntHashtable();
updateEventList();
}
connectHt = new StringIntHashtable();
updateEventList();
}
/**
* Default constructor used when there is a problem restoring state
* on the workspace; want the restore() method to still work.
*/
ToolConnectionImpl() {
}
/*
/**
* Default constructor used when there is a problem restoring state
* on the workspace; want the restore() method to still work.
*/
ToolConnectionImpl() {
}
/*
* @see ghidra.framework.model.ToolConnection#connect(java.lang.String)
*/
@Override
@Override
public void connect(String eventName) {
validateEventName(eventName);
connectHt.put(eventName, CONNECTED);
if (!listenerAdded) {
producerTool.addToolListener(this);
listenerAdded = true;
}
changed = true;
}
/*
validateEventName(eventName);
connectHt.put(eventName, CONNECTED);
if (!listenerAdded) {
producerTool.addToolListener(this);
listenerAdded = true;
}
changed = true;
}
/*
* @see ghidra.framework.model.ToolConnection#isConnected(java.lang.String)
*/
@Override
@Override
public boolean isConnected(String eventName) {
if (!connectHt.contains(eventName)) {
return false;
}
try {
int value = connectHt.get(eventName);
return (value == CONNECTED);
if (!connectHt.contains(eventName)) {
return false;
}
try {
int value = connectHt.get(eventName);
return (value == CONNECTED);
} catch (NoValueException e) {
return false;
}
}
catch (NoValueException e) {
return false;
}
}
/*
}
/*
* @see ghidra.framework.model.ToolConnection#getEvents()
*/
@Override
@Override
public String[] getEvents() {
String []keys = connectHt.getKeys();
Arrays.sort(keys);
String[] keys = connectHt.getKeys();
Arrays.sort(keys);
return keys;
}
/*
return keys;
}
/*
* @see ghidra.framework.model.ToolConnection#disconnect(java.lang.String)
*/
@Override
@Override
public void disconnect(String eventName) {
validateEventName(eventName);
connectHt.put(eventName, DISCONNECTED);
checkConnections();
changed = true;
}
validateEventName(eventName);
connectHt.put(eventName, DISCONNECTED);
checkConnections();
changed = true;
}
/*
/*
* @see ghidra.framework.model.ToolConnection#getProducer()
*/
@Override
public Tool getProducer() {
return producerTool;
}
/*
@Override
public PluginTool getProducer() {
return producerTool;
}
/*
* @see ghidra.framework.model.ToolConnection#getConsumer()
*/
@Override
public Tool getConsumer() {
return consumerTool;
}
@Override
public PluginTool getConsumer() {
return consumerTool;
}
/*
/*
* @see ghidra.framework.model.ToolListener#processToolEvent(ghidra.framework.model.ToolEvent)
*/
@Override
public void processToolEvent(PluginEvent toolEvent) {
if (isConnected(toolEvent.getToolEventName())) {
consumerTool.processToolEvent(toolEvent);
}
}
if (isConnected(toolEvent.getToolEventName())) {
consumerTool.processToolEvent(toolEvent);
}
}
/**
* Saves the Tool Connection into an XML element.
*/
public Element saveToXml() {
/**
* Saves the Tool Connection into an XML element.
*/
public Element saveToXml() {
Element root = new Element("CONNECTION");
root.setAttribute("PRODUCER",producerTool.getName());
root.setAttribute("CONSUMER",consumerTool.getName());
root.setAttribute("LISTENER_ADDED",""+listenerAdded);
String [] keys = connectHt.getKeys();
for (int i = 0 ; i < keys.length ; ++i) {
root.setAttribute("PRODUCER", producerTool.getName());
root.setAttribute("CONSUMER", consumerTool.getName());
root.setAttribute("LISTENER_ADDED", "" + listenerAdded);
String[] keys = connectHt.getKeys();
for (String key : keys) {
Element elem = new Element("EVENT");
elem.setAttribute("NAME", keys[i]);
elem.setAttribute("NAME", key);
int val = DISCONNECTED;
try {
val = connectHt.get(keys[i]);
val = connectHt.get(key);
}
catch (NoValueException nve) {
}
catch (NoValueException nve) {}
elem.setAttribute("CONNECTED", (val == CONNECTED ? "true" : "false"));
root.addContent(elem);
}
changed = false;
return root;
}
/**
* restores the ToolConnection from an XML element
*
* @param root XML element to restore ToolConnection from.
*/
public void restoreFromXml(Element root) {
changed = false;
return root;
}
/**
* restores the ToolConnection from an XML element
*
* @param root XML element to restore ToolConnection from.
*/
public void restoreFromXml(Element root) {
listenerAdded = false;
Iterator<?> iter = root.getChildren("EVENT").iterator();
@ -181,144 +186,144 @@ class ToolConnectionImpl implements ToolConnection, ToolListener {
String state = elem.getAttributeValue("CONNECTED");
boolean connected = (state != null && state.equalsIgnoreCase("true"));
connectHt.put(name, (connected ? CONNECTED : DISCONNECTED));
if (connected && !listenerAdded) {
producerTool.addToolListener(this);
listenerAdded = true;
}
if (connected && !listenerAdded) {
producerTool.addToolListener(this);
listenerAdded = true;
}
}
}
}
/**
* Returns a hash code value for the object. This method is
* supported for the benefit of hashtables such as those provided by
* <code>java.util.Hashtable</code>.
*/
@Override
public int hashCode() {
return producerTool.getName().hashCode() +
consumerTool.getName().hashCode();
}
/**
* Returns a hash code value for the object. This method is
* supported for the benefit of hashtables such as those provided by
* <code>java.util.Hashtable</code>.
*/
@Override
public int hashCode() {
return producerTool.getName().hashCode() +
consumerTool.getName().hashCode();
}
/**
* Indicates whether some other object is "equal to" this one.
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
/**
* Indicates whether some other object is "equal to" this one.
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (getClass() != obj.getClass()) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ToolConnectionImpl tc = (ToolConnectionImpl)obj;
ToolConnectionImpl tc = (ToolConnectionImpl) obj;
return producerTool.getName().equals(tc.producerTool.getName()) &&
consumerTool.getName().equals(tc.consumerTool.getName());
}
/**
* Returns a string representation of the object. In general, the
* <code>toString</code> method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
*/
@Override
public String toString() {
return "Producer=" + producerTool.getName() +
", Consumer=" + consumerTool.getName();
}
return producerTool.getName().equals(tc.producerTool.getName()) &&
consumerTool.getName().equals(tc.consumerTool.getName());
}
////////////////////////////////////////////////////////////////
// ** package methods
///////////////////////////////////////////////////////////////
/**
* Return true if the connection changed.
*/
boolean hasChanged() {
return changed;
}
/**
* Returns a string representation of the object. In general, the
* <code>toString</code> method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
*/
@Override
public String toString() {
return "Producer=" + producerTool.getName() +
", Consumer=" + consumerTool.getName();
}
/**
* Update the events that are consumed and produced, as the tool
* may have added or removed plugins.
*/
void updateEventList() {
////////////////////////////////////////////////////////////////
// ** package methods
///////////////////////////////////////////////////////////////
/**
* Return true if the connection changed.
*/
boolean hasChanged() {
return changed;
}
String[] producerEvents = producerTool.getToolEventNames();
String[] consumedEvents = consumerTool.getConsumedToolEventNames();
List<String> pList = Arrays.asList(producerEvents);
List<String> cList = Arrays.asList(consumedEvents);
ArrayList<String> producerList = new ArrayList<>(pList);
ArrayList<String> consumerList = new ArrayList<>(cList);
/**
* Update the events that are consumed and produced, as the tool
* may have added or removed plugins.
*/
void updateEventList() {
// get the intersection of the lists
producerList.retainAll(consumerList);
consumerList.retainAll(producerList);
String[] producerEvents = producerTool.getToolEventNames();
String[] consumedEvents = consumerTool.getConsumedToolEventNames();
List<String> pList = Arrays.asList(producerEvents);
List<String> cList = Arrays.asList(consumedEvents);
ArrayList<String> producerList = new ArrayList<>(pList);
ArrayList<String> consumerList = new ArrayList<>(cList);
for (int i=0; i<producerList.size(); i++) {
String event = producerList.get(i);
if (!connectHt.contains(event)) {
connectHt.put(event, DISCONNECTED);
}
}
String[] keys = connectHt.getKeys();
for (int i=0; i<keys.length; i++) {
if (!producerList.contains(keys[i])) {
connectHt.remove(keys[i]);
}
}
}
// get the intersection of the lists
producerList.retainAll(consumerList);
consumerList.retainAll(producerList);
////////////////////////////////////////////////////////////////
// ** private methods
////////////////////////////////////////////////////////////////
for (int i = 0; i < producerList.size(); i++) {
String event = producerList.get(i);
if (!connectHt.contains(event)) {
connectHt.put(event, DISCONNECTED);
}
}
String[] keys = connectHt.getKeys();
for (String key : keys) {
if (!producerList.contains(key)) {
connectHt.remove(key);
}
}
}
/**
* Verify that the given event name is produced by the
* producer tool and is consumed by the consumer tool.
*
* @throws IllegalArgumentException if the event is not in the
* list of events for this producer/consumer pair.
*/
private void validateEventName(String eventName) {
if (!connectHt.contains(eventName)) {
throw new IllegalArgumentException("Event name " + eventName +
" is not valid for producer " +
producerTool.getName() + ", consumer " +
consumerTool.getName());
}
}
////////////////////////////////////////////////////////////////
// ** private methods
////////////////////////////////////////////////////////////////
/**
* Check the connections; if there are none, then remove the
* consumer tool as a listener on the producer tool; called
* when a disconnect is made.
*/
private void checkConnections() {
/**
* Verify that the given event name is produced by the
* producer tool and is consumed by the consumer tool.
*
* @throws IllegalArgumentException if the event is not in the
* list of events for this producer/consumer pair.
*/
private void validateEventName(String eventName) {
if (!connectHt.contains(eventName)) {
throw new IllegalArgumentException("Event name " + eventName +
" is not valid for producer " +
producerTool.getName() + ", consumer " +
consumerTool.getName());
}
}
String [] eventNames = connectHt.getKeys();
boolean connectionFound = false;
for (int i=0; i<eventNames.length; i++) {
try {
int value = connectHt.get(eventNames[i]);
if (value == CONNECTED) {
connectionFound = true;
break;
}
}
catch(NoValueException e) {
Msg.showError(this, null, "Error", "Event name not in table: " + e.getMessage());
}
}
if (!connectionFound) {
producerTool.removeToolListener(this);
listenerAdded = false;
}
}
/**
* Check the connections; if there are none, then remove the
* consumer tool as a listener on the producer tool; called
* when a disconnect is made.
*/
private void checkConnections() {
String[] eventNames = connectHt.getKeys();
boolean connectionFound = false;
for (String eventName : eventNames) {
try {
int value = connectHt.get(eventName);
if (value == CONNECTED) {
connectionFound = true;
break;
}
}
catch (NoValueException e) {
Msg.showError(this, null, "Error", "Event name not in table: " + e.getMessage());
}
}
if (!connectionFound) {
producerTool.removeToolListener(this);
listenerAdded = false;
}
}
}

View file

@ -15,7 +15,8 @@
*/
package ghidra.framework.project.tool;
import java.beans.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.*;
import org.jdom.Element;
@ -24,6 +25,7 @@ import docking.ComponentProvider;
import ghidra.framework.main.AppInfo;
import ghidra.framework.main.FrontEndTool;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.DuplicateNameException;
@ -56,7 +58,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
private Map<String, ToolConnectionImpl> connectMap;
// map generic tool names to list of tools
private Map<String, List<Tool>> namesMap;
private Map<String, List<PluginTool>> namesMap;
/**
* keep a handle to the active workspace to make inactive when another
@ -90,8 +92,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
* @param toolName the name of the tool being registers
* @param tool the tool being registered
*/
private void registerTool(String toolName, Tool tool) {
List<Tool> list = namesMap.get(toolName);
private void registerTool(String toolName, PluginTool tool) {
List<PluginTool> list = namesMap.get(toolName);
if (list == null) {
list = new ArrayList<>(5);
namesMap.put(toolName, list);
@ -109,8 +111,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
tool.addPropertyChangeListener(this);
}
private void deregisterTool(String toolName, Tool tool) {
List<Tool> list = namesMap.get(toolName);
private void deregisterTool(String toolName, PluginTool tool) {
List<PluginTool> list = namesMap.get(toolName);
SystemUtilities.assertTrue(list != null, "Attempted to remove tool that's not there");
list.remove(tool);
if (list.size() == 0) {
@ -126,45 +128,45 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
}
@Override
public Tool[] getConsumerTools() {
ArrayList<Tool> consumers = new ArrayList<>(TYPICAL_NUM_TOOLS);
Tool[] runningTools = getRunningTools();
for (Tool tool : runningTools) {
public PluginTool[] getConsumerTools() {
ArrayList<PluginTool> consumers = new ArrayList<>(TYPICAL_NUM_TOOLS);
PluginTool[] runningTools = getRunningTools();
for (PluginTool tool : runningTools) {
if (tool.getConsumedToolEventNames().length > 0) {
consumers.add(tool);
}
}
Tool[] tools = new Tool[consumers.size()];
PluginTool[] tools = new PluginTool[consumers.size()];
consumers.toArray(tools);
return tools;
}
@Override
public Tool[] getProducerTools() {
ArrayList<Tool> producers = new ArrayList<>(TYPICAL_NUM_TOOLS);
Tool[] runningTools = getRunningTools();
for (Tool tool : runningTools) {
public PluginTool[] getProducerTools() {
ArrayList<PluginTool> producers = new ArrayList<>(TYPICAL_NUM_TOOLS);
PluginTool[] runningTools = getRunningTools();
for (PluginTool tool : runningTools) {
if (tool.getToolEventNames().length > 0) {
producers.add(tool);
}
}
Tool[] tools = new Tool[producers.size()];
PluginTool[] tools = new PluginTool[producers.size()];
return producers.toArray(tools);
}
@Override
public Tool[] getRunningTools() {
public PluginTool[] getRunningTools() {
Workspace[] wsList = new Workspace[workspaces.size()];
workspaces.toArray(wsList);
ArrayList<Tool> runningTools = new ArrayList<>(TYPICAL_NUM_TOOLS);
ArrayList<PluginTool> runningTools = new ArrayList<>(TYPICAL_NUM_TOOLS);
for (Workspace element : wsList) {
Tool[] tools = element.getTools();
for (Tool tool : tools) {
PluginTool[] tools = element.getTools();
for (PluginTool tool : tools) {
runningTools.add(tool);
}
}
Tool[] tools = new Tool[runningTools.size()];
PluginTool[] tools = new PluginTool[runningTools.size()];
runningTools.toArray(tools);
return tools;
@ -174,7 +176,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
* @see ghidra.framework.model.ToolManager#getConnection(ghidra.framework.model.Tool, ghidra.framework.model.Tool)
*/
@Override
public ToolConnection getConnection(Tool producer, Tool consumer) {
public ToolConnection getConnection(PluginTool producer, PluginTool consumer) {
String key = getKey(producer, consumer);
ToolConnectionImpl tc = connectMap.get(key);
if (tc == null) {
@ -229,8 +231,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
// first close all the tools running in the workspace
// and if any of the tools don't close, don't remove the workspace
Tool[] runningTools = ws.getTools();
for (Tool runningTool : runningTools) {
PluginTool[] runningTools = ws.getTools();
for (PluginTool runningTool : runningTools) {
// if data has changed in the tool, the frontEnd will take care
// of asking/confirming saving tool
runningTool.close();
@ -310,7 +312,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
public void restoreFromXml(Element root) {
inRestoreMode = true;
try {
HashMap<String, Tool> toolMap = new HashMap<>();
HashMap<String, PluginTool> toolMap = new HashMap<>();
String activeWSName = root.getAttributeValue("ACTIVE_WORKSPACE");
Workspace makeMeActive = null;
@ -325,8 +327,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
if (ws.getName().equals(activeWSName)) {
makeMeActive = ws;
}
Tool[] tools = ws.getTools();
for (Tool tool : tools) {
PluginTool[] tools = ws.getTools();
for (PluginTool tool : tools) {
toolMap.put(tool.getName(), tool);
}
}
@ -340,8 +342,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
String producerName = elem.getAttributeValue("PRODUCER");
String consumerName = elem.getAttributeValue("CONSUMER");
// get the tools
Tool producer = toolMap.get(producerName);
Tool consumer = toolMap.get(consumerName);
PluginTool producer = toolMap.get(producerName);
PluginTool consumer = toolMap.get(consumerName);
if (producer != null && consumer != null) {
ToolConnectionImpl tc = new ToolConnectionImpl(producer, consumer);
tc.restoreFromXml(elem);
@ -393,9 +395,9 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
public boolean saveSessionTools() {
Set<String> keySet = namesMap.keySet();
for (String toolName : keySet) {
List<Tool> tools = namesMap.get(toolName);
List<PluginTool> tools = namesMap.get(toolName);
if (tools.size() == 1) {
Tool tool = tools.get(0);
PluginTool tool = tools.get(0);
if (tool.shouldSave()) {
toolServices.saveTool(tool);
}
@ -410,9 +412,9 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
return true;
}
private boolean saveToolSet(List<Tool> tools) {
List<Tool> changedTools = new ArrayList<>();
for (Tool tool : tools) {
private boolean saveToolSet(List<PluginTool> tools) {
List<PluginTool> changedTools = new ArrayList<>();
for (PluginTool tool : tools) {
if (tool.hasConfigChanged()) {
changedTools.add(tool);
}
@ -422,7 +424,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
}
if (changedTools.size() == 1) {
Tool changedTool = changedTools.get(0);
PluginTool changedTool = changedTools.get(0);
if (changedTool.shouldSave()) {
toolServices.saveTool(changedTool);
}
@ -436,7 +438,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
return false;
}
Tool tool = dialog.getSelectedTool();
PluginTool tool = dialog.getSelectedTool();
if (tool != null) {
toolServices.saveTool(tool);
}
@ -467,15 +469,15 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Tool tool = (Tool) evt.getSource();
PluginTool tool = (PluginTool) evt.getSource();
String propertyName = evt.getPropertyName();
if (propertyName.equals(Tool.PLUGIN_COUNT_PROPERTY_NAME)) {
if (propertyName.equals(PluginTool.PLUGIN_COUNT_PROPERTY_NAME)) {
updateConnections(evt);
}
if (!propertyName.equals(Tool.TOOL_NAME_PROPERTY)) {
if (!propertyName.equals(PluginTool.TOOL_NAME_PROPERTY)) {
return;
}
@ -524,7 +526,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
}
@Override
public void toolChanged(Tool tool) {
public void toolChanged(PluginTool tool) {
updateConnectMap(tool);
}
@ -536,13 +538,13 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
* @param toolName the name of the tool
* @return the tool
*/
public Tool getTool(String toolName) {
public PluginTool getTool(String toolName) {
ToolTemplate template = toolServices.getToolChest().getToolTemplate(toolName);
if (template == null) {
return null;
}
Tool tool = template.createTool(project);
PluginTool tool = template.createTool(project);
if (tool != null) {
registerTool(toolName, tool);
}
@ -558,13 +560,13 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
*
* @param tool tool to be closed.
*/
void closeTool(Tool tool) {
void closeTool(PluginTool tool) {
// find the workspace running the tool
for (int i = 0; i < workspaces.size(); i++) {
WorkspaceImpl ws = (WorkspaceImpl) workspaces.get(i);
Tool[] tools = ws.getTools();
for (Tool tool2 : tools) {
PluginTool[] tools = ws.getTools();
for (PluginTool tool2 : tools) {
if (tool == tool2) {
ws.closeRunningTool(tool);
return;
@ -655,8 +657,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
/*
* Get a tool from the template; set the instance name.
*/
Tool getTool(Workspace ws, ToolTemplate template) {
Tool tool = template.createTool(project);
PluginTool getTool(Workspace ws, ToolTemplate template) {
PluginTool tool = template.createTool(project);
if (tool != null) {
registerTool(tool.getToolName(), tool);
}
@ -666,7 +668,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
/*
* Called by the workspace when a tool is removed.
*/
void toolRemoved(Workspace ws, Tool tool) {
void toolRemoved(Workspace ws, PluginTool tool) {
deregisterTool(tool.getToolName(), tool);
disconnectTool(tool);
@ -680,13 +682,13 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
* Generate an instance name in the form
* of a one-up number.
*/
private String generateInstanceName(String toolName, Tool tool) {
List<Tool> list = namesMap.get(toolName);
private String generateInstanceName(String toolName, PluginTool tool) {
List<PluginTool> list = namesMap.get(toolName);
if (list.size() <= 1) {
return "";
}
Tool lastTool = list.get(list.size() - 2); // the last one is the one we just added above
PluginTool lastTool = list.get(list.size() - 2); // the last one is the one we just added above
String instanceName = lastTool.getInstanceName();
if (instanceName.length() == 0) {
return "2";
@ -696,8 +698,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
return "" + (n + 1);
}
Tool createEmptyTool() {
Tool tool = new GhidraTool(project, "Untitled");
PluginTool createEmptyTool() {
PluginTool tool = new GhidraTool(project, "Untitled");
addNewTool(tool, "Untitled");
return tool;
}
@ -706,18 +708,12 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
* Add the tool to the table, add us as a listener for property
* changes on the tool.
*/
private void addNewTool(Tool tool, String toolName) {
try {
tool.setToolName(toolName);
registerTool(toolName, tool);
}
catch (PropertyVetoException e) {
// shouldn't happen
Msg.showError(this, null, "Error Setting Tool Name", "Set tool name was vetoed", e);
}
private void addNewTool(PluginTool tool, String toolName) {
tool.setToolName(toolName);
registerTool(toolName, tool);
}
void fireToolAddedEvent(Workspace ws, Tool tool) {
void fireToolAddedEvent(Workspace ws, PluginTool tool) {
for (int i = 0; i < changeListeners.size(); i++) {
WorkspaceChangeListener l = changeListeners.get(i);
l.toolAdded(ws, tool);
@ -725,13 +721,13 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
}
@Override
public void disconnectTool(Tool tool) {
public void disconnectTool(PluginTool tool) {
Iterator<String> keys = connectMap.keySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
ToolConnection tc = connectMap.get(key);
Tool producer = tc.getProducer();
Tool consumer = tc.getConsumer();
PluginTool producer = tc.getProducer();
PluginTool consumer = tc.getConsumer();
if (producer == tool || consumer == tool) {
keys.remove();
producer.removeToolListener((ToolConnectionImpl) tc);
@ -739,15 +735,15 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
}
}
private void updateConnectMap(Tool tool) {
private void updateConnectMap(PluginTool tool) {
Iterator<String> keys = connectMap.keySet().iterator();
Map<String, ToolConnectionImpl> map = new HashMap<>();
while (keys.hasNext()) {
String key = keys.next();
ToolConnectionImpl tc = connectMap.get(key);
Tool producer = tc.getProducer();
Tool consumer = tc.getConsumer();
PluginTool producer = tc.getProducer();
PluginTool consumer = tc.getConsumer();
if (producer == tool || consumer == tool) {
String newkey = getKey(producer, consumer);
tc.updateEventList();
@ -767,13 +763,13 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
* @param consumer tool consuming an event
*
*/
private String getKey(Tool producer, Tool consumer) {
private String getKey(PluginTool producer, PluginTool consumer) {
return producer.getName() + "+" + consumer.getName();
}
private void updateConnections(PropertyChangeEvent ev) {
Tool tool = (Tool) ev.getSource();
PluginTool tool = (PluginTool) ev.getSource();
updateConnectMap(tool);
// notify listeners of tool change
@ -809,7 +805,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
return name;
}
public boolean canAutoSave(Tool tool) {
public boolean canAutoSave(PluginTool tool) {
ToolSaveStatus status = toolStatusMap.get(tool.getToolName());
if (status == ToolSaveStatus.ASK_SAVE_MODE) {
return false;
@ -829,7 +825,7 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
return (status == ToolSaveStatus.AUTO_SAVE_MODE);
}
public void toolSaved(Tool tool, boolean toolChanged) {
public void toolSaved(PluginTool tool, boolean toolChanged) {
String toolName = tool.getToolName();
if (getToolInstanceCount(tool) == 1) {
// saving with only one instance open resets the status
@ -841,8 +837,8 @@ public class ToolManagerImpl implements ToolManager, PropertyChangeListener {
}
}
private int getToolInstanceCount(Tool tool) {
List<Tool> list = namesMap.get(tool.getToolName());
private int getToolInstanceCount(PluginTool tool) {
List<PluginTool> list = namesMap.get(tool.getToolName());
if (list == null) {
return 0;
}

View file

@ -60,7 +60,7 @@ class ToolServicesImpl implements ToolServices {
}
@Override
public void closeTool(Tool tool) {
public void closeTool(PluginTool tool) {
toolManager.closeTool(tool);
}
@ -150,7 +150,7 @@ class ToolServicesImpl implements ToolServices {
}
@Override
public void saveTool(Tool tool) {
public void saveTool(PluginTool tool) {
boolean toolChanged = tool.hasConfigChanged();
ToolTemplate template = tool.saveToolToToolTemplate();
toolManager.toolSaved(tool, toolChanged);
@ -164,10 +164,10 @@ class ToolServicesImpl implements ToolServices {
}
@Override
public void displaySimilarTool(Tool tool, DomainFile domainFile, PluginEvent event) {
public void displaySimilarTool(PluginTool tool, DomainFile domainFile, PluginEvent event) {
Tool[] similarTools = getSameNamedRunningTools(tool);
Tool matchingTool = findToolUsingFile(similarTools, domainFile);
PluginTool[] similarTools = getSameNamedRunningTools(tool);
PluginTool matchingTool = findToolUsingFile(similarTools, domainFile);
if (matchingTool != null) {
// Bring the matching tool forward.
matchingTool.toFront();
@ -185,11 +185,11 @@ class ToolServicesImpl implements ToolServices {
}
@Override
public Tool launchDefaultTool(DomainFile domainFile) {
public PluginTool launchDefaultTool(DomainFile domainFile) {
ToolTemplate template = getDefaultToolTemplate(domainFile);
if (template != null) {
Workspace workspace = toolManager.getActiveWorkspace();
Tool tool = workspace.runTool(template);
PluginTool tool = workspace.runTool(template);
tool.setVisible(true);
if (domainFile != null) {
tool.acceptDomainFiles(new DomainFile[] { domainFile });
@ -200,11 +200,11 @@ class ToolServicesImpl implements ToolServices {
}
@Override
public Tool launchTool(String toolName, DomainFile domainFile) {
public PluginTool launchTool(String toolName, DomainFile domainFile) {
ToolTemplate template = findToolChestToolTemplate(toolName);
if (template != null) {
Workspace workspace = toolManager.getActiveWorkspace();
Tool tool = workspace.runTool(template);
PluginTool tool = workspace.runTool(template);
tool.setVisible(true);
if (domainFile != null) {
tool.acceptDomainFiles(new DomainFile[] { domainFile });
@ -451,20 +451,20 @@ class ToolServicesImpl implements ToolServices {
*
* @return array of tools that are running and named the same as this one.
*/
private Tool[] getSameNamedRunningTools(Tool tool) {
private PluginTool[] getSameNamedRunningTools(PluginTool tool) {
String toolName = tool.getToolName();
Tool[] tools = toolManager.getRunningTools();
List<Tool> toolList = new ArrayList<>(tools.length);
for (Tool element : tools) {
PluginTool[] tools = toolManager.getRunningTools();
List<PluginTool> toolList = new ArrayList<>(tools.length);
for (PluginTool element : tools) {
if (toolName.equals(element.getToolName())) {
toolList.add(element);
}
}
return toolList.toArray(new Tool[toolList.size()]);
return toolList.toArray(new PluginTool[toolList.size()]);
}
@Override
public Tool[] getRunningTools() {
public PluginTool[] getRunningTools() {
return toolManager.getRunningTools();
}
@ -476,8 +476,8 @@ class ToolServicesImpl implements ToolServices {
*
* @return first tool found to be using the domainFile
*/
private Tool findToolUsingFile(Tool[] tools, DomainFile domainFile) {
Tool matchingTool = null;
private PluginTool findToolUsingFile(PluginTool[] tools, DomainFile domainFile) {
PluginTool matchingTool = null;
for (int toolNum = 0; (toolNum < tools.length) && (matchingTool == null); toolNum++) {
PluginTool pTool = (PluginTool) tools[toolNum];
// Is this tool the same as the type we are in.
@ -493,7 +493,7 @@ class ToolServicesImpl implements ToolServices {
}
@Override
public boolean canAutoSave(Tool tool) {
public boolean canAutoSave(PluginTool tool) {
return toolManager.canAutoSave(tool);
}
}

View file

@ -19,7 +19,9 @@ import java.util.*;
import org.jdom.Element;
import ghidra.framework.model.*;
import ghidra.framework.model.ToolTemplate;
import ghidra.framework.model.Workspace;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.exception.DuplicateNameException;
/**
@ -33,7 +35,7 @@ class WorkspaceImpl implements Workspace {
private String name;
private ToolManagerImpl toolManager;
private Set<Tool> runningTools = new HashSet<Tool>(TYPICAL_NUM_RUNNING_TOOLS);
private Set<PluginTool> runningTools = new HashSet<PluginTool>(TYPICAL_NUM_RUNNING_TOOLS);
private boolean isActive;
WorkspaceImpl(String name, ToolManagerImpl toolManager) {
@ -47,16 +49,16 @@ class WorkspaceImpl implements Workspace {
}
@Override
public Tool[] getTools() {
Tool[] tools = new Tool[runningTools.size()];
public PluginTool[] getTools() {
PluginTool[] tools = new PluginTool[runningTools.size()];
runningTools.toArray(tools);
return tools;
}
@Override
public Tool createTool() {
public PluginTool createTool() {
// launch the empty tool
Tool emptyTool = toolManager.createEmptyTool();
PluginTool emptyTool = toolManager.createEmptyTool();
// add the new tool to our list of running tools
runningTools.add(emptyTool);
@ -70,9 +72,9 @@ class WorkspaceImpl implements Workspace {
}
@Override
public Tool runTool(ToolTemplate template) {
public PluginTool runTool(ToolTemplate template) {
Tool tool = toolManager.getTool(this, template);
PluginTool tool = toolManager.getTool(this, template);
if (tool != null) {
tool.setVisible(true);
@ -129,7 +131,7 @@ class WorkspaceImpl implements Workspace {
root.setAttribute("NAME", name);
root.setAttribute("ACTIVE", "" + isActive);
for (Tool tool : runningTools) {
for (PluginTool tool : runningTools) {
Element elem = new Element("RUNNING_TOOL");
elem.setAttribute("TOOL_NAME", tool.getToolName());
elem.addContent(tool.saveWindowingDataToXml());
@ -156,12 +158,12 @@ class WorkspaceImpl implements Workspace {
String defaultTool = System.getProperty("ghidra.defaulttool");
if (defaultTool != null && !defaultTool.equals("")) {
Tool tool = toolManager.getTool(defaultTool);
PluginTool tool = toolManager.getTool(defaultTool);
runningTools.add(tool);
toolManager.fireToolAddedEvent(this, tool);
return;
}
Iterator<?> iter = root.getChildren("RUNNING_TOOL").iterator();
while (iter.hasNext()) {
Element elememnt = (Element) iter.next();
@ -170,7 +172,7 @@ class WorkspaceImpl implements Workspace {
continue;
}
Tool tool = toolManager.getTool(toolName);
PluginTool tool = toolManager.getTool(toolName);
if (tool != null) {
tool.setVisible(isActive);
@ -198,26 +200,19 @@ class WorkspaceImpl implements Workspace {
}
}
/*********************************************************************
* package level methods
********************************************************************/
//==================================================================================================
// Package Methods
//==================================================================================================
/**
* sets the workspace inactive so it can hide its tools
*/
void setVisible(boolean state) {
isActive = state;
Tool[] tools = getTools();
for (int t = 0; t < tools.length; t++) {
tools[t].setVisible(state);
PluginTool[] tools = getTools();
for (PluginTool tool : tools) {
tool.setVisible(state);
}
}
/**
* Called by the ToolManagerImpl when ToolServices calls
* the closeTool() method.
*/
void closeRunningTool(Tool tool) {
void closeRunningTool(PluginTool tool) {
// tool is already closed via the call that got us here, so just clean up
runningTools.remove(tool);
@ -232,7 +227,7 @@ class WorkspaceImpl implements Workspace {
* ToolManagerImpl which is called from the Project's close()
*/
void close() {
for (Tool tool : runningTools) {
for (PluginTool tool : runningTools) {
try {
tool.exit();
}

View file

@ -15,7 +15,6 @@
*/
package ghidra.framework.plugintool;
import ghidra.framework.model.Tool;
import ghidra.framework.plugintool.util.PluginClassManager;
/**
@ -37,7 +36,7 @@ public class DummyPluginTool extends PluginTool {
private static class DummyToolServices extends ToolServicesAdapter {
@Override
public void closeTool(Tool t) {
public void closeTool(PluginTool t) {
// If we call this, then the entire test VM will exit, which is bad
// System.exit(0);
}