use of edu.cmu.tetrad.session.SessionAdapter in project tetrad by cmu-phil.
the class SessionEditorNode method addListeners.
private void addListeners(final SessionEditorNode sessionEditorNode, final SessionNodeWrapper modelNode) {
// Add a mouse listener for popups.
sessionEditorNode.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
toolTipManager.setInitialDelay(750);
sessionEditorNode.getPopup().show(sessionEditorNode, e.getX(), e.getY());
}
e.consume();
}
});
// sessionEditorNode.addMouseMotionListener(new MouseMotionAdapter() {
// public void mouseMoved(MouseEvent e) {
// Point p = e.getPoint();
// if (p.getX() > 40 && p.getY() > 40) {
// ToolTipManager toolTipManager =
// ToolTipManager.sharedInstance();
// toolTipManager.setInitialDelay(750);
// JPopupMenu popup = sessionEditorNode.getPopup();
//
// if (!popup.isShowing()) {
// popup.show(sessionEditorNode, e.getX(), e.getY());
// }
// }
// }
// });
sessionEditorNode.addComponentListener(new ComponentAdapter() {
@Override
public void componentMoved(ComponentEvent e) {
sessionEditorNode.getSimulationStudy().getSession().setSessionChanged(true);
}
});
SessionNode sessionNode = modelNode.getSessionNode();
sessionNode.addSessionListener(new SessionAdapter() {
@Override
public void modelCreated(SessionEvent sessionEvent) {
sessionEditorNode.adjustToModel();
// 5/18/02
if (sessionEditorNode.spawnedEditor() != null) {
EditorWindow editorWindow = sessionEditorNode.spawnedEditor();
editorWindow.closeDialog();
}
}
@Override
public void modelDestroyed(SessionEvent sessionEvent) {
sessionEditorNode.adjustToModel();
// the getModel editor window is closed. jdramsey 5/18/02
if (sessionEditorNode.spawnedEditor() != null) {
EditorWindow editorWindow = sessionEditorNode.spawnedEditor();
editorWindow.closeDialog();
}
}
@Override
public void modelUnclear(SessionEvent sessionEvent) {
try {
if (simulationStudy == null) {
boolean created = sessionEditorNode.createModel(false);
if (!created) {
return;
}
sessionEditorNode.adjustToModel();
}
} catch (Exception e) {
String message = e.getMessage();
message = "I could not make a model for this box, sorry. Maybe the \n" + "parents aren't right or have not been constructed yet.";
e.printStackTrace();
// throw new IllegalArgumentException("I could not make a model for this box, sorry. Maybe the \n" +
// "parents aren't right or have not been constructed yet.");
JOptionPane.showMessageDialog(sessionEditorNode, message);
}
}
});
}
Aggregations