Java Code Examples for docking.widgets.OptionDialog#OPTION_TWO
The following examples show how to use
docking.widgets.OptionDialog#OPTION_TWO .
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: DebugDecompilerAction.java From ghidra with Apache License 2.0 | 6 votes |
@Override protected void decompilerActionPerformed(DecompilerActionContext context) { JComponent parentComponent = context.getDecompilerPanel(); GhidraFileChooser fileChooser = new GhidraFileChooser(parentComponent); fileChooser.setTitle("Please Choose Output File"); fileChooser.setFileFilter(new ExtensionFileFilter(new String[] { "xml" }, "XML Files")); File file = fileChooser.getSelectedFile(); if (file == null) { return; } if (file.exists()) { if (OptionDialog.showYesNoDialog(parentComponent, "Overwrite Existing File?", "Do you want to overwrite the existing file?") == OptionDialog.OPTION_TWO) { return; } } controller.setStatusMessage("Dumping debug info to " + file.getAbsolutePath()); controller.refreshDisplay(controller.getProgram(), controller.getLocation(), file); }
Example 2
Source File: GhidraScript.java From ghidra with Apache License 2.0 | 6 votes |
protected boolean promptToKeepChangesOnException() { String message = "<html>Encountered exception running script \"" + HTMLUtilities.escapeHTML(sourceFile.getName()) + "\".<br><br>Keep the changes to the program?"; //@formatter:off int choice = OptionDialog.showOptionNoCancelDialog( null, "Keep Changes?", message, "<html>No (<font color=\"red\">discard</font> changes)", "<html>Yes (<font color=\"green\">keep</font> changes)", OptionDialog.QUESTION_MESSAGE); //@formatter:on if (choice == OptionDialog.OPTION_TWO) { // Yes return true; } return false; }
Example 3
Source File: GhidraScriptEditorComponentProvider.java From ghidra with Apache License 2.0 | 6 votes |
/** * Returns false if the user cancels--meaning they did not make a decision regarding the * file (or 'handle' it). */ private boolean handleDeletedFile() { int choice = OptionDialog.showOptionDialog(scrollPane, FILE_ON_DISK_MISSING_TITLE, "The script file on disk no longer exists.\nWould you like to " + "keep the changes in the editor or discard your changes?", KEEP_CHANGES_TEXT, DISCARD_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE); if (choice == OptionDialog.CANCEL_OPTION) { // Cancel return false; } if (choice == OptionDialog.OPTION_TWO) { // Discard Changes! closeComponentWithoutSaving(); return true; } saveAs(); return true; }
Example 4
Source File: SetStackDepthChangeAction.java From ghidra with Apache License 2.0 | 6 votes |
private void setStackDepthChange(final Program program, final Address address, final int newStackDepthChange, final Address callToAddress) { if (callToAddress == null) { setStackDepthChange(program, address, newStackDepthChange); return; } int result = showPurgeQuestionDialog(funcPlugin.getTool(), address, callToAddress); switch (result) { case OptionDialog.OPTION_ONE: // Local (SetStackDepthChange) setStackDepthChange(program, address, newStackDepthChange); break; case OptionDialog.OPTION_TWO: // Global (SetFunctionPurge) setFunctionPurge(program, address, newStackDepthChange, callToAddress); break; case OptionDialog.CANCEL_OPTION: // Cancel break; } }
Example 5
Source File: FunctionEditorDialog.java From ghidra with Apache License 2.0 | 6 votes |
protected boolean handleParseException(Exception exception) { String message = exception.getMessage(); String details = CParserUtils.handleParseProblem(exception, signatureTextField.getText()); if (details != null) { message = details; } message = HTMLUtilities.wrapAsHTML( message + "<BR><BR><CENTER><B>Do you want to continue editing or " + "abort your changes?</B></CENTER>"); int result = OptionDialog.showOptionNoCancelDialog(rootPanel, "Invalid Function Signature", message, "Continue Editing", "Abort Changes", OptionDialog.ERROR_MESSAGE); if (result == OptionDialog.OPTION_TWO) { model.resetSignatureTextField(); return true; } return false; }
Example 6
Source File: GFileSystemExtractAllTask.java From ghidra with Apache License 2.0 | 6 votes |
@Override protected boolean handleUnexpectedException(GFile file, Exception e) { errorredFiles.put(file.getFSRL(), e.getMessage()); if (skipAllErrors) { return true; } int option = OptionDialog.showOptionDialog(parentComponent, "Error Extracting File", "There was a problem copying file " + file.getPath() + "\n\n" + e.getMessage() + "\n\nSkip this file and continue or cancel entire operation?", "Skip && Continue", "Skip All"); if (option == OptionDialog.OPTION_TWO /* Skip All */) { skipAllErrors = true; } if (!skipAllErrors && option != OptionDialog.OPTION_ONE /* ie. != Skip this one*/) { return false; } return true; }
Example 7
Source File: PluginTool.java From ghidra with Apache License 2.0 | 5 votes |
/** * 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; }
Example 8
Source File: ExportToCAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected void decompilerActionPerformed(DecompilerActionContext context) { File file = getFile(context.getDecompilerPanel()); if (file == null) { return; } if (file.exists()) { if (OptionDialog.showYesNoDialog(context.getDecompilerPanel(), "Overwrite Existing File?", "Do you want to overwrite the existing file?") == OptionDialog.OPTION_TWO) { return; } } try { PrintWriter writer = new PrintWriter(new FileOutputStream(file)); ClangTokenGroup grp = context.getCCodeModel(); PrettyPrinter printer = new PrettyPrinter(context.getFunction(), grp); DecompiledFunction decompFunc = printer.print(true); writer.write(decompFunc.getC()); writer.close(); context.setStatusMessage( "Successfully exported function(s) to " + file.getAbsolutePath()); } catch (IOException e) { Msg.showError(getClass(), context.getDecompilerPanel(), "Export to C Failed", "Error exporting to C: " + e); } }
Example 9
Source File: EnumEditorPanel.java From ghidra with Apache License 2.0 | 5 votes |
void domainObjectRestored(DataTypeManagerDomainObject domainObject, EnumDataType enuum) { stopCellEditing(); this.originalEnumDT = enuum; this.editedEnumDT = (EnumDataType) enuum.copy(enuum.getDataTypeManager()); DataTypeManager objectDataTypeManager = domainObject.getDataTypeManager(); DataTypeManager providerDataTypeManager = provider.getDataTypeManager(); if (objectDataTypeManager != providerDataTypeManager) { return; // The editor isn't associated with the restored domain object. } String objectType = "domain object"; if (domainObject instanceof Program) { objectType = "program"; } else if (domainObject instanceof DataTypeArchive) { objectType = "data type archive"; } if (tableModel.hasChanges()) { if (OptionDialog.showYesNoDialogWithNoAsDefaultButton(this, "Reload Enum Editor?", "The " + objectType + " \"" + objectDataTypeManager.getName() + "\" has been restored.\n" + "\"" + tableModel.getEnum().getDisplayName() + "\" may have changed outside this editor.\n" + "Do you want to discard edits and reload the Enum?") == OptionDialog.OPTION_TWO) { // no categoryField.setText(provider.getCategoryText()); return; // Don't reload. } } // Reloading the enum. setFieldInfo(editedEnumDT); tableModel.setEnum(editedEnumDT, false); }
Example 10
Source File: EnumEditorProvider.java From ghidra with Apache License 2.0 | 5 votes |
/** * Checks to see if the new changes to the enum will affect equates based off of it. * @param editedEnum the enum to check for conflicts with * @param dtm the data type manager that this enum lies within * @return true if the enum should save its changes; otherwise, false */ private boolean resolveEquateConflicts(Enum editedEnum, DataTypeManager dtm) { Program program = plugin.getProgram(); if (program == null) { // No open program; data type not from the program archive. return true; } EquateTable et = program.getEquateTable(); Set<String> oldFieldConflicts = new HashSet<>(); Set<String> conflictingEquates = new HashSet<>(); for (Equate eq : CollectionUtils.asIterable(et.getEquates())) { if (eq.isEnumBased() && originalEnum.getUniversalID().equals(eq.getEnumUUID()) && editedEnum.getName(eq.getValue()) == null) { oldFieldConflicts.add(originalEnum.getName(eq.getValue())); conflictingEquates.add(eq.getName()); } } if (conflictingEquates.isEmpty()) { return true; } switch (showOptionDialog(editedEnum, oldFieldConflicts)) { case OptionDialog.OPTION_ONE: removeEquates(et, conflictingEquates); case OptionDialog.OPTION_TWO: return true; case OptionDialog.CANCEL_OPTION: default: return false; } }
Example 11
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(); }
Example 12
Source File: ProgramSaveManager.java From ghidra with Apache License 2.0 | 5 votes |
private boolean getSaveAsLock(Program program) { if (!program.lock(null)) { String title = "Save Program As (Busy)"; StringBuffer buf = new StringBuffer(); buf.append( "The Program is currently being modified by the following actions/tasks:\n "); Transaction t = program.getCurrentTransaction(); List<String> list = t.getOpenSubTransactions(); Iterator<String> it = list.iterator(); while (it.hasNext()) { buf.append("\n "); buf.append(it.next()); } buf.append("\n \n"); buf.append( "WARNING! The above task(s) should be cancelled before attempting a Save As...\n"); buf.append("Only proceed if unable to cancel them.\n \n"); buf.append("If you click 'Save As (Rollback)' {recommended}, all changes made\n"); buf.append("by these tasks, as well as any other overlapping task, will be LOST!\n"); buf.append( "If you click 'Save As (As Is)', the program will be saved in its current\n"); buf.append("state which may contain some incomplete data.\n"); buf.append("Any forced save may also result in subsequent transaction errors while\n"); buf.append("the above tasks remain active.\n "); int result = OptionDialog.showOptionDialog(tool.getToolFrame(), title, buf.toString(), "Save As (Rollback)!", "Save As (As Is)!", OptionDialog.WARNING_MESSAGE); if (result == OptionDialog.OPTION_ONE) { program.forceLock(true, "Save Program As"); return true; } else if (result == OptionDialog.OPTION_TWO) { program.forceLock(false, "Save Program As"); return true; } return false; } return true; }
Example 13
Source File: ProjectDataDeleteTask.java From ghidra with Apache License 2.0 | 4 votes |
@Override public void run(TaskMonitor monitor) { // Check all files directly given to this task if (!preprocessStartFilesAndFolders(monitor)) { return; } // If there are problems, ask the user what to do if (!failPreprocessReadOnly.isEmpty()) { int option = OptionDialog.showOptionDialog(parentComponent, "Delete Read-only Files?", "<html>There were " + failPreprocessReadOnly.size() + " read-only files found in the requested set of files. Override the read-only status and delete?", "Delete Read-only Files", "Continue and Skip Read-only Files", OptionDialog.QUESTION_MESSAGE); switch (option) { case OptionDialog.OPTION_ONE:// Delete read-only files for (DomainFile f : failPreprocessReadOnly) { filesToDelete.put(f, null); } readOnlyOverride.addAll(failPreprocessReadOnly); failPreprocessReadOnly.clear(); break; case OptionDialog.OPTION_TWO:// Continue and skip // nada break; case OptionDialog.CANCEL_OPTION: // stop delete task return; } } if (!failPreprocessCheckedOut.isEmpty()) { if (!confirmUserSkipFailedPreprocessedFiles()) { return; } } if (filesToDelete.isEmpty() && foldersToDelete.isEmpty()) { Msg.showInfo(this, parentComponent, "Delete finished", "Nothing to do, finished."); return; } if (!confirmDeleteFiles()) { return; } try { deleteFiles(monitor); deleteFolders(monitor); } catch (CancelledException ce) { Msg.info(this, "Canceled delete"); } if (hasErrors()) { showErrorSummary(monitor.isCancelled()); } }
Example 14
Source File: GhidraScriptEditorComponentProvider.java From ghidra with Apache License 2.0 | 4 votes |
private void handleChangesOnDisk() { int choice = OptionDialog.showOptionDialog(scrollPane, FILE_ON_DISK_CHANGED_TITLE, "<html>The contents of the script file have changed on disk.<br><br>Would " + "you like to <b>keep your changes</b> in the editor or <b><font color=\"red\">" + "discard</font></b> your changes?", KEEP_CHANGES_TEXT, DISCARD_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE); if (choice == OptionDialog.CANCEL_OPTION) { // Cancel return; } if (choice == OptionDialog.OPTION_TWO) { // Discard Changes! reloadScript(); return; } // implicit: choice == OptionDialog.OPTION_ONE // // The user wants to keep the changes, but how? // choice = OptionDialog.showOptionDialog(scrollPane, CHANGE_DESTINATION_TITLE, "<html>You can save your current changes to <b>another file</b> or " + "<b><font color=\"red\">overwrite</font></b> the contents of the file on disk.", SAVE_CHANGES_AS_TEXT, OVERWRITE_CHANGES_TEXT, OptionDialog.QUESTION_MESSAGE); // // Cancel // if (choice == OptionDialog.OPTION_THREE) { // Cancel return; } // // Save As... // ResourceFile previousFile = scriptSourceFile; if (choice == OptionDialog.OPTION_ONE) { // Save As... if (saveAs()) { // Save As completed successfully; open a new editor // with the original file provider.editScriptInGhidra(previousFile); } return; } // // Overwrite changes on disk with a normal save operation // doSave(); }
Example 15
Source File: DataTypeManagerHandler.java From ghidra with Apache License 2.0 | 4 votes |
private boolean getSaveAsLock(UndoableDomainObject undoableDomainObject) { if (!undoableDomainObject.lock(null)) { String title = "Save " + CONTENT_NAME + " As (Busy)"; StringBuffer buf = new StringBuffer(); buf.append("The " + CONTENT_NAME + " is currently being modified by the following actions/tasks:\n \n"); Transaction t = undoableDomainObject.getCurrentTransaction(); List<String> list = t.getOpenSubTransactions(); Iterator<String> it = list.iterator(); while (it.hasNext()) { buf.append("\n "); buf.append(it.next()); } buf.append("\n \n"); buf.append( "WARNING! The above task(s) should be cancelled before attempting a Save As...\n"); buf.append("Only proceed if unable to cancel them.\n \n"); buf.append( "If you click 'Save Archive As (Rollback)' {recommended}, all changes made\n"); buf.append("by these tasks, as well as any other overlapping task, will be LOST!\n"); buf.append( "If you click 'Save As (As Is)', the archive will be saved in its current\n"); buf.append("state which may contain some incomplete data.\n"); buf.append("Any forced save may also result in subsequent transaction errors while\n"); buf.append("the above tasks remain active.\n "); int result = OptionDialog.showOptionDialog(tool.getToolFrame(), title, buf.toString(), "Save Archive As (Rollback)!", "Save Archive As (As Is)!", OptionDialog.WARNING_MESSAGE); if (result == OptionDialog.OPTION_ONE) { undoableDomainObject.forceLock(true, "Save Archive As"); return true; } else if (result == OptionDialog.OPTION_TWO) { undoableDomainObject.forceLock(false, "Save Archive As"); return true; } return false; } return true; }