Java Code Examples for ghidra.program.model.listing.Program#isChanged()
The following examples show how to use
ghidra.program.model.listing.Program#isChanged() .
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: ProgramManagerPlugin.java From ghidra with Apache License 2.0 | 6 votes |
private void updateActions() { Program p = programMgr.getCurrentProgram(); updateCloseAction(p); updateProgramOptionsAction(p); updateSaveAction(p); updateSaveAsAction(p); closeAllAction.setEnabled(p != null); optionsAction.setEnabled(p != null); Program[] programList = programMgr.getAllPrograms(); closeOthersAction.setEnabled(programList.length > 1); saveAllAction.setEnabled(false); for (Program element : programList) { if (element.isChanged()) { saveAllAction.setEnabled(true); break; } } tool.contextChanged(null); }
Example 2
Source File: ProgramSaveManager.java From ghidra with Apache License 2.0 | 6 votes |
/** * Saves all programs that have changes * */ public void saveChangedPrograms() { int saveCnt = 0; int unsavedCnt = 0; Program[] programs = programMgr.getAllOpenPrograms(); for (Program program : programs) { if (program.isChanged()) { if (program.canSave()) { save(program); ++saveCnt; } else { ++unsavedCnt; } } } if (saveCnt != 0) { Msg.showInfo(getClass(), tool.getToolFrame(), "Save All...", "Saved " + saveCnt + " modified programs."); } if (unsavedCnt != 0) { Msg.showWarn(getClass(), tool.getToolFrame(), "Save All...", "Unable to save " + unsavedCnt + " read-only programs!"); } }
Example 3
Source File: ProgramManagerPlugin.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected boolean hasUnsaveData() { Program[] allOpenPrograms = getAllOpenPrograms(); for (Program program : allOpenPrograms) { if (program.isChanged()) { return true; } } return false; }
Example 4
Source File: ProgramManagerPlugin.java From ghidra with Apache License 2.0 | 5 votes |
private void updateSaveAllAction() { boolean saveAllEnable = false; Program[] programList = programMgr.getAllPrograms(); for (Program element : programList) { if (element.isChanged()) { saveAllEnable = true; break; } } saveAllAction.setEnabled(saveAllEnable); }
Example 5
Source File: MultiProgramManager.java From ghidra with Apache License 2.0 | 5 votes |
void releaseProgram(Program program, Object owner) { ProgramInfo info = programMap.get(program); if (info != null && info.owner == owner) { info.owner = null; if (!info.visible) { if (program.isChanged()) { info.setVisible(true); } plugin.closeProgram(program, false); } else if (program.isTemporary()) { plugin.closeProgram(program, false); } } }
Example 6
Source File: MultiTabPlugin.java From ghidra with Apache License 2.0 | 5 votes |
String getStringUsedInList(Program program) { DomainFile df = program.getDomainFile(); String changeIndicator = program.isChanged() ? "*" : ""; if (!df.isInWritableProject()) { return df.toString() + " [Read-Only]" + changeIndicator; } return df.toString() + changeIndicator; }
Example 7
Source File: ProgramSaveManager.java From ghidra with Apache License 2.0 | 5 votes |
private boolean handleChangedProgram(Program currentProgram) { if (!currentProgram.isChanged()) { return true; } DomainFile df = currentProgram.getDomainFile(); String filename = df.getName(); if (!df.isInWritableProject()) { return OptionDialog.showOptionDialog(tool.getToolFrame(), "Program Changed", HTMLUtilities.lineWrapWithHTMLLineBreaks( "<html>Viewed file '" + HTMLUtilities.escapeHTML(filename) + "' has been changed. \n" + "If you continue, your changes will be lost!"), "Continue", OptionDialog.QUESTION_MESSAGE) != OptionDialog.CANCEL_OPTION; } if (df.isReadOnly()) { return OptionDialog.showOptionDialog(tool.getToolFrame(), "Program Changed", HTMLUtilities.lineWrapWithHTMLLineBreaks( "<html>Read-only file '" + HTMLUtilities.escapeHTML(filename) + "' has been changed. \n" + "If you continue, your changes will be lost!"), "Continue", OptionDialog.QUESTION_MESSAGE) != OptionDialog.CANCEL_OPTION; } int result = OptionDialog.showOptionDialog(tool.getToolFrame(), "Save Program?", HTMLUtilities.lineWrapWithHTMLLineBreaks("<html>" + HTMLUtilities.escapeHTML(filename) + " has changed.\nDo you want to save it?"), "&Save", "Do&n't Save", OptionDialog.QUESTION_MESSAGE); if (result == OptionDialog.CANCEL_OPTION) { return false; } if (result == OptionDialog.OPTION_ONE) { SaveFileTask task = new SaveFileTask(currentProgram.getDomainFile()); new TaskLauncher(task, tool.getToolFrame()); } return true; }
Example 8
Source File: SaveVersionTrackingSessionAction.java From ghidra with Apache License 2.0 | 5 votes |
private boolean hasUnsavedVersionTrackingChanges() { // Check to see if there are unsaved changes to the results. VTSession session = controller.getSession(); if (session == null) { return false; } if (session instanceof VTSessionDB) { VTSessionDB sessionDB = (VTSessionDB) session; if (sessionDB.isChanged()) { return true; } } Program destinationProgram = controller.getDestinationProgram(); return destinationProgram.isChanged(); }