Search in sources :

Example 6 with SessionEditorIndirectRef

use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.

the class CloseSessionAction method actionPerformed.

/**
 * Closes the frontmost session of this action's desktop.
 */
public void actionPerformed(ActionEvent e) {
    // Get the frontmost SessionWrapper.
    SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench graph = sessionEditor.getSessionWorkbench();
    SessionWrapper sessionWrapper = graph.getSessionWrapper();
    if (sessionWrapper.isSessionChanged()) {
        String name = sessionWrapper.getName();
        // check to make sure user wants to evaporate this window...
        String msg = "Do you want to save the changes you made to " + name + "?";
        int response = JOptionPane.showConfirmDialog(JOptionUtils.centeringComp(), msg, "Fair Warning", JOptionPane.YES_NO_CANCEL_OPTION);
        if (response == JOptionPane.YES_OPTION) {
            SaveSessionAction saveSessionAction = new SaveSessionAction();
            saveSessionAction.actionPerformed(e);
            this.saved = saveSessionAction.isSaved();
        } else if (response == JOptionPane.CANCEL_OPTION) {
            return;
        }
    }
    DesktopController.getInstance().closeFrontmostSession();
}
Also used : SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) SessionWrapper(edu.cmu.tetradapp.model.SessionWrapper)

Example 7 with SessionEditorIndirectRef

use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.

the class ConstructTemplateAction method estimateThenUpdateUsingSearchResult.

private void estimateThenUpdateUsingSearchResult(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, leftX + 150, 100));
    String graph = nextName("Graph");
    nodes.add(addNode("Graph", graph, leftX + 150, 200));
    String pm = nextName("PM");
    nodes.add(addNode("PM", pm, leftX + 150, 300));
    String estimator = nextName("Estimator");
    nodes.add(addNode("Estimator", estimator, leftX, 300));
    String updater = nextName("Updater");
    nodes.add(addNode("Updater", updater, leftX, 400));
    addEdge(data, search);
    addEdge(search, graph);
    addEdge(graph, pm);
    addEdge(data, estimator);
    addEdge(data, pm);
    addEdge(pm, estimator);
    addEdge(estimator, updater);
    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 8 with SessionEditorIndirectRef

use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.

the class ConstructTemplateAction method searchFromSimulatedDataWithCompare.

private void searchFromSimulatedDataWithCompare(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("Simulation");
    String search = nextName("Search");
    String compare = nextName("Compare");
    nodes.add(addNode("Simulation", data, leftX, 100));
    nodes.add(addNode("Search", search, 150 + leftX, 100));
    nodes.add(addNode("Compare", compare, 80 + leftX, 200));
    addEdge(data, search);
    addEdge(data, compare);
    addEdge(search, compare);
    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 9 with SessionEditorIndirectRef

use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.

the class ConstructTemplateAction method getLeftX.

// =============================PRIVATE METHODS========================//
private int getLeftX() {
    SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
    sessionWorkbench.deselectAll();
    Component[] components = sessionWorkbench.getComponents();
    int leftX = 0;
    for (Component component : components) {
        Rectangle bounds = component.getBounds();
        int rightmost = bounds.x + bounds.width;
        if (rightmost > leftX) {
            leftX = rightmost;
        }
    }
    leftX += 100;
    return leftX;
}
Also used : SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) Endpoint(edu.cmu.tetrad.graph.Endpoint)

Example 10 with SessionEditorIndirectRef

use of edu.cmu.tetradapp.util.SessionEditorIndirectRef in project tetrad by cmu-phil.

the class ConstructTemplateAction method nextName.

/**
 * Returns the next string in the sequence.
 *
 * @param base the string base of the name--for example, "Graph".
 * @return the next string in the sequence--for example, "Graph1".
 */
private static String nextName(String base) {
    SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
    SessionWrapper graph = sessionWorkbench.getSessionWrapper();
    if (base == null) {
        throw new NullPointerException("Base name must be non-null.");
    }
    // Sequence 1, 2, 3, ...
    int i = 0;
    loop: while (true) {
        i++;
        String name = base + i;
        for (Object o : graph.getNodes()) {
            Node node = (Node) (o);
            if (node.getName().equals(name)) {
                continue loop;
            }
        }
        break;
    }
    return base + i;
}
Also used : Node(edu.cmu.tetrad.graph.Node) SessionNode(edu.cmu.tetrad.session.SessionNode) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) Endpoint(edu.cmu.tetrad.graph.Endpoint) SessionWrapper(edu.cmu.tetradapp.model.SessionWrapper)

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