Search in sources :

Example 11 with SessionEditorIndirectRef

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;
}
Also used : SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef)

Example 12 with SessionEditorIndirectRef

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);
}
Also used : Node(edu.cmu.tetrad.graph.Node) SessionNode(edu.cmu.tetrad.session.SessionNode) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) Edge(edu.cmu.tetrad.graph.Edge)

Example 13 with SessionEditorIndirectRef

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);
}
Also used : Node(edu.cmu.tetrad.graph.Node) SessionNode(edu.cmu.tetrad.session.SessionNode) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) LinkedList(java.util.LinkedList)

Example 14 with SessionEditorIndirectRef

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));
}
Also used : ActionEvent(java.awt.event.ActionEvent) HpcAccountSettingAction(edu.cmu.tetradapp.app.hpc.action.HpcAccountSettingAction) ActionListener(java.awt.event.ActionListener) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef)

Example 15 with SessionEditorIndirectRef

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;
}
Also used : SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef)

Aggregations

SessionEditorIndirectRef (edu.cmu.tetradapp.util.SessionEditorIndirectRef)19 Node (edu.cmu.tetrad.graph.Node)7 SessionNode (edu.cmu.tetrad.session.SessionNode)7 SessionWrapper (edu.cmu.tetradapp.model.SessionWrapper)5 LinkedList (java.util.LinkedList)5 TetradMetadata (edu.cmu.tetradapp.model.TetradMetadata)3 List (java.util.List)3 Endpoint (edu.cmu.tetrad.graph.Endpoint)2 Edge (edu.cmu.tetrad.graph.Edge)1 HpcAccountSettingAction (edu.cmu.tetradapp.app.hpc.action.HpcAccountSettingAction)1 TetradMetadataIndirectRef (edu.cmu.tetradapp.util.TetradMetadataIndirectRef)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 Transferable (java.awt.datatransfer.Transferable)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 SimpleDateFormat (java.text.SimpleDateFormat)1