Search in sources :

Example 41 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class CNameListGenerators method getNameList.

/**
   * Generates a name list from the names of the given projects.
   * 
   * @param projects The projects that provide the names.
   * 
   * @return The generated name list.
   */
public static String getNameList(final INaviProject[] projects) {
    int count = 0;
    final StringBuilder list = new StringBuilder();
    for (final INaviProject project : projects) {
        list.append("- ");
        list.append(project.getConfiguration().getName());
        list.append('\n');
        count++;
        if ((count == MAX_LIST_LENGTH) && (projects.length != MAX_LIST_LENGTH)) {
            list.append("\n... ");
            list.append(String.format("%d others ...", projects.length - count));
            break;
        }
    }
    return list.toString();
}
Also used : INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject)

Example 42 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject 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 43 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class CProjectsModel method setValueAt.

@Override
public void setValueAt(final Object value, final int row, final int col) {
    if ((col != NAME_COLUMN) && (col != DESCRIPTION_COLUMN)) {
        throw new IllegalStateException("IE01172: Column can not be edited");
    }
    final INaviProject project = getProjects().get(row);
    if (col == NAME_COLUMN) {
        try {
            project.getConfiguration().setName((String) value);
        } catch (final CouldntSaveDataException e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00174: " + "Could not save project name";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The new name of the project '%s' could not be saved.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The project keeps its old name." });
            NaviErrorDialog.show(null, innerMessage, innerDescription, e);
        }
    } else if (col == DESCRIPTION_COLUMN) {
        try {
            project.getConfiguration().setDescription((String) value);
        } catch (final CouldntSaveDataException e) {
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00175: " + "Could not save project description";
            final String innerDescription = CUtilityFunctions.createDescription(String.format("The new description of the project '%s' could not be saved.", project.getConfiguration().getName()), new String[] { "There was a problem with the database connection." }, new String[] { "The project keeps its old description." });
            NaviErrorDialog.show(null, innerMessage, innerDescription, e);
        }
    }
}
Also used : INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 44 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class CProjectNodeMenuBuilder method getPluginProjects.

/**
   * Returns the API project objects for the projects for which the menu was built.
   * 
   * @return The API project objects.
   */
private List<Project> getPluginProjects() {
    final DatabaseManager manager = PluginInterface.instance().getDatabaseManager();
    for (final Database database : manager) {
        if (database.getNative() == m_database) {
            final List<Project> allProjects = database.getProjects();
            final List<Project> menuProjects = new ArrayList<Project>();
            for (final INaviProject project : m_projects) {
                menuProjects.add(ObjectFinders.getObject(project, allProjects));
            }
            return menuProjects;
        }
    }
    throw new IllegalStateException("IE01168: Unknown database");
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) CProject(com.google.security.zynamics.binnavi.disassembly.CProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) DatabaseManager(com.google.security.zynamics.binnavi.API.disassembly.DatabaseManager) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) ArrayList(java.util.ArrayList)

Example 45 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class CProjectNodeMenuBuilder method createMenu.

@Override
protected void createMenu(final JComponent menu) {
    if ((m_projects.length == 1) && (m_addAddressSpaceAction == null)) {
        // We delay the creation of the m_addAddressSpaceAction object because we need to have
        // getSelectionUpdater working.
        final INaviProject singleProject = m_projects[0];
        m_addAddressSpaceAction = CActionProxy.proxy(new CAddAddressSpaceAction(getProjectTree(), singleProject, getSelectionUpdater()));
        updateActions(singleProject);
    }
    final boolean isSingleSelection = m_projects.length == 1;
    if (canOpen()) {
        menu.add(new JMenuItem(m_loadProjectAction));
        menu.add(new JSeparator());
    }
    if (isSingleSelection) {
        // We can not search in more than one project at a time, and only if the project
        // is already loaded.
        menu.add(new JMenuItem(m_searchViewAction));
        menu.add(new JSeparator());
        // We do not allow the user to add address spaces to more than one
        // project at a time. And the project must be loaded too.
        menu.add(new JMenuItem(m_addAddressSpaceAction));
        menu.add(new JSeparator());
        menu.add(new JMenuItem(m_forwardAction));
        menu.add(new JSeparator());
    }
    menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteProjectAction(getParent(), m_database, m_projects, getParentUpdater()))));
    if (m_table != null) {
        menu.add(new JSeparator());
        menu.add(new JMenuItem(CActionProxy.proxy(new CSearchTableAction(getParent(), m_table))));
        menu.add(new JMenuItem(CActionProxy.proxy(new CopySelectionAction(m_table))));
    }
    addPluginMenus(menu);
}
Also used : INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) CopySelectionAction(com.google.security.zynamics.zylib.gui.tables.CopySelectionAction) CAddAddressSpaceAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CAddAddressSpaceAction) CDeleteProjectAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CDeleteProjectAction) JMenuItem(javax.swing.JMenuItem) CSearchTableAction(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Actions.CSearchTableAction) JSeparator(javax.swing.JSeparator)

Aggregations

INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)45 Test (org.junit.Test)31 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)27 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)6 ViewNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)4 PostgreSQLViewNotificationParser (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser)4 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 MockProject (com.google.security.zynamics.binnavi.disassembly.MockProject)4 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)3 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)3 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)2 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)2 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)2