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;
}
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();
}
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;
}
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;
}
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);
}
Aggregations