Search in sources :

Example 1 with LastDirFileChooser

use of com.google.security.zynamics.binnavi.Gui.LastDirFileChooser in project binnavi by google.

the class CMemoryFunctions method showSaveDialog.

/**
   * Displays a Save File dialog.
   *
   * @param parent Parent window of the dialog.
   *
   * @return A pair with the return value of the dialog and the selected file.
   */
private static Pair<Integer, File> showSaveDialog(final JFrame parent) {
    final LastDirFileChooser fileChooser = new LastDirFileChooser();
    fileChooser.setDialogTitle("Save Data to File");
    final int val = fileChooser.showSaveDialog(parent);
    return new Pair<Integer, File>(val, fileChooser.getSelectedFile());
}
Also used : LastDirFileChooser(com.google.security.zynamics.binnavi.Gui.LastDirFileChooser) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 2 with LastDirFileChooser

use of com.google.security.zynamics.binnavi.Gui.LastDirFileChooser in project binnavi by google.

the class CGraphExporter method exportAsSvg.

/**
   * Exports the current view as a SVG image after prompting the user for a filename.
   *
   * @param parent Parent frame that is used to display error messages.
   * @param graph Graph to be exported to a SVG file.
   */
public static void exportAsSvg(final JFrame parent, final ZyGraph graph) {
    Preconditions.checkNotNull(parent, "IE01737: Parent argument can not be null");
    Preconditions.checkNotNull(graph, "IE01738: Graph argument can not be null");
    final LastDirFileChooser fileChooser = new LastDirFileChooser();
    final int retval = fileChooser.showSaveDialog(parent);
    if (retval == JFileChooser.APPROVE_OPTION) {
        try {
            if (!GraphExporters.exportAllAsSVG(graph, fileChooser.getSelectedFile().getAbsolutePath())) {
                throw new IOException("Failed to save SVG");
            }
        } catch (final IOException e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00195: " + "Could not save view to SVG file";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be written to the file '%s'.", graph.getViewName(), fileChooser.getSelectedFile().getAbsolutePath()), new String[] { "There was a problem writing the PNG file." }, new String[] { "The view was not written to the PNG file." });
            NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
        }
    }
}
Also used : LastDirFileChooser(com.google.security.zynamics.binnavi.Gui.LastDirFileChooser) IOException(java.io.IOException)

Example 3 with LastDirFileChooser

use of com.google.security.zynamics.binnavi.Gui.LastDirFileChooser in project binnavi by google.

the class CGraphExporter method exportAsPng.

/**
   * Exports the current view as a PNG image after prompting the user for a filename.
   *
   * @param parent Parent frame that is used to display error messages.
   * @param graph Graph to be exported to a PNG file.
   */
public static void exportAsPng(final JFrame parent, final ZyGraph graph) {
    Preconditions.checkNotNull(parent, "IE01735: Parent argument can not be null");
    Preconditions.checkNotNull(graph, "IE01736: Graph argument can not be null");
    final LastDirFileChooser fileChooser = new LastDirFileChooser();
    final int retval = fileChooser.showSaveDialog(parent);
    if (retval == JFileChooser.APPROVE_OPTION) {
        try {
            if (!GraphExporters.exportAllAsPNG(graph, fileChooser.getSelectedFile().getAbsolutePath())) {
                throw new IOException("Failed to write the PNG");
            }
        } catch (final IOException e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00194: " + "Could not save view to PNG file";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be written to the file '%s'.", graph.getViewName(), fileChooser.getSelectedFile().getAbsolutePath()), new String[] { "There was a problem writing the PNG file." }, new String[] { "The view was not written to the PNG file." });
            NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
        }
    }
}
Also used : LastDirFileChooser(com.google.security.zynamics.binnavi.Gui.LastDirFileChooser) IOException(java.io.IOException)

Aggregations

LastDirFileChooser (com.google.security.zynamics.binnavi.Gui.LastDirFileChooser)3 IOException (java.io.IOException)2 Pair (com.google.security.zynamics.zylib.general.Pair)1