actions = pl.getPopupActions(context);
+ if (actions != null) {
+ actionList.addAll(actions);
+ }
+ }
+ return actionList;
+ }
+
public void addContextListener(DockingContextListener listener) {
contextListeners.add(listener);
}
@@ -2122,12 +2153,9 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
* @param component the component that will be parented in a docking window system.
* @param listener the listener to be notified the component was parented.
*/
- public static void registerComponentLoadedListener(final Component component,
- final ComponentLoadedListener listener) {
+ public static void registerComponentLoadedListener(Component component,
+ ComponentLoadedListener listener) {
- // We want to load our state after the column model is loaded. We are using this
- // listener to know when the table has been added to the component hierarchy, as its
- // model has been loaded by then.
component.addHierarchyListener(new HierarchyListener() {
@Override
public void hierarchyChanged(HierarchyEvent e) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionProviderIf.java b/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionProviderIf.java
index 176987d272..2aff5ffbcc 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionProviderIf.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionProviderIf.java
@@ -17,6 +17,8 @@ package docking.action;
import java.util.List;
+import docking.DockingTool;
+
/**
* An interface for objects (really Components) to implement that signals they provide actions
* for the Docking environment. This interface will be called when the implementor is the source
@@ -25,8 +27,12 @@ import java.util.List;
* As an example, a JTable that wishes to provide popup menu actions can implement this interface.
* When the user right-clicks on said table, then Docking system will ask this object for its
* actions. Further, in this example, the actions given will be inserted into the popup menu
- * that is shown.
+ * that is shown.
+ *
+ * @deprecated use {@link DockingTool}
*/
+// Note: this API is not likely used by forward-facing clients and can be removed in the next release
+@Deprecated(since = "9.1", forRemoval = true)
public interface DockingActionProviderIf {
/**
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/actions/PopupActionProvider.java b/Ghidra/Framework/Docking/src/main/java/docking/actions/PopupActionProvider.java
new file mode 100644
index 0000000000..3f1b6c9edc
--- /dev/null
+++ b/Ghidra/Framework/Docking/src/main/java/docking/actions/PopupActionProvider.java
@@ -0,0 +1,47 @@
+/* ###
+ * 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 docking.actions;
+
+import java.util.List;
+
+import docking.ActionContext;
+import docking.DockingTool;
+import docking.action.DockingActionIf;
+
+/**
+ * Provides notification when the popup action menu is displayed. This interface allows
+ * temporary/transient actions (those not registered with the tool via
+ * {@link DockingTool#addAction(DockingActionIf)}) to be used in the popup context menu.
+ *
+ *
+ * Most clients will register actions directly with the tool. However, clients that have numerous
+ * actions that vary greatly with the context can use this method to only create those actions
+ * on demand as the popup is about to be shown, and only if their context is active. This
+ * mechanism can reduce the tool's action management overhead.
+ */
+public interface PopupActionProvider {
+
+ /**
+ * Provides notification that the popup menu is about to be displayed and allows a set of
+ * temporary actions to be included in the popup menu. Actions returned will be
+ * included in the menu if they have a valid popup menu path and respond true to the
+ * {@link DockingActionIf#isValidContext(ActionContext)} call.
+ *
+ * @param context the ActionContext
+ * @return list of temporary popup actions; return null if there are no popup actions
+ */
+ public List getPopupActions(ActionContext context);
+}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java
index 58e884d7a8..1a2de7d1c5 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java
@@ -32,6 +32,7 @@ import javax.swing.table.*;
import docking.*;
import docking.action.*;
import docking.actions.KeyBindingUtils;
+import docking.actions.PopupActionProvider;
import docking.widgets.OptionDialog;
import docking.widgets.dialogs.SettingsDialog;
import docking.widgets.filechooser.GhidraFileChooser;
@@ -69,7 +70,7 @@ import resources.ResourceManager;
*
* @see GTableFilterPanel
*/
-public class GTable extends JTable implements KeyStrokeConsumer, DockingActionProviderIf {
+public class GTable extends JTable implements KeyStrokeConsumer, PopupActionProvider {
private static final String LAST_EXPORT_FILE = "LAST_EXPORT_DIR";
@@ -510,20 +511,8 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
}
@Override
- public List getDockingActions() {
- return getDefaultDockingActions();
- }
+ public List getPopupActions(ActionContext context) {
- /**
- * Returns the default actions of this table. Normally, the Docking Windows systems uses
- * {@link #getDockingActions()} to get the correct actions to show. However,
- * there are some cases where clients override what appears when you click on a table (such
- * as in {@link DialogComponentProvider}s. For those clients that are creating their own
- * action building, they need a way to get the default actions, hence this method.
- *
- * @return the default actions
- */
- public List getDefaultDockingActions() {
// we want these top-level groups to all appear together, with no separator
DockingWindowManager dwm = DockingWindowManager.getInstance(this);
dwm.setMenuGroup(new String[] { "Copy" }, actionMenuGroup, "1");
@@ -590,6 +579,10 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
createPopupActions();
initializeRowHeight();
+
+ DockingWindowManager.registerComponentLoadedListener(this, dwm -> {
+ dwm.getTool().addPopupActionProvider(this);
+ });
}
private void initializeHeader(JTableHeader header) {
@@ -1490,5 +1483,4 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
// ignored
}
}
-
}
diff --git a/Ghidra/Framework/Docking/src/test/java/docking/FakeDockingTool.java b/Ghidra/Framework/Docking/src/test/java/docking/FakeDockingTool.java
index bbbba7ab68..2696dbccaa 100644
--- a/Ghidra/Framework/Docking/src/test/java/docking/FakeDockingTool.java
+++ b/Ghidra/Framework/Docking/src/test/java/docking/FakeDockingTool.java
@@ -20,7 +20,6 @@ import java.util.List;
import javax.swing.ImageIcon;
-import docking.action.DockingActionIf;
import docking.actions.ToolActions;
import docking.framework.ApplicationInformationDisplayFactory;
import ghidra.framework.options.ToolOptions;
@@ -33,10 +32,9 @@ public class FakeDockingTool extends AbstractDockingTool {
public FakeDockingTool() {
- DockWinListener listener = new DummyListener();
List windowIcons = ApplicationInformationDisplayFactory.getWindowIcons();
- winMgr = new DockingWindowManager(this, windowIcons, listener, false /*isModal*/,
- true /*isDockable*/, true /*hasStatus*/, null /*DropTargetFactory*/);
+ winMgr = new DockingWindowManager(this, windowIcons, false /*isModal*/, true /*isDockable*/,
+ true /*hasStatus*/, null /*DropTargetFactory*/);
toolActions = new ToolActions(this, new ActionToGuiHelper(winMgr));
}
@@ -60,16 +58,8 @@ public class FakeDockingTool extends AbstractDockingTool {
return opt;
}
- private class DummyListener implements DockWinListener {
-
- @Override
- public void close() {
- // stub
- }
-
- @Override
- public List getPopupActions(ActionContext context) {
- return null;
- }
+ @Override
+ public void close() {
+ // stub
}
}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/app/util/GenericHelpTopics.java b/Ghidra/Framework/Project/src/main/java/ghidra/app/util/GenericHelpTopics.java
index 579fc9a760..2286853585 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/app/util/GenericHelpTopics.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/app/util/GenericHelpTopics.java
@@ -44,6 +44,11 @@ public class GenericHelpTopics {
*/
public final static String REPOSITORY = "Repository";
+ /**
+ * Help Topic for the version control.
+ */
+ public final static String VERSION_CONTROL = "VersionControl";
+
/**
* Help Topic for tools.
*/
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java
index d3fe4da3e8..bf265fbe23 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java
@@ -490,7 +490,7 @@ public class ProjectDataTablePanel extends JPanel {
}
@Override
- public List getDockingActions() {
+ public List getPopupActions(ActionContext context) {
// TODO we should at least add the 'copy' action
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryDialog.java
index 6272482da1..4dbcdfe0db 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryDialog.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryDialog.java
@@ -23,7 +23,6 @@ import javax.swing.SwingUtilities;
import docking.ActionContext;
import docking.DialogComponentProvider;
import docking.action.DockingActionIf;
-import docking.action.DockingActionProviderIf;
import ghidra.app.util.GenericHelpTopics;
import ghidra.framework.main.AppInfo;
import ghidra.framework.main.FrontEndTool;
@@ -31,24 +30,26 @@ import ghidra.framework.model.*;
import ghidra.framework.store.FileSystem;
import ghidra.util.HelpLocation;
-public class VersionHistoryDialog extends DialogComponentProvider
- implements ProjectListener, DockingActionProviderIf {
+public class VersionHistoryDialog extends DialogComponentProvider implements ProjectListener {
private VersionHistoryPanel versionPanel;
private MyFolderListener listener = new MyFolderListener();
+ private List popupActions;
- public VersionHistoryDialog() {
+ public VersionHistoryDialog(DomainFile domainFile) {
super("Version History", false);
FrontEndTool frontEndTool = AppInfo.getFrontEndTool();
- setHelpLocation(new HelpLocation(GenericHelpTopics.REPOSITORY, "Show_History"));
- versionPanel = new VersionHistoryPanel(frontEndTool, null, true);
+ setHelpLocation(new HelpLocation(GenericHelpTopics.VERSION_CONTROL, "Show_History"));
+ versionPanel = new VersionHistoryPanel(frontEndTool, domainFile, true);
addWorkPanel(versionPanel);
addDismissButton();
- versionPanel.addPopupActions(this);
+
+ setDomainFile(domainFile);
+ popupActions = versionPanel.createPopupActions();
}
- public void setDomainFile(DomainFile df) {
+ private void setDomainFile(DomainFile df) {
versionPanel.setDomainFile(df);
@@ -59,18 +60,24 @@ public class VersionHistoryDialog extends DialogComponentProvider
setTitle("Version History for " + df.getName());
project.getProjectData().addDomainFolderChangeListener(listener);
}
- else {
- setTitle("Version History");
- project.getProjectData().removeDomainFolderChangeListener(listener);
+ }
+
+ @Override
+ protected void dialogShown() {
+ super.dialogShown();
+
+ for (DockingActionIf action : popupActions) {
+ addAction(action);
}
}
@Override
- protected void dismissCallback() {
+ protected void dialogClosed() {
+ super.dialogClosed();
- close();
-
- setDomainFile(null);
+ for (DockingActionIf action : popupActions) {
+ removeAction(action);
+ }
}
@Override
@@ -127,13 +134,8 @@ public class VersionHistoryDialog extends DialogComponentProvider
@Override
public ActionContext getActionContext(MouseEvent event) {
- ActionContext actionContext = new ActionContext(null, this, this);
+ ActionContext actionContext = new ActionContext(null, versionPanel.getTable(), this);
actionContext.setMouseEvent(event);
return actionContext;
}
-
- @Override
- public List getDockingActions() {
- return versionPanel.getDockingActions();
- }
}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryPanel.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryPanel.java
index ffb621583b..91328086e4 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryPanel.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/VersionHistoryPanel.java
@@ -31,26 +31,29 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
-import docking.*;
+import docking.ActionContext;
import docking.action.*;
import docking.dnd.*;
import docking.widgets.OptionDialog;
import docking.widgets.table.*;
+import ghidra.app.util.GenericHelpTopics;
import ghidra.framework.client.ClientUtil;
import ghidra.framework.main.GetVersionedObjectTask;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.ItemCheckoutStatus;
import ghidra.framework.store.Version;
-import ghidra.util.HTMLUtilities;
-import ghidra.util.Msg;
+import ghidra.util.*;
import ghidra.util.task.*;
/**
- * Panel that shows version history in a JTable.
+ * Panel that shows version history in a JTable
*/
public class VersionHistoryPanel extends JPanel implements Draggable {
+ private static final HelpLocation HELP =
+ new HelpLocation(GenericHelpTopics.VERSION_CONTROL, "Show History");
+
private PluginTool tool;
private DomainFile domainFile;
private String domainFilePath;
@@ -79,7 +82,6 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
* @param tool tool
* @param domainFile domain file
* @param enableUserInteraction if true Draggable support will be enabled
- * @throws IOException
*/
VersionHistoryPanel(PluginTool tool, DomainFile domainFile, boolean enableUserInteraction) {
super(new BorderLayout());
@@ -94,11 +96,11 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
}
/**
- * Set the domain file to show its history.
+ * Set the domain file to show its history
+ * @param domainFile the file
*/
public void setDomainFile(DomainFile domainFile) {
this.domainFile = domainFile;
- domainFilePath = null;
if (domainFile != null) {
this.domainFilePath = domainFile.getPathname();
}
@@ -122,21 +124,25 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
}
/**
- * Add the list selection listener to the history table.
+ * Add the list selection listener to the history table
+ * @param selectionListener the listener
*/
- public void addListSelectionListener(ListSelectionListener listener1) {
- table.getSelectionModel().addListSelectionListener(listener1);
+ public void addListSelectionListener(ListSelectionListener selectionListener) {
+ table.getSelectionModel().addListSelectionListener(selectionListener);
}
/**
* Remove the list selection listener from history table.
+ * @param selectionListener the listener
*/
- public void removeListSelectionListener(ListSelectionListener listener1) {
- table.getSelectionModel().removeListSelectionListener(listener1);
+ public void removeListSelectionListener(ListSelectionListener selectionListener) {
+ table.getSelectionModel().removeListSelectionListener(selectionListener);
}
/**
* Get the domain object for the selected version.
+ * @param consumer the consumer
+ * @param readOnly true if read only
* @return null if there is no selection
*/
public DomainObject getSelectedVersion(Object consumer, boolean readOnly) {
@@ -148,16 +154,10 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
return null;
}
- /**
- * Return whether a version is selected.
- */
public boolean isVersionSelected() {
return !table.getSelectionModel().isSelectionEmpty();
}
- /**
- * Get the version number that was selected.
- */
public int getSelectedVersionNumber() {
int row = table.getSelectedRow();
if (row >= 0) {
@@ -167,33 +167,21 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
return -1;
}
- /* (non-Javadoc)
- * @see ghidra.util.bean.dnd.Draggable#dragCanceled()
- */
@Override
public void dragCanceled(DragSourceDropEvent event) {
// no-op
}
- /* (non-Javadoc)
- * @see ghidra.util.bean.dnd.Draggable#getDragAction()
- */
@Override
public int getDragAction() {
return dragAction;
}
- /* (non-Javadoc)
- * @see ghidra.util.bean.dnd.Draggable#getDragSourceListener()
- */
@Override
public DragSourceListener getDragSourceListener() {
return dragSourceAdapter;
}
- /* (non-Javadoc)
- * @see ghidra.util.bean.dnd.Draggable#getTransferable(java.awt.Point)
- */
@Override
public Transferable getTransferable(Point p) {
int row = table.rowAtPoint(p);
@@ -204,9 +192,6 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
return null;
}
- /* (non-Javadoc)
- * @see ghidra.util.bean.dnd.Draggable#isStartDragOk(java.awt.dnd.DragGestureEvent)
- */
@Override
public boolean isStartDragOk(DragGestureEvent e) {
int row = table.rowAtPoint(e.getDragOrigin());
@@ -216,9 +201,6 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
return false;
}
- /* (non-Javadoc)
- * @see ghidra.util.bean.dnd.Draggable#move()
- */
@Override
public void move() {
// no-op
@@ -363,6 +345,38 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
openWith(null);
}
+ public List createPopupActions() {
+
+ List list = new ArrayList<>();
+ list.add(new DeleteAction());
+
+ Project project = tool.getProject();
+ ToolChest toolChest = project.getLocalToolChest();
+ if (toolChest == null) {
+ return list;
+ }
+
+ ToolTemplate[] templates = toolChest.getToolTemplates();
+ if (templates.length == 0) {
+ return list;
+ }
+
+ list.add(new OpenDefaultAction());
+ for (ToolTemplate toolTemplate : templates) {
+ list.add(new OpenWithAction(toolTemplate.getName()));
+ }
+
+ return list;
+ }
+
+ GTable getTable() {
+ return table;
+ }
+
+//==================================================================================================
+// Inner Classes
+//==================================================================================================
+
private class MyCellRenderer extends GTableCellRenderer {
@Override
@@ -398,36 +412,11 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
}
- public void addPopupActions(DialogComponentProvider provider) {
- provider.addAction(new DeleteAction());
- }
-
- public List getDockingActions() {
- List list = new ArrayList<>(table.getDefaultDockingActions());
- Project project = tool.getProject();
- ToolChest toolChest = project.getLocalToolChest();
- if (toolChest == null) {
- return list;
- }
-
- ToolTemplate[] templates = toolChest.getToolTemplates();
- if (templates.length == 0) {
- return list;
- }
-
- ToolTemplate defaultConfig = tool.getToolServices().getDefaultToolTemplate(domainFile);
- if (defaultConfig != null) {
- list.add(new OpenDefaultAction());
- }
- for (final ToolTemplate toolTemplate : templates) {
- list.add(new OpenWithAction(toolTemplate.getName()));
- }
- return list;
- }
-
private abstract class HistoryTableAction extends DockingAction {
+
HistoryTableAction(String name) {
super(name, "Version History Panel", false);
+ setHelpLocation(HELP);
}
@Override
@@ -436,6 +425,15 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
if (mouseEvent == null) {
return false;
}
+
+ if (context.getContextObject() != table) {
+ return false;
+ }
+
+ if (domainFile == null) {
+ return false;
+ }
+
int rowAtPoint = table.rowAtPoint(mouseEvent.getPoint());
return rowAtPoint >= 0;
}
@@ -479,8 +477,6 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
setDescription("Opens the version using the " + toolName + " tool.");
MenuData data = new MenuData(new String[] { "Open With", toolName }, "AAB");
setPopupMenuData(data);
- DockingWindowManager dwm = DockingWindowManager.getInstance(table);
- dwm.setMenuGroup(new String[] { "Open With" }, "AAB", "2");
}
@Override
@@ -526,9 +522,4 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
}
}
-
- GTable getTable() {
- return table;
- }
-
}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/VersionControlShowHistoryAction.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/VersionControlShowHistoryAction.java
index 7421dc745e..b9d7549b09 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/VersionControlShowHistoryAction.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/VersionControlShowHistoryAction.java
@@ -74,10 +74,8 @@ public class VersionControlShowHistoryAction extends VersionControlAction {
if (domainFiles.size() != 1) {
return;
}
- if (dialog == null) {
- dialog = new VersionHistoryDialog();
- }
- dialog.setDomainFile(domainFiles.get(0));
+
+ dialog = new VersionHistoryDialog(domainFiles.get(0));
tool.showDialog(dialog, tool.getToolFrame());
}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/Tool.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/Tool.java
index 9f72cbf106..823ab8141d 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/Tool.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/Tool.java
@@ -56,13 +56,6 @@ public interface Tool extends DockingTool, ToolListener {
*/
public void exit();
- /**
- * Suggests the tool to attempt to close(). This will be as though the user
- * selected the close menu option on the tool or hit the closeWindow x button in
- * the upper corner (Windows systems).
- */
- public void close();
-
/**
* Can this tool be closed?
* @param isExiting true if all of Ghidra is closing, false if just this tool is closing.
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java
index de97d4660d..99af2d9841 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java
@@ -22,7 +22,6 @@ import java.awt.*;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
@@ -34,6 +33,7 @@ import org.jdom.Element;
import docking.*;
import docking.action.*;
+import docking.actions.PopupActionProvider;
import docking.actions.ToolActions;
import docking.framework.AboutDialog;
import docking.framework.ApplicationInformationDisplayFactory;
@@ -58,24 +58,24 @@ import ghidra.framework.plugintool.util.*;
import ghidra.framework.project.ProjectDataService;
import ghidra.framework.project.tool.ToolIconURL;
import ghidra.util.*;
-import ghidra.util.datastruct.WeakDataStructureFactory;
-import ghidra.util.datastruct.WeakSet;
import ghidra.util.task.Task;
import ghidra.util.task.TaskLauncher;
/**
- * Base class that is a container to manage plugins and their actions, and
- * to coordinate the firing of plugin events and tool events. A
- * PluginTool may have visible components supplied by
- * ComponentProviders
. These components may be docked within the
- * tool, or moved out into their own windows.
- * The PluginTool also manages tasks that run in the background, and
- * options used by the plugins.
- *
+ * Base class that is a container to manage plugins and their actions, and to coordinate the
+ * firing of plugin events and tool events. A PluginTool may have visible components supplied by
+ * ComponentProviders
. These components may be docked within the tool, or moved
+ * out into their own windows.
+ *
+ * Plugins normally add actions via {@link #addAction(DockingActionIf)}. There is also
+ * an alternate method for getting actions to appear in the popup context menu (see
+ * {@link #addPopupActionProvider(PopupActionProvider)}). The popup listener mechanism is generally not
+ * needed and should only be used in special circumstances (see {@link PopupActionProvider}).
+ *
+ *
The PluginTool also manages tasks that run in the background, and options used by the plugins.
*
*/
-public abstract class PluginTool extends AbstractDockingTool
- implements Tool, DockWinListener, ServiceProvider {
+public abstract class PluginTool extends AbstractDockingTool implements Tool, ServiceProvider {
private static final String DOCKING_WINDOWS_ON_TOP = "Docking Windows On Top";
@@ -96,8 +96,6 @@ public abstract class PluginTool extends AbstractDockingTool
private DialogManager dialogMgr;
private PropertyChangeSupport propertyChangeMgr;
- private WeakSet popupListeners =
- WeakDataStructureFactory.createSingleThreadAccessWeakSet();
private OptionsChangeListener optionsListener = new ToolOptionsListener();
protected ManagePluginsDialog manageDialog;
protected ExtensionTableProvider extensionTableProvider;
@@ -192,7 +190,7 @@ public abstract class PluginTool extends AbstractDockingTool
List windowIcons = ApplicationInformationDisplayFactory.getWindowIcons();
DockingWindowManager newManager =
- new DockingWindowManager(this, windowIcons, this, isModal, isDockable, hasStatus, null);
+ new DockingWindowManager(this, windowIcons, isModal, isDockable, hasStatus, null);
return newManager;
}
@@ -264,17 +262,6 @@ public abstract class PluginTool extends AbstractDockingTool
return winMgr.isWindowsOnTop();
}
- /**
- * Add popup listener that is notified when the popup menu is about to be
- * displayed.
- *
- * @param listener listener that is notified when the popup menu is to
- * be displayed
- */
- public void addPopupListener(PopupListener listener) {
- popupListeners.add(listener);
- }
-
/**
* Returns the manage plugins dialog that is currently
* being used.
@@ -308,15 +295,6 @@ public abstract class PluginTool extends AbstractDockingTool
showDialog(extensionTableProvider);
}
- /**
- * Remove popup listener
- * @param listener listener that is notified when the popup menu is to
- * be displayed
- */
- public void removePopupListener(PopupListener listener) {
- popupListeners.remove(listener);
- }
-
/**
* Set whether a component's header should be shown; the header is the component that
* is dragged in order to move the component within the tool, or out of the tool
@@ -1102,19 +1080,6 @@ public abstract class PluginTool extends AbstractDockingTool
eventMgr.clearLastEvents();
}
- @Override
- public List getPopupActions(ActionContext context) {
-
- List actionList = new ArrayList<>();
- for (PopupListener pl : popupListeners) {
- List actions = pl.getPopupActions(context);
- if (actions != null) {
- actionList.addAll(actions);
- }
- }
- return actionList;
- }
-
/**
* Close this tool:
*
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PopupListener.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PopupListener.java
deleted file mode 100644
index 5cca8158d7..0000000000
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PopupListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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.
- * 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.plugintool;
-
-import java.util.List;
-
-import docking.ActionContext;
-import docking.action.DockingActionIf;
-
-/**
- * PopupListener
provides notification when the popup action
- * menu is displayed.
- */
-public interface PopupListener {
-
- /**
- * Provides notification that the popup menu is about to be displayed
- * and allows a set of temporary actions to be included in the popup menu.
- * Actions returned will be included in the menu if they have a valid popup
- * menu path and respond true to the isValidContext method.
- * @param context the ActionContext
- * @return list of temporary popup actions (null may be returned)
- */
- List getPopupActions(ActionContext context);
-
-}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/tool/GhidraTool.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/tool/GhidraTool.java
index c9804a1f47..cadcb8c8d4 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/tool/GhidraTool.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/tool/GhidraTool.java
@@ -84,7 +84,7 @@ public class GhidraTool extends PluginTool {
@Override
protected DockingWindowManager createDockingWindowManager(boolean isDockable, boolean hasStatus,
boolean isModal) {
- return new DockingWindowManager(this, null, this, isModal, isDockable, hasStatus,
+ return new DockingWindowManager(this, null, isModal, isDockable, hasStatus,
new OpenFileDropHandlerFactory(this));
}
diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/VersionControlScreenShots.java b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/VersionControlScreenShots.java
index 95eccb2390..2ea3e10283 100644
--- a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/VersionControlScreenShots.java
+++ b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/VersionControlScreenShots.java
@@ -136,9 +136,8 @@ public class VersionControlScreenShots extends GhidraScreenShotGenerator {
@Test
public void testVersionHistory() throws Exception {
- VersionHistoryDialog dialog = new VersionHistoryDialog();
DomainFile df = createDomainFile();
- dialog.setDomainFile(df);
+ VersionHistoryDialog dialog = new VersionHistoryDialog(df);
runSwing(() -> tool.showDialog(dialog));
VersionHistoryDialog d = waitForDialogComponent(dialog.getClass());