use of com.google.security.zynamics.binnavi.ZyGraph.INaviGraphListener in project binnavi by google.
the class ZyGraph method saveAs.
/**
* Creates a copy of the current native view and transfers the copied native view into the graph
* object. That means that the graph object changes its underlying raw view when this function is
* called.
*
* @param container The view container where the view is copied to.
* @param name The new name of the raw view.
* @param description The new description of the raw view.
*
* @return The new raw view.
*
* @throws CouldntSaveDataException Thrown if the view could not be saved.
*/
public INaviView saveAs(final IViewContainer container, final String name, final String description) throws CouldntSaveDataException {
Preconditions.checkNotNull(container, "IE00871: Container argument can not be null");
Preconditions.checkNotNull(name, "IE00872: Name argument can not be null");
Preconditions.checkNotNull(description, "IE00899: Description argument can not be null");
final INaviView oldView = m_rawView;
final INaviView newView = container.createView(name, description);
CViewInserter.insertView(oldView, newView);
final List<INaviViewNode> oldNodes = oldView.getGraph().getNodes();
final List<INaviViewNode> newNodes = newView.getGraph().getNodes();
for (int i = 0; i < oldNodes.size(); i++) {
final INaviViewNode newNode = newNodes.get(i);
final NaviNode oldNode = getMappings().getNode(oldNodes.get(i));
getMappings().setNode(newNode, oldNode);
oldNode.setRawNode(newNode);
for (final INaviGraphListener listener : m_listeners) {
try {
listener.changedModel(this, oldNode);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
}
final List<INaviEdge> oldEdges = oldView.getGraph().getEdges();
final List<INaviEdge> newEdges = newView.getGraph().getEdges();
for (int i = 0; i < oldEdges.size(); i++) {
final INaviEdge newEdge = newEdges.get(i);
final NaviEdge oldEdge = getMappings().getEdge(oldEdges.get(i));
assert oldEdge != null;
getMappings().setEdge(newEdge, oldEdge);
final ZyEdgeRealizer<NaviEdge> realizer = oldEdge.getRealizer();
realizer.setUpdater(new CEdgeUpdater(newEdge));
oldEdge.setRawEdge(newEdge);
}
removeListeners();
newView.save();
CSettingsFunctions.saveSettings(newView, getView(), m_settings);
m_rawView = newView;
initializeListeners();
m_synchronizer.reset();
for (final INaviGraphListener listener : m_listeners) {
// ESCA-JAVA0166: Catch Exception here because we are calling a listener function.
try {
listener.changedView(oldView, newView);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
oldView.close();
return m_rawView;
}
Aggregations