Search in sources :

Example 16 with ChildWindow

use of cbit.vcell.client.ChildWindowManager.ChildWindow in project vcell by virtualcell.

the class NetworkConstraintsPanel method runBioNetGen.

private void runBioNetGen() {
    EditConstraintsPanel panel = new EditConstraintsPanel(this);
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
    ChildWindow childWindow = childWindowManager.addChildWindow(panel, panel, "Edit / Test Constraints");
    Dimension dim = new Dimension(360, 160);
    childWindow.pack();
    panel.setChildWindow(childWindow);
    childWindow.setPreferredSize(dim);
    childWindow.showModal();
    int maxIterations;
    int maxMolecules;
    if (panel.getButtonPushed() == ActionButtons.Run) {
        maxIterations = new Integer(panel.maxIterationTextField.getText());
        maxMolecules = new Integer(panel.maxMolTextField.getText());
        fieldSimulationContext.getNetworkConstraints().setTestConstraints(maxIterations, maxMolecules);
    } else if (panel.getButtonPushed() == ActionButtons.Apply) {
        activateConsole();
        maxIterations = new Integer(panel.maxIterationTextField.getText());
        maxMolecules = new Integer(panel.maxMolTextField.getText());
        fieldSimulationContext.getNetworkConstraints().setTestConstraints(maxIterations, maxMolecules);
        fieldSimulationContext.getNetworkConstraints().updateConstraintsFromTest();
        // apply will invalidate everything: generated species, reactions, console, cache, etc
        updateBioNetGenOutput(null);
        refreshInterface();
        TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.Clean, "");
        fieldSimulationContext.appendToConsole(tcm);
        String message = "Warning: The current Constraints are not tested / validated.";
        tcm = new TaskCallbackMessage(TaskCallbackStatus.Warning, message);
        fieldSimulationContext.appendToConsole(tcm);
        message = "The Network generation may take a very long time or the generated network may be incomplete. " + "We recommend testing this set of constraints.";
        tcm = new TaskCallbackMessage(TaskCallbackStatus.Notification, message);
        fieldSimulationContext.appendToConsole(tcm);
        return;
    } else {
        return;
    }
    // TODO: do not delete the commented code below
    // uncomment the next 6 lines to keep the data in the dialogs synchronized with the most recent reaction network
    // if(viewSpeciesDialog != null) {
    // viewSpeciesDialog.dispose();
    // }
    // if(viewReactionsDialog != null) {
    // viewReactionsDialog.dispose();
    // }
    activateConsole();
    // previousIterationSpecies = 0;
    synchronized (this) {
        fieldSimulationContext.setMd5hash(null);
        fieldSimulationContext.setMostRecentlyCreatedOutputSpec(null);
    }
    refreshInterface();
    if (!checkBnglRequirements()) {
        return;
    }
    NetworkTransformer transformer = new NetworkTransformer();
    MathMappingCallback dummyCallback = new MathMappingCallback() {

        public void setProgressFraction(float percentDone) {
        }

        public void setMessage(String message) {
        }

        public boolean isInterrupted() {
            return false;
        }
    };
    // we alter the input string to use the test values for max iterations and max molecules per species
    String input = transformer.convertToBngl(fieldSimulationContext, true, dummyCallback, NetworkGenerationRequirements.ComputeFullNoTimeout);
    // get rid of the default generate network command...
    input = input.substring(0, input.indexOf("generate_network({"));
    // ... and replace it with the "fake" one
    StringWriter bnglStringWriter = new StringWriter();
    PrintWriter pw = new PrintWriter(bnglStringWriter);
    RbmNetworkGenerator.generateNetworkEx(maxIterations, maxMolecules, pw, fieldSimulationContext.getModel().getRbmModelContainer(), fieldSimulationContext, NetworkGenerationRequirements.ComputeFullNoTimeout);
    String genNetStr = bnglStringWriter.toString();
    pw.close();
    input += genNetStr;
    BNGInput bngInput = new BNGInput(input);
    final BNGExecutorService bngService = BNGExecutorService.getInstance(bngInput, NetworkGenerationRequirements.NoTimeoutMS);
    bngService.registerBngUpdaterCallback(this);
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    AsynchClientTask[] tasksArray = new AsynchClientTask[3];
    TaskCallbackMessage message = new TaskCallbackMessage(TaskCallbackStatus.Clean, "");
    fieldSimulationContext.appendToConsole(message);
    tasksArray[0] = new RunBioNetGen(bngService);
    tasksArray[1] = new CreateBNGOutputSpec(bngService);
    tasksArray[2] = new ReturnBNGOutput(bngService, fieldSimulationContext, this);
    ClientTaskDispatcher.dispatch(this, hash, tasksArray, false, true, new ProgressDialogListener() {

        @Override
        public void cancelButton_actionPerformed(EventObject newEvent) {
            try {
                bngService.stopBNG();
                String s = "...user cancelled.";
                TaskCallbackMessage tcm = new TaskCallbackMessage(TaskCallbackStatus.TaskStopped, s);
                // message will be processed in TaskCallbackProcessor::case TaskStopped
                setNewCallbackMessage(tcm);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ReturnBNGOutput(cbit.vcell.client.task.ReturnBNGOutput) StringWriter(java.io.StringWriter) ProgressDialogListener(org.vcell.util.ProgressDialogListener) BNGInput(cbit.vcell.server.bionetgen.BNGInput) RunBioNetGen(cbit.vcell.client.task.RunBioNetGen) PrintWriter(java.io.PrintWriter) TaskCallbackMessage(cbit.vcell.mapping.TaskCallbackMessage) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) CreateBNGOutputSpec(cbit.vcell.client.task.CreateBNGOutputSpec) Hashtable(java.util.Hashtable) NetworkTransformer(cbit.vcell.mapping.NetworkTransformer) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) BNGExecutorService(cbit.vcell.server.bionetgen.BNGExecutorService) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) EventObject(java.util.EventObject) EventObject(java.util.EventObject)

Example 17 with ChildWindow

use of cbit.vcell.client.ChildWindowManager.ChildWindow in project vcell by virtualcell.

the class FieldDataWindowManager method viewData.

public void viewData(final ExternalDataIdentifier eDI) {
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
    if (eDI != null && eDI.equals(currentlyViewedEDI) && childWindowManager != null && childWindowManager.getChildWindowFromContext(eDI) != null) {
        childWindowManager.getChildWindowFromContext(eDI).show();
    } else {
        if (currentlyViewedOutputFunctionViewer != null) {
            if (getLocalRequestManager() != null && getLocalRequestManager().getAsynchMessageManager() != null) {
                getLocalRequestManager().getAsynchMessageManager().removeDataJobListener(currentlyViewedOutputFunctionViewer.getPDEDataViewer());
            }
            if (currentlyViewedOutputFunctionViewer != null) {
                currentlyViewedOutputFunctionViewer.getPDEDataViewer().getPdeDataContext().removePropertyChangeListener(this);
            }
        }
        if (currentlyViewedOutputFunctionViewer != null) {
            ChildWindow childWindow = childWindowManager.getChildWindowFromContext(eDI);
            if (childWindow != null) {
                childWindow.close();
            }
        }
        currentlyViewedEDI = null;
        currentlyViewedOutputFunctionViewer = null;
        if (eDI == null) {
            return;
        }
        AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                ClientPDEDataContext newPDEDataContext = getPDEDataContext(eDI, new OutputContext(new AnnotatedFunction[0]));
                hashTable.put("newPDEDataContext", newPDEDataContext);
            }
        };
        AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                try {
                    PDEDataViewer currentlyViewedPDEDV = new PDEDataViewer();
                    ClientPDEDataContext newPDEDataContext = (ClientPDEDataContext) hashTable.get("newPDEDataContext");
                    currentlyViewedPDEDV.setPdeDataContext(newPDEDataContext);
                    newPDEDataContext.addPropertyChangeListener(FieldDataWindowManager.this);
                    getLocalRequestManager().getAsynchMessageManager().addDataJobListener(currentlyViewedPDEDV);
                    currentlyViewedOutputFunctionViewer = new OutputFunctionViewer(currentlyViewedPDEDV, FieldDataWindowManager.this, eDI);
                    DataViewerManager dvm = new DataViewerManager() {

                        public void dataJobMessage(DataJobEvent event) {
                        }

                        public void exportMessage(ExportEvent event) {
                        }

                        public void addDataListener(DataListener newListener) {
                        }

                        public UserPreferences getUserPreferences() {
                            return getRequestManager().getUserPreferences();
                        }

                        public void removeDataListener(DataListener newListener) {
                        }

                        public void startExport(Component requester, OutputContext outputContext, ExportSpecs exportSpecs) {
                            getLocalRequestManager().startExport(outputContext, requester, exportSpecs);
                        }

                        public void simStatusChanged(SimStatusEvent simStatusEvent) {
                        }

                        public User getUser() {
                            return getRequestManager().getDocumentManager().getUser();
                        }

                        public RequestManager getRequestManager() {
                            return FieldDataWindowManager.this.getRequestManager();
                        }
                    };
                    try {
                        currentlyViewedPDEDV.setDataViewerManager(dvm);
                    } catch (PropertyVetoException e) {
                        e.printStackTrace();
                    }
                    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
                    currentlyViewedEDI = eDI;
                    ChildWindow childWindow = childWindowManager.addChildWindow(currentlyViewedOutputFunctionViewer, currentlyViewedEDI, "Field Data Viewer (" + eDI.getName() + ")");
                    childWindow.setSize(600, 500);
                    childWindow.setIsCenteredOnParent();
                    childWindow.show();
                } catch (Exception e) {
                    if (currentlyViewedOutputFunctionViewer != null) {
                        if (getLocalRequestManager() != null && getLocalRequestManager().getAsynchMessageManager() != null) {
                            getLocalRequestManager().getAsynchMessageManager().removeDataJobListener(currentlyViewedOutputFunctionViewer.getPDEDataViewer());
                        }
                        if (currentlyViewedOutputFunctionViewer != null) {
                            currentlyViewedOutputFunctionViewer.getPDEDataViewer().getPdeDataContext().removePropertyChangeListener(FieldDataWindowManager.this);
                        }
                    }
                    throw e;
                }
            }
        };
        ClientTaskDispatcher.dispatch(this.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ExportEvent(cbit.rmi.event.ExportEvent) ExportSpecs(cbit.vcell.export.server.ExportSpecs) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) OutputContext(cbit.vcell.simdata.OutputContext) PropertyVetoException(java.beans.PropertyVetoException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) PropertyVetoException(java.beans.PropertyVetoException) DataJobEvent(cbit.rmi.event.DataJobEvent) SimStatusEvent(cbit.vcell.client.server.SimStatusEvent) ClientPDEDataContext(cbit.vcell.simdata.ClientPDEDataContext) DataListener(cbit.vcell.simdata.DataListener) Component(java.awt.Component) PDEDataViewer(cbit.vcell.client.data.PDEDataViewer) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 18 with ChildWindow

use of cbit.vcell.client.ChildWindowManager.ChildWindow in project vcell by virtualcell.

the class GeometryWindowManager method showGeometryViewer.

private void showGeometryViewer() {
    String geoViewerTitle = "Geometry Editor";
    geoViewer.setGeometry(getGeometry());
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
    ChildWindow childWindow = childWindowManager.getChildWindowFromContentPane(geoViewer);
    if (childWindow == null) {
        childWindow = childWindowManager.addChildWindow(geoViewer, geoViewer, geoViewerTitle);
        childWindow.setSize(600, 600);
        childWindow.setIsCenteredOnParent();
        childWindow.addChildWindowListener(new ChildWindowListener() {

            public void closing(ChildWindow childWindow) {
                getGeometryEditor().setToggleButtonSelected("Geometry Editor", false);
            }
        });
    }
    childWindow.show();
}
Also used : ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Example 19 with ChildWindow

use of cbit.vcell.client.ChildWindowManager.ChildWindow in project vcell by virtualcell.

the class GeometryWindowManager method showSurfaceViewer.

/**
 * Insert the method's description here.
 * Creation date: (5/5/2004 9:44:15 PM)
 */
private void showSurfaceViewer() {
    String surfaceViewerTitle = "Surface Viewer";
    surfaceViewer.setGeometry(getGeometry());
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
    ChildWindow childWindow = childWindowManager.getChildWindowFromContentPane(surfaceViewer);
    if (childWindow == null) {
        childWindow = childWindowManager.addChildWindow(surfaceViewer, surfaceViewer, surfaceViewerTitle);
        childWindow.setSize(600, 600);
        childWindow.addChildWindowListener(new ChildWindowListener() {

            public void closing(ChildWindow childWindow) {
                getGeometryEditor().setToggleButtonSelected("Surface Viewer", false);
            }
        });
    }
    childWindow.show();
}
Also used : ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Example 20 with ChildWindow

use of cbit.vcell.client.ChildWindowManager.ChildWindow in project vcell by virtualcell.

the class MathModelWindowManager method addResultsFrame.

/**
 * Insert the method's description here.
 * Creation date: (6/11/2004 7:32:07 AM)
 * @param newDocument cbit.vcell.document.VCDocument
 */
public void addResultsFrame(SimulationWindow simWindow) {
    simulationWindowsHash.put(simWindow.getVcSimulationIdentifier(), simWindow);
    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getJPanel());
    ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindow);
    if (childWindow == null) {
        childWindow = childWindowManager.addChildWindow(simWindow.getDataViewer(), simWindow, "simulation results for " + simWindow.getSimulation().getName());
        simWindow.setChildWindow(childWindow);
        childWindow.setIsCenteredOnParent();
        childWindow.pack();
    }
    childWindow.show();
}
Also used : ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow)

Aggregations

ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)35 ChildWindowManager (cbit.vcell.client.ChildWindowManager)14 Hashtable (java.util.Hashtable)10 Dimension (java.awt.Dimension)8 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)7 Vector (java.util.Vector)5 UserCancelException (org.vcell.util.UserCancelException)5 SimulationWindow (cbit.vcell.client.desktop.simulation.SimulationWindow)4 SinglePoint (cbit.vcell.geometry.SinglePoint)4 Simulation (cbit.vcell.solver.Simulation)4 Point (java.awt.Point)4 PlotPane (cbit.plot.gui.PlotPane)3 DataViewer (cbit.vcell.client.data.DataViewer)3 VariableType (cbit.vcell.math.VariableType)3 SpatialSelection (cbit.vcell.simdata.SpatialSelection)3 SpatialSelectionVolume (cbit.vcell.simdata.SpatialSelectionVolume)3 SimulationInfo (cbit.vcell.solver.SimulationInfo)3 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)3 PropertyVetoException (java.beans.PropertyVetoException)3 DataAccessException (org.vcell.util.DataAccessException)3