use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphModel in project binnavi by google.
the class PluginInterface method show.
/**
* Shows a view in a given graph window.
*
* @param graphWindow The window in which the view is shown. This argument can be null.
* @param view The view to show.
* @param container Context in which the view is opened.
*
* @return Describes the open view.
*/
private View2D show(final CGraphWindow graphWindow, final View view, final IViewContainer container) {
for (final CGraphWindow window : CWindowManager.instance()) {
for (final IGraphPanel panel : window) {
if (panel.getModel().getGraph().getRawView() == view.getNative()) {
return panel.getModel().getView2D();
}
}
}
final WindowWaiter waiter = new WindowWaiter(view.getNative());
CWindowManager.instance().addListener(waiter);
final List<CGraphWindow> openBefore = CWindowManager.instance().getOpenWindows();
for (final CGraphWindow window : openBefore) {
window.addListener(waiter);
}
CViewOpener.showView(mainWindow.getFrame(), container, view.getNative(), graphWindow);
while (waiter.getModel() == null) {
try {
Thread.sleep(1000);
} catch (final InterruptedException exception) {
CUtilityFunctions.logException(exception);
// restore the interrupted status of the thread.
// http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
java.lang.Thread.currentThread().interrupt();
}
}
final CGraphModel model = waiter.getModel();
CWindowManager.instance().removeListener(waiter);
for (final CGraphWindow window : openBefore) {
window.removeListener(waiter);
}
return model.getView2D();
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphModel in project binnavi by google.
the class CViewLoader method load.
/**
* Loads a view.
*
* @throws LoadCancelledException Thrown if the user canceled the load operation.
* @throws CPartialLoadException Thrown if not all required modules are loaded.
* @throws CouldntLoadDataException Thrown if the view data could not be loaded from the database.
*/
public void load() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
if (!view.isLoaded()) {
view.load();
}
// Convert the data from the raw view into a graph that can be displayed.
final ZyGraph graph = container instanceof CModuleContainer ? CGraphBuilder.buildDnDGraph(view, container.getModules().get(0).getTypeManager()) : CGraphBuilder.buildGraph(view);
CRegisterHotKeys.register(graph);
if (window == null) {
// If the parent window of the graph is null, a new graph window is created.
final CGraphWindow navi = new CGraphWindow();
final CGraphModel model = new CGraphModel(navi, container.getDatabase(), container, graph);
CNodeUpdaterInitializer.addUpdaters(model);
final CGraphPanel panel = new CGraphPanel(model);
navi.addGraph(panel);
CWindowManager.instance().register(navi);
// Part of the workaround you can find in WorkaroundListener in CGraphWindow
navi.setSize(Toolkit.getDefaultToolkit().getScreenSize());
navi.setVisible(true);
GuiHelper.applyWindowFix(navi);
navi.setExtendedState(Frame.MAXIMIZED_BOTH);
workArounds(panel);
graphModel = model;
} else {
final CGraphModel model = new CGraphModel(window, container.getDatabase(), container, graph);
CNodeUpdaterInitializer.addUpdaters(model);
final CGraphPanel panel = new CGraphPanel(model);
// If a parent window is given, the graph is added to this window.
window.addGraph(panel);
workArounds(panel);
window.toFront();
graphModel = model;
}
}
Aggregations