Search in sources :

Example 1 with TetradMetadataIndirectRef

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

the class SessionVersionAction method actionPerformed.

/**
 * Performs the action of loading a session from a file.
 */
public void actionPerformed(ActionEvent e) {
    // Get the frontmost SessionWrapper.
    SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench workbench = sessionEditor.getSessionWorkbench();
    SessionWrapper sessionWrapper = workbench.getSessionWrapper();
    TetradMetadataIndirectRef metadataRef = DesktopController.getInstance().getTetradMetadata(sessionWrapper);
    TetradMetadata metadata = (TetradMetadata) metadataRef;
    StringBuilder buf = new StringBuilder();
    if (metadata == null) {
        buf.append("This session has not yet been saved or loaded. The model\n");
        buf.append("version you are working in is ");
        buf.append(Version.currentViewableVersion());
        buf.append(".");
        JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), buf.toString());
        return;
    }
    SimpleDateFormat df = new SimpleDateFormat("MMM dd, yyyy");
    buf.append("Version information for \"");
    buf.append(sessionWrapper.getName());
    buf.append("\":\n\n");
    buf.append("Last saved using Tetrad ");
    buf.append(metadata.getVersion());
    buf.append(" (");
    buf.append(df.format(metadata.getDate()));
    buf.append(").\n");
    buf.append("You are running Tetrad ");
    buf.append(Version.currentViewableVersion());
    buf.append(".");
    JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), buf.toString());
}
Also used : TetradMetadataIndirectRef(edu.cmu.tetradapp.util.TetradMetadataIndirectRef) TetradMetadata(edu.cmu.tetradapp.model.TetradMetadata) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) SimpleDateFormat(java.text.SimpleDateFormat) SessionWrapper(edu.cmu.tetradapp.model.SessionWrapper)

Aggregations

SessionWrapper (edu.cmu.tetradapp.model.SessionWrapper)1 TetradMetadata (edu.cmu.tetradapp.model.TetradMetadata)1 SessionEditorIndirectRef (edu.cmu.tetradapp.util.SessionEditorIndirectRef)1 TetradMetadataIndirectRef (edu.cmu.tetradapp.util.TetradMetadataIndirectRef)1 SimpleDateFormat (java.text.SimpleDateFormat)1