use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CEventTableMenu method addOpenFunction.
/**
* Adds a menu item to open the selected trace.
*
* @param parent Parent window of the menu.
* @param traces The selected traces.
*/
private void addOpenFunction(final Window parent, final List<ITraceEvent> traces) {
if (traces.size() == 1) {
final ITraceEvent trace = traces.get(0);
final INaviModule module = trace.getOffset().getModule();
if (module.isLoaded()) {
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(trace.getOffset().getAddress().getAddress());
if (function != null) {
final IViewContainer container = graphModel.getViewContainer();
final INaviView view = container.getView(function);
if (view != null) {
add(new JMenuItem(CActionProxy.proxy(new COpenInLastWindowAction(parent, container, new INaviView[] { view }))));
addSeparator();
}
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView 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;
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CViewsToTagHandler method drop.
@SuppressWarnings("unchecked")
@Override
public void drop(final DefaultMutableTreeNode parentNode, final Object data) {
final List<INaviView> views = (List<INaviView>) data;
final CTag tag = ((CTagNode) parentNode).getObject().getObject();
for (final INaviView view : views) {
CViewFunctions.tagView(m_parent, view, tag);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CViewsToTagHandler method canHandle.
@SuppressWarnings("unchecked")
@Override
public boolean canHandle(final DefaultMutableTreeNode parentNode, final Object data) {
if (parentNode instanceof CTagNode) {
final List<INaviView> views = (List<INaviView>) data;
final CTag tag = ((CTagNode) parentNode).getObject().getObject();
for (final INaviView view : views) {
if (!view.getConfiguration().isTagged(tag) && view.inSameDatabase(tag)) {
return true;
}
}
return false;
}
return false;
}
use of com.google.security.zynamics.binnavi.disassembly.views.INaviView in project binnavi by google.
the class CNameListGenerators method getNameList.
/**
* Generates a name list from the names of the given views.
*
* @param views The views that provide the names.
*
* @return The generated name list.
*/
public static String getNameList(final INaviView[] views) {
int count = 0;
final StringBuilder list = new StringBuilder();
for (final INaviView view : views) {
list.append("- ");
list.append(view.getName());
list.append('\n');
count++;
if ((count == MAX_LIST_LENGTH) && (views.length != MAX_LIST_LENGTH)) {
list.append("\n... ");
list.append(String.format("%d others ...", views.length - count));
break;
}
}
return list.toString();
}
Aggregations