Search in sources :

Example 1 with TMLPanel

use of cbit.xml.merge.gui.TMLPanel in project vcell by virtualcell.

the class ClientRequestManager method showComparisonResults.

public void showComparisonResults(TopLevelWindowManager requester, XmlTreeDiff diffTree, String baselineDesc, String modifiedDesc) {
    TMLPanel comparePanel = new TMLPanel();
    comparePanel.setXmlTreeDiff(diffTree);
    comparePanel.setBaselineVersionDescription(baselineDesc);
    comparePanel.setModifiedVersionDescription(modifiedDesc);
    JOptionPane comparePane = new JOptionPane(null, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[] { /*"Apply Changes", */
    "Close" });
    comparePane.setMessage(comparePanel);
    JDialog compareDialog = comparePane.createDialog(requester.getComponent(), "Compare Models");
    compareDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    compareDialog.setResizable(true);
    compareDialog.pack();
    compareDialog.setVisible(true);
    // ZEnforcer.showModalDialogOnTop(compareDialog,JOptionPane.getFrameForComponent(requester.getComponent()));
    if ("Apply Changes".equals(comparePane.getValue())) {
        if (!comparePanel.tagsResolved()) {
            DialogUtils.showErrorDialog(comparePanel, "Please resolve all tagged elements/attributes before proceeding.");
        } else {
            BeanUtils.setCursorThroughout((Container) requester.getComponent(), Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            try {
                processComparisonResult(comparePanel, requester);
            } catch (RuntimeException e) {
                throw e;
            } finally {
                BeanUtils.setCursorThroughout((Container) requester.getComponent(), Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        }
    }
}
Also used : TMLPanel(cbit.xml.merge.gui.TMLPanel) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 2 with TMLPanel

use of cbit.xml.merge.gui.TMLPanel in project vcell by virtualcell.

the class BioModelEditorApplicationsPanel method compareButtonPressed.

private void compareButtonPressed() {
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length != 2) {
        return;
    }
    try {
        SimulationContext simContext1 = tableModel.getValueAt(rows[0]);
        SimulationContext simContext2 = tableModel.getValueAt(rows[1]);
        BioModel bioModel = simContext1.getBioModel();
        MathMappingCallback callback = new MathMappingCallback() {

            @Override
            public void setProgressFraction(float fractionDone) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: progress = " + (fractionDone * 100.0) + "% done");
            }

            @Override
            public void setMessage(String message) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: message = " + message);
            }

            @Override
            public boolean isInterrupted() {
                return false;
            }
        };
        simContext1.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        simContext2.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        Xmlproducer xmlProducer = new Xmlproducer(false);
        String simContext1XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext1, bioModel));
        String simContext2XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext2, bioModel));
        DiffConfiguration comparisonSetting = DiffConfiguration.COMPARE_DOCS_OTHER;
        XmlTreeDiff diffTree = XmlHelper.compareMerge(simContext1XML, simContext2XML, comparisonSetting, true);
        String baselineDesc = "application " + simContext1.getName();
        String modifiedDesc = "application " + simContext2.getName();
        TMLPanel comparePanel = new TMLPanel();
        comparePanel.setXmlTreeDiff(diffTree);
        comparePanel.setBaselineVersionDescription(baselineDesc);
        comparePanel.setModifiedVersionDescription(modifiedDesc);
        ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
        String title = "comparing application " + simContext1.getName() + " and " + simContext2.getName();
        ChildWindow childWindow = childWindowManager.addChildWindow(comparePanel, diffTree, title, true);
        childWindow.setSize(new Dimension(600, 600));
        childWindow.show();
    } catch (XmlParseException e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog(this, "failed to compare applications: \n\n" + e.getMessage());
    }
}
Also used : DiffConfiguration(cbit.xml.merge.XmlTreeDiff.DiffConfiguration) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) Xmlproducer(cbit.vcell.xml.Xmlproducer) XmlTreeDiff(cbit.xml.merge.XmlTreeDiff) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) TMLPanel(cbit.xml.merge.gui.TMLPanel) BioModel(cbit.vcell.biomodel.BioModel)

Aggregations

TMLPanel (cbit.xml.merge.gui.TMLPanel)2 BioModel (cbit.vcell.biomodel.BioModel)1 ChildWindowManager (cbit.vcell.client.ChildWindowManager)1 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 MathMappingCallback (cbit.vcell.mapping.SimulationContext.MathMappingCallback)1 XmlParseException (cbit.vcell.xml.XmlParseException)1 Xmlproducer (cbit.vcell.xml.Xmlproducer)1 XmlTreeDiff (cbit.xml.merge.XmlTreeDiff)1 DiffConfiguration (cbit.xml.merge.XmlTreeDiff.DiffConfiguration)1 Dimension (java.awt.Dimension)1 JDialog (javax.swing.JDialog)1 JOptionPane (javax.swing.JOptionPane)1