Search in sources :

Example 1 with DocumentWindowManager

use of cbit.vcell.client.DocumentWindowManager in project vcell by virtualcell.

the class PDEExportDataPanel method createSimulationSelector.

private ExportSpecs.SimulationSelector createSimulationSelector() {
    ExportSpecs.SimulationSelector simulationSelector = new ExportSpecs.SimulationSelector() {

        private ExportSpecs.SimNameSimDataID[] multiSimNameSimDataIDs;

        // private ExportSpecs.ExportParamScanInfo exportParamScanInfo;
        private int[] selectedParamScanIndexes;

        private Simulation[] simulations;

        public SimNameSimDataID[] getSelectedSimDataInfo() {
            // }
            if (multiSimNameSimDataIDs == null) {
                return new ExportSpecs.SimNameSimDataID[] { currentSimNameSimDataID };
            }
            return multiSimNameSimDataIDs;
        }

        public void selectSimulations() {
            getNumAvailableSimulations();
            String[][] rowData = new String[simulations.length][5];
            for (int i = 0; i < rowData.length; i++) {
                rowData[i][0] = simulations[i].getName();
                rowData[i][1] = simulations[i].getMeshSpecification().getSamplingSize().toString();
                rowData[i][2] = simulations[i].getSolverTaskDescription().getExpectedNumTimePoints() + "";
                rowData[i][3] = simulations[i].getSolverTaskDescription().getTimeBounds().getEndingTime() + "";
                rowData[i][4] = simulations[i].getSolverTaskDescription().getOutputTimeSpec().getShortDescription();
            }
            try {
                int[] choices = DialogUtils.showComponentOKCancelTableList(PDEExportDataPanel.this, "Choose Sims to export together", new String[] { "Simulation", "Mesh x,y,z", "NumTimePoints", "EndTime", "Output Descr." }, rowData, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                if (choices != null) {
                    multiSimNameSimDataIDs = new ExportSpecs.SimNameSimDataID[choices.length];
                    for (int i = 0; i < choices.length; i++) {
                        multiSimNameSimDataIDs[i] = new ExportSpecs.SimNameSimDataID(simulations[choices[i]].getName(), simulations[choices[i]].getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), SimResultsViewer.getParamScanInfo(simulations[choices[i]], (currentSimNameSimDataID == null ? 0 : currentSimNameSimDataID.getDefaultJobIndex())));
                    }
                }
            } catch (UserCancelException uce) {
            // ignore
            }
        }

        public void selectParamScanInfo() {
            String[][] rowData = new String[currentSimNameSimDataID.getExportParamScanInfo().getParamScanJobIndexes().length][currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantNames().length];
            for (int i = 0; i < rowData.length; i++) {
                for (int j = 0; j < rowData[i].length; j++) {
                    rowData[i][j] = currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantValues()[i][j];
                }
            }
            try {
                int[] choices = DialogUtils.showComponentOKCancelTableList(PDEExportDataPanel.this, "Choose ParameterScans to export together", currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantNames(), rowData, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                if (choices != null && choices.length > 0) {
                    selectedParamScanIndexes = new int[choices.length];
                    // String[][] selectedParamScanValues = new String[choices.length][currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantNames().length];
                    for (int i = 0; i < choices.length; i++) {
                        selectedParamScanIndexes[i] = choices[i];
                    // for (int j = 0; j < currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantNames().length; j++) {
                    // selectedParamScanValues[i][j] = currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantValues()[choices[i]][j];
                    // }
                    }
                // exportParamScanInfo =
                // new ExportSpecs.ExportParamScanInfo(selectedParamScanIndexes, selectedParamScanIndexes[0], currentSimNameSimDataID.getExportParamScanInfo().getParamScanConstantNames(), selectedParamScanValues);
                } else {
                    selectedParamScanIndexes = null;
                }
            } catch (UserCancelException uce) {
            // ignore
            }
        }

        public int[] getselectedParamScanIndexes() {
            return selectedParamScanIndexes;
        }

        public int getNumAvailableParamScans() {
            if (currentSimNameSimDataID == null || currentSimNameSimDataID.getExportParamScanInfo() == null) {
                return 0;
            }
            return currentSimNameSimDataID.getExportParamScanInfo().getParamScanJobIndexes().length;
        }

        public int getNumAvailableSimulations() {
            if (simulations == null) {
                VCDocument thisDocument = (getDataViewerManager() instanceof DocumentWindowManager ? ((DocumentWindowManager) getDataViewerManager()).getVCDocument() : null);
                if (thisDocument instanceof BioModel) {
                    String thisSimContextName = dataInfoProvider.getSimulationModelInfo().getContextName();
                    SimulationContext[] simContexts = ((BioModel) thisDocument).getSimulationContexts();
                    SimulationContext thisSimulationContext = null;
                    for (int i = 0; i < simContexts.length; i++) {
                        if (thisSimContextName.equals(thisDocument.getName() + "::" + simContexts[i].getName())) {
                            thisSimulationContext = simContexts[i];
                            break;
                        }
                    }
                    simulations = thisSimulationContext.getSimulations();
                } else if (thisDocument instanceof MathModel) {
                    simulations = ((MathModel) thisDocument).getSimulations();
                } else {
                    simulations = new Simulation[0];
                }
            }
            return simulations.length;
        }
    };
    return simulationSelector;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) ExportSpecs(cbit.vcell.export.server.ExportSpecs) UserCancelException(org.vcell.util.UserCancelException) SimulationContext(cbit.vcell.mapping.SimulationContext) SimNameSimDataID(cbit.vcell.export.server.ExportSpecs.SimNameSimDataID) Simulation(cbit.vcell.solver.Simulation) SimNameSimDataID(cbit.vcell.export.server.ExportSpecs.SimNameSimDataID) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) BioModel(cbit.vcell.biomodel.BioModel)

Example 2 with DocumentWindowManager

use of cbit.vcell.client.DocumentWindowManager in project vcell by virtualcell.

the class DocumentValidTask method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
    if (documentWindowManager.getVCDocument() instanceof BioModel) {
        // try to successfully generate math and geometry region info
        BioModel bioModel = (BioModel) documentWindowManager.getVCDocument();
        SimulationContext[] scArray = bioModel.getSimulationContexts();
        if (scArray != null) {
            MathDescription[] mathDescArray = new MathDescription[scArray.length];
            for (int i = 0; i < scArray.length; i++) {
                // check if all structure sizes are specified
                scArray[i].checkValidity();
                // 
                // compute Geometric Regions if necessary
                // 
                cbit.vcell.geometry.surface.GeometrySurfaceDescription geoSurfaceDescription = scArray[i].getGeometry().getGeometrySurfaceDescription();
                if (geoSurfaceDescription != null && geoSurfaceDescription.getGeometricRegions() == null) {
                    cbit.vcell.geometry.surface.GeometrySurfaceUtils.updateGeometricRegions(geoSurfaceDescription);
                }
                if (scArray[i].getModel() != bioModel.getModel()) {
                    throw new Exception("The BioModel's physiology doesn't match that for Application '" + scArray[i].getName() + "'");
                }
                // 
                // create new MathDescription
                // 
                MathDescription math = scArray[i].createNewMathMapping().getMathDescription();
                // 
                // load MathDescription into SimulationContext
                // (BioModel is responsible for propagating this to all applicable Simulations).
                // 
                mathDescArray[i] = math;
            }
            hashTable.put("mathDescArray", mathDescArray);
        }
        // check issues for errors
        DocumentValidUtil.checkIssuesForErrors(bioModel);
    // Vector<Issue> issueList = new Vector<Issue>();
    // IssueContext issueContext = new IssueContext();
    // bioModel.gatherIssues(issueContext,issueList);
    // for (int i = 0; i < issueList.size(); i++){
    // Issue issue = issueList.elementAt(i);
    // if (issue.getSeverity() == Issue.SEVERITY_ERROR){
    // String errMsg = "Error: ";
    // Object issueSource = issue.getSource();
    // if (issueSource instanceof OutputFunctionIssueSource) {
    // SimulationOwner simulationOwner = ((OutputFunctionIssueSource)issueSource).getOutputFunctionContext().getSimulationOwner();
    // String funcName = ((OutputFunctionIssueSource)issueSource).getAnnotatedFunction().getDisplayName();
    // if (simulationOwner instanceof SimulationContext) {
    // String opErrMsg = "Output Function '" + funcName + "' in application '" + simulationOwner.getName() + "' ";
    // if (issue.getCategory().equals(IssueCategory.OUTPUTFUNCTIONCONTEXT_FUNCTION_EXPBINDING)) {
    // opErrMsg += "refers to an unknown variable. Either the model changed or this version of VCell generates variable names differently.\n\n";
    // }
    // errMsg += opErrMsg;
    // }
    // }
    // throw new Exception(errMsg + issue.getMessage());
    // }
    // }
    }
    if (documentWindowManager.getVCDocument() instanceof cbit.vcell.geometry.Geometry) {
        // try to successfully generate GeometricRegions if spatial and not present.
        cbit.vcell.geometry.Geometry geometry = (cbit.vcell.geometry.Geometry) documentWindowManager.getVCDocument();
        if (geometry.getGeometrySurfaceDescription() != null && geometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
            try {
                cbit.vcell.geometry.surface.GeometrySurfaceUtils.updateGeometricRegions(geometry.getGeometrySurfaceDescription());
            } catch (Exception e) {
                throw new Exception("Error determining regions in spatial geometry '" + geometry.getName() + "': \n" + e.getMessage());
            }
        }
    }
    if (documentWindowManager.getVCDocument() instanceof cbit.vcell.mathmodel.MathModel) {
        // try to successfully generate GeometricRegions if spatial and not present.
        cbit.vcell.mathmodel.MathModel mathModel = (cbit.vcell.mathmodel.MathModel) documentWindowManager.getVCDocument();
        cbit.vcell.geometry.Geometry geometry = mathModel.getMathDescription().getGeometry();
        if (geometry.getGeometrySurfaceDescription() != null && geometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
            try {
                cbit.vcell.geometry.surface.GeometrySurfaceUtils.updateGeometricRegions(geometry.getGeometrySurfaceDescription());
            } catch (Exception e) {
                throw new Exception("Error determining regions in spatial geometry '" + geometry.getName() + "': \n" + e.getMessage());
            }
        }
    }
}
Also used : MathDescription(cbit.vcell.math.MathDescription) SimulationContext(cbit.vcell.mapping.SimulationContext) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) BioModel(cbit.vcell.biomodel.BioModel)

Example 3 with DocumentWindowManager

use of cbit.vcell.client.DocumentWindowManager in project vcell by virtualcell.

the class NewName method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
    VCDocument document = documentWindowManager.getVCDocument();
    if (document.getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
        if (((MathModelWindowManager) documentWindowManager).hasUnappliedChanges()) {
            String msg = "Changes have been made in VCML Editor, please click \"Apply Changes\" or \"Cancel\" to proceed.";
            PopupGenerator.showErrorDialog(documentWindowManager, msg);
            throw UserCancelException.CANCEL_UNAPPLIED_CHANGES;
        }
    }
    MDIManager mdiManager = (MDIManager) hashTable.get("mdiManager");
    String oldName = document.getName();
    User user = mdiManager.getFocusedWindowManager().getRequestManager().getDocumentManager().getUser();
    DocumentManager documentManager = mdiManager.getFocusedWindowManager().getRequestManager().getDocumentManager();
    VCDocumentInfo[] vcDocumentInfos = new VCDocumentInfo[0];
    String documentTypeDescription = "unknown";
    if (document.getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
        documentTypeDescription = "MathModel";
        vcDocumentInfos = documentManager.getMathModelInfos();
    } else if (document.getDocumentType() == VCDocumentType.BIOMODEL_DOC) {
        documentTypeDescription = "BioModel";
        vcDocumentInfos = documentManager.getBioModelInfos();
    } else if (document.getDocumentType() == VCDocumentType.GEOMETRY_DOC) {
        documentTypeDescription = "Geometry";
        vcDocumentInfos = documentManager.getGeometryInfos();
    }
    String newDocumentName = (oldName == null ? "New" + documentTypeDescription : oldName);
    while (true) {
        newDocumentName = mdiManager.getDatabaseWindowManager().showSaveDialog(document.getDocumentType(), (Component) hashTable.get("currentDocumentWindow"), newDocumentName);
        if (newDocumentName == null || newDocumentName.trim().length() == 0) {
            newDocumentName = null;
            DialogUtils.showWarningDialog((Component) hashTable.get("currentDocumentWindow"), "New " + documentTypeDescription + " name cannot be empty.");
            continue;
        }
        // Check name conflict
        boolean bNameConflict = false;
        for (int i = 0; i < vcDocumentInfos.length; i++) {
            if (vcDocumentInfos[i].getVersion().getOwner().compareEqual(user)) {
                if (vcDocumentInfos[i].getVersion().getName().equals(newDocumentName)) {
                    bNameConflict = true;
                    break;
                }
            }
        }
        if (bNameConflict) {
            DialogUtils.showWarningDialog((Component) hashTable.get("currentDocumentWindow"), "A " + documentTypeDescription + " with name '" + newDocumentName + "' already exists.  Choose a different name.");
            continue;
        } else {
            break;
        }
    }
    hashTable.put("newName", newDocumentName);
}
Also used : MDIManager(cbit.vcell.client.MDIManager) User(org.vcell.util.document.User) VCDocument(org.vcell.util.document.VCDocument) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) DocumentManager(cbit.vcell.clientdb.DocumentManager) Component(java.awt.Component) MathModelWindowManager(cbit.vcell.client.MathModelWindowManager)

Example 4 with DocumentWindowManager

use of cbit.vcell.client.DocumentWindowManager in project vcell by virtualcell.

the class VCellClientTest method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    class ParseVCellUserEvents implements Runnable {

        AWTEvent event;

        public ParseVCellUserEvents(AWTEvent event) {
            this.event = event;
        }

        @Override
        public void run() {
            if (event instanceof MouseEvent) {
                MouseEvent mouseEvent = (MouseEvent) event;
                Object details = null;
                if (mouseEvent.getID() == MouseEvent.MOUSE_RELEASED) {
                    if (mouseEvent.getComponent() instanceof JTable) {
                        JTable comp = (JTable) mouseEvent.getComponent();
                        int[] selRows = comp.getSelectedRows();
                        if (selRows != null && selRows.length > 0) {
                            StringBuffer sb = new StringBuffer();
                            for (int i = 0; i < selRows.length; i++) {
                                for (int j = 0; j < comp.getColumnCount(); j++) {
                                    try {
                                        sb.append((j == 0 ? "" : ",") + comp.getColumnName(j) + "='" + comp.getModel().getValueAt(selRows[i], j) + "'");
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                            details = sb.toString();
                        }
                    } else if (mouseEvent.getComponent() instanceof JTree) {
                        JTree comp = (JTree) mouseEvent.getComponent();
                        TreePath treePath = comp.getSelectionPath();
                        if (treePath != null) {
                            details = treePath.getLastPathComponent();
                            // BioModel, MathModel, Geometry document tree selections
                            if (details instanceof BioModelNode) {
                                // VCellBasicCellRenderer.VCDocumentInfoNode
                                BioModelNode bioModelNode = (BioModelNode) details;
                                boolean isVCDocumentInfo = bioModelNode.getUserObject() instanceof VCDocumentInfo;
                                boolean isBioModelsNetModelInfo = bioModelNode.getUserObject() instanceof BioModelsNetModelInfo;
                                if (!isVCDocumentInfo && bioModelNode.getChildCount() > 0 && bioModelNode.getUserObject() instanceof VCellBasicCellRenderer.VCDocumentInfoNode) {
                                    TreeNode treeNode = bioModelNode.getFirstChild();
                                    if (treeNode instanceof BioModelNode && ((BioModelNode) treeNode).getUserObject() instanceof VCDocumentInfo) {
                                        details = ((BioModelNode) treeNode).getUserObject();
                                    }
                                } else if (isBioModelsNetModelInfo) {
                                    details = BioModelsNetModelInfo.class.getSimpleName() + " '" + ((BioModelsNetModelInfo) bioModelNode.getUserObject()).getName() + "'";
                                }
                            }
                        }
                    } else if (mouseEvent.getComponent() instanceof JTabbedPane) {
                        JTabbedPane comp = (JTabbedPane) mouseEvent.getComponent();
                        details = "'" + comp.getTitleAt(comp.getSelectedIndex()) + "'";
                    } else if (mouseEvent.getComponent() instanceof JMenuItem) {
                        JMenuItem comp = (JMenuItem) mouseEvent.getComponent();
                        details = "'" + comp.getText() + "'";
                    } else if (mouseEvent.getComponent() instanceof AbstractButton) {
                        AbstractButton comp = (AbstractButton) mouseEvent.getComponent();
                        Boolean bSelected = (comp instanceof JToggleButton ? ((JToggleButton) comp).isSelected() : null);
                        details = (bSelected != null ? "(" + (bSelected ? "selected" : "unselected") + ")" : "") + "'" + comp.getText() + "'";
                    } else if (mouseEvent.getComponent() instanceof JComboBox<?>) {
                        JComboBox<?> comp = (JComboBox<?>) mouseEvent.getComponent();
                        details = "'" + comp.getSelectedItem().toString() + "'";
                    } else if (mouseEvent.getComponent() instanceof JList<?>) {
                        JList<?> comp = (JList<?>) mouseEvent.getComponent();
                        details = "'" + comp.getSelectedValue() + "'";
                    } else {
                        details = "TBD " + mouseEvent.getComponent();
                    }
                    Component parentComponent = mouseEvent.getComponent();
                    StringBuffer parentInfo = new StringBuffer();
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(BeanUtils.vcDateFormat, Locale.US);
                    do {
                        String title = "";
                        if (parentComponent instanceof Dialog) {
                            title = ((Dialog) parentComponent).getTitle();
                        } else if (parentComponent instanceof Frame) {
                            title = ((Frame) parentComponent).getTitle();
                        }
                        parentInfo.append(parentComponent.getClass().getTypeName() + "(" + parentComponent.getName() + (title != null && title.length() > 0 ? ",title='" + title + "'" : "") + ")");
                        if (parentComponent instanceof DocumentWindow && ((DocumentWindow) parentComponent).getTopLevelWindowManager() instanceof DocumentWindowManager) {
                            VCDocument vcDocument = ((DocumentWindowManager) ((DocumentWindow) parentComponent).getTopLevelWindowManager()).getVCDocument();
                            if (vcDocument != null) {
                                String date = (vcDocument.getVersion() != null && vcDocument.getVersion().getDate() != null ? simpleDateFormat.format(vcDocument.getVersion().getDate()) : "nodate");
                                parentInfo.append("doc=" + vcDocument.getDocumentType() + " '" + vcDocument.getName() + "' " + date);
                            }
                        }
                        parentInfo.append(" -> ");
                    } while ((parentComponent = parentComponent.getParent()) != null);
                    // try to add event, if full remove an event from the top
                    while (!recordedUserEvents.offer(mouseEvent.getClickCount() + " " + (details == null ? "null" : details.toString()) + BeanUtils.PLAINTEXT_EMAIL_NEWLINE + parentInfo.toString())) {
                        recordedUserEvents.poll();
                    }
                }
            }
        }
    }
    ;
    AWTEventListener awtEventListener = new AWTEventListener() {

        @Override
        public void eventDispatched(final AWTEvent event) {
            if (event instanceof MouseEvent) {
                if (((MouseEvent) event).getID() == MouseEvent.MOUSE_RELEASED) {
                    new Thread(new ParseVCellUserEvents(event)).start();
                }
            }
        }
    };
    Toolkit.getDefaultToolkit().addAWTEventListener(awtEventListener, AWTEvent.MOUSE_EVENT_MASK);
    // check synchronize Proxy prefs, Proxy Properties
    Preferences prefs = Preferences.userNodeForPackage(RemoteProxyVCellConnectionFactory.class);
    Boolean bHttp = (System.getProperty(NetworkProxyUtils.PROXY_HTTP_HOST) == null && System.getProperty(NetworkProxyUtils.PROXY_SOCKS_HOST) == null ? null : System.getProperty(NetworkProxyUtils.PROXY_HTTP_HOST) != null);
    String currentProxyHost = (bHttp == null ? null : (bHttp ? System.getProperty(NetworkProxyUtils.PROXY_HTTP_HOST) : System.getProperty(NetworkProxyUtils.PROXY_SOCKS_HOST)));
    String currentProxyPort = (bHttp == null ? null : (bHttp ? System.getProperty(NetworkProxyUtils.PROXY_HTTP_PORT) : System.getProperty(NetworkProxyUtils.PROXY_SOCKS_PORT)));
    NetworkProxyUtils.setProxyProperties(false, null, prefs.get(NetworkProxyPreferences.prefProxyType, NetworkProxyPreferences.prefProxyType), currentProxyHost, currentProxyPort, prefs.get(NetworkProxyPreferences.prefProxyType, NetworkProxyPreferences.prefProxyType), prefs.get(NetworkProxyPreferences.prefProxyHost, NetworkProxyPreferences.prefProxyHost), prefs.get(NetworkProxyPreferences.prefProxyPort, NetworkProxyPreferences.prefProxyPort));
    final boolean IS_DEBUG = ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
    if (!IS_DEBUG) {
        String siteName = VCellSoftwareVersion.fromSystemProperty().getSite().name().toLowerCase();
        ConsoleCapture.getInstance().captureStandardOutAndError(new File(ResourceUtil.getLogDir(), "vcellrun_" + siteName + ".log"));
    }
    Logging.init();
    ErrorUtils.setDebug(IS_DEBUG);
    if (args != null && args.length >= 1 && args[0].equals("-console")) {
        // remove install4j parameter
        List<String> newArgs = new ArrayList<String>();
        newArgs.addAll(Arrays.asList(args));
        newArgs.remove(0);
        args = newArgs.toArray(new String[0]);
    }
    StringBuffer stringBuffer = new StringBuffer();
    for (int i = 0; i < args.length; i++) {
        stringBuffer.append("arg" + i + "=\"" + args[i] + "\" ");
    }
    System.out.println("starting with arguments [" + stringBuffer + "]");
    System.out.println("Running under Java major version: ONE point " + ResourceUtil.getJavaVersion().toString() + ".  Specifically: Java " + (System.getProperty("java.version")) + ", published by " + (System.getProperty("java.vendor")) + ", on the " + (System.getProperty("os.arch")) + " architecture running version " + (System.getProperty("os.version")) + " of the " + (System.getProperty("os.name")) + " operating system");
    ClientServerInfo csInfo = null;
    String hoststr = System.getProperty(PropertyLoader.vcellServerHost);
    String[] hosts = null;
    if (hoststr != null) {
        StringTokenizer st = new StringTokenizer(hoststr, " ,;");
        if (st.countTokens() >= 1) {
            hosts = new String[st.countTokens()];
            int count = 0;
            while (st.hasMoreTokens()) {
                hosts[count++] = st.nextToken();
            }
        }
    }
    if (hosts == null) {
        hosts = new String[1];
    }
    String user = null;
    String password = null;
    VCDocument initialDocument = null;
    if (args.length == 3) {
        hosts[0] = args[0];
        user = args[1];
        password = args[2];
    } else if (args.length == 0) {
    // this is ok
    } else if (args.length == 1) {
        // Check if arg is drag-n-drop file or a 'hostname'
        try {
            // drag and drop file on install4j VCell launcher will pass filepath as single arg to VCell
            File openThisVCellFile = new File(args[0]);
            if (openThisVCellFile.exists() && openThisVCellFile.isFile()) {
                initialDocument = startupWithOpen(args[0]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        // continue to hostname check
        }
        // If startup file not exist assume arg is a hostname
        if (initialDocument == null) {
            hosts[0] = args[0];
        }
    // If install4j drag-n-drop, hosts[0] stays null and host is assumed to be loaded from a client property
    } else if (args.length == 2 && args[0].equals("-open")) {
        // hosts[0] = "-local";
        initialDocument = startupWithOpen(args[1]);
    } else {
        System.out.println("usage: VCellClientTest ( ((-local|host[:port]) [userid password]) | ([-open] filename) )");
        System.exit(1);
    }
    if (hosts[0] != null && hosts[0].equalsIgnoreCase("-local")) {
        csInfo = ClientServerInfo.createLocalServerInfo(user, (password == null || password.length() == 0 ? null : new UserLoginInfo.DigestedPassword(password)));
    } else {
        String[] hostParts = hosts[0].split(":");
        String apihost = hostParts[0];
        int apiport = Integer.parseInt(hostParts[1]);
        csInfo = ClientServerInfo.createRemoteServerInfo(apihost, apiport, user, (password == null || password.length() == 0 ? null : new UserLoginInfo.DigestedPassword(password)));
    }
    try {
        String propertyFile = PropertyLoader.getProperty(PropertyLoader.propertyFileProperty, "");
        if (propertyFile.length() > 0) {
            PropertyLoader.loadProperties(ArrayUtils.addAll(REQUIRED_CLIENT_PROPERTIES, REQUIRED_LOCAL_PROPERTIES));
            try {
                VCMongoMessage.enabled = true;
                VCMongoMessage.serviceStartup(ServiceName.client, null, null);
                PropertyLoader.sendErrorsToMongo();
            } catch (Exception e) {
                System.out.println("failed to start Mongo logging");
            }
        } else {
            PropertyLoader.loadProperties(REQUIRED_CLIENT_PROPERTIES);
            VCMongoMessage.enabled = false;
        }
        // call in main thread, since it's quick and not necessarily thread safe
        ResourceUtil.setNativeLibraryDirectory();
        vcellClient = VCellClient.startClient(initialDocument, csInfo);
        VCellClientDataService vcellClientDataService = new VCellClientDataServiceImpl(vcellClient);
        VCellProxyServer.startVCellVisitDataServerThread(vcellClientDataService);
        // starting loading libraries
        new LibraryLoaderThread(true).start();
        try {
            PythonSupport.verifyInstallation(PythonPackage.values());
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    // SimulationService.Iface simService = new SimulationServiceImpl();
    // VCellIJServer.startVCellVisitDataServerThread(simService, false);
    } catch (Throwable exception) {
        ErrorUtils.sendRemoteLogMessage(csInfo.getUserLoginInfo(), csInfo.toString() + "\nvcell startup failed\n\n" + exception.getMessage());
        JOptionPane.showMessageDialog(null, exception.getMessage(), "Fatal Error", JOptionPane.OK_OPTION);
        System.err.println("Exception occurred in main() of VCellApplication");
        exception.printStackTrace(System.out);
    }
}
Also used : VCellClientDataService(cbit.vcell.client.pyvcellproxy.VCellClientDataService) BioModelsNetModelInfo(cbit.vcell.client.desktop.biomodel.BioModelsNetModelInfo) ArrayList(java.util.ArrayList) ClientServerInfo(cbit.vcell.client.server.ClientServerInfo) JToggleButton(javax.swing.JToggleButton) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) TreeNode(javax.swing.tree.TreeNode) Dialog(java.awt.Dialog) AWTEvent(java.awt.AWTEvent) AbstractButton(javax.swing.AbstractButton) VCDocument(org.vcell.util.document.VCDocument) DocumentWindow(cbit.vcell.client.desktop.DocumentWindow) JTree(javax.swing.JTree) JTable(javax.swing.JTable) File(java.io.File) JList(javax.swing.JList) Frame(java.awt.Frame) AWTEventListener(java.awt.event.AWTEventListener) JTabbedPane(javax.swing.JTabbedPane) BioModelNode(cbit.vcell.desktop.BioModelNode) VCellClientDataServiceImpl(cbit.vcell.client.data.VCellClientDataServiceImpl) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) NetworkProxyPreferences(cbit.vcell.client.desktop.NetworkProxyPreferences) Preferences(java.util.prefs.Preferences) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) LibraryLoaderThread(cbit.vcell.resource.LibraryLoaderThread) LibraryLoaderThread(cbit.vcell.resource.LibraryLoaderThread) StringTokenizer(java.util.StringTokenizer) TreePath(javax.swing.tree.TreePath) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with DocumentWindowManager

use of cbit.vcell.client.DocumentWindowManager in project vcell by virtualcell.

the class DocumentWindow method showViewJobsDialog.

public void showViewJobsDialog() {
    System.out.println("ViewJobs menu item pressed.");
    // https://vcellapi.cam.uchc.edu:8080/simtask?submitLow=&submitHigh=&startRow=1&maxRows=100&serverId=&computeHost+value%3D=&simId=&jobId=&taskId=&hasData=all&queued=on&dispatched=on&running=on
    DocumentWindowManager dwm = getWindowManager();
    ViewJobsPanel panel = new ViewJobsPanel(dwm);
    panel.setPreferredSize(new Dimension(1000, 600));
    if (viewSpeciesDialog != null) {
        // uncomment these 3 lines to allow only one instance of the dialog
        viewSpeciesDialog.dispose();
    }
    JOptionPane pane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[] { "Close" });
    viewSpeciesDialog = pane.createDialog(this, "View Simulation Jobs Status");
    viewSpeciesDialog.setModal(false);
    viewSpeciesDialog.setResizable(true);
    viewSpeciesDialog.setVisible(true);
}
Also used : DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) Dimension(java.awt.Dimension) JOptionPane(javax.swing.JOptionPane)

Aggregations

DocumentWindowManager (cbit.vcell.client.DocumentWindowManager)15 VCDocument (org.vcell.util.document.VCDocument)9 BioModel (cbit.vcell.biomodel.BioModel)6 DocumentManager (cbit.vcell.clientdb.DocumentManager)6 MathModel (cbit.vcell.mathmodel.MathModel)4 Simulation (cbit.vcell.solver.Simulation)4 SimulationContext (cbit.vcell.mapping.SimulationContext)3 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)3 MDIManager (cbit.vcell.client.MDIManager)2 MathModelWindowManager (cbit.vcell.client.MathModelWindowManager)2 Geometry (cbit.vcell.geometry.Geometry)2 GeometryInfo (cbit.vcell.geometry.GeometryInfo)2 MathDescription (cbit.vcell.math.MathDescription)2 Component (java.awt.Component)2 Hashtable (java.util.Hashtable)2 BioModelInfo (org.vcell.util.document.BioModelInfo)2 MathModelInfo (org.vcell.util.document.MathModelInfo)2 Version (org.vcell.util.document.Version)2 ClientSimManager (cbit.vcell.client.ClientSimManager)1 DatabaseWindowManager (cbit.vcell.client.DatabaseWindowManager)1