Search in sources :

Example 16 with CDefaultProgressOperation

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

the class CProjectFunctions method addAddressSpace.

/**
   * Adds a new address space with a default name to a given project.
   * 
   * @param parent Parent window used for dialogs.
   * @param project The project where the new address space is added.
   * @param updater Updates the project tree after the execution is complete.
   */
public static void addAddressSpace(final Window parent, final INaviProject project, final INodeSelectionUpdater updater) {
    new Thread() {

        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
            operation.getProgressPanel().setMaximum(2);
            try {
                operation.getProgressPanel().setText("Creating new address space");
                operation.getProgressPanel().next();
                final CAddressSpace addressSpace = project.getContent().createAddressSpace("New Address Space");
                operation.getProgressPanel().setText("Loading new address space");
                addressSpace.load();
                operation.getProgressPanel().next();
                operation.stop();
                updater.setObject(addressSpace);
                updater.update();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00136: " + "Could not add address space";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("It was not possible to add a new address space to the project '%s'.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The address space was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            } catch (final CouldntLoadDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00137: " + "Could not load the new address space";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The new address space in project '%s' was created but it could not be loaded.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The address space was created but not loaded." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            } catch (final LoadCancelledException e) {
            // Do nothing
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)

Example 17 with CDefaultProgressOperation

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

the class CProjectFunctions method createProject.

/**
   * Creates a new project.
   * 
   * @param parent Parent window used for dialogs.
   * @param database Database where the project is created.
   * @param updater Responsible for updating the project tree after the project was created.
   */
public static void createProject(final JFrame parent, final IDatabase database, final INodeSelectionUpdater updater) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, true);
                operation.getProgressPanel().setMaximum(3);
                operation.getProgressPanel().setText("Creating new project");
                final INaviProject newProject = database.getContent().addProject("New Project");
                operation.getProgressPanel().next();
                try {
                    newProject.load();
                } catch (final LoadCancelledException e) {
                // Do nothing
                }
                operation.getProgressPanel().next();
                createDefaultAddressSpace(parent, newProject);
                updater.setObject(newProject);
                updater.update();
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00140: " + "New project could not be created";
                final String innerDescription = CUtilityFunctions.createDescription("It was not possible to create a new project in the selected database.", new String[] { "There was a problem with the database connection." }, new String[] { "No new project was created in the selected database." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            } catch (final CouldntLoadDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00141: " + "New project could not be loaded";
                final String innerDescription = CUtilityFunctions.createDescription("The new project could not be loaded.", new String[] { "There was a problem with the database connection." }, new String[] { "The new project was created but it could not be loaded." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Example 18 with CDefaultProgressOperation

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

the class CTagFunctions method insertTag.

/**
   * Inserts a tag into the tag hierarchy. The new tag is used as the parent tag of the child tags
   * of the old parent tag.
   * 
   * @param parent Parent window used for dialogs.
   * @param tagManager The tag manager that manages the old parent tag and the new tag.
   * @param parentTag The parent tag of the new tag.
   * @param name The name of the new tag.
   */
public static void insertTag(final JFrame parent, final ITagManager tagManager, final TreeNode<CTag> parentTag, final String name) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Inserting new tag" + ": " + name);
                tagManager.insertTag(parentTag, name);
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00147: " + "Could not insert tag";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("BinNavi could not insert a new tag with the name '%s'.", name), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 19 with CDefaultProgressOperation

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

the class CTagFunctions method addTag.

/**
   * Adds a new tag to the database.
   * 
   * @param parent Parent window used for dialogs.
   * @param tagManager The tag manager where the tag is stored.
   * @param parentTag The parent tag of the tag. This parameter can be null for root tags.
   * @param name The name of the tag.
   */
public static void addTag(final JFrame parent, final ITagManager tagManager, final ITreeNode<CTag> parentTag, final String name) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Creating new tag" + ": " + name);
                tagManager.addTag(parentTag, name);
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00144: " + "Could not create tag";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The new tag '%s' could not be created.", name), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 20 with CDefaultProgressOperation

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

the class CTagFunctions method deleteTag.

/**
   * Deletes a tag from the database. Child tags of the tag are connected to the parent tag of the
   * tag.
   * 
   * @param parent Parent window used for dialogs.
   * @param tagManager The tag manager that manages the tag.
   * @param tag The tag to be deleted.
   */
public static void deleteTag(final JFrame parent, final ITagManager tagManager, final TreeNode<CTag> tag) {
    if (CMessageBox.showYesNoQuestion(parent, String.format("Do you really want to delete the tag '%s' from the database?", tag.getObject().getName())) == JOptionPane.YES_OPTION) {
        new Thread() {

            @Override
            public void run() {
                try {
                    final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                    operation.getProgressPanel().setMaximum(1);
                    operation.getProgressPanel().setText("Deleting tag" + ": " + tag.getObject().getName());
                    tagManager.deleteTag(tag);
                    operation.getProgressPanel().next();
                    operation.stop();
                } catch (final CouldntDeleteException e) {
                    CUtilityFunctions.logException(e);
                    final String innerMessage = "E00145: " + "Could not delete tag";
                    final String innerDescription = CUtilityFunctions.createDescription(String.format("The tag '%s' could not be deleted.", tag.getObject().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not deleted and can still be used." });
                    NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
                }
            }
        }.start();
    }
}
Also used : CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)

Aggregations

CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)21 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)10 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)8 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)5 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)4 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)4 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)2 INaviAddressSpace (com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)2 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)1 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)1 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)1 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)1 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)1 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)1 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)1 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)1 SwingInvoker (com.google.security.zynamics.zylib.gui.SwingInvoker)1 ArrayList (java.util.ArrayList)1