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

The following examples show how to use docking.action.DockingAction#setEnabled() . 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 vote down vote up
/**
 * 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: 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 3
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 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: 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 6
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 7
Source File: InterpreterComponentProvider.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * 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 8
Source File: DiffDetailsProvider.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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 9
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 10
Source File: EventDisplayComponentProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createAction() {
	clearAction = new DockingAction("Clear Display", getName()) {
		@Override
		public void actionPerformed(ActionContext context) {
			clear();
		}
	};

	clearAction.markHelpUnnecessary();
	clearAction.setEnabled(true);
	ImageIcon icon = ResourceManager.loadImage("images/erase16.png");
	clearAction.setToolBarData(new ToolBarData(icon));
	addLocalAction(clearAction);
}
 
Example 11
Source File: DomainFolderChangesDisplayComponentProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createAction() {
	clearAction = new DockingAction("Clear Display", getName()) {
		@Override
		public void actionPerformed(ActionContext context) {
			clear();
		}
	};
	clearAction.setEnabled(true);
	ImageIcon icon = ResourceManager.loadImage("images/erase16.png");
	clearAction.setToolBarData(new ToolBarData(icon));
	addLocalAction(clearAction);
}
 
Example 12
Source File: ProgramPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Enable the action when the program is opened; disable it when
 * the program is closed.
 * @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 enableOnProgram(DockingAction action) {
	if (locationActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to location 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");
	}
	programActionList.add(action);
	action.setEnabled(currentProgram != null);
}
 
Example 13
Source File: GhidraX64DbgPlugin.java    From GhidraX64Dbg with MIT License 5 votes vote down vote up
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);
}
 
Example 14
Source File: ProgramPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Enable the action when a selection event comes in; disable it if
 * the selection is null or empty.
 * @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 enableOnSelection(DockingAction action) {
	if (programActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to program action list");
	}
	if (locationActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to location action list");
	}
	if (highlightActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to highlight action list");
	}
	selectionActionList.add(action);
	action.setEnabled(currentSelection != null);
}
 
Example 15
Source File: ProgramPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Enable the action when a highlight event comes in; disable it if
 * the highlight is null or empty.
 * @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 enableOnHighlight(DockingAction action) {
	if (programActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to program action list");
	}
	if (locationActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to location action list");
	}
	if (selectionActionList.contains(action)) {
		throw new IllegalArgumentException("Action already added to selection action list");
	}
	highlightActionList.add(action);
	action.setEnabled(currentHighlight != null);
}
 
Example 16
Source File: ShowInfoComponentProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createActions() {
	clearAction = new DockingAction("Clear Text Area", getName()) {
		@Override
		public void actionPerformed(ActionContext context) {
			textArea.setText("");
		}
	};
	clearAction.setToolBarData(new ToolBarData(CLEAR_ICON, null));

	clearAction.setEnabled(true);
	tool.addLocalAction(this, clearAction);
}
 
Example 17
Source File: SkeletonPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 18
Source File: SymbolTreeProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createActions() {
	DockingAction createImportAction = new CreateLibraryAction(plugin);
	DockingAction setExternalProgramAction = new SetExternalProgramAction(plugin, this);
	DockingAction createExternalLocationAction = new CreateExternalLocationAction(plugin);
	DockingAction editExternalLocationAction = new EditExternalLocationAction(plugin);
	DockingAction createClassAction = new CreateClassAction(plugin);
	DockingAction createNamespaceAction = new CreateNamespaceAction(plugin);

	DockingAction renameAction = new RenameAction(plugin);
	DockingAction cutAction = new CutAction(plugin, this);
	DockingAction pasteAction = new PasteAction(plugin, this);
	DockingAction deleteAction = new DeleteAction(plugin);
	deleteAction.setEnabled(false);

	DockingAction referencesAction =
		new ShowSymbolReferencesAction(plugin.getTool(), plugin.getName());

	DockingAction selectionAction = new SelectionAction(plugin);
	selectionAction.setEnabled(false);

	goToToggleAction = new GoToToggleAction(plugin);
	DockingAction goToExternalAction = new GoToExternalLocationAction(plugin);
	goToExternalAction.setEnabled(false);

	tool.addLocalAction(this, createImportAction);
	tool.addLocalAction(this, setExternalProgramAction);
	tool.addLocalAction(this, createExternalLocationAction);
	tool.addLocalAction(this, editExternalLocationAction);
	tool.addLocalAction(this, createClassAction);
	tool.addLocalAction(this, createNamespaceAction);
	tool.addLocalAction(this, renameAction);
	tool.addLocalAction(this, cutAction);
	tool.addLocalAction(this, pasteAction);
	tool.addLocalAction(this, deleteAction);
	tool.addLocalAction(this, referencesAction);
	tool.addLocalAction(this, goToToggleAction);
	tool.addLocalAction(this, selectionAction);
	tool.addLocalAction(this, goToExternalAction);
}
 
Example 19
Source File: InterpreterComponentProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createActions() {

		DockingAction clearAction = new DockingAction("Clear Interpreter", getName()) {
			@Override
			public void actionPerformed(ActionContext context) {
				clear();
			}
		};
		clearAction.setDescription("Clear Interpreter");
		clearAction.setToolBarData(new ToolBarData(ResourceManager.loadImage(CLEAR_GIF), null));
		clearAction.setEnabled(true);

		addLocalAction(clearAction);
	}
 
Example 20
Source File: ProgramPlugin.java    From ghidra with Apache License 2.0 3 votes vote down vote up
/**
 * Enable actions in the list according to the enabled param.
 * @param enabled true means to enable the action AND set the
 * add to popup as true; false means disable the action and set
 * add to popup according to the removeFromPopup
 * @param removeFromPopup only used if enabled is false
 */
private void enableActions(ArrayList<DockingAction> list, boolean enabled) {
	for (int i = 0; i < list.size(); i++) {
		DockingAction a = list.get(i);
		a.setEnabled(enabled);
	}
}