IGraphView view = JGraphView.this;
IGraphView subgraph = new JGraphView(JGraphView.this, view.getSelectionSubGraph());
if (!isSelected())
return;
UIRequestOpenSubGraph r = new UIRequestOpenSubGraph(subgraph, JGraphView.this.requestOwner);
JGraphView.this.userInterface.addRequest(r);
}
});
this.popup.add(openSubGraphMenuItem);
this.connectorPopup = new JMenu("go to notepad");
this.popup.add(connectorPopup);
graphComponent.getGraphControl().addMouseListener(new MouseAdapter() {
private void popupTriger(MouseEvent e) {
if (e.isPopupTrigger()) {
openSubGraphMenuItem.setEnabled(JGraphView.this.isSelected());
mxCell cell = (mxCell) graphComponent.getCellAt(e.getX(), e.getY());
if (cell != null) {
connectorPopup.removeAll();
for (final Connection con : connections.values()) {
Set<StorableAttribute> attributes = null;
if (cell.isVertex())
attributes = vertexAttributes.get(cell).keySet();
else if (cell.isEdge()) {
attributes = edgeAttributes.get(cell).keySet();
} else
break;
for (final StorableAttribute attr : attributes) {
if (attr.getName().equals(con.attributeName)) {
JMenuItem item = new JMenuItem(con.connectName);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
UIRequestGoToInAIF r = new UIRequestGoToInAIF(con.connectId, attr.getValue(),
JGraphView.this.requestOwner);
JGraphView.this.userInterface.addRequest(r);
}
});
connectorPopup.add(item);
}
}
}
connectorPopup.setEnabled(connectorPopup.getItemCount() > 0);
} else {
connectorPopup.setEnabled(false);
}
JGraphView.this.popup.show(e.getComponent(), e.getX(), e.getY());
}
SwingUtilities.updateComponentTreeUI(popup);
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.getClickCount() > 1) {
mxCell cell = (mxCell) graphComponent.getCellAt(e.getX(), e.getY());
if (cell != null && subgraphsid.containsKey(cell)) {
if (JGraphView.this.model != null) {
StorableSubGraph ssg = JGraphView.this.model.getStorableSubGraph(subgraphsid.get(cell).intValue());
IGraphView view = new JGraphView(ssg, JGraphView.this.userInterface);
UIRequestOpenSubGraph r = new UIRequestOpenSubGraph(view, JGraphView.this.requestOwner);
JGraphView.this.userInterface.addRequest(r);
} else {
VisualGraph.log.printError("[" + this.getClass().getName()
+ ".JGraphView.mouseReleased] [BAD] Can't get storable subgraph, because model = null.");
}