docking.widgets.filechooser.GhidraFileChooser Java Examples
The following examples show how to use
docking.widgets.filechooser.GhidraFileChooser.
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: PathnameTablePanelTest.java From ghidra with Apache License 2.0 | 6 votes |
private void selectFromFileChooser() throws Exception { final GhidraFileChooser fileChooser = waitForDialogComponent(GhidraFileChooser.class); assertNotNull(fileChooser); JButton chooseButton = findButtonByText(fileChooser, "OK"); assertNotNull(chooseButton); //JTextField filenameTextField = (JTextField)findComponentByName(fileChooser.getComponent(), "filenameTextField"); //setJTextField(filenameTextField, "fred.h"); runSwing(() -> fileChooser.setSelectedFile( new File(fileChooser.getCurrentDirectory(), "fred.h"))); waitForUpdateOnChooser(fileChooser); pressButton(chooseButton, true); waitForPostedSwingRunnables(); }
Example #2
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 #3
Source File: PopulateFidDialog.java From ghidra with Apache License 2.0 | 6 votes |
private JComponent buildSymbolsFileField() { JPanel panel = new JPanel(new BorderLayout()); symbolsFileTextField = new JTextField(); panel.add(symbolsFileTextField, BorderLayout.CENTER); JButton browseButton = createBrowseButton(); browseButton.addActionListener(e -> { GhidraFileChooser chooser = new GhidraFileChooser(tool.getToolFrame()); chooser.setTitle("Choose Common Symbols File"); chooser.setFileSelectionMode(GhidraFileChooser.FILES_ONLY); // chooser.setFileFilter(null); File selectedFile = chooser.getSelectedFile(); if (selectedFile != null) { symbolsFileTextField.setText(selectedFile.getAbsolutePath()); } }); symbolsFileTextField.getDocument().addUndoableEditListener(e -> updateOkEnablement()); panel.add(browseButton, BorderLayout.EAST); return panel; }
Example #4
Source File: GraphExporterDialog.java From ghidra with Apache License 2.0 | 6 votes |
private void chooseDestinationFile() { GhidraFileChooser chooser = new GhidraFileChooser(getComponent()); chooser.setSelectedFile(getLastExportDirectory()); chooser.setTitle("Select Output File"); chooser.setApproveButtonText("Select Output File"); chooser.setApproveButtonToolTipText("Select File"); chooser.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY); chooser.setSelectedFileFilter(GhidraFileFilter.ALL); GraphExportFormat exporter = getSelectedExporter(); if (exporter != null) { chooser.setFileFilter( new ExtensionFileFilter(exporter.getDefaultFileExtension(), exporter.toString())); } String filePath = filePathTextField.getText().trim(); File currentFile = filePath.isEmpty() ? null : new File(filePath); if (currentFile != null) { chooser.setSelectedFile(currentFile); } File file = chooser.getSelectedFile(); if (file != null) { setLastExportDirectory(file); filePathTextField.setText(file.getAbsolutePath()); } }
Example #5
Source File: AbstractDockingTest.java From ghidra with Apache License 2.0 | 6 votes |
public static void waitForUpdateOnChooser(GhidraFileChooser chooser) throws Exception { // make sure swing has handled any pending changes waitForSwing(); // Use an artificially high wait period that won't be reached most of the time. We // need this because file choosers use the native filesystem, which can have 'hiccups' int timeoutMillis = PRIVATE_LONG_WAIT_TIMEOUT; int totalTime = 0; while (pendingUpdate(chooser) && (totalTime < timeoutMillis)) { Thread.sleep(DEFAULT_WAIT_DELAY); totalTime += DEFAULT_WAIT_DELAY; } if (totalTime >= timeoutMillis) { Assert.fail("Timed-out waiting for directory to load"); } // make sure swing has handled any pending changes waitForSwing(); }
Example #6
Source File: GTable.java From ghidra with Apache License 2.0 | 6 votes |
private File chooseExportFile() { GhidraFileChooser chooser = createExportFileChooser(); File file = chooser.getSelectedFile(); if (file == null) { return null; } if (file.exists()) { int result = OptionDialog.showYesNoDialog(GTable.this, "Overwrite?", "File exists. Do you want to overwrite?"); if (result != OptionDialog.OPTION_ONE) { return null; } } storeLastExportDirectory(file); return file; }
Example #7
Source File: ExporterDialog.java From ghidra with Apache License 2.0 | 6 votes |
private void chooseDestinationFile() { GhidraFileChooser chooser = new GhidraFileChooser(getComponent()); chooser.setSelectedFile(getLastExportDirectory()); chooser.setTitle("Select Output File"); chooser.setApproveButtonText("Select Output File"); chooser.setApproveButtonToolTipText("Select File"); chooser.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY); chooser.setSelectedFileFilter(GhidraFileFilter.ALL); Exporter exporter = getSelectedExporter(); if (exporter != null && exporter.getDefaultFileExtension() != null) { chooser.setFileFilter( new ExtensionFileFilter(exporter.getDefaultFileExtension(), exporter.getName())); } String filePath = filePathTextField.getText().trim(); File currentFile = filePath.isEmpty() ? null : new File(filePath); if (currentFile != null) { chooser.setSelectedFile(currentFile); } File file = chooser.getSelectedFile(); if (file != null) { setLastExportDirectory(file); filePathTextField.setText(file.getAbsolutePath()); } }
Example #8
Source File: SaveImageAction.java From ghidra with Apache License 2.0 | 6 votes |
private static File getExportFile() { GhidraFileChooser chooser = new GhidraFileChooser(null); chooser.setTitle("Export Image As..."); chooser.setApproveButtonText("Save As"); chooser.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY); chooser.setMultiSelectionEnabled(false); File selected = chooser.getSelectedFile(true); if (chooser.wasCancelled()) { return null; } return selected; }
Example #9
Source File: KeyBindingUtils.java From ghidra with Apache License 2.0 | 6 votes |
private static File getFileFromUser(File startingDir) { KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Component activeComponent = kfm.getActiveWindow(); GhidraFileChooser fileChooser = new GhidraFileChooser(activeComponent); fileChooser.setTitle("Please Select A File"); fileChooser.setFileFilter(FILE_FILTER); fileChooser.setApproveButtonText("OK"); fileChooser.setCurrentDirectory(startingDir); File selectedFile = fileChooser.getSelectedFile(); // make sure the file has the correct extension if ((selectedFile != null) && !selectedFile.getName().endsWith(PREFERENCES_FILE_EXTENSION)) { selectedFile = new File(selectedFile.getAbsolutePath() + PREFERENCES_FILE_EXTENSION); } // save off the last location to which the user navigated so we can // return them to that spot if they user the dialog again. Preferences.setProperty(LAST_KEY_BINDING_EXPORT_DIRECTORY, fileChooser.getCurrentDirectory().getAbsolutePath()); return selectedFile; }
Example #10
Source File: GhidraScriptAskMethodsTest.java From ghidra with Apache License 2.0 | 6 votes |
private void waitForUpdateOnDirectory(GhidraFileChooser chooser) throws Exception { // make sure swing has handled any pending changes waitForSwing(); // artificially high wait period that won't be reached most of the time int timeoutMillis = TIMEOUT_MILLIS; int totalTime = 0; while (hasPendingUpdate(chooser) && (totalTime < timeoutMillis)) { Thread.sleep(50); totalTime += 50; } if (totalTime >= timeoutMillis) { Assert.fail("Timed-out waiting for directory to load"); } // make sure swing has handled any pending changes waitForSwing(); }
Example #11
Source File: AbstractCreateArchiveTest.java From ghidra with Apache License 2.0 | 6 votes |
protected void waitForUpdateOnDirectory(GhidraFileChooser chooser) throws Exception { // make sure swing has handled any pending changes waitForPostedSwingRunnables(); // artificially high wait period that won't be reached most of the time int timeoutMillis = 5000; int totalTime = 0; while (chooserIsPendingUpdate(chooser) && (totalTime < timeoutMillis)) { Thread.sleep(50); totalTime += 50; } if (totalTime >= timeoutMillis) { Assert.fail("Timed-out waiting for directory to load"); } // make sure swing has handled any pending changes waitForPostedSwingRunnables(); }
Example #12
Source File: StructureEditorArchiveTest.java From ghidra with Apache License 2.0 | 6 votes |
private void createNewArchive(String archiveName, boolean deleteExisting) throws Exception { File archiveFile = new File(getTestDirectoryPath(), archiveName); if (deleteExisting) { archiveFile.delete(); } final DockingActionIf action = getAction(plugin, "New File Data Type Archive"); DataTypeTestUtils.performAction(action, dtTree, false); GhidraFileChooser chooser = waitForDialogComponent(tool.getToolFrame(), GhidraFileChooser.class, 10000); assertNotNull("Never found chooser!", chooser); selectFileInChooser(chooser, archiveFile); // hit "Create Archive" button JButton saveAsButton = findButtonByText(chooser, "Create Archive"); pressButton(saveAsButton); waitForPostedSwingRunnables(); }
Example #13
Source File: OptionsDialogTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testFileChooserEditor() throws Exception { ScrollableOptionsEditor editor = showOptions(ToolConstants.TOOL_OPTIONS); pressBrowseButton(editor, "My PathName"); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); assertNotNull(chooser); assertEquals("Choose Path", chooser.getTitle()); File file = createTempFile("MyFile.txt"); file.deleteOnExit(); writeTempFile(file.getAbsolutePath()); runSwing(() -> chooser.setSelectedFile(file)); waitForUpdateOnChooser(chooser); JButton openButton = findButtonByText(chooser, "Choose Path"); pressButton(openButton); waitForSwing(); JTextField pathField = getEditorTextField(editor, "My PathName"); assertEquals(file.getAbsolutePath(), pathField.getText()); }
Example #14
Source File: ToolActionManagerTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testExportToolOverwriteCancel() throws Exception { // export using the menu action createTool(); DockingActionIf exportAction = getAction("Untitled", "Export Tool"); performAction(exportAction, "Untitled", false); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); setSelectedFile(chooser, exportFile); pressButtonByText(chooser, "Export"); waitForSwing(); performAction(exportAction, "Untitled", false); chooser = waitForDialogComponent(GhidraFileChooser.class); setSelectedFile(chooser, exportFile); JButton b = findButtonByText(chooser, "Export"); pressButton(b, false); OptionDialog optD = waitForDialogComponent(OptionDialog.class); assertNotNull(optD); assertEquals("Overwrite?", optD.getTitle()); pressButtonByText(optD.getComponent(), "Cancel"); }
Example #15
Source File: ToolSaving3Test.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testExportDefaultTool() throws Exception { // // Verify a 'default' tool does not contain 'config state' when written // PluginTool tool1 = launchTool(DEFAULT_TEST_TOOL_NAME); DockingActionIf exportAction = getAction(tool1, "Export Default Tool"); performAction(exportAction, false); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); File exportedFile = createTempFile("ExportedDefaultTool", ToolUtils.TOOL_EXTENSION); chooser.setSelectedFile(exportedFile); waitForUpdateOnChooser(chooser); pressButtonByText(chooser, "Export"); OptionDialog overwriteDialog = waitForDialogComponent(OptionDialog.class); pressButtonByText(overwriteDialog, "Overwrite"); waitForCondition(() -> exportedFile.length() > 0); assertExportedFileDoesNotContainsLine(exportedFile, "PLUGIN_STATE"); }
Example #16
Source File: ToolSaving3Test.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testExportedToolContainsConfigSettings() throws Exception { // // Regression test: ensure that an exported tool contains config settings // PluginTool tool1 = launchTool(DEFAULT_TEST_TOOL_NAME); DockingActionIf exportAction = getAction(tool1, "Export Tool"); performAction(exportAction, false); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); File exportedFile = createTempFile("ExportedTool", ToolUtils.TOOL_EXTENSION); chooser.setSelectedFile(exportedFile); waitForUpdateOnChooser(chooser); pressButtonByText(chooser, "Export"); OptionDialog overwriteDialog = waitForDialogComponent(OptionDialog.class); pressButtonByText(overwriteDialog, "Overwrite"); waitForCondition(() -> exportedFile.length() > 0); assertExportedFileContainsLine(exportedFile, "PLUGIN_STATE"); }
Example #17
Source File: ToolActionManagerTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testExportTool() throws Exception { // export using the menu action createTool(); DockingActionIf exportAction = getAction("Untitled", "Export Tool"); performAction(exportAction, "Untitled", false); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); setSelectedFile(chooser, exportFile); pressButtonByText(chooser, "Export"); waitForSwing(); assertTrue(exportFile.exists()); }
Example #18
Source File: AbstractCreateArchiveTest.java From ghidra with Apache License 2.0 | 5 votes |
protected void selectFileInChooser(final GhidraFileChooser fileChooser, final File file) throws Exception { waitForUpdateOnDirectory(fileChooser); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { Msg.trace(this, "\t\t\t" + testName.getMethodName() + "set file in chooser: " + file.getName()); fileChooser.setSelectedFile(file); } }); waitForUpdateOnChooser(fileChooser); }
Example #19
Source File: FSBActionManager.java From ghidra with Apache License 2.0 | 5 votes |
FSBActionManager(FileSystemBrowserPlugin plugin, FileSystemBrowserComponentProvider provider, TextEditorService textEditorService, GTree gTree) { this.plugin = plugin; this.provider = provider; this.textEditorService = textEditorService; this.gTree = gTree; chooserExport = new GhidraFileChooser(provider.getComponent()); chooserExportAll = new GhidraFileChooser(provider.getComponent()); createActions(); }
Example #20
Source File: ToolActionManagerTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testImportTool() throws Exception { // action for import a tool final ToolChest tc = frontEndTool.getToolServices().getToolChest(); int count = tc.getToolCount(); String toolNamePrefix = "TestCodeBrowser"; final File cbFile = ResourceManager.getResourceFile( "defaultTools/" + toolNamePrefix + ToolUtils.TOOL_EXTENSION); assertNotNull(cbFile); DockingActionIf importAction = getAction("Import Tool"); performAction(importAction, false); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); setSelectedFile(chooser, cbFile); pressButtonByText(chooser, "Import"); waitForSwing(); assertEquals(count + 1, tc.getToolCount()); ToolTemplate[] configs = tc.getToolTemplates(); final ArrayList<String> list = new ArrayList<>(); for (ToolTemplate config : configs) { if (config.getName().startsWith(toolNamePrefix + "_")) { list.add(config.getName()); } } assertTrue(list.size() > 0); Collections.sort(list); runSwing(() -> tc.remove(list.get(list.size() - 1))); }
Example #21
Source File: RestoreDialog.java From ghidra with Apache License 2.0 | 5 votes |
/** * Creates a directory chooser for selecting the directory where the * archive will be restored.. * @return the file chooser. */ private GhidraFileChooser createDirectoryChooser() { GhidraFileChooser fileChooser = new GhidraFileChooser(null); // start the browsing in the user's preferred project directory File projectDirectory = new File(GenericRunInfo.getProjectsDirPath()); fileChooser.setFileSelectionMode(GhidraFileChooser.DIRECTORIES_ONLY); fileChooser.setCurrentDirectory(projectDirectory); fileChooser.setSelectedFile(projectDirectory); return fileChooser; }
Example #22
Source File: ImportPatternFileActionListener.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { GhidraFileChooser fileChooser = new GhidraFileChooser(component); fileChooser.setFileSelectionMode(GhidraFileChooser.FILES_ONLY); fileChooser.setTitle("Select Pattern File"); String baseDir = Preferences.getProperty(XML_IMPORT_DIR_PROPERTY); if (baseDir != null) { fileChooser.setCurrentDirectory(new File(baseDir)); } ExtensionFileFilter xmlFilter = new ExtensionFileFilter("xml", "XML Files"); fileChooser.setFileFilter(xmlFilter); File patternFile = fileChooser.getSelectedFile(); if (fileChooser.wasCancelled() || patternFile == null) { return; } Preferences.setProperty(XML_IMPORT_DIR_PROPERTY, fileChooser.getCurrentDirectory().getAbsolutePath()); Preferences.store(); //only clear the patterns if new patterns are loaded from a file ResourceFile resource = new ResourceFile(patternFile); try { PatternPairSet pairSet = ClipboardPanel.parsePatternPairSet(resource); if (pairSet == null) { return; } plugin.clearPatterns(); for (DittedBitSequence pre : pairSet.getPreSequences()) { PatternInfoRowObject preRow = new PatternInfoRowObject(PatternType.PRE, pre, null); plugin.addPattern(preRow); } //post patterns can have alignment and context register restrictions processPostPatterns(pairSet); } catch (IOException | SAXException e1) { Msg.showError(this, component, "Import Error", "Error Importing file " + patternFile.getAbsolutePath(), e1); } plugin.updateClipboard(); }
Example #23
Source File: FidPlugin.java From ghidra with Apache License 2.0 | 5 votes |
/** * Method to ask for a file (copied from GhidraScript). * @param title popup window title * @param approveButtonText text for the "yes" button * @return the file chosen, or null */ private File askFile(final String title, final String approveButtonText) { final GhidraFileChooser chooser = new GhidraFileChooser(tool.getActiveWindow()); chooser.setApproveButtonText(approveButtonText); chooser.setTitle(title); chooser.setFileSelectionMode(GhidraFileChooser.FILES_ONLY); return chooser.getSelectedFile(); }
Example #24
Source File: FidDebugPlugin.java From ghidra with Apache License 2.0 | 5 votes |
/** * Creates a raw read-only database file from a packed database. This file is useful * for including in a distribution. */ protected void createRawFile() { FidFile fidFile = askChoice("Choose destination FidDb", "Please choose the destination FidDb for population", fidFileManager.getUserAddedFiles(), null); if (fidFile == null) { return; } GhidraFileChooser chooser = new GhidraFileChooser(tool.getToolFrame()); chooser.setTitle("Where do you want to create the read-only installable database?"); chooser.setFileSelectionMode(GhidraFileChooserMode.DIRECTORIES_ONLY); File selectedFile = chooser.getSelectedFile(); if (selectedFile == null) { return; } File outputFile = new File(selectedFile, fidFile.getBaseName() + FidFile.FID_RAW_DATABASE_FILE_EXTENSION); try (FidDB fidDB = fidFile.getFidDB(false)) { fidDB.saveRawDatabaseFile(outputFile, TaskMonitor.DUMMY); } catch (VersionException | IOException | CancelledException e) { // BTW CancelledException can't happen because we used a DUMMY monitor. Msg.showError(this, null, "Error saving read-only installable database", e.getMessage(), e); } }
Example #25
Source File: KeyBindingUtilsTest.java From ghidra with Apache License 2.0 | 5 votes |
private File findAndTestFileChooser(File path, String filename) throws Exception { // get the file chooser and set the file it will use GhidraFileChooser fileChooser = waitForDialogComponent(GhidraFileChooser.class); if (fileChooser == null) { Msg.debug(this, "Couldn't find file chooser"); printOpenWindows(); Assert.fail("Did not get the expected GhidraFileChooser"); } // change directories if (path != null) { fileChooser.setCurrentDirectory(path); } waitForUpdateOnChooser(fileChooser); File currentDirectory = fileChooser.getCurrentDirectory(); File fileToSelect = new File(currentDirectory, filename); fileChooser.setSelectedFile(fileToSelect); waitForUpdateOnChooser(fileChooser); // press OK on the file chooser final JButton okButton = (JButton) getInstanceField("okButton", fileChooser); runSwing(() -> okButton.doClick()); // wait to make sure that there is enough time to write the data waitForPostedSwingRunnables(); // make sure that the file was created or already existed File selectedFile = fileChooser.getSelectedFile(false); assertTrue("The test file was not created after exporting.", selectedFile.exists()); return selectedFile; }
Example #26
Source File: SaveToolConfigDialog.java From ghidra with Apache License 2.0 | 5 votes |
/** * Pop up a file chooser for the user to look for icon images. */ private void browseForIcons() { GhidraFileChooser iconFileChooser = new GhidraFileChooser(getComponent()); iconFileChooser.setFileSelectionMode(GhidraFileChooser.FILES_ONLY); iconFileChooser.setTitle("Choose Icon"); iconFileChooser.setApproveButtonToolTipText("Choose Icon"); iconFileChooser.setFileFilter( new ExtensionFileFilter(new String[] { "gif", "jpg", "bmp", "png" }, "Image Files")); String iconDir = Preferences.getProperty(LAST_ICON_DIRECTORY); if (iconDir != null) { iconFileChooser.setCurrentDirectory(new File(iconDir)); } File file = iconFileChooser.getSelectedFile(); if (file == null) { return; } String filename = file.getAbsolutePath(); iconField.setText(filename); ToolIconURL url = new ToolIconURL(filename); iconListModel.addElement(url); iconList.setSelectedValue(url, true); setPicture(url); Preferences.setProperty(LAST_ICON_DIRECTORY, file.getParent()); }
Example #27
Source File: DragonHelper.java From dragondance with GNU General Public License v3.0 | 5 votes |
public static String askFile(Component parent, String title, String okButtonText) { GhidraFileChooser gfc = new GhidraFileChooser(parent); if (!Globals.LastFileDialogPath.isEmpty()) { File def = new File(Globals.LastFileDialogPath); gfc.setSelectedFile(def); } gfc.setTitle(title); gfc.setApproveButtonText(okButtonText); gfc.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY); File file = gfc.getSelectedFile(); if (file == null) { return null; } if (!file.exists()) return null; Globals.LastFileDialogPath = Util.getDirectoryOfFile(file.getAbsolutePath()); if (Globals.LastFileDialogPath == null) Globals.LastFileDialogPath = System.getProperty("user.dir"); return file.getAbsolutePath(); }
Example #28
Source File: EditActionManager.java From ghidra with Apache License 2.0 | 5 votes |
private GhidraFileChooser createCertFileChooser() { GhidraFileChooser fileChooser = new GhidraFileChooser(tool.getToolFrame()); fileChooser.setTitle("Select Certificate (req'd for PKI authentication only)"); fileChooser.setApproveButtonText("Set Certificate"); fileChooser.setFileFilter(ApplicationKeyManagerFactory.CERTIFICATE_FILE_FILTER); fileChooser.setFileSelectionMode(GhidraFileChooser.FILES_ONLY); fileChooser.setHelpLocation(new HelpLocation(plugin.getName(), "Set_PKI_Certificate")); return fileChooser; }
Example #29
Source File: ToolActionManagerTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testExportToolOverwrite() throws Exception { // export using the menu action createTool(); DockingActionIf exportAction = getAction("Untitled", "Export Tool"); performAction(exportAction, "Untitled", false); GhidraFileChooser chooser = waitForDialogComponent(GhidraFileChooser.class); setSelectedFile(chooser, exportFile); pressButtonByText(chooser, "Export"); waitForSwing(); performAction(exportAction, "Untitled", false); chooser = waitForDialogComponent(GhidraFileChooser.class); setSelectedFile(chooser, exportFile); JButton b = findButtonByText(chooser, "Export"); pressButton(b, false); OptionDialog optD = waitForDialogComponent(OptionDialog.class); assertNotNull(optD); assertEquals("Overwrite?", optD.getTitle()); pressButtonByText(optD.getComponent(), "Overwrite"); waitForSwing(); assertTrue(exportFile.exists()); }
Example #30
Source File: ToolServicesImpl.java From ghidra with Apache License 2.0 | 5 votes |
private GhidraFileChooser getFileChooser() { GhidraFileChooser newFileChooser = new GhidraFileChooser(null); newFileChooser.setFileFilter(new GhidraFileFilter() { @Override public boolean accept(File file, GhidraFileChooserModel model) { if (file == null) { return false; } if (file.isDirectory()) { return true; } return file.getAbsolutePath().toLowerCase().endsWith("tool"); } @Override public String getDescription() { return "Tools"; } }); String exportDir = Preferences.getProperty(Preferences.LAST_TOOL_EXPORT_DIRECTORY); if (exportDir != null) { newFileChooser.setCurrentDirectory(new File(exportDir)); } newFileChooser.setTitle("Export Tool"); newFileChooser.setApproveButtonText("Export"); return newFileChooser; }