Skip to content

Commit

Permalink
Merge pull request #1769 from cmu-phil/joe-work-2024-5-7
Browse files Browse the repository at this point in the history
Finished up experimental LV-Lite and cleaned up the rest of the LV code.
  • Loading branch information
jdramsey authored May 31, 2024
2 parents e7a4b28 + 6d2ccb6 commit ebaba1b
Show file tree
Hide file tree
Showing 299 changed files with 11,515 additions and 5,025 deletions.
2 changes: 1 addition & 1 deletion tetrad-gui/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>tetrad</artifactId>
<groupId>io.github.cmu-phil</groupId>
<version>7.6.4</version>
<version>7.6.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tetrad-gui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public void watch() {

throw e1;
} catch (Exception e2) {
e2.printStackTrace();
TetradLogger.getInstance().forceLogMessage("Exception: " + e2.getMessage());
}
} else if (o instanceof SessionWrapper) {
Expand Down Expand Up @@ -158,8 +159,10 @@ public void watch() {
DesktopController.getInstance().closeEmptySessions();
DesktopController.getInstance().putMetadata(sessionWrapper, metadata);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "That wasn't a TETRAD session file: " + file);
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "An error occurred attempting to load the session.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectOutputStream;
import java.io.Serial;
import java.nio.file.Files;
Expand Down Expand Up @@ -106,6 +107,11 @@ public void watch() {
sessionWrapper.setNewSession(false);
objOut.writeObject(metadata);
objOut.writeObject(sessionWrapper);
} catch (NotSerializableException exception) {
exception.printStackTrace(System.err);
JOptionPane.showMessageDialog(
JOptionUtils.centeringComp(),
"An error occurred while attempting to save the session. The session could not be saved.");
} catch (IOException exception) {
exception.printStackTrace(System.err);
JOptionPane.showMessageDialog(
Expand Down
102 changes: 66 additions & 36 deletions tetrad-gui/src/main/java/edu/cmu/tetradapp/app/SessionEditorNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,19 @@ public void doDoubleClickAction() {
public void doDoubleClickAction(Graph sessionWrapper) {
this.sessionWrapper = (SessionWrapper) sessionWrapper;

class MyWatchedProcess extends WatchedProcess {
public void watch() {
TetradLogger.getInstance().setTetradLoggerConfig(getSessionNode().getLoggerConfig());
launchEditorVisit();
}
}
SwingUtilities.invokeLater(() -> {
TetradLogger.getInstance().setTetradLoggerConfig(getSessionNode().getLoggerConfig());
launchEditorVisit();
});

new MyWatchedProcess();
// class MyWatchedProcess extends WatchedProcess {
// public void watch() {
// TetradLogger.getInstance().setTetradLoggerConfig(getSessionNode().getLoggerConfig());
// launchEditorVisit();
// }
// }
//
// new MyWatchedProcess();
}

private void launchEditorVisit() {
Expand Down Expand Up @@ -816,42 +821,67 @@ private void showLogConfig(TetradLoggerConfig config) {
}

private void executeSessionNode(SessionNode sessionNode) {
class MyWatchedProcess extends WatchedProcess {
@Override
public void watch() {
final Class c = SessionEditorWorkbench.class;
Container container = SwingUtilities.getAncestorOfClass(c,
SessionEditorNode.this);
SessionEditorWorkbench workbench
= (SessionEditorWorkbench) container;
SwingUtilities.invokeLater(() -> {
final Class c = SessionEditorWorkbench.class;
Container container = SwingUtilities.getAncestorOfClass(c,
SessionEditorNode.this);
SessionEditorWorkbench workbench
= (SessionEditorWorkbench) container;

System.out.println("Executing " + sessionNode);
System.out.println("Executing " + sessionNode);

workbench.getSimulationStudy().execute(sessionNode, true);
}
}
workbench.getSimulationStudy().execute(sessionNode, true);
});

new MyWatchedProcess();
// class MyWatchedProcess extends WatchedProcess {
// @Override
// public void watch() {
// final Class c = SessionEditorWorkbench.class;
// Container container = SwingUtilities.getAncestorOfClass(c,
// SessionEditorNode.this);
// SessionEditorWorkbench workbench
// = (SessionEditorWorkbench) container;
//
// System.out.println("Executing " + sessionNode);
//
// workbench.getSimulationStudy().execute(sessionNode, true);
// }
// }

// new MyWatchedProcess();
}

private void createDescendantModels() {
class MyWatchedProcess extends WatchedProcess {
@Override
public void watch() {
final Class clazz = SessionEditorWorkbench.class;
Container container = SwingUtilities.getAncestorOfClass(clazz,
SessionEditorNode.this);
SessionEditorWorkbench workbench
= (SessionEditorWorkbench) container;

if (workbench != null) {
workbench.getSimulationStudy().createDescendantModels(
getSessionNode(), true);
}
SwingUtilities.invokeLater(() -> {
final Class clazz = SessionEditorWorkbench.class;
Container container = SwingUtilities.getAncestorOfClass(clazz,
SessionEditorNode.this);
SessionEditorWorkbench workbench
= (SessionEditorWorkbench) container;

if (workbench != null) {
workbench.getSimulationStudy().createDescendantModels(
getSessionNode(), true);
}
}

new MyWatchedProcess();
});
//
// class MyWatchedProcess extends WatchedProcess {
// @Override
// public void watch() {
// final Class clazz = SessionEditorWorkbench.class;
// Container container = SwingUtilities.getAncestorOfClass(clazz,
// SessionEditorNode.this);
// SessionEditorWorkbench workbench
// = (SessionEditorWorkbench) container;
//
// if (workbench != null) {
// workbench.getSimulationStudy().createDescendantModels(
// getSessionNode(), true);
// }
// }
// }
//
// new MyWatchedProcess();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public SessionEditorToolbar(SessionEditorWorkbench workbench) {
new ButtonInfo("Graph", "Graph", "graph", "<html>Add a graph node.</html>"),
new ButtonInfo("Compare", "Compare", "compare",
"<html>Add a node to compare graphs or SEM IM's.</html>"),
new ButtonInfo("GridSearch", "Grid Search", "search",
"<html>Add a node to do a grid search.</html>"),
new ButtonInfo("PM", "Parametric Model", "pm",
"<html>Add a node for a parametric model.</html>"),
new ButtonInfo("IM", "Instantiated Model", "im",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void setEditorPanel() {

Graph graph = this.wrapper.getBayesPm().getDag();
GraphWorkbench workbench = new GraphWorkbench(graph);
workbench.enableEditing(false);
workbench.setEnableEditing(false);
BayesPmEditorWizard wizard = new BayesPmEditorWizard(this.wrapper.getBayesPm(), workbench);

JScrollPane workbenchScroll = new JScrollPane(workbench);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ private JMenu createGraphMenu() {
graph.addSeparator();

graph.add(new GraphPropertiesAction(this.workbench));
graph.add(new PathsAction(this.workbench));
graph.add(new PathsAction(this.workbench, parameters));
graph.add(new UnderliningsAction(this.workbench));
graph.addSeparator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public EditorWindow(JComponent editor, String title, String buttonName,

this.centeringComp = centeringComp;

setClosable(false);
// setClosable(false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public boolean isEnableEditing() {
public void enableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down
24 changes: 12 additions & 12 deletions tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GraphEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void initUI(GraphWrapper graphWrapper) {
Graph graph = graphWrapper.getGraph();

this.workbench = new GraphWorkbench(graph);
this.workbench.enableEditing(this.enableEditing);
this.workbench.setEnableEditing(this.enableEditing);

this.workbench.addPropertyChangeListener((PropertyChangeEvent evt) -> {
String propertyName = evt.getPropertyName();
Expand All @@ -272,7 +272,7 @@ private void initUI(GraphWrapper graphWrapper) {
// Update the graphWrapper
graphWrapper.setGraph(targetGraph);
// Also need to update the UI
// updateBootstrapTable(targetGraph);
updateBootstrapTable(targetGraph);
}
} else if ("modelChanged".equals(propertyName)) {
firePropertyChange("modelChanged", null, null);
Expand All @@ -290,12 +290,12 @@ private void initUI(GraphWrapper graphWrapper) {
graphToolbar.setMaximumSize(new Dimension(140, 450));

// topBox right side graph editor
this.graphEditorScroll.setPreferredSize(new Dimension(760, 450));
this.graphEditorScroll.setPreferredSize(new Dimension(500, 500));
this.graphEditorScroll.setViewportView(this.workbench);

// topBox contains the topGraphBox and the instructionBox underneath
Box topBox = Box.createVerticalBox();
topBox.setPreferredSize(new Dimension(820, 400));
topBox.setPreferredSize(new Dimension(450, 400));

// topGraphBox contains the vertical graph toolbar and graph editor
Box topGraphBox = Box.createHorizontalBox();
Expand All @@ -304,7 +304,7 @@ private void initUI(GraphWrapper graphWrapper) {

// Instruction with info button
Box instructionBox = Box.createHorizontalBox();
instructionBox.setMaximumSize(new Dimension(820, 40));
instructionBox.setMaximumSize(new Dimension(450, 40));

JLabel label = new JLabel("Double click variable/node rectangle to change name.");
label.setFont(new Font("SansSerif", Font.PLAIN, 12));
Expand Down Expand Up @@ -344,7 +344,7 @@ private void initUI(GraphWrapper graphWrapper) {
topBox.add(topGraphBox);
topBox.add(instructionBox);

this.edgeTypeTable.setPreferredSize(new Dimension(820, 150));
this.edgeTypeTable.setPreferredSize(new Dimension(500, 150));

// //Use JSplitPane to allow resize the bottom box - Zhou
// JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new PaddingPanel(topBox), new PaddingPanel(edgeTypeTable));
Expand All @@ -371,8 +371,8 @@ private void initUI(GraphWrapper graphWrapper) {
* Updates the graph in workbench when changing graph model
*/
private void updateGraphWorkbench(Graph graph) {
this.workbench = new GraphWorkbench(graph);
this.workbench.enableEditing(this.enableEditing);
this.workbench.setGraph(graph);// = new GraphWorkbench(graph);
this.workbench.setEnableEditing(this.enableEditing);
this.graphEditorScroll.setViewportView(this.workbench);

validate();
Expand Down Expand Up @@ -411,7 +411,7 @@ private void modelSelection(GraphWrapper graphWrapper) {
updateGraphWorkbench(graphWrapper.getGraph());

// Update the bootstrap table
// updateBootstrapTable(graphWrapper.getGraph());
updateBootstrapTable(graphWrapper.getGraph());
});

// Put together
Expand Down Expand Up @@ -442,10 +442,10 @@ public boolean isEnableEditing() {
*
* @param enableEditing a boolean
*/
public void enableEditing(boolean enableEditing) {
public void setEnableEditing(boolean enableEditing) {
this.enableEditing = enableEditing;
if (this.workbench != null) {
this.workbench.enableEditing(enableEditing);
this.workbench.setEnableEditing(enableEditing);
}
}

Expand Down Expand Up @@ -514,7 +514,7 @@ private JMenu createGraphMenu() {
graph.addSeparator();

graph.add(new GraphPropertiesAction(getWorkbench()));
graph.add(new PathsAction(getWorkbench()));
graph.add(new PathsAction(getWorkbench(), parameters));
graph.add(new UnderliningsAction(getWorkbench()));
graph.addSeparator();

Expand Down
Loading

0 comments on commit ebaba1b

Please sign in to comment.