Search in sources :

Example 1 with CViewCommentDialog

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

the class CTagFunctions method editTag.

/**
   * Used to edit the name and description of a tag.
   *
   * @param parent Parent window used for dialogs.
   * @param tag The tag to delete.
   */
public static void editTag(final JFrame parent, final CTag tag) {
    final CViewCommentDialog dlg = new CViewCommentDialog(parent, "Edit Tag", tag.getName(), tag.getDescription());
    dlg.setVisible(true);
    if (!dlg.wasCancelled()) {
        try {
            tag.setName(dlg.getName());
        } catch (final CouldntSaveDataException e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00126: " + "Could not change tag name";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The name of the tag '%s' could not be changed.", tag.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The tag name could not be changed." });
            NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
        }
        try {
            tag.setDescription(dlg.getComment());
        } catch (final CouldntSaveDataException e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00127: " + "Could not change tag description";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The description of the tag '%s' could not be changed.", tag.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The tag description could not be changed." });
            NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
        }
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CViewCommentDialog(com.google.security.zynamics.binnavi.Gui.GraphWindows.CViewCommentDialog)

Example 2 with CViewCommentDialog

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

the class CGraphSaver method saveAs.

/**
   * Prompts the user for a new graph description and stores a copy of the graph in the database.
   *
   * @param parent Parent window used to display dialogs.
   * @param graph Graph to be written to the database.
   * @param container View container the graph is written to.
   *
   * @return Information about the save progress.
   */
public static CSaveProgress saveAs(final Window parent, final ZyGraph graph, final IViewContainer container) {
    Preconditions.checkNotNull(parent, "IE01754: Parent argument can not be null");
    Preconditions.checkNotNull(graph, "IE01755: Graph argument can not be null");
    final INaviView view = graph.getRawView();
    final CViewCommentDialog dlg = new CViewCommentDialog(parent, "Save", view.getName(), view.getConfiguration().getDescription());
    dlg.setVisible(true);
    if (dlg.wasCancelled()) {
        return new CSaveProgress(true);
    }
    final String newName = dlg.getName();
    final String newDescription = dlg.getComment();
    final CSaveProgress progress = new CSaveProgress(false);
    new Thread() {

        @Override
        public void run() {
            final CViewSaverOperation operation = new CViewSaverOperation(String.format("Saving view '%s'", newName));
            try {
                if (graph.saveAs(container, newName, newDescription) == null) {
                    throw new CouldntSaveDataException("Failure saving the view.");
                }
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00121: " + "Could not save graph";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The view '%s' could not be saved.", newName), new String[] { "There was a problem with the database connection." }, new String[] { "The new view was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            } finally {
                operation.stop();
                progress.setDone();
            }
        }
    }.start();
    return progress;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CViewCommentDialog(com.google.security.zynamics.binnavi.Gui.GraphWindows.CViewCommentDialog) CEndlessHelperThread(com.google.security.zynamics.zylib.gui.ProgressDialogs.CEndlessHelperThread)

Example 3 with CViewCommentDialog

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

the class CGraphDialogs method showViewDescriptionDialog.

/**
   * Shows the user the dialog where he can modify the description string of the view.
   *
   * @param parent Parent window of the dialog.
   * @param view View whose comment can be edited.
   */
public static void showViewDescriptionDialog(final JFrame parent, final INaviView view) {
    final CViewCommentDialog dlg = new CViewCommentDialog(parent, "Change view description", view.getName(), view.getConfiguration().getDescription());
    dlg.setVisible(true);
    if (!dlg.wasCancelled()) {
        try {
            view.getConfiguration().setName(dlg.getName());
            view.getConfiguration().setDescription(dlg.getComment());
        } catch (final Exception e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00114: " + "View description could not be changed";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The view description of view '%s' could not be changed.", view.getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The view was not updated and the new view description is lost." });
            NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
        }
    }
}
Also used : CViewCommentDialog(com.google.security.zynamics.binnavi.Gui.GraphWindows.CViewCommentDialog)

Aggregations

CViewCommentDialog (com.google.security.zynamics.binnavi.Gui.GraphWindows.CViewCommentDialog)3 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)1 CEndlessHelperThread (com.google.security.zynamics.zylib.gui.ProgressDialogs.CEndlessHelperThread)1