Search in sources :

Example 1 with LoadCancelledException

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

the class ZyGraphBuilder method convert.

/**
   * Converts a view to a Graph2D object.
   *
   * @param nodes Nodes to convert.
   * @param edges Edges to convert.
   * @param graphSettings Graph settings used to build the graph.
   * @param adjustColors True, to initialize the colors of the nodes. False, otherwise.
   *
   * @return The created Graph2D object.
   * @throws LoadCancelledException Thrown if loading the graph was cancelled.
   */
public Graph2D convert(final Collection<INaviViewNode> nodes, final Collection<INaviEdge> edges, final ZyGraphViewSettings graphSettings, final boolean adjustColors) throws LoadCancelledException {
    Preconditions.checkNotNull(nodes, "IE00905: View can not be null");
    Preconditions.checkNotNull(edges, "IE00906: Edges argument can not be null");
    if (!m_loadReporter.report(GraphBuilderEvents.Started)) {
        throw new LoadCancelledException();
    }
    m_loadReporter.start();
    final Graph2D graph2D = new Graph2D();
    final HierarchyManager hierarchyManager = new HierarchyManager(graph2D);
    graph2D.setHierarchyManager(hierarchyManager);
    hierarchyManager.addHierarchyListener(new GroupNodeRealizer.StateChangeListener());
    checkCancellation(GraphBuilderEvents.InitializedGraph);
    // Keep track of all connections between view nodes and yfiles nodes
    final HashMap<INaviViewNode, Node> rawNodeToNodeMap = new HashMap<INaviViewNode, Node>();
    // To convert the view into a Graph2D object, it is necessary to convert every node
    // and every edge from the view into the corresponding yfiles objects.
    convertNodes(nodes, graph2D, rawNodeToNodeMap, graphSettings);
    checkCancellation(GraphBuilderEvents.ConvertedNodes);
    convertEdges(edges, graph2D, rawNodeToNodeMap, adjustColors);
    checkCancellation(GraphBuilderEvents.ConvertedEdges);
    setupGroupNodes(nodes, graph2D, rawNodeToNodeMap);
    checkCancellation(GraphBuilderEvents.CreatedGroupNodes);
    checkCancellation(GraphBuilderEvents.Finished);
    return graph2D;
}
Also used : GroupNodeRealizer(y.view.hierarchy.GroupNodeRealizer) HierarchyManager(y.view.hierarchy.HierarchyManager) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) Graph2D(y.view.Graph2D)

Example 2 with LoadCancelledException

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

the class CAddressSpaceFunctions method loadAddressSpaces.

/**
   * Loads one or more address spaces.
   * 
   * @param projectTree Project tree of the main window.
   * @param addressSpaces The address spaces to load.
   */
public static void loadAddressSpaces(final JTree projectTree, final INaviAddressSpace[] addressSpaces) {
    new Thread() {

        @Override
        public void run() {
            final CDefaultProgressOperation operation = new CDefaultProgressOperation("Loading address spaces", false, true);
            operation.getProgressPanel().setMaximum(addressSpaces.length);
            for (final INaviAddressSpace addressSpace : addressSpaces) {
                operation.getProgressPanel().setText("Loading address spaces" + ": '" + addressSpace.getConfiguration().getName() + "'");
                try {
                    addressSpace.load();
                    new SwingInvoker() {

                        @Override
                        protected void operation() {
                            CNodeExpander.expandNode(projectTree, addressSpace);
                        }
                    }.invokeLater();
                } catch (final CouldntLoadDataException exception) {
                    CUtilityFunctions.logException(exception);
                    final String message = "E00109: " + "Address space could not be loaded";
                    final String description = CUtilityFunctions.createDescription(String.format("The address space '%s' could not be loaded. Try loading the address space again. If the problem persists, disconnect from and reconnect to the database, restart com.google.security.zynamics.binnavi, or contact the BinNavi support.", addressSpace.getConfiguration().getName()), new String[] { "Database connection problems." }, new String[] { "The address space was not loaded." });
                    NaviErrorDialog.show(SwingUtilities.getWindowAncestor(projectTree), message, description, exception);
                } catch (final LoadCancelledException e) {
                // Do nothing
                } finally {
                    operation.getProgressPanel().next();
                }
            }
            operation.stop();
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) SwingInvoker(com.google.security.zynamics.zylib.gui.SwingInvoker) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) INaviAddressSpace(com.google.security.zynamics.binnavi.disassembly.INaviAddressSpace)

Example 3 with LoadCancelledException

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

the class CProjectContent method createView.

/**
   * Creates a new empty view with the given name and description in the project. The new view is
   * not stored in the database until INaviView::save is called.
   * 
   * @param name The name of the new view.
   * @param description The description of the new view.
   * 
   * @return The new view that was created in the project.
   */
public INaviView createView(final String name, final String description) {
    final Date date = new Date();
    final CProjectViewGenerator generator = new CProjectViewGenerator(m_provider, m_project);
    final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
    try {
        view.load();
    } catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
        // This can not happen; new views with ID -1 do not access the database
        // when they are loaded.
        CUtilityFunctions.logException(e);
    }
    addView(view);
    return view;
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CProjectViewGenerator(com.google.security.zynamics.binnavi.Database.CProjectViewGenerator) Date(java.util.Date)

Example 4 with LoadCancelledException

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

the class CViewContainer method createView.

/**
   * Creates a new empty view in the module.
   *
   * @param name The name of the new view.
   * @param description The description of the new view.
   *
   * @return The new view.
   */
public CView createView(final String name, final String description) {
    Preconditions.checkNotNull(name, "IE00164: Name argument can not be null");
    Preconditions.checkNotNull(description, "IE00165: Name description can not be null");
    final Date date = new Date();
    final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, m_module);
    final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
    try {
        view.load();
    } catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
        CUtilityFunctions.logException(e);
    }
    addView(view);
    return view;
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) CModuleViewGenerator(com.google.security.zynamics.binnavi.Database.CModuleViewGenerator) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) Date(java.util.Date)

Example 5 with LoadCancelledException

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

the class PostgreSQLTypeInstanceFunctionsTests method setUp.

@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, CouldntSaveDataException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, LoadCancelledException, FileReadException {
    final String[] parts = CConfigLoader.loadPostgreSQL();
    database = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
    database.connect();
    database.load();
    try {
        final Field privateProviderField = CDatabase.class.getDeclaredField("provider");
        privateProviderField.setAccessible(true);
        provider = (SQLProvider) privateProviderField.get(database);
    } catch (final Exception exception) {
        throw new RuntimeException(exception);
    }
    provider.createDebuggerTemplate("Test Debugger", "localhost", 2222);
    final CProject project = provider.createProject("Test Project");
    provider.createAddressSpace(project, "Test Address Space");
    ConfigManager.instance().read();
    module = database.getContent().getModules().get(0);
}
Also used : Field(java.lang.reflect.Field) CProject(com.google.security.zynamics.binnavi.disassembly.CProject) CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) FileReadException(com.google.security.zynamics.binnavi.config.FileReadException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) IOException(java.io.IOException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CPartialLoadException(com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException) Before(org.junit.Before)

Aggregations

LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)19 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)18 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 CPartialLoadException (com.google.security.zynamics.binnavi.Database.Exceptions.CPartialLoadException)6 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)5 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)4 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)4 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)4 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)4 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)4 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)4 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)3 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)3 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 ArrayList (java.util.ArrayList)3 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)2