Java Code Examples for docking.widgets.OptionDialog#NO_OPTION

The following examples show how to use docking.widgets.OptionDialog#NO_OPTION . 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: PluginTool.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Can this tool be closed?
 * <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.
 */
public boolean canClose(boolean isExiting) {
	if (taskMgr.isBusy()) {
		if (isExiting) {
			int result = OptionDialog.showYesNoDialog(getToolFrame(),
				"Tool Busy Executing Task",
				"The tool is busy performing a background task.\n If you continue the" +
					" task may be terminated and some work may be lost!\n\nContinue anyway?");
			if (result == OptionDialog.NO_OPTION) {
				return false;
			}
			taskMgr.stop(false);
		}
		else {
			beep();
			Msg.showInfo(getClass(), getToolFrame(), "Tool Busy",
				"You must stop all background tasks before exiting.");
			return false;
		}
	}
	if (!pluginMgr.canClose()) {
		return false;
	}
	return true;
}
 
Example 2
Source File: EditExternalLocationPanel.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private boolean validLocationName() {
	// Will this generate a duplicate name conflict?
	String extLibName = getExtLibName();
	if (extLibName == null || extLibName.length() == 0) {
		return true; // Any name is considered valid until we have a external library for it.
	}
	String locationName = getLocationName();
	if (locationName != null && locationName.length() > 0) {
		ExternalManager externalManager = program.getExternalManager();
		List<ExternalLocation> externalLocations =
			externalManager.getExternalLocations(extLibName, locationName);
		externalLocations.remove(externalLocation);
		if (!externalLocations.isEmpty()) {
			int result = OptionDialog.showYesNoDialog(null, "Duplicate External Name",
				"Another symbol named '" + locationName + "' already exists in the '" +
					extLibName + "' library. Are you sure you want to create another?");
			if (result == OptionDialog.NO_OPTION) {
				selectLocationName();
				return false;
			}
		}
	}
	return true;
}
 
Example 3
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 4
Source File: GFileSystemExtractAllTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private boolean verifyRootOutputDir(String destDirName) {
	boolean isSameName = destDirName.equals(rootOutputDirectory.getName());
	File newRootOutputDir =
		isSameName ? rootOutputDirectory : new File(rootOutputDirectory, destDirName);
	if (newRootOutputDir.isFile()) {
		Msg.showError(this, parentComponent, "Export Destination Error",
			"Unable to export to " + newRootOutputDir + " as it is a file");
		return false;
	}
	if (newRootOutputDir.exists() && newRootOutputDir.list().length > 0) {
		int answer = OptionDialog.showYesNoDialog(parentComponent, "Verify Export Destination",
			newRootOutputDir.getAbsolutePath() + "\n" + "The directory is not empty." + "\n" +
				"Do you want to overwrite the contents?");
		if (answer == OptionDialog.NO_OPTION) {
			return false;
		}
	}
	rootOutputDirectory = newRootOutputDir;
	return true;
}
 
Example 5
Source File: VTSubToolManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean canClose() {
	if (isToolExecutingCommand(sourceTool)) {
		VTPlugin.showBusyToolMessage(sourceTool);
		return false;
	}
	else if (isToolExecutingCommand(destinationTool)) {
		VTPlugin.showBusyToolMessage(destinationTool);
		return false;
	}

	int resp = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Version Tracking",
		"Closing this tool will terminate the active Version " +
			"Tracking Session.\nContinue closing tool?");

	if (resp != OptionDialog.NO_OPTION) {
		closeSessionLater();
	}
	return false;
}
 
Example 6
Source File: VTSubToolManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean canCloseDomainObject(DomainObject dObj) {
	Program sourceProgram = controller.getSourceProgram();
	Program destintationProgram = controller.getDestinationProgram();
	if (dObj != sourceProgram && dObj != destintationProgram) {
		return true;
	}
	int resp = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Version Tracking",
		"Closing this program will terminate " +
			"the active Version Tracking Session.\nContinue?");

	if (resp != OptionDialog.NO_OPTION) {
		closeSessionLater();
	}
	return false;
}
 
Example 7
Source File: ResetToolAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionContext context) {
	DomainFile vtSessionFile = null;
	VTSession session = controller.getSession();
	if (session != null) {
		int result =
			OptionDialog.showYesNoDialog(controller.getTool().getToolFrame(),
				"Restart Session?", "This action needs to close and reopen the "
					+ "session to reset the tools.\nDo you want to continue?");

		if (result == OptionDialog.NO_OPTION) {
			return;
		}
		if (session instanceof VTSessionDB) {
			vtSessionFile = ((VTSessionDB) session).getDomainFile();
		}
		if (!controller.closeVersionTrackingSession()) {
			return; // user cancelled  during save dialog
		}
	}
	toolManager.resetTools();

	if (vtSessionFile != null) {
		controller.openVersionTrackingSession(vtSessionFile);
	}
}
 
Example 8
Source File: RemoveMatchTagAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void removeTag(ActionContext context) {
	VTMatchContext matchContext = (VTMatchContext) context;

	ComponentProvider componentProvider = matchContext.getComponentProvider();
	JComponent component = componentProvider.getComponent();

	String message = "1 tag?";
	if (tagCount > 1) {
		message = tagCount + " tags?";
	}

	int choice =
		OptionDialog.showYesNoDialog(component, "Remove Match Tag?", "Remove " + message);
	if (choice == OptionDialog.NO_OPTION) {
		return;
	}

	List<VTMatch> matches = matchContext.getSelectedMatches();
	ClearMatchTagTask task = new ClearMatchTagTask(matchContext.getSession(), matches);
	new TaskLauncher(task, component);
}
 
Example 9
Source File: ColumnFilterDialog.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public void filterChanged(ColumnBasedTableFilter<R> newFilter) {
	if (Objects.equals(newFilter, filterModel.getTableColumnFilter())) {
		return;
	}
	getComponent().requestFocus();  // work around for java parenting bug where dialog appears behind
	if (filterModel.hasUnappliedChanges()) {
		int result = OptionDialog.showYesNoDialog(getComponent(), "Filter Changed",
			"The filter has been changed externally.\n" +
				" Do you want to update this editor and lose your current changes?");
		if (result == OptionDialog.NO_OPTION) {
			return;
		}
	}
	filterModel.setFilter(newFilter);
}
 
Example 10
Source File: FileFormatsPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a crypto key file template based on the specified files under the GTree node.
 *
 * @param fsrl FSRL of a child file of the container that the crypto will be associated with
 * @param node GTree node with children that will be iterated
 */
private void createCryptoTemplate(FSRL fsrl, FSBRootNode node) {
	try {
		String fsContainerName = fsrl.getFS().getContainer().getName();
		CryptoKeyFileTemplateWriter writer = new CryptoKeyFileTemplateWriter(fsContainerName);
		if (writer.exists()) {
			int answer = OptionDialog.showYesNoDialog(getTool().getActiveWindow(),
				"WARNING!! Crypto Key File Already Exists",
				"WARNING!!" + "\n" + "The crypto key file already exists. " +
					"Are you really sure that you want to overwrite it?");
			if (answer == OptionDialog.NO_OPTION) {
				return;
			}
		}
		writer.open();
		try {
			// gTree.expandAll( node );
			writeFile(writer, node.getChildren());
		}
		finally {
			writer.close();
		}
	}
	catch (IOException e) {
		FSUtilities.displayException(this, getTool().getActiveWindow(),
			"Error writing crypt key file", e.getMessage(), e);
	}

}
 
Example 11
Source File: MemoryMapModel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void revertBlockToUnitialized(MemoryBlock block) {
	int result = OptionDialog.showYesNoDialog(provider.getComponent(),
		"Confirm Setting Block To Unitialized",
		"Are you sure you want to remove the bytes from this block? \n\n" +
			"This will result in removing all functions, instructions, data,\n" +
			"and outgoing references from the block!");

	if (result == OptionDialog.NO_OPTION) {
		return;
	}
	UninitializedBlockCmd cmd = new UninitializedBlockCmd(program, block);
	provider.getTool().executeBackgroundCommand(cmd, program);
}
 
Example 12
Source File: ArchiveUtils.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static boolean canClose(Archive archive, Component component) {
	if (!archive.isChanged()) {
		return true;
	}
	int result =
		OptionDialog.showYesNoCancelDialog(component, "Save Archive?", "Datatype Archive \"" +
			archive.getName() + "\" has been changed.\n Do you want to save the changes?");

	if (result == OptionDialog.CANCEL_OPTION) {
		return false;
	}
	if (result == OptionDialog.NO_OPTION) {
		if (archive instanceof FileArchive) {
			// Release the write lock without saving. Returns file archive to its unedited state.
			try {
				((FileArchive) archive).releaseWriteLock();
			}
			catch (IOException e) {
				Msg.showError(log, component, "Unable to release File Archive write lock.",
					e.getMessage(), e);
				return false;
			}
		}
		return true;
	}

	return saveArchive(archive, component);
}
 
Example 13
Source File: DataTypeTreeCopyMoveTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
boolean isConfirmed() throws CancelledException {
	if (confirmed == null) {
		int result = askToAssociateDataTypes();
		if (result == OptionDialog.NO_OPTION) {
			confirmed = false;
		}
		else if (result == OptionDialog.YES_OPTION) {
			confirmed = true;
		}
		else {
			throw new CancelledException();
		}
	}
	return confirmed;
}