use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.
the class ConstructTemplateAction method getSessionWorkbench.
private SessionEditorWorkbench getSessionWorkbench() {
if (sessionWorkbench == null) {
SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
if (sessionEditor == null) {
DesktopController.getInstance().newSessionEditor();
sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
sessionEditor = (SessionEditor) sessionEditorRef;
}
this.sessionWorkbench = sessionEditor.getSessionWorkbench();
}
return sessionWorkbench;
}
use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.
the class ConstructTemplateAction method selectSubgraph.
private static void selectSubgraph(List<Node> nodes) {
SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
for (Node node : nodes) {
sessionWorkbench.selectNode(node);
}
Set<Edge> edges = sessionWorkbench.getGraph().getEdges();
for (Edge edge : edges) {
Node node1 = edge.getNode1();
Node node2 = edge.getNode2();
if (nodes.contains(node1) && nodes.contains(node2)) {
sessionWorkbench.selectEdge(edge);
}
}
sessionWorkbench.scrollNodesToVisible(nodes);
}
use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.
the class ConstructTemplateAction method searchFromLoadedOrSimulatedData.
private void searchFromLoadedOrSimulatedData(int leftX) {
SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
sessionWorkbench.deselectAll();
List<Node> nodes = new LinkedList<>();
String data = nextName("Data");
String search = nextName("Search");
nodes.add(addNode("Data", data, leftX, 100));
nodes.add(addNode("Search", search, 125 + leftX, 100));
addEdge(data, search);
selectSubgraph(nodes);
}
use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.
the class TetradMenuBar method buildFileMenu.
// ================================ Private Method ===============================//
private void buildFileMenu(final JMenu fileMenu) {
// =======================FILE MENU=========================//
// These have to be wrapped in JMenuItems to get the keyboard
// accelerators to work correctly.
JMenuItem newSession = new JMenuItem(new NewSessionAction());
JMenuItem loadSession = new JMenuItem(new LoadSessionAction());
JMenuItem closeSession = new JMenuItem(new CloseSessionAction());
JMenuItem saveSession = new JMenuItem(new SaveSessionAction());
fileMenu.add(newSession);
fileMenu.add(loadSession);
fileMenu.add(closeSession);
// fileMenu.addSeparator();
// fileMenu.add(templateMenu);
//
// //=======================EXAMPLES MENU=========================//
// // Build a LoadTemplateAction for each file name in
// // this.exampleFiles.
// String[] templateNames = ConstructTemplateAction.getTemplateNames();
// for (String templateName : templateNames) {
// if ("--separator--".equals(templateName)) {
// fileMenu.addSeparator();
// } else {
// ConstructTemplateAction action =
// new ConstructTemplateAction(templateName);
// fileMenu.add(action);
// }
// }
fileMenu.addSeparator();
fileMenu.add(saveSession);
fileMenu.add(new SaveSessionAsAction());
fileMenu.addSeparator();
fileMenu.add(new SessionVersionAction());
fileMenu.addSeparator();
// fileMenu.add(new SaveScreenshot(desktop, true, "Save Screenshot..."));
final JMenuItem menuItem = new JMenuItem("Save Session Workspace Image...");
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SessionEditorIndirectRef editorRef = DesktopController.getInstance().getFrontmostSessionEditor();
SessionEditor editor = (SessionEditor) editorRef;
editor.saveSessionImage();
}
});
fileMenu.add(menuItem);
fileMenu.addSeparator();
JMenu settingsMenu = new JMenu("Settings");
JMenuItem loggingSettingMenuItem = new JMenuItem(new SetupLoggingAction());
JMenuItem hpcAccountSettingMenuItem = new JMenuItem(new HpcAccountSettingAction());
settingsMenu.add(loggingSettingMenuItem);
settingsMenu.add(hpcAccountSettingMenuItem);
fileMenu.add(settingsMenu);
fileMenu.addSeparator();
JMenuItem exit = new JMenuItem(new ExitAction());
fileMenu.add(exit);
exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
newSession.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
loadSession.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
saveSession.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
closeSession.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
}
use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.
the class ConstructTemplateAction method getSessionWrapper.
private SessionWrapper getSessionWrapper() {
SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
sessionWorkbench.deselectAll();
return sessionWorkbench.getSessionWrapper();
// if (sessionWrapper == null) {
// this.sessionWrapper = getSessionWorkbench().getSessionWrapper();
// }
// return sessionWrapper;
}
Aggregations