Java Code Examples for docking.action.DockingAction#setMenuBarData()

The following examples show how to use docking.action.DockingAction#setMenuBarData() . 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: GhidraTool.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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 2
Source File: FrontEndTool.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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 3
Source File: ProcessorListPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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 4
Source File: RestoreSelectionPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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 5
Source File: TipOfTheDayPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: CParserPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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 7
Source File: TemplateProgramPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
* 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 8
Source File: HelloWorldPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Plugin constructor - all plugins must have a constructor with this signature
 * @param tool the pluginTool that this plugin is added to.
 */
public HelloWorldPlugin(PluginTool tool) {
	super(tool);

	// Create the hello action.
	helloAction = new DockingAction("Hello World", getName()) {
		@Override
		public void actionPerformed(ActionContext context) {
			Msg.info(this, "Hello World!");
		}
	};
	// Enable the action - by default actions are disabled.
	helloAction.setEnabled(true);

	// Put the action in the global "View" menu.
	helloAction.setMenuBarData(new MenuData(new String[] { "View", "Hello World" }));

	// Add the action to the tool.
	tool.addAction(helloAction);
}
 
Example 9
Source File: SymbolMapExporterPlugin.java    From Ghidra-GameCube-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * 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 10
Source File: ProjectActionManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createSwitchWorkspaceAction() {
	String owner = plugin.getName();

	switchWSAction = new DockingAction("Switch Workspace", owner) {
		@Override
		public void actionPerformed(ActionContext context) {
			ToolManager toolManager = activeProject.getToolManager();
			Workspace[] workspaces = toolManager.getWorkspaces();
			if (workspaces.length <= 1) {
				Msg.info("FrontEnd", "Unable to switch workspace, only 1 exists.");
				return;//can't switch, there is only 1
			}
			Workspace activeWorkspace = plugin.getWorkspacePanel().getActiveWorkspace();
			int index = 0;
			for (Workspace workspace : workspaces) {
				++index;
				if (workspace.equals(activeWorkspace)) {
					break;
				}
			}
			if (index >= workspaces.length) {
				index = 0;//at the end, so loop back around
			}
			plugin.getWorkspacePanel().setActiveWorkspace(workspaces[index]);
		}
	};
	switchWSAction.setEnabled(false);

	switchWSAction.setMenuBarData(new MenuData(
		new String[] { ToolConstants.MENU_PROJECT, "Workspace", "Switch..." }, "zProject"));
	tool.addAction(switchWSAction);
}
 
Example 11
Source File: JavaHelpPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public JavaHelpPlugin(PluginTool tool) {
	super(tool);

	DockingAction action = new DockingAction("Generate Help Info File", getName()) {
		@Override
		public void actionPerformed(ActionContext context) {
			TaskLauncher.launch(new WriterTask());
		}
	};

	DockingWindowManager.getHelpService().excludeFromHelp(action);
	action.setMenuBarData(
		new MenuData(new String[] { ToolConstants.MENU_TOOLS, "Write Help Info File" }));
	tool.addAction(action);
}
 
Example 12
Source File: FindPossibleReferencesPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
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 13
Source File: SelectByScopedFlowPlugin.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void createActions() {
	DockingAction action =
		new NavigatableContextAction("Select Forward Scoped Flow", getName()) {
			@Override
			public void actionPerformed(NavigatableActionContext context) {
				FunctionManager functionManager = currentProgram.getFunctionManager();
				Function function =
					functionManager.getFunctionContaining(currentLocation.getAddress());

				if (!isValidFunction(function)) {
					Msg.showWarn(this, null, "Cursor Must Be In a Function",
						"Selecting scoped flow requires the cursor to be " +
							"inside of a function");
					return;
				}

				try {
					ProgramSelection selection = makeForwardScopedSelection(function,
						currentProgram, currentLocation, new TaskMonitorAdapter(true));
					updateStatusText(selection);
					setSelection(selection);
				}
				catch (CancelledException e) {
					Msg.debug(this, "Calculating Forward Scoped Flow cancelled", e);
				}
			}
		};
	action.setMenuBarData(new MenuData(
		new String[] { ToolConstants.MENU_SELECTION, "Scoped Flow", "Forward Scoped Flow" },
		null, "Select"));

	action.setDescription("Allows user to select scoped flow from current location.");
	action.setHelpLocation(new HelpLocation("FlowSelection", "Scoped_Flow"));
	tool.addAction(action);

	action = new NavigatableContextAction("Select Reverse Scoped Flow", getName()) {
		@Override
		public void actionPerformed(NavigatableActionContext context) {
			FunctionManager functionManager = currentProgram.getFunctionManager();
			Function function =
				functionManager.getFunctionContaining(currentLocation.getAddress());

			if (!isValidFunction(function)) {
				Msg.showWarn(this, null, "Cursor Must Be In a Function",
					"Selecting scoped flow requires the cursor to be " +
						"inside of a function");
				return;
			}

			try {
				ProgramSelection selection = makeReverseScopedSelection(function,
					currentProgram, currentLocation, new TaskMonitorAdapter(true));
				updateStatusText(selection);
				setSelection(selection);
			}
			catch (CancelledException e) {
				Msg.debug(this, "Calculating Reverse Scoped Flow cancelled", e);
			}
		}
	};
	action.setMenuBarData(new MenuData(
		new String[] { ToolConstants.MENU_SELECTION, "Scoped Flow", "Reverse Scoped Flow" },
		null, "Select"));

	action.setDescription("Allows user to select scoped flow to the current location.");
	action.setHelpLocation(new HelpLocation("FlowSelection", "Scoped_Flow"));
	tool.addAction(action);
}