Java Code Examples for docking.widgets.OptionDialog#showYesNoCancelDialog()
The following examples show how to use
docking.widgets.OptionDialog#showYesNoCancelDialog() .
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: EnumEditorProvider.java From ghidra with Apache License 2.0 | 6 votes |
/** * Prompts the user if the editor has unsaved changes. Saves the changes if * the user indicates to do so. * @return CANCEL (0) if the user canceled; * SAVE (1) if the user saved changes; * NO_SAVE (2) if the user did not save changes or no save was required; * ERROR (3) if there was an error when the changes were applied. */ private int saveChangesForCloseEvent(boolean allowCancel) { // Check for changes and prompt user to check if saving them. if (hasChanges()) { String question = "The Enum Editor is closing.\n" + "Save the changes to " + editorPanel.getEnum().getDisplayName() + "?"; String title = "Save Enum Editor Changes?"; int response; if (allowCancel) { response = OptionDialog.showYesNoCancelDialog(editorPanel, title, question); } else { response = OptionDialog.showYesNoDialog(editorPanel, title, question); } if (response == OptionDialog.OPTION_ONE) { // YES selected. if (!applyChanges()) { return ERROR; } } return response; } return NO_SAVE; // no save required, or No selected }
Example 2
Source File: CompositeEditorProvider.java From ghidra with Apache License 2.0 | 6 votes |
/** * Prompts the user if the editor has unsaved changes. Saves the changes if * the user indicates to do so. * @return 0 if the user canceled; 1 if the user saved changes; * 2 if the user did not to save changes; 3 if there was an error when * the changes were applied. */ protected int saveChanges(boolean allowCancel) { // Check for changes and prompt user to check if saving them. if (editorModel.isValidName() && editorModel.hasChanges()) { String question = "The " + editorModel.getTypeName() + " Editor is closing.\n" + "Save the changes to " + getDtPath() + "?"; String title = "Save " + editorModel.getTypeName() + " Editor Changes?"; int response; if (allowCancel) { response = OptionDialog.showYesNoCancelDialog(editorPanel, title, question); } else { response = OptionDialog.showYesNoDialog(editorPanel, title, question); } if (response == 1) { // YES selected. if (!applyChanges()) { return 3; } } return response; } return 2; }
Example 3
Source File: VTWizardUtils.java From ghidra with Apache License 2.0 | 6 votes |
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 4
Source File: DataPlugin.java From ghidra with Apache License 2.0 | 5 votes |
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 5
Source File: ArchiveUtils.java From ghidra with Apache License 2.0 | 5 votes |
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 6
Source File: CommentsDialog.java From ghidra with Apache License 2.0 | 5 votes |
/** * Callback for the cancel button. */ @Override protected void cancelCallback() { if (wasChanged) { int result = OptionDialog.showYesNoCancelDialog(getComponent(), "Save Changes?", "Some comments were modified.\nSave Changes?"); if (result == OptionDialog.OPTION_ONE) { applyCallback(); } else if (result == OptionDialog.OPTION_TWO) { if (!preField.getText().equals(preComment)) { preField.setText(preComment); } if (!postField.getText().equals(postComment)) { postField.setText(postComment); } if (!eolField.getText().equals(eolComment)) { eolField.setText(eolComment); } if (!plateField.getText().equals(plateComment)) { plateField.setText(plateComment); } if (!repeatableField.getText().equals(repeatableComment)) { repeatableField.setText(repeatableComment); } wasChanged = false; setApplyEnabled(false); } else { // cancel cancel return; } } close(); }