docking.action.DockingAction Java Examples
The following examples show how to use
docking.action.DockingAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProgramPlugin.java From ghidra with Apache License 2.0 | 6 votes |
/** * Enable the action when a program location event comes in; disable it * if either the location is null, or if the address in the location * is null. * @throws IllegalArgumentException if this action was called for * another enableOnXXX(PlugAction) method. * @deprecated {@link ActionContext} is now used for action enablement. Deprecated in 9.1; to * be removed no sooner than two versions after that. */ @Deprecated protected void enableOnLocation(DockingAction action) { if (programActionList.contains(action)) { throw new IllegalArgumentException("Action already added to program action list"); } if (selectionActionList.contains(action)) { throw new IllegalArgumentException("Action already added to selection action list"); } if (highlightActionList.contains(action)) { throw new IllegalArgumentException("Action already added to highlight action list"); } locationActionList.add(action); action.setEnabled(currentLocation != null); }
Example #2
Source File: TipOfTheDayPlugin.java From ghidra with Apache License 2.0 | 6 votes |
@Override protected void init() { action = new DockingAction("Tips of the day", getName()) { @Override public void actionPerformed(ActionContext context) { dialog.doShow(tool.getToolFrame()); } }; action.setMenuBarData(new MenuData(new String[] { "Help", "Tip of the Day" }, ToolConstants.HELP_CONTENTS_MENU_GROUP)); action.setEnabled(true); action.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Tip_of_the_day")); tool.addAction(action); List<String> tips = null; try { tips = loadTips(); } catch (IOException e) { tips = new ArrayList<>(); } dialog = new TipOfTheDayDialog(this, tips); readPreferences(); }
Example #3
Source File: MemoryMapPluginScreenShots.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testMoveMemory() { performAction("Memory Map", "DockingWindows", true); ComponentProvider provider = getProvider("Memory Map"); JComponent component = provider.getComponent(); GhidraTable table = findComponent(component, GhidraTable.class); waitForSwing(); selectRow(table, ".text"); waitForSwing(); DockingAction action = (DockingAction) getInstanceField("moveAction", provider); performAction(action, false); captureDialog(); }
Example #4
Source File: GhidraTool.java From ghidra with Apache License 2.0 | 6 votes |
private void addCloseAction() { DockingAction closeAction = new DockingAction("Close Tool", ToolConstants.TOOL_OWNER) { @Override public void actionPerformed(ActionContext context) { close(); } }; closeAction.setHelpLocation( new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, closeAction.getName())); closeAction.setEnabled(true); closeAction.setMenuBarData( new MenuData(new String[] { ToolConstants.MENU_FILE, "Close Tool" }, null, "Window_A")); addAction(closeAction); }
Example #5
Source File: ComputeChecksumsPluginTest.java From ghidra with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { env = new TestEnv(); tool = env.getTool(); configureTool(tool); plugin = env.getPlugin(ComputeChecksumsPlugin.class); showProviderAction = (DockingAction) getAction(plugin, "GenerateChecksum"); computeAction = (DockingAction) getAction(plugin, "Compute Checksum"); hexAction = (ToggleDockingAction) getAction(plugin, "Show Hex Values"); selectionAction = (ToggleDockingAction) getAction(plugin, "On Selection"); onesCompAction = (ToggleDockingAction) getAction(plugin, "Ones Complement"); onesCompAction = (ToggleDockingAction) getAction(plugin, "Ones Complement"); twosCompAction = (ToggleDockingAction) getAction(plugin, "Twos Complement"); openProgram(); }
Example #6
Source File: MemoryMapPluginScreenShots.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testMemoryExpandUp() { performAction("Memory Map", "DockingWindows", true); ComponentProvider provider = getProvider("Memory Map"); JComponent component = provider.getComponent(); GhidraTable table = findComponent(component, GhidraTable.class); waitForSwing(); selectRow(table, ".text"); waitForSwing(); DockingAction action = (DockingAction) getInstanceField("expandUpAction", provider); performAction(action, false); captureDialog(); }
Example #7
Source File: FrontEndPlugin.java From ghidra with Apache License 2.0 | 6 votes |
protected void createToolSpecificOpenActions() { for (DockingAction action : openActions) { tool.removeAction(action); } if (activeProject == null) { return; } ToolChest toolChest = activeProject.getLocalToolChest(); if (toolChest == null) { return; } tool.setMenuGroup(new String[] { "Open With" }, "Open"); ToolTemplate[] templates = toolChest.getToolTemplates(); for (ToolTemplate toolTemplate : templates) { final String toolName = toolTemplate.getName(); DockingAction toolAction = new ProjectDataOpenToolAction(getName(), "Open", toolName, toolTemplate.getIcon()); tool.addAction(toolAction); openActions.add(toolAction); } }
Example #8
Source File: LabelMgrPlugin.java From ghidra with Apache License 2.0 | 6 votes |
/** * Creation of the Label Mgr plugin actions. */ private void setupActions() { DockingAction addLabelAction = new AddLabelAction(this); tool.addAction(addLabelAction); // add the plugin action DockingAction editLabelAction = new EditLabelAction(this); tool.addAction(editLabelAction); DockingAction editExternalLabelAction = new EditExternalLabelAction(this); tool.addAction(editExternalLabelAction); DockingAction removeLabelAction = new RemoveLabelAction(this); tool.addAction(removeLabelAction); // add the plugin action DockingAction setOperandLabelAction = new SetOperandLabelAction(this); tool.addAction(setOperandLabelAction); // add the plugin action DockingAction labelHistoryAction = new LabelHistoryAction(tool, getName()); tool.addAction(labelHistoryAction); // Create the Show All History action DockingAction allHistoryAction = new AllHistoryAction(tool, getName()); tool.addAction(allHistoryAction); }
Example #9
Source File: HeaderActionsTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testRemoveFieldAction() { FormatManager formatManager = header.getFormatManager(); FieldFormatModel functionFormat = formatManager.getFunctionFormat(); FieldFactory[] factories = functionFormat.getFactorys(0); selectHeaderField(factories[0]); assertEquals(3, factories.length); assertTrue(factories[1] instanceof FunctionSignatureFieldFactory); FieldHeaderLocation loc = new FieldHeaderLocation(functionFormat, factories[1], 0, 1); ActionContext context = createContext(provider, loc); DockingAction headerAction = getHeaderAction("Remove Field"); performAction(headerAction, context, true); factories = functionFormat.getFactorys(0); assertTrue(!(factories[1] instanceof FunctionSignatureFieldFactory)); assertEquals(2, factories.length); }
Example #10
Source File: HeaderActionsTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testDisableEnableFieldActions() { FormatManager formatManager = header.getFormatManager(); FieldFormatModel functionFormat = formatManager.getFunctionFormat(); FieldFactory[] factories = functionFormat.getFactorys(0); selectHeaderField(factories[0]); assertTrue(factories[1].isEnabled()); FieldHeaderLocation loc = new FieldHeaderLocation(functionFormat, factories[1], 0, 0); ActionContext context = createContext(provider, loc); DockingAction headerAction = getHeaderAction("Disable Field"); performAction(headerAction, context, true); assertTrue(!factories[1].isEnabled()); headerAction = getHeaderAction("Enable Field"); performAction(headerAction, context, true); assertTrue(factories[1].isEnabled()); }
Example #11
Source File: MemoryMapPluginScreenShots.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testMemoryExpandDown() { performAction("Memory Map", "DockingWindows", true); ComponentProvider provider = getProvider("Memory Map"); JComponent component = provider.getComponent(); GhidraTable table = findComponent(component, GhidraTable.class); waitForSwing(); selectRow(table, ".text"); waitForSwing(); DockingAction action = (DockingAction) getInstanceField("expandDownAction", provider); performAction(action, false); captureDialog(); }
Example #12
Source File: MemoryMapPluginScreenShots.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testSplitMemoryBlock() { performAction("Memory Map", "DockingWindows", true); ComponentProvider provider = getProvider("Memory Map"); JComponent component = provider.getComponent(); GhidraTable table = findComponent(component, GhidraTable.class); waitForSwing(); selectRow(table, ".text"); waitForSwing(); DockingAction action = (DockingAction) getInstanceField("splitAction", provider); performAction(action, false); captureDialog(); }
Example #13
Source File: FrontEndTool.java From ghidra with Apache License 2.0 | 6 votes |
private void createActions() { addExitAction(); addManagePluginsAction(); addManageExtensionsAction(); addOptionsAction(); addHelpActions(); // our log file action DockingAction action = new DockingAction("Show Log", ToolConstants.TOOL_OWNER) { @Override public void actionPerformed(ActionContext context) { showGhidraUserLogFile(); } }; action.setMenuBarData( new MenuData(new String[] { ToolConstants.MENU_HELP, "Show Log" }, null, "BBB")); action.setEnabled(true); addAction(action); }
Example #14
Source File: HeaderActionsTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testAddSpacerAction() { FormatManager formatManager = header.getFormatManager(); FieldFormatModel functionFormat = formatManager.getFunctionFormat(); FieldFactory[] factories = functionFormat.getFactorys(0); assertTrue(factories[0] instanceof SpacerFieldFactory); assertTrue(factories[1] instanceof FunctionSignatureFieldFactory); assertEquals(200, factories[1].getStartX()); selectHeaderField(factories[0]); FieldHeaderLocation loc = new FieldHeaderLocation(functionFormat, factories[0], 0, 0); ActionContext context = createContext(provider, loc); DockingAction headerAction = getHeaderAction("Add Spacer Field"); performAction(headerAction, context, true); functionFormat = formatManager.getFunctionFormat(); factories = functionFormat.getFactorys(0); assertTrue(factories[0] instanceof SpacerFieldFactory); assertTrue(factories[1] instanceof SpacerFieldFactory); assertTrue(factories[2] instanceof FunctionSignatureFieldFactory); assertEquals(300, factories[2].getStartX()); }
Example #15
Source File: TableChooserDialog.java From ghidra with Apache License 2.0 | 6 votes |
private void createActions() { String owner = getClass().getSimpleName(); DockingAction selectAction = new MakeProgramSelectionAction(owner, table) { @Override protected ProgramSelection makeSelection(ActionContext context) { ProgramSelection selection = table.getProgramSelection(); if (navigatable != null) { navigatable.goTo(program, new ProgramLocation(program, selection.getMinAddress())); navigatable.setSelection(selection); navigatable.requestFocus(); } return selection; } }; DockingAction selectionNavigationAction = new SelectionNavigationAction(owner, table); selectionNavigationAction.setHelpLocation( new HelpLocation(HelpTopics.SEARCH, "Selection_Navigation")); addAction(selectAction); addAction(selectionNavigationAction); }
Example #16
Source File: InterpreterComponentProvider.java From ghidra with Apache License 2.0 | 6 votes |
/** * Overridden so that we can add our custom actions for transient tools. */ @Override public void setTransient() { DockingAction disposeAction = new DockingAction("Remove Interpreter", getName()) { @Override public void actionPerformed(ActionContext context) { int choice = OptionDialog.showYesNoDialog(panel, "Remove Interpreter?", "Are you sure you want to permanently close the interpreter?"); if (choice == OptionDialog.NO_OPTION) { return; } InterpreterComponentProvider.this.dispose(); } }; disposeAction.setDescription("Remove interpreter from tool"); disposeAction.setToolBarData(new ToolBarData(Icons.STOP_ICON, null)); disposeAction.setEnabled(true); addLocalAction(disposeAction); }
Example #17
Source File: RestoreSelectionPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private void createActions() { DockingAction action = new DockingAction( RESTORE_SELECTION_ACTION_NAME, getName() ) { @Override public void actionPerformed( ActionContext context ) { SelectionState programSelectionState = programToSelectionMap.get( currentProgram ); firePluginEvent( new ProgramSelectionPluginEvent( RestoreSelectionPlugin.this.getName(), programSelectionState.getSelectionToRestore(), currentProgram ) ); } }; // ACTIONS - auto generated action.setMenuBarData( new MenuData( new String[]{ToolConstants.MENU_SELECTION, RESTORE_SELECTION_ACTION_NAME}, null, "SelectUtils" ) ); action.setHelpLocation(new HelpLocation(HelpTopics.SELECTION, RESTORE_SELECTION_ACTION_NAME)); action.setEnabled( false ); tool.addAction( action ); restoreSelectionAction = action; }
Example #18
Source File: MultiTabPluginTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testGoToLastProgramAction() throws Exception { openPrograms_HideLastOpened(); Program startProgram = panel.getSelectedProgram(); MultiTabPlugin plugin = env.getPlugin(MultiTabPlugin.class); DockingAction action = (DockingAction) TestUtils.getInstanceField("goToLastActiveProgramAction", plugin); assertTrue(!action.isEnabled());// disabled before we've changed tabs // select second tab JPanel tab = panel.getTab(programs[1]); Point p = tab.getLocationOnScreen(); clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0); assertEquals(programs[1], panel.getSelectedProgram()); assertTrue(!startProgram.equals(panel.getSelectedProgram())); assertTrue(action.isEnabled()); performAction(action, true); assertEquals(startProgram, panel.getSelectedProgram()); }
Example #19
Source File: CopyPasteCommentsTest.java From ghidra with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private DockingAction getLocalAction(ClipboardContentProviderService service, String actionName, ClipboardPlugin clipboardPlugin) { Map<?, ?> serviceMap = (Map<?, ?>) getInstanceField("serviceActionMap", clipboardPlugin); Set<?> keySet = serviceMap.keySet(); for (Object name : keySet) { ClipboardContentProviderService currentService = (ClipboardContentProviderService) name; if (currentService == service) { List<DockingAction> actionList = (List<DockingAction>) serviceMap.get(service); for (DockingAction pluginAction : actionList) { if (pluginAction.getName().equals(actionName)) { return pluginAction; } } } } return null; }
Example #20
Source File: DiffDetailsProvider.java From ghidra with Apache License 2.0 | 6 votes |
public void addActions() { DockingAction refreshDetailsAction = new DockingAction("Refresh Diff Details", plugin.getName()) { @Override public void actionPerformed(ActionContext context) { refreshDetails(plugin.getCurrentLocation()); } }; refreshDetailsAction.setDescription( "Refresh the details to show any differences at the current location."); refreshDetailsAction.setEnabled(true); refreshDetailsAction.setToolBarData(new ToolBarData(REFRESH_ICON, "Diff")); refreshDetailsAction.setHelpLocation( new HelpLocation(HelpTopics.DIFF, "Refresh Diff Details")); plugin.getTool().addLocalAction(this, refreshDetailsAction); // plugin.getTool().addLocalAction(this, new DiffIgnoreAllAction(this)); }
Example #21
Source File: HeaderActionsTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testAddAllFieldsAction() { FormatManager formatManager = header.getFormatManager(); FieldFormatModel functionFormat = formatManager.getFunctionFormat(); FieldFactory[] factories = functionFormat.getFactorys(0); int defaultSize = factories.length; selectHeaderField(factories[0]); functionFormat.removeAllFactories(); FieldHeaderLocation loc = new FieldHeaderLocation(functionFormat, factories[1], 0, 1); ActionContext context = createContext(provider, loc); DockingAction headerAction = getHeaderAction("Add All Field"); performAction(headerAction, context, true); factories = functionFormat.getFactorys(0); assertTrue(factories.length > defaultSize); }
Example #22
Source File: SymbolMapExporterPlugin.java From Ghidra-GameCube-Loader with Apache License 2.0 | 6 votes |
/** * Method to create the "standard" actions, which users controlling or creating * FID databases would want to use. */ private void createStandardActions() { DockingAction action = new DockingAction("Export Symbols", getName()) { @Override public void actionPerformed(ActionContext context) { try { exportToFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; action.setMenuBarData( new MenuData(new String[] { ToolConstants.MENU_TOOLS, SymbolMapExporterPlugin.NAME, "Export to File..." }, null, MENU_GROUP_1, MenuData.NO_MNEMONIC, "1")); action.setDescription("Export Symbols to a file"); tool.addAction(action); chooseAction = action; }
Example #23
Source File: ProgramDnDTree.java From ghidra with Apache License 2.0 | 6 votes |
/** * Return whether the given action should be added to popup, based * on what is currently selected. Called by the ProgramTreeAction. */ boolean addActionToPopup(DockingAction action) { if (!(action instanceof ProgramTreeAction)) { return true; } ProgramTreeAction a = (ProgramTreeAction) action; int selectionCount = getSelectionCount(); if (a.getSelectionType() == ProgramTreeAction.SINGLE_SELECTION) { if (selectionCount == 1) { return true; } else if (selectionCount == 0) { return true; } return false; } // allow 1 or many in selection if (selectionCount > 0) { return true; } return false; }
Example #24
Source File: ProcessorListPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private void setupActions() { processorListAction = new DockingAction(ACTION_NAME, PLUGIN_NAME) { @Override public void actionPerformed(ActionContext context) { showProcessorList(); } }; processorListAction.setEnabled(true); processorListAction.setMenuBarData( new MenuData(new String[] { ToolConstants.MENU_HELP, ACTION_NAME }, null, "AAAZ")); processorListAction.setHelpLocation(new HelpLocation(HelpTopics.ABOUT, "ProcessorList")); processorListAction.setDescription(getPluginDescription().getDescription()); tool.addAction(processorListAction); }
Example #25
Source File: HeaderActionsTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testResetFormatAction() { FormatManager formatManager = header.getFormatManager(); FieldFormatModel functionFormat = formatManager.getFunctionFormat(); FieldFactory[] factorys = functionFormat.getFactorys(0); selectHeaderField(factorys[0]); removeAllFactories(functionFormat); assertEquals(0, functionFormat.getNumFactorys(0)); DockingAction headerAction = getHeaderAction("Reset Format"); performAction(headerAction, false); pressContinueOnResetFormatDialog("Reset Format?"); functionFormat = formatManager.getFunctionFormat(); assertEquals(3, functionFormat.getNumFactorys(0)); }
Example #26
Source File: CParserPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private void createActions() { DockingAction parseAction = new DockingAction(PARSE_ACTION_NAME, getName()) { @Override public void actionPerformed(ActionContext context) { showParseDialog(); } }; String[] menuPath = { ToolConstants.MENU_FILE, "Parse C Source..." }; MenuData menuData = new MenuData(menuPath, "Import/Export"); menuData.setMenuSubGroup("d"); // below the major actions in the "Import/Export" group parseAction.setMenuBarData(menuData); parseAction.setDescription(DESCRIPTION); parseAction.setHelpLocation(new HelpLocation(this.getName(), "Parse_C_Source")); parseAction.setEnabled(true); tool.addAction(parseAction); }
Example #27
Source File: TemplateProgramPlugin.java From ghidra with Apache License 2.0 | 6 votes |
/** * Set up Actions */ private void setupActions() { // // Function 1 // action = new DockingAction("Function 1 Code", getName()) { @Override public void actionPerformed(ActionContext e) { Function_1(); } @Override public boolean isValidContext(ActionContext context) { return context instanceof ListingActionContext; } }; action.setEnabled(false); action.setMenuBarData( new MenuData(new String[] { "Misc", "Menu", "Menu item 1" }, null, null)); action.setHelpLocation( new HelpLocation("SampleHelpTopic", "TemplateProgramPlugin_Anchor_Name")); tool.addAction(action); }
Example #28
Source File: FunctionGraphPluginScreenShots.java From ghidra with Apache License 2.0 | 6 votes |
private DialogComponentProvider showGroupTextDialog(FGVertex... vertices) { HashSet<FGVertex> set = new HashSet<>(); for (FGVertex v : vertices) { set.add(v); } pickVertices(set); FGVertex aVertex = vertices[0]; JComponent component = getComponent(aVertex); DockingAction action = (DockingAction) TestUtils.getInstanceField("groupAction", component); performAction(action, graphProvider, false); waitForAnimation(); return waitForDialogComponent(MultiLineInputDialog.class); }
Example #29
Source File: FindPossibleReferencesPlugin.java From ghidra with Apache License 2.0 | 5 votes |
private void createLocalActions(ProgramLocationActionContext context, ComponentProvider p, FindReferencesTableModel model) { addLocalAlignment(p, model, 1); addLocalAlignment(p, model, 2); addLocalAlignment(p, model, 3); addLocalAlignment(p, model, 4); addLocalAlignment(p, model, 8); final ProgramSelection selection = context.getSelection(); final Program pgm = context.getProgram(); DockingAction localAction = new DockingAction(RESTORE_SELECTION_ACTION_NAME, getName()) { @Override public void actionPerformed(ActionContext actionContext) { restoreSearchSelection(selection, pgm); } }; localAction.setEnabled(false); localAction.setHelpLocation( new HelpLocation(HelpTopics.SEARCH, RESTORE_SELECTION_ACTION_NAME)); String group = "selection"; localAction.setMenuBarData( new MenuData(new String[] { "Restore Search Selection" }, group)); localAction.setPopupMenuData( new MenuData(new String[] { "Restore Search Selection" }, group)); localAction.setDescription( "Sets the program selection back to the selection this search was based upon."); if (selection != null && !selection.isEmpty()) { localAction.setEnabled(true); tool.addLocalAction(p, localAction); } }
Example #30
Source File: SkeletonPlugin.java From ghidra with Apache License 2.0 | 5 votes |
private void createActions() { action = new DockingAction("My Action", getName()) { @Override public void actionPerformed(ActionContext context) { Msg.showInfo(getClass(), panel, "Custom Action", "Hello!"); } }; action.setToolBarData(new ToolBarData(Icons.ADD_ICON, null)); action.setEnabled(true); action.markHelpUnnecessary(); dockingTool.addLocalAction(this, action); }