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();
}
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);
}
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);
}
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;
}
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;
}
Aggregations