Java Code Examples for docking.widgets.OptionDialog#YES_OPTION

The following examples show how to use docking.widgets.OptionDialog#YES_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: EditActionManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void clearCertPath() {

		String path = ApplicationKeyManagerFactory.getKeyStore();
		if (path == null) {
			// unexpected
			clearCertPathAction.setEnabled(false);
			return;
		}

		if (OptionDialog.YES_OPTION != OptionDialog.showYesNoDialog(tool.getToolFrame(),
			"Clear PKI Certificate", "Clear PKI certificate setting?\n(" + path + ")")) {
			return;
		}

		try {
			ApplicationKeyManagerFactory.setKeyStore(null, true);
			clearCertPathAction.setEnabled(false);
		}
		catch (IOException e) {
			Msg.error(this,
				"Error occurred while clearing PKI certificate setting: " + e.getMessage());
		}
	}
 
Example 2
Source File: FSBActionManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private boolean searchProjectForMatchingFileOrFail(FSRL fsrl, String suggestedDestinationPath,
		ProgramManager programManager, TaskMonitor monitor) {
	boolean doSearch = isProjectSmallEnoughToSearchWithoutWarningUser() ||
		OptionDialog.showYesNoDialog(null, "Search Project for matching program?",
			"Search entire Project for matching program? (WARNING, could take large amount of time)") == OptionDialog.YES_OPTION;

	Map<FSRL, DomainFile> matchedFSRLs = doSearch
			? ProgramMappingService.searchProjectForMatchingFiles(Arrays.asList(fsrl), monitor)
			: Collections.emptyMap();

	DomainFile domainFile = matchedFSRLs.get(fsrl);
	if (domainFile != null) {
		ProgramMappingService.createAssociation(fsrl, domainFile);
		showProgramInProgramManager(fsrl, domainFile, programManager, true);
		return true;
	}
	return false;
}
 
Example 3
Source File: VTWizardUtils.java    From ghidra with Apache License 2.0 6 votes vote down vote up
static public boolean askUserToSave(Component parent, DomainFile domainFile) {

		String filename = domainFile.getName();
		int result = OptionDialog.showYesNoDialog(parent, "Save Version Tracking Changes?",
			"<html>Unsaved Version Tracking changes found for session: " +
				HTMLUtilities.escapeHTML(filename) + ".  <br>" +
				"Would you like to save these changes?");

		boolean doSave = result == OptionDialog.YES_OPTION;
		if (doSave) {
			SaveTask saveTask = new SaveTask(domainFile);
			new TaskLauncher(saveTask, parent);
			return saveTask.didSave();
		}
		return false;
	}
 
Example 4
Source File: CreateArrayAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Get the number of elements to create from the user.
 */
private int getNumElements(final DataType dt, final int maxNoConflictElements,
		final int maxElements) {
	NumberInputDialog numberInputDialog = new NumberInputDialog("Create " + dt.getName() + "[]",
		"Enter number of array elements (1 - " + maxElements + ") :", maxNoConflictElements, 1,
		maxElements, false);
	if (maxNoConflictElements < maxElements) {
		numberInputDialog.setDefaultMessage(
			"Entering more than " + maxNoConflictElements + " will overwrite existing data");
	}
	if (!numberInputDialog.show()) {
		return Integer.MIN_VALUE; // cancelled
	}
	int value = numberInputDialog.getValue();
	if (value > maxNoConflictElements) {
		int result = OptionDialog.showYesNoDialog(null, "Overwrite Existing Data?",
			"Existing data will be overridden if you create this array.\n" +
				"Are you sure you want to continue?");
		if (result != OptionDialog.YES_OPTION) {
			return Integer.MIN_VALUE;  	// Cancel create array
		}
	}
	return value;
}
 
Example 5
Source File: VTWizardUtils.java    From ghidra with Apache License 2.0 6 votes vote down vote up
static public boolean askUserToSaveBeforeClosing(Component parent, DomainFile domainFile) {

		String filename = domainFile.getName();
		int result = OptionDialog.showYesNoCancelDialog(parent, "Save Version Tracking Changes?",
			"<html>Unsaved Version Tracking changes found for session: " +
				HTMLUtilities.escapeHTML(filename) + ".  <br>" +
				"Would you like to save these changes?");

		if (result == OptionDialog.CANCEL_OPTION) {
			return false;
		}
		boolean doSave = result == OptionDialog.YES_OPTION;
		if (doSave) {
			SaveTask saveTask = new SaveTask(domainFile);
			new TaskLauncher(saveTask, parent);
			return saveTask.didSave();
		}
		return true;
	}
 
Example 6
Source File: PathnameTablePanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void reset() {
	String confirmation = "Are you sure you would like to reset\nlibrary" +
		" paths to the default list? This\nwill remove all paths manually added.";
	String header = "Reset Library Paths?";

	int optionChosen = OptionDialog.showYesNoDialog(this, header, confirmation);

	if (resetCallback != null && optionChosen == OptionDialog.YES_OPTION) {
		resetCallback.call();
	}
}
 
Example 7
Source File: AnalysisPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void restoreDefaults() {
	int answer = OptionDialog.showYesNoDialog(this, "Restore Default Analysis Options",
		"Do you really want to restore the analysis options to the default values?");
	if (answer == OptionDialog.YES_OPTION) {
		AutoAnalysisManager manager = AutoAnalysisManager.getAnalysisManager(programs.get(0));
		manager.restoreDefaultOptions();
		editorStateFactory.clearAll();
		load();
	}
}
 
Example 8
Source File: PluginInstallerTableModel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden to handle the case where a user has toggled the installation column
 * checkbox.
 */
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	super.setValueAt(aValue, rowIndex, columnIndex);

	// We only care about the install column here, as it's the only one that
	// is editable. 
	if (columnIndex != INSTALLED_COL) {
		return;
	}

	PluginDescription targetPluginDescription = getRowObject(rowIndex);
	boolean install = ((Boolean) aValue).booleanValue();
	if (install) {
		addPlugin(targetPluginDescription);
	}
	else {
		List<PluginDescription> pluginsThatUseTarget =
			model.getDependencies(targetPluginDescription);
		String dependenciesToUnloadHtmlList =
			pluginsThatUseTarget.stream().map(PluginDescription::getName).sorted().collect(
				Collectors.joining("<li>", "<ul><li>", "</ul>"));

		if (pluginsThatUseTarget.isEmpty() ||
			OptionDialog.showYesNoDialog(parentComponent, "Confirm plugin removal",
				"<html>Other plugins depend on " +
					HTMLUtilities.escapeHTML(targetPluginDescription.getName()) + "<p><p>" +
					"Removing it will also remove:" + dependenciesToUnloadHtmlList + "<p><p>" +
					"Continue?") == OptionDialog.YES_OPTION) {
			model.removePlugin(targetPluginDescription);
		}

	}

	// Full repaint, as other row data may be changed when adding/removing plugins
	parentComponent.repaint();
}
 
Example 9
Source File: FSBActionManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private List<FSRL> searchProjectForMatchingFilesOrFail(List<FSRL> fsrlList,
		ProgramManager programManager, TaskMonitor monitor, int programsOpened) {
	boolean doSearch = isProjectSmallEnoughToSearchWithoutWarningUser() ||
		OptionDialog.showYesNoDialog(null, "Search Project for matching programs?",
			"Search entire Project for matching programs? " +
				"(WARNING, could take large amount of time)") == OptionDialog.YES_OPTION;

	Map<FSRL, DomainFile> matchedFSRLs =
		doSearch ? ProgramMappingService.searchProjectForMatchingFiles(fsrlList, monitor)
				: Collections.emptyMap();

	List<FSRL> unmatchedFSRLs = new ArrayList<>();
	for (FSRL fsrl : fsrlList) {
		DomainFile domainFile = matchedFSRLs.get(fsrl);
		if (domainFile != null) {
			ProgramMappingService.createAssociation(fsrl, domainFile);
		}
		if (showProgramInProgramManager(fsrl, domainFile, programManager,
			programsOpened == 0)) {
			programsOpened++;
		}
		else {
			unmatchedFSRLs.add(fsrl);
		}
	}

	return unmatchedFSRLs;
}
 
Example 10
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;
}
 
Example 11
Source File: FSUtilities.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static void displayCryptoException(Object originator, Component parent, String title,
		String message, CryptoException ce) {
	String ce_msg = ce.getMessage();
	if (ce_msg.contains("Install the JCE")) {
		File javaHomeDir = new File(System.getProperty("java.home"));
		File libSecurityDir = new File(new File(javaHomeDir, "lib"), "security");
		//@formatter:off
			if (OptionDialog.showYesNoDialog(parent, title,
				"<html><div style='margin-bottom: 20pt'>A problem with the Java crypto subsystem was encountered:</div>" +
					"<div style='font-weight: bold; margin-bottom: 20pt; margin-left: 50pt'>" + ce_msg + "</div>" +
					"<div style='margin-bottom: 20pt'>Which caused:</div>" +
					"<div style='font-weight: bold; margin-bottom: 20pt; margin-left: 50pt'>" + message + "</div>" +
					"<div style='margin-bottom: 20pt'>This may be fixed by installing the unlimited strength JCE into your JRE's \"lib/security\" directory.</div>" +
					"<div style='margin-bottom: 20pt'>The unlimited strength JCE should be available from the same download location as your JRE.</div>" +
					"<div>Display your JRE's \"lib/security\" directory?</div></html>") == OptionDialog.YES_OPTION) {
			//@formatter:on
			try {
				FileUtilities.openNative(libSecurityDir);
			}
			catch (IOException e) {
				Msg.showError(originator, parent, "Problem starting explorer",
					"Problem starting file explorer: " + e.getMessage());
			}
		}
		return;
	}
	Msg.showWarn(originator, parent, title, message + ": " + ce_msg);
}
 
Example 12
Source File: DataPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private boolean dataExists(Program program, DataType dataType, Data definedData, Address start,
		Address end) {

	if (definedData == null) {
		return false;
	}

	if (definedData.getMinAddress().compareTo(end) > 0) {
		return false;
	}

	//@formatter:off
	int resp =
		OptionDialog.showYesNoCancelDialog(tool.getActiveWindow(), "Data Conflict",
			"Data applied from " + start + " to " + end +
			"\nconflicts with existing defined data!\n\n" +
			"Clear conflicting data?");
	//@formatter:on

	if (resp != OptionDialog.YES_OPTION) {
		tool.setStatusInfo("Create " + dataType.getName() + " failed: Data exists at address " +
			definedData.getMinAddress() + " to " + definedData.getMaxAddress());
		return true; // data exists--don't overwrite
	}

	return false; // OK to clear the existing data
}
 
Example 13
Source File: DisassociateDataTypeAction.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private boolean confirmOperation(List<DataTypeNode> nodes) {
	String message = "This will <b>permanently</b> disassociate these datatypes" +
		" from the archive.<br><br>Are you sure you want to <b><u>disassociate</u></b> " +
		nodes.size() + " datatype(s)?";
	String asHtml = HTMLUtilities.wrapAsHTML(message);
	int result = OptionDialog.showYesNoDialog(plugin.getTool().getToolFrame(),
		"Confirm Disassociate", asHtml);
	return result == OptionDialog.YES_OPTION;
}
 
Example 14
Source File: DisassociateAction.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private boolean confirmOperation(List<DataTypeSyncInfo> selectedList) {
	String message = "This will <b>permanently</b> disassociate these datatypes" +
		" from the archive.<br><br>Are you sure you want to <b><u>disassociate</u></b> " +
		selectedList.size() + " datatype(s)?";
	String asHtml = HTMLUtilities.wrapAsHTML(message);
	int result = OptionDialog.showYesNoDialog(plugin.getTool().getToolFrame(),
		"Confirm Disassociate", asHtml);
	return result == OptionDialog.YES_OPTION;
}
 
Example 15
Source File: CompEditorPanel.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void updatedStructureSize() {

		if (updatingSize) {
			return;
		}
		if (!sizeStatusTextField.isShowing()) {
			return;
		}

		if (!((CompEditorModel) model).isSizeEditable()) {
			return;
		}

		String valueStr = sizeStatusTextField.getText();
		Integer value;
		try {
			updatingSize = true;
			value = Integer.decode(valueStr);
			int structureSize = value.intValue();
			if (structureSize < 0) {
				model.setStatus("Structure size cannot be negative.", true);
			}
			else {
				if (structureSize < model.getLength()) {
					// Decreasing structure length.
					// Verify that user really wants this.
					String question =
						"The size field was changed to " + structureSize + " bytes.\n" +
							"Do you really want to truncate " + model.getCompositeName() + "?";
					String title = "Truncate " + model.getTypeName() + " In Editor?";
					int response =
						OptionDialog.showYesNoDialogWithNoAsDefaultButton(this, title, question);
					if (response != OptionDialog.YES_OPTION) {
						compositeInfoChanged();
						return;
					}
				}
				((StructureEditorModel) model).setStructureSize(structureSize);
			}
		}
		catch (NumberFormatException e1) {
			model.setStatus("Invalid structure size \"" + valueStr + "\".", true);
		}
		finally {
			updatingSize = false;
		}
		compositeInfoChanged();
	}
 
Example 16
Source File: SyncAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private boolean confirmOperation(List<DataTypeSyncInfo> selectedList) {
	int result = OptionDialog.showYesNoDialog(plugin.getTool().getToolFrame(),
		"Confirm " + getOperationName(), getConfirmationMessage(selectedList));
	return result == OptionDialog.YES_OPTION;
}
 
Example 17
Source File: RevertThunkFunctionAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
/**
 * Method called when the action is invoked.
 * @param ActionEvent details regarding the invocation of this action
 */
@Override
public void actionPerformed(ProgramActionContext context) {

	Program program = context.getProgram();

	FunctionManager functionMgr = program.getFunctionManager();
	Function func;
	if (context instanceof ListingActionContext) {
		ListingActionContext listingContext = (ListingActionContext) context;
		func = functionMgr.getFunctionAt(listingContext.getAddress());
	}
	else if (context instanceof ProgramSymbolActionContext) {
		ProgramSymbolActionContext symbolContext = (ProgramSymbolActionContext) context;
		Symbol symbol = symbolContext.getFirstSymbol();
		if (symbol == null) {
			return; // assume symbol removed
		}
		func = (Function) symbol.getObject();
	}
	else {
		throw new RuntimeException("Invalid context for action");
	}

	if (func == null || !func.isThunk()) {
		return;
	}

	int resp = OptionDialog.showYesNoDialog(funcPlugin.getTool().getActiveWindow(),
		"Revert Thunk Confirmation",
		"Do you wish to revert function '" + func.getName() + "' to a non-thunk Function?");
	if (resp != OptionDialog.YES_OPTION) {
		return;
	}

	int txId = program.startTransaction("Revert Thunk");
	try {
		func.setThunkedFunction(null);
	}
	finally {
		program.endTransaction(txId, true);
	}
}
 
Example 18
Source File: ProgramDiffPlugin.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private boolean openSecondProgram(Program newProgram, JComponent selectDialog) {
	if (newProgram == null) {
		displayStatus(selectDialog, "Can't Open Selected Program",
			"Couldn't open second program.", OptionDialog.ERROR_MESSAGE);
		return false;
	}

	if (!ProgramMemoryComparator.similarPrograms(currentProgram, newProgram)) {
		newProgram.release(this);
		String message = "Programs languages don't match.\n" + currentProgram.getName() + " (" +
			currentProgram.getLanguageID() + ")\n" + newProgram.getName() + " (" +
			newProgram.getLanguageID() + ")";
		displayStatus(selectDialog, "Can't Open Selected Program", message,
			OptionDialog.ERROR_MESSAGE);
		return false;
	}
	ProgramMemoryComparator programMemoryComparator = null;
	try {

		programMemoryComparator = new ProgramMemoryComparator(currentProgram, newProgram);
	}
	catch (ProgramConflictException e) {
		Msg.error(this, "Unexpected exception creating memory comparator", e);
		return false;
	}
	addressesOnlyInP1 = programMemoryComparator.getAddressesOnlyInOne();
	compatibleOnlyInP2 = programMemoryComparator.getCompatibleAddressesOnlyInTwo();
	AddressSet addressesInCommon = programMemoryComparator.getAddressesInCommon();
	AddressSet combinedAddresses =
		ProgramMemoryComparator.getCombinedAddresses(currentProgram, newProgram);
	if (addressesInCommon.isEmpty()) {
		int selectedOption = OptionDialog.showYesNoDialog(selectDialog, "No Memory In Common",
			"The two programs have no memory addresses in common.\n" +
				"Do you want to continue?");
		if (selectedOption != OptionDialog.YES_OPTION) {
			newProgram.release(this);
			return false;
		}
	}
	if (secondaryDiffProgram != null) {
		closeProgram2();
	}

	primaryProgram = currentProgram;
	secondaryDiffProgram = newProgram;
	p2AddressFactory = secondaryDiffProgram.getAddressFactory();
	applyFilter = applySettingsMgr.getDefaultApplyFilter();
	diffDetails = new ProgramDiffDetails(primaryProgram, secondaryDiffProgram);
	primaryProgram.addListener(this);

	try {
		settingLocation = true;
		diffListingPanel.setProgram(secondaryDiffProgram);
		AddressSet p2ViewAddrSet =
			DiffUtility.getCompatibleAddressSet(p1ViewAddrSet, secondaryDiffProgram);
		diffListingPanel.setView(p2ViewAddrSet);
		// If the entire first program is being viewed then force any additional memory in
		// program2 that isn't in program1 but that is compatible with program1 to get added
		// to the first program's view.
		if (p1ViewAddrSet.contains(primaryProgram.getMemory())) {
			this.firePluginEvent(
				new ViewChangedPluginEvent(this.getName(), null, combinedAddresses));
		}
		FieldPanel fp = diffListingPanel.getFieldPanel();
		showSecondView();
		AddressIndexMap indexMap = diffListingPanel.getAddressIndexMap();
		fp.setBackgroundColorModel(
			new MarkerServiceBackgroundColorModel(markerManager, indexMap));
	}
	finally {
		settingLocation = false;
	}
	markerManager.setProgram(secondaryDiffProgram);
	setupBookmarkNavigators();

	sameProgramContext = ProgramMemoryComparator.sameProgramContextRegisterNames(primaryProgram,
		secondaryDiffProgram);
	actionManager.secondProgramOpened();
	actionManager.addActions();
	diffListingPanel.goTo(currentLocation);

	MarkerSet cursorMarkers = getCursorMarkers();
	Address currentP2Address = currentLocation.getAddress();
	if (currentLocation.getProgram() != secondaryDiffProgram) { // Make sure address is from P2.
		currentP2Address = SimpleDiffUtility.getCompatibleAddress(currentLocation.getProgram(),
			currentLocation.getAddress(), secondaryDiffProgram);
	}
	if (currentP2Address != null) {
		cursorMarkers.setAddressSet(new AddressSet(currentP2Address));
	}

	updatePgm2Enablement();

	if (diffControl != null) {
		clearDiff();
	}
	return true;
}
 
Example 19
Source File: VersionControlCheckOutAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private boolean gatherVersionedFiles(TaskMonitor monitor, List<DomainFile> results)
		throws CancelledException {

	monitor.setMessage("Examining Files...");
	monitor.setMaximum(files.size());

	for (DomainFile df : files) {
		monitor.checkCanceled();

		if (df.isVersioned() && !df.isCheckedOut()) {
			results.add(df);
		}
		monitor.incrementProgress(1);
	}

	int n = results.size();
	if (n == 0) {
		Msg.showError(this, tool.getToolFrame(), "Checkout Failed",
			"The specified files do not contain any versioned files available for " +
				"checkeout");
		return false;
	}

	//
	// Confirm checkout - prompt for exclusive checkout, if possible.  Otherwise, only
	//                    confirm a bulk checkout.
	//

	// note: a 'null' user means that we are using a local repository
	User user = getUser();
	if (user != null && user.hasWritePermission()) {
		CheckoutDialog checkout = new CheckoutDialog();
		if (checkout.showDialog(tool) != CheckoutDialog.OK) {
			return false;
		}
		exclusive = checkout.exclusiveCheckout();
		return true;
	}

	if (n == 1) {
		return true; // single file; no prompt needed
	}

	// more than one file
	int choice = OptionDialog.showYesNoDialogWithNoAsDefaultButton(tool.getToolFrame(),
		"Confirm Bulk Checkout",
		"Would you like to checkout " + results.size() + " files as specified?");
	return choice == OptionDialog.YES_OPTION;
}
 
Example 20
Source File: RemoveUserCheckoutsScript.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
protected void run() throws Exception {
	
	Project project = state.getProject();
	
	ProjectData projectData = project.getProjectData();
	
	RepositoryAdapter repository = projectData.getRepository();
	if (repository == null) {
		printerr("Project is not a shared project");
		return;
	}
	
	User currentUser = repository.getUser();
	if (!currentUser.isAdmin()) {
		printerr("You are not a repository administrator for " + repository.getName());
		return;
	}
	
	String uname = askString("Remove User Checkouts" , "Enter user ID to be cleared");
	
	boolean found = false;
	for (User u : repository.getUserList()) {
		if (uname.equals(u.getName())) {
			found = true;
			break;
		}
	}
	if (!found) {
		if (OptionDialog.showYesNoDialogWithNoAsDefaultButton(null, "User Name Confirmation",
				"User '" + uname + "' not a registered server user.\nDo you still want to search for and remove checkouts for this user?") != OptionDialog.YES_OPTION) {
			return;
		}
	}
	
	if (projectData.getFileCount() > 1000) {
		if (OptionDialog.showYesNoDialogWithNoAsDefaultButton(null, "Large Repository Confirmation",
				"Repository contains a large number of failes and could be slow to search.\nDo you still want to search for and remove checkouts?") != OptionDialog.YES_OPTION) {
			return;
		}
	}
	
	int count = removeCheckouts(repository, "/", uname, monitor);
	popup("Removed " + count + " checkouts");
	
}