docking.widgets.OptionDialog Java Examples

The following examples show how to use docking.widgets.OptionDialog. 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: GhidraScriptComponentProvider.java    From ghidra with Apache License 2.0 6 votes vote down vote up
boolean removeScriptEditor(ResourceFile script, boolean checkForSave) {
	GhidraScriptEditorComponentProvider editor = editorMap.get(script);
	if (editor == null) {
		return true;
	}

	if (checkForSave && editor.hasChanges()) {
		JComponent parentComponent = getComponent();
		if (plugin.getTool().isVisible(editor)) {
			parentComponent = editor.getComponent();
		}
		int result = OptionDialog.showYesNoDialog(parentComponent, getName(),
			"'" + script.getName() + "' has been modified. Discard changes?");
		if (result != OptionDialog.OPTION_ONE) {
			return false;
		}
	}

	plugin.getTool().removeComponentProvider(editor);
	editorMap.remove(script);
	return true;
}
 
Example #2
Source File: SetFormatDialogComponentProvider.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionContext context) {
	int userChoice = OptionDialog.showOptionDialog(listingPanel, "Reset All Formats?",
		"There is no undo for this action.\n" +
			"Are you sure you want to reset all formats?",
		"Continue", OptionDialog.WARNING_MESSAGE);
	if (userChoice == OptionDialog.CANCEL_OPTION) {
		return;
	}

	FormatManager listingFormatManager = listingPanel.getFormatManager();
	SaveState saveState = new SaveState();
	defaultFormatManager.saveState(saveState);

	// update the dialog's GUI (which will later be used as the new format if the
	// user presses OK)
	listingFormatManager.readState(saveState);
}
 
Example #3
Source File: EquateTablePluginTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testEquateTableDeleteCancel() throws Exception {
	// select equate TWO
	int rowCount = equatesModel.getRowCount();
	setRowSelection(equatesTable, 5, 5);
	Equate eq = equatesModel.getEquate(5);
	assertEquals("TWO", eq.getName());

	DockingActionIf pluginAction = getAction(plugin, "Delete Equate");
	assertNotNull(pluginAction);
	assertTrue(pluginAction.isEnabled());
	performAction(pluginAction, false);

	OptionDialog d = waitForDialogComponent(tool.getToolFrame(), OptionDialog.class, 2000);
	assertNotNull(d);
	assertEquals("Delete Equate?", d.getTitle());

	pressButtonByText(d.getComponent(), "Cancel");
	eq = equatesModel.getEquate(5);
	assertEquals("TWO", eq.getName());

	assertEquals(rowCount, equatesModel.getRowCount());
}
 
Example #4
Source File: DeleteAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionContext context) {
	int choice = OptionDialog.showYesNoDialogWithNoAsDefaultButton(null,
		"Confirm Delete Operation", "Are you sure you want to delete selected\n categories " +
			"and/or dataTypes?\n(Note: There is no undo for archives.)");
	if (choice != OptionDialog.OPTION_ONE) {
		return;
	}

	GTree gtree = (GTree) context.getContextObject();
	TreePath[] selectionPaths = gtree.getSelectionPaths();
	List<GTreeNode> nodeList = new ArrayList<>(selectionPaths.length);
	for (TreePath path : selectionPaths) {
		nodeList.add((GTreeNode) path.getLastPathComponent());
	}
	plugin.getTool().execute(new DataTypeTreeDeleteTask(plugin, nodeList), 250);
}
 
Example #5
Source File: MemoryMapProvider1Test.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testChangeInitState2() throws Exception {

	Rectangle rect = table.getCellRect(0, MemoryMapModel.INIT, true);
	clickMouse(table, 1, rect.x, rect.y, 2, 0);
	waitForPostedSwingRunnables();

	OptionDialog dialog = waitForDialogComponent(null, OptionDialog.class, 1000);
	assertNotNull(dialog);
	invokeInstanceMethod("okCallback", dialog);
	waitForPostedSwingRunnables();

	waitForBusyTool(tool);

	assertEquals(Boolean.FALSE, model.getValueAt(0, MemoryMapModel.INIT));
	assertTrue(table.getModel().isCellEditable(0, MemoryMapModel.INIT));
}
 
Example #6
Source File: AbstractGhidraScriptMgrPluginTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected ResourceFile chooseSaveAs() {
	String title = GhidraScriptEditorComponentProvider.FILE_ON_DISK_CHANGED_TITLE;
	OptionDialog fileChangedDialog = waitForDialogComponent(OptionDialog.class);
	assertNotNull("Could not find dialog: " + title, fileChangedDialog);

	final JButton keepChangesButton = findButtonByText(fileChangedDialog,
		GhidraScriptEditorComponentProvider.KEEP_CHANGES_TEXT);
	runSwing(() -> keepChangesButton.doClick());

	OptionDialog optionDialog = waitForDialogComponent(OptionDialog.class);
	assertEquals(GhidraScriptEditorComponentProvider.CHANGE_DESTINATION_TITLE,
		optionDialog.getTitle());

	final JButton saveAsButton = findButtonByText(optionDialog,
		GhidraScriptEditorComponentProvider.SAVE_CHANGES_AS_TEXT);
	runSwing(() -> saveAsButton.doClick());

	return processSaveAsDialog();
}
 
Example #7
Source File: ToolActionManagerTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteTool() throws Exception {
	// delete a tool from the tool chest
	// verify delete menu is updated
	// verify "open with" menu is updated
	createTool();
	DockingActionIf action = getAction("Untitled", "Delete Tool");
	assertNotNull(action);
	performAction(action, "Untitled", false);
	OptionDialog d = waitForDialogComponent(OptionDialog.class);
	assertNotNull(d);
	assertEquals("Confirm Delete", d.getTitle());
	pressButtonByText(d.getComponent(), "Delete");
	waitForSwing();

	assertNull(getAction("Untitled", "Delete Tool"));
	assertNull(getAction("Untitled", "Run Tool"));
	assertNull(getAction("Untitled", "Export Tool"));
}
 
Example #8
Source File: DeleteProjectFilesTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private int showConfirmReadOnlyDialog(DomainFile file) {
	if (readOnlyDialogBuilder == null) {

		//@formatter:off
		readOnlyDialogBuilder = 
				new OptionDialogBuilder("Confirm Delete Read-only File")
				.addOption("Yes")
				.addOption("No")
				.addCancel()
				.setMessageType(OptionDialog.WARNING_MESSAGE)
				.setDefaultButton("No")
				;
		//@formatter:on

		if (getFileCount() > 1) {
			readOnlyDialogBuilder.addApplyToAllOption();
		}
	}

	String msg = "The file \"" + file.getName() +
		"\" is marked as \"Read-Only\". \nAre you sure you want to delete it?";
	readOnlyDialogBuilder.setMessage(msg);
	return readOnlyDialogBuilder.show(parent);
}
 
Example #9
Source File: DeleteProjectFilesTask.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void showFileInUseDialog(DomainFile file) throws CancelledException {
	if (fileInUseDialogBuilder == null) {

		//@formatter:off
		fileInUseDialogBuilder = 
			new OptionDialogBuilder("Delete Not Allowed")
			.addOption("OK")
			.setMessageType(OptionDialog.ERROR_MESSAGE)
			.addCancel()
			;
		//@formatter:on

		if (getFileCount() > 1) {
			fileInUseDialogBuilder.addDontShowAgainOption();
		}
	}

	String msg =
		"The file \"" + file.getName() + "\" is currently in use. It can't \nbe deleted!";
	fileInUseDialogBuilder.setMessage(msg);
	if (fileInUseDialogBuilder.show(parent) == OptionDialog.CANCEL_OPTION) {
		throw new CancelledException();
	}
}
 
Example #10
Source File: FrontEndPluginActionsTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testRenameFileInUse() throws Exception {
	final GTreeNode npNode = rootNode.getChild("notepad");
	DomainFile df = ((DomainFileNode) npNode).getDomainFile();

	setInUse(df);

	setSelectionPath(npNode.getTreePath());

	DockingActionIf renameAction = getAction("Rename");
	executeOnSwingWithoutBlocking(
		() -> performAction(renameAction, getDomainFileActionContext(), true));
	waitForSwing();
	OptionDialog dlg = waitForDialogComponent(OptionDialog.class);
	assertEquals("Rename Not Allowed", dlg.getTitle());
	pressButtonByText(dlg.getComponent(), "OK");
	assertNotNull(rootNode.getChild("notepad"));
}
 
Example #11
Source File: TextEditorManagerPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public boolean removeTextFile(TextEditorComponentProvider editor, String textFileName) {
       if ( editor.isChanged() ) {
           JComponent parentComponent = editor.getComponent();
           if ( tool.isVisible( editor ) ) {
           	parentComponent = editor.getComponent();
           }
		int result = OptionDialog.showYesNoDialog( parentComponent, getName(),
       					"'"+textFileName+"' has been modified. Discard changes?");
           if (result != OptionDialog.OPTION_ONE) {
               return false;
           }
       }
       tool.removeComponentProvider( editor );
       editors.remove( editor );
       return true;
}
 
Example #12
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 #13
Source File: ProgramSaveManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void saveAs(Program currentProgram, DomainFolder folder, String name) {
	DomainFile existingFile = folder.getFile(name);
	if (existingFile == currentProgram.getDomainFile()) {
		save(currentProgram);
		return;
	}
	if (existingFile != null) {
		String msg = "Program " + name + " already exists.\n" + "Do you want to overwrite it?";
		if (OptionDialog.showOptionDialog(tool.getToolFrame(), "Duplicate Name", msg,
			"Overwrite", OptionDialog.QUESTION_MESSAGE) == OptionDialog.CANCEL_OPTION) {
			return;
		}
	}
	tool.prepareToSave(currentProgram);
	SaveAsTask task = new SaveAsTask(currentProgram, folder, name, existingFile != null);
	new TaskLauncher(task, tool.getToolFrame());
}
 
Example #14
Source File: OptionsPanel.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Component createRestoreDefaultsButton() {

		JButton button = new JButton("Restore Defaults");
		button.addActionListener(e -> {
			Options currentOptions = getSelectedOptions();

			int userChoice = OptionDialog.showOptionDialog(viewPanel, "Restore Defaults?",
				"<html>Restore <b>" + HTMLUtilities.escapeHTML(currentOptions.getName()) +
					"</b> to default option values <b>and erase current settings?</b>",
				"Restore Defaults");
			if (userChoice == OptionDialog.CANCEL_OPTION) {
				return;
			}

			restoreDefaultOptionsForCurrentEditor();
		});
		return button;
	}
 
Example #15
Source File: ComponentNode.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent event) {
	ComponentProvider provider = placeholder.getProvider();
	JComponent component = provider.getComponent();
	String currentTabText = provider.getTabText();
	String newName = OptionDialog.showInputSingleLineDialog(component, "Rename Tab",
		"New name:", currentTabText);
	if (newName == null || newName.isEmpty()) {
		return; // cancelled
	}

	// If the user changes the name, then we want to replace all of the
	// parts of the title with that name.  We skip the subtitle, as that 
	// doesn't make sense in that case.
	provider.setTitle(newName);   // title on window
	provider.setSubTitle("");     // part after the title
	provider.setTabText(newName); // text on the tab
	placeholder.update();
}
 
Example #16
Source File: SelectChangedToolDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private JPanel buildWorkPanel() {

		JPanel panel = new JPanel(new BorderLayout());

		String toolName = toolList.get(0).getToolName();
		JLabel descriptionLabel = new GHtmlLabel(HTMLUtilities.toHTML(
			"There are multiple changed instances of " + HTMLUtilities.escapeHTML(toolName) +
				" running.<p>Which one would like to save to your tool chest?"));
		descriptionLabel.setIconTextGap(15);
		descriptionLabel.setIcon(OptionDialog.getIconForMessageType(OptionDialog.WARNING_MESSAGE));
		descriptionLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		panel.add(descriptionLabel, BorderLayout.NORTH);
		JScrollPane scrollPane = new JScrollPane(buildRadioButtonPanel());
		scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		panel.add(scrollPane);
		return panel;
	}
 
Example #17
Source File: ApplyBlockedMatchAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionContext context) {
	VTMatchContext matchContext = (VTMatchContext) context;
	List<VTMatch> matches = matchContext.getSelectedMatches();
	if (matches.size() != 1) {
		return;
	}
	VTMatch match = matches.get(0);
	VTAssociation association = match.getAssociation();
	VTAssociationStatus status = association.getStatus();
	if (status != VTAssociationStatus.BLOCKED) {
		return;
	}
	List<VTAssociation> conflicts = getConflictingMatches(match);
	String conflictMessage = getConflictingMatchesDisplayString(match, conflicts);
	int response = OptionDialog.showOptionDialog(null, "Clear Conflicting Matches and Apply?",
		conflictMessage, "Clear and Apply", OptionDialog.QUESTION_MESSAGE);
	if (response == OptionDialog.OPTION_ONE) {
		ApplyBlockedMatchTask task = new ApplyBlockedMatchTask(controller, match, conflicts);
		controller.runVTTask(task);
	}

}
 
Example #18
Source File: MergeManagerProvider.java    From ghidra with Apache License 2.0 6 votes vote down vote up
void cancelCallback(boolean force) {

		boolean cancel = force;
		if (!force) {
			int choice =
				OptionDialog.showYesNoDialogWithNoAsDefaultButton(null, "Confirm Cancel Merge",
					"Warning!  Cancel causes the entire merge process to be canceled.\n" +
						"Do you want to cancel the Merge Process?");
			cancel = choice == OptionDialog.OPTION_ONE;
		}

		if (cancel) {
			wasCanceled = true;
			MergeManager mergeManager = plugin.getMergeManager();
			if (mergeManager != null) {
				mergeManager.cancel();
			}
		}
	}
 
Example #19
Source File: EclipseIntegrationPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEclipseError(String error, boolean askAboutOptions, Throwable t) {
	if (askAboutOptions && !SystemUtilities.isInHeadlessMode()) {
		SystemUtilities.runSwingNow(() -> {
			int choice = OptionDialog.showYesNoDialog(null, "Failed to launch Eclipse",
				error + "\nWould you like to verify your \"" +
					EclipseIntegrationOptionsPlugin.PLUGIN_OPTIONS_NAME + "\" options now?");
			if (choice == OptionDialog.YES_OPTION) {
				AppInfo.getFrontEndTool().getService(OptionsService.class).showOptionsDialog(
					EclipseIntegrationOptionsPlugin.PLUGIN_OPTIONS_NAME, null);
			}
		});
	}
	else {
		Msg.showError(EclipseConnectorTask.class, null, "Failed to launch Eclipse", error, t);
	}
}
 
Example #20
Source File: EquatePlugin1Test.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that the user is prompted before attempting to remove an equate within
 * a selection. 
 * 
 * @throws Exception
 */
@Test
public void testRemoveSelection() throws Exception {

	// Place the cursor on a known scalar.
	putCursorOnOperand(0x01006455, 1);

	// Make a selection containing the scalar above.
	makeSelection(tool, program, addr("1004bbd"), addr("1004bc5"));

	// Call the action to remove the equate(s).
	performAction(removeAction, cb.getProvider(), false);

	// Wait for the confirmation dialog to pop up and verify.
	OptionDialog d = waitForDialogComponent(tool.getToolFrame(), OptionDialog.class, 2000);
	assertNotNull(d);
	close(d);
}
 
Example #21
Source File: EquatePluginScreenShots.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Captures the info dialog that is shown when the user attempts to remove an
 * equate on a selection.
 *
 * @throws Exception
 */
@Test
public void testRemoveSelection() throws Exception {

	// Place the cursor on a known scalar.
	Address addr = program.getMinAddress().getNewAddress(0x0040e00d);
	fireOperandFieldLocationEvent(addr, 0);

	// Make a selection containing the scalar above.
	AddressFactory addressFactory = program.getAddressFactory();
	AddressSet addressSet = new AddressSet();
	addressSet.addRange(addressFactory.getAddress("0040e00d"),
		addressFactory.getAddress("0040e00f"));
	ProgramSelection programSelection = new ProgramSelection(addressSet);
	tool.firePluginEvent(
		new ProgramSelectionPluginEvent("Test Scalar Selection", programSelection, program));

	// Call the action to remove the equates from the selection.
	performAction(removeAction, cb.getProvider(), false);

	// Capture the confirmation dialog.
	waitForDialogComponent(OptionDialog.class);
	captureDialog(OptionDialog.class);
}
 
Example #22
Source File: CheckoutDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private JPanel buildMainPanel() {
	JPanel innerPanel = new JPanel();
	innerPanel.setLayout(new BorderLayout());
	innerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));

	JPanel msgPanel = new JPanel(new BorderLayout());
	msgPanel.add(
		new GIconLabel(OptionDialog.getIconForMessageType(OptionDialog.QUESTION_MESSAGE)),
		BorderLayout.WEST);

	MultiLineLabel msgText = new MultiLineLabel("Checkout selected file(s)?");
	msgText.setMaximumSize(msgText.getPreferredSize());
	msgPanel.add(msgText, BorderLayout.CENTER);

	innerPanel.add(msgPanel, BorderLayout.CENTER);

	exclusiveCB = new GCheckBox("Request exclusive checkout");

	JPanel cbPanel = new JPanel(new BorderLayout());
	cbPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
	cbPanel.add(exclusiveCB);
	innerPanel.add(cbPanel, BorderLayout.SOUTH);

	return innerPanel;
}
 
Example #23
Source File: LookAndFeelPlugin.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void issuePreferredDarkThemeLaFNotification() {
	if (issuedPreferredDarkThemeLafNotification) {
		return;
	}

	issuedPreferredDarkThemeLafNotification = true;

	if (DockingWindowsLookAndFeelUtils.METAL_LOOK_AND_FEEL.equals(selectedLookAndFeel)) {
		return;
	}

	int choice = OptionDialog.showYesNoDialog(null, "Change Look and Feel?", "The '" +
		USE_INVERTED_COLORS_NAME + "' setting works best with the " +
		"'Metal' Look and Feel.\nWould  you like to switch to that Look and Feel upon restart?");
	if (choice == OptionDialog.YES_OPTION) {
		SystemUtilities.runSwingLater(() -> {

			saveLookAndFeel(DockingWindowsLookAndFeelUtils.METAL_LOOK_AND_FEEL);
		});
	}
}
 
Example #24
Source File: GoToHelper.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void createExternalAssociation(Program program, String extProgName) {
	int result = OptionDialog.showOptionDialog(null, "No Program Association",
		"The external program name \"" + extProgName +
			"\" is not associated with a Ghidra Program\n" +
			"Would you like to create an association?",
		"Create Association", OptionDialog.QUESTION_MESSAGE);
	if (result == OptionDialog.CANCEL_OPTION) {
		return;
	}
	final DataTreeDialog dialog = new DataTreeDialog(null,
		"Choose External Program (" + extProgName + ")", DataTreeDialog.OPEN);

	dialog.setSearchText(extProgName);
	dialog.setHelpLocation(new HelpLocation("ReferencesPlugin", "ChooseExternalProgram"));
	tool.showDialog(dialog);
	DomainFile domainFile = dialog.getDomainFile();
	if (dialog.wasCancelled() || domainFile == null) {
		return;
	}
	String pathName = domainFile.toString();
	ExternalManager externalManager = program.getExternalManager();
	String externalLibraryPath = externalManager.getExternalLibraryPath(extProgName);
	if (!pathName.equals(externalLibraryPath)) {
		Command cmd = new SetExternalNameCmd(extProgName, domainFile.getPathname());
		tool.execute(cmd, program);
	}
}
 
Example #25
Source File: AbstractFunctionGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected FGData reset() {

		DockingActionIf action = getAction(tool, graphPlugin.getName(), "Reset Graph");
		performAction(action, graphProvider, false);

		OptionDialog dialog = waitForDialogComponent(OptionDialog.class);
		pressButtonByText(dialog, "Yes");

		// wait for the threaded graph layout code
		return getFunctionGraphData();
	}
 
Example #26
Source File: VersionExceptionHandler.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public static boolean isUpgradeOK(Component parent, DomainFile domainFile, String actionName,
		VersionException ve) {
	String contentType = domainFile.getContentType();
	if (domainFile.isReadOnly() || ve.getVersionIndicator() != VersionException.OLDER_VERSION ||
		!ve.isUpgradable()) {
		showVersionError(parent, domainFile.getName(), contentType, actionName, ve);
		return false;
	}
	String filename = domainFile.getName();

	// make sure the user wants to upgrade

	if (domainFile.isVersioned() && !domainFile.isCheckedOutExclusive()) {
		showNeedExclusiveCheckoutDialog(parent, filename, contentType, actionName);
		return false;
	}

	int userChoice = showUpgradeDialog(parent, ve, filename, contentType, actionName);
	if (userChoice != OptionDialog.OPTION_ONE) {
		return false;
	}
	if (domainFile.isCheckedOut()) {
		userChoice = showWarningDialog(parent, filename, contentType, actionName);
		if (userChoice != OptionDialog.OPTION_ONE) {
			return false;
		}
	}

	return true;
}
 
Example #27
Source File: OpenProgramTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private boolean askRecoverFile(final String filename) {

		int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
			"<html>" + HTMLUtilities.escapeHTML(filename) + " has crash data.<br>" +
				"Would you like to recover unsaved changes?");
		return option == OptionDialog.OPTION_ONE;
	}
 
Example #28
Source File: ProjectDataDeleteTask.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private boolean confirmUserSkipFailedPreprocessedFiles() {

		String msg = "<html><div style='margin-bottom: 20pt; text-align: center;'>There were " +
			failPreprocessCheckedOut.size() +
			" versioned and checked-out files in the requested set of files that cannot be deleted.</div>" +
			"<div style='margin-bottom: 20pt; text-align: center;'>Skip these files and continue or cancel delete operation?</div>";

		if (OptionDialog.showOptionDialog(parentComponent, "Continue and Skip Problem Files?", msg,
			"Skip and Continue") != OptionDialog.OPTION_ONE) {
			return false;
		}

		return true;
	}
 
Example #29
Source File: CheckoutDialog.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private JPanel buildMainPanel(DomainFile df, User user) {
	JPanel innerPanel = new JPanel();
	innerPanel.setLayout(new BorderLayout());
	innerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));

	JPanel msgPanel = new JPanel(new BorderLayout());
	msgPanel.add(
		new GIconLabel(OptionDialog.getIconForMessageType(OptionDialog.WARNING_MESSAGE)),
		BorderLayout.WEST);

	MultiLineLabel msgText = new MultiLineLabel("File " + df.getName() +
		" is NOT CHECKED OUT.\n" + "If you want to make changes and save them\n" +
		"to THIS file, then you must first check out the file.\n" +
		"Do you want to Check Out this file?");
	msgText.setMaximumSize(msgText.getPreferredSize());
	msgPanel.add(msgText, BorderLayout.CENTER);

	innerPanel.add(msgPanel, BorderLayout.CENTER);

	exclusiveCheckout = true;
	if (user != null) {
		exclusiveCheckout = false;
		if (user.hasWritePermission()) {
			final JCheckBox exclusiveCB = new GCheckBox("Request exclusive check out");
			exclusiveCB.setSelected(false);
			exclusiveCB.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					exclusiveCheckout = exclusiveCB.isSelected();
				}
			});
			JPanel cbPanel = new JPanel(new BorderLayout());
			cbPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
			cbPanel.add(exclusiveCB);
			innerPanel.add(cbPanel, BorderLayout.SOUTH);
		}
	}
	return innerPanel;
}
 
Example #30
Source File: PluginTool.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/** 
 * Called when it is time to save the tool.  Handles auto-saving logic.
 * @return true if a save happened
 */
protected boolean doSaveTool() {
	if (toolServices.canAutoSave(this)) {
		saveTool();
	}
	else {
		if (configChangedFlag) {
			int result = OptionDialog.showOptionDialog(getToolFrame(), SAVE_DIALOG_TITLE,
				"This tool has changed.  There are/were multiple instances of this tool\n" +
					"running and Ghidra cannot determine if this tool instance should\n" +
					"automatically be saved.  Do you want to save the configuration of this tool\n" +
					"instance?",
				"Save", "Save As...", "Don't Save", OptionDialog.WARNING_MESSAGE);
			if (result == OptionDialog.CANCEL_OPTION) {
				return false;
			}
			if (result == OptionDialog.OPTION_ONE) {
				saveTool();
			}
			else if (result == OptionDialog.OPTION_TWO) {
				boolean didSave = saveToolAs();
				if (!didSave) {
					return doSaveTool();
				}
			}
			// option 3 is don't save; just exit
		}
	}
	return true;
}