Search in sources :

Example 31 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTagSortingHandler method drop.

@Override
public void drop(final DNDTree target, final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
    final ITagManager tagManager = ((CTagTreeNode) parentNode).getTagManager();
    final ITreeNode<CTag> parentNodeNode = ((CTagTreeNode) parentNode).getTag();
    final ITreeNode<CTag> draggedNodeNode = ((CTagTreeNode) draggedNode).getTag();
    try {
        tagManager.moveTag(parentNodeNode, draggedNodeNode);
    } catch (final CouldntSaveDataException e) {
        // TODO: Improve this
        CUtilityFunctions.logException(e);
    }
}
Also used : ITagManager(com.google.security.zynamics.binnavi.Tagging.ITagManager) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTagTreeNode)

Example 32 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class AppendMemberAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final MemberDialog dlg = MemberDialog.createBuildNewMemberDialog(owner, typeManager);
    GuiHelper.centerChildToParent(owner, dlg, true);
    dlg.setVisible(true);
    if (!dlg.wasCanceled()) {
        final String name = dlg.getMemberName();
        final BaseType baseType = dlg.getBaseType();
        try {
            final TypeMember member = typeManager.appendMember(selectedType, baseType, name);
            if (member == null) {
                CMessageBox.showInformation(owner, "Unable to append member since that would create a recursive type definition.");
            }
        } catch (final CouldntSaveDataException exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : BaseType(com.google.security.zynamics.binnavi.disassembly.types.BaseType) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) MemberDialog(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.MemberDialog)

Example 33 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class EditMemberAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final MemberDialog dialog = MemberDialog.createEditMemberDialog(owner, typeManager, selectedMember);
    GuiHelper.centerChildToParent(owner, dialog, true);
    dialog.setVisible(true);
    if (!dialog.wasCanceled()) {
        try {
            switch(selectedMember.getParentType().getCategory()) {
                case STRUCT:
                    typeManager.updateStructureMember(selectedMember, dialog.getBaseType(), dialog.getMemberName(), selectedMember.getBitOffset().get());
                    break;
                case UNION:
                    typeManager.updateUnionMember(selectedMember, dialog.getBaseType(), dialog.getMemberName());
                    break;
                case FUNCTION_PROTOTYPE:
                    typeManager.updateFunctionPrototypeMember(selectedMember, dialog.getBaseType(), dialog.getMemberName(), selectedMember.getArgumentIndex().get());
                default:
                    throw new IllegalStateException("Error: can not edit a member of a non compound type.");
            }
        } catch (final CouldntSaveDataException exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) MemberDialog(com.google.security.zynamics.binnavi.Gui.GraphWindows.types.MemberDialog)

Example 34 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CGraphSaver method save.

/**
   * Stores a graph to the database.
   *
   * @param parent Parent window used to display dialogs.
   * @param graph Graph to be written to the database.
   *
   * @return Information about the save progress.
   */
public static CSaveProgress save(final Window parent, final ZyGraph graph) {
    Preconditions.checkNotNull(parent, "IE01752: Parent argument can not be null");
    Preconditions.checkNotNull(graph, "IE01753: Graph argument can not be null");
    final CSaveProgress progress = new CSaveProgress(false);
    new Thread() {

        @Override
        public void run() {
            final CViewSaverOperation operation = new CViewSaverOperation(String.format("Saving view '%s'", graph.getRawView().getName()));
            try {
                if (!graph.save()) {
                    throw new CouldntSaveDataException("Something went wrong saving");
                }
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00120: " + "Could not save graph";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The function '%s' could not be saved.", graph.getRawView().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The graph remains unsaved." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            } finally {
                operation.stop();
                progress.setDone();
            }
        }
    }.start();
    return progress;
}
Also used : CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CEndlessHelperThread(com.google.security.zynamics.zylib.gui.ProgressDialogs.CEndlessHelperThread)

Example 35 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTraceCombinationFunctions method differenceTraces.

/**
   * Creates a new trace that contains exactly those events that appear in the first trace but not
   * in the second trace.
   *
   * @param parent Parent window used for dialogs.
   * @param provider Creates the new trace.
   * @param trace1 The first input trace.
   * @param trace2 The second input trace.
   */
public static void differenceTraces(final JFrame parent, final ITraceListProvider provider, final TraceList trace1, final TraceList trace2) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
                operation.getProgressPanel().setMaximum(3);
                operation.getProgressPanel().setText(String.format("Creating trace difference between '%s' and '%s'", trace1.getName(), trace2.getName()));
                final TraceList newTrace = provider.createTrace("Combined Trace", String.format("%s - %s", trace1.getName(), trace2.getName()));
                operation.getProgressPanel().next();
                createCombinedTrace(newTrace, Lists.newArrayList(trace1, trace2), getDifferenceAddresses(trace1, trace2));
                operation.getProgressPanel().next();
                newTrace.save();
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException e) {
                CUtilityFunctions.logException(e);
                final String innerMessage = "E00191: " + "Could not combine debug traces";
                final String innerDescription = CUtilityFunctions.createDescription("The selected traces could not be combined into a larger trace.", new String[] { "There was a problem with the database connection." }, new String[] { "The trace list was not created. You could try to combine the lists again once the connection problem was resolved." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList)

Aggregations

CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)133 SQLException (java.sql.SQLException)71 PreparedStatement (java.sql.PreparedStatement)38 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)35 CallableStatement (java.sql.CallableStatement)20 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)17 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)13 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)10 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)10 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)9 ArrayList (java.util.ArrayList)9 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)8 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 BigInteger (java.math.BigInteger)8 Connection (java.sql.Connection)8 ResultSet (java.sql.ResultSet)8 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)7 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)6 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)5