Search in sources :

Example 26 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class TestingFrameworkPanel method getTreeSelection.

/**
 * Comment
 */
public Object getTreeSelection() {
    TreeSelectionModel treeSelectionModel = getselectionModel();
    TreePath treePath = treeSelectionModel.getSelectionPath();
    if (treePath == null) {
        return null;
    }
    BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
    Object object = bioModelNode.getUserObject();
    return object;
}
Also used : TreePath(javax.swing.tree.TreePath) BioModelNode(cbit.vcell.desktop.BioModelNode) TreeSelectionModel(javax.swing.tree.TreeSelectionModel)

Example 27 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class TestingFrameworkPanel method selectInTreeView.

public void selectInTreeView(final BigDecimal testSuiteKey, final BigDecimal testCaseKey, final BigDecimal testCriteriaKey) {
    new Thread(new Runnable() {

        public void run() {
            long WAIT_TIME_MILLISEC = 20000;
            long startTime = System.currentTimeMillis();
            boolean UPDATE_IN_PROGRESS = false;
            do {
                if ((System.currentTimeMillis() - startTime) >= WAIT_TIME_MILLISEC) {
                    return;
                }
                final BioModelNode testSuiteRootNode = TestingFrmwkTreeModel.getTestSuiteRoot((DefaultTreeModel) getJTree1().getModel());
                for (int i = 0; i < testSuiteRootNode.getChildCount(); i++) {
                    final int finalI = i;
                    TestSuiteInfoNew tsInfo = (TestSuiteInfoNew) ((BioModelNode) testSuiteRootNode.getChildAt(i)).getUserObject();
                    if (tsInfo.getTSKey().equals(testSuiteKey)) {
                        if (testCaseKey != null) {
                            if (TestingFrameworkPanel.hasNullChild((BioModelNode) testSuiteRootNode.getChildAt(i))) {
                                if (UPDATE_IN_PROGRESS) {
                                    break;
                                }
                                AsynchClientTask[] tasksArr = new AsynchClientTask[] { new TFUpdateRunningStatus(getTestingFrameworkWindowManager(), tsInfo), new TFRefresh(getTestingFrameworkWindowManager(), tsInfo) };
                                ClientTaskDispatcher.dispatch(TestingFrameworkPanel.this, new Hashtable<String, Object>(), tasksArr, true);
                                UPDATE_IN_PROGRESS = true;
                                break;
                            }
                            UPDATE_IN_PROGRESS = false;
                            for (int j = 0; j < testSuiteRootNode.getChildAt(i).getChildCount(); j++) {
                                final int finalJ = j;
                                TestCaseNew tcase = (TestCaseNew) ((BioModelNode) testSuiteRootNode.getChildAt(i).getChildAt(j)).getUserObject();
                                if (tcase.getTCKey().equals(testCaseKey)) {
                                    if (testCriteriaKey != null) {
                                        for (int k = 0; k < testSuiteRootNode.getChildAt(i).getChildAt(j).getChildCount(); k++) {
                                            final int finalK = k;
                                            TestCriteriaNew tcrit = (TestCriteriaNew) ((BioModelNode) testSuiteRootNode.getChildAt(i).getChildAt(j).getChildAt(k)).getUserObject();
                                            if (tcrit.getTCritKey().equals(testCriteriaKey)) {
                                                SwingUtilities.invokeLater(new Runnable() {

                                                    public void run() {
                                                        TreePath treePath = new TreePath(((DefaultTreeModel) getJTree1().getModel()).getPathToRoot(testSuiteRootNode.getChildAt(finalI).getChildAt(finalJ).getChildAt(finalK)));
                                                        getJTree1().setSelectionPath(treePath);
                                                        getJTree1().scrollPathToVisible(treePath);
                                                    }
                                                });
                                                break;
                                            }
                                        }
                                        ;
                                    } else {
                                        SwingUtilities.invokeLater(new Runnable() {

                                            public void run() {
                                                TreePath treePath = new TreePath(((DefaultTreeModel) getJTree1().getModel()).getPathToRoot(testSuiteRootNode.getChildAt(finalI).getChildAt(finalJ)));
                                                getJTree1().setSelectionPath(treePath);
                                                getJTree1().scrollPathToVisible(treePath);
                                            }
                                        });
                                        break;
                                    }
                                }
                            }
                        } else {
                            SwingUtilities.invokeLater(new Runnable() {

                                public void run() {
                                    TreePath treePath = new TreePath(((DefaultTreeModel) getJTree1().getModel()).getPathToRoot(testSuiteRootNode.getChildAt(finalI)));
                                    getJTree1().setSelectionPath(treePath);
                                    getJTree1().scrollPathToVisible(treePath);
                                }
                            });
                            break;
                        }
                    }
                }
            } while (UPDATE_IN_PROGRESS);
        }
    }).start();
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) BioModelNode(cbit.vcell.desktop.BioModelNode) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TFUpdateRunningStatus(cbit.vcell.client.task.TFUpdateRunningStatus) TreePath(javax.swing.tree.TreePath) TFRefresh(cbit.vcell.client.task.TFRefresh) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew)

Example 28 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class TestingFrmwkTreeModel method refreshTree.

public void refreshTree(LoadTestInfoOpResults loadTestInfoOpResults) {
    // Create Load Test Info Tree
    // BioModelNode loadTestNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_SUBTREE_NAME, true);
    BioModelNode[] infoNodeArr = new BioModelNode[loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps().length];
    for (int i = 0; i < loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps().length; i++) {
        LoadTestTreeInfo loadTestTreeInfo = new LoadTestTreeInfo();
        loadTestTreeInfo.loadTestSoftwareVersionTimeStamp = loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i];
        loadTestTreeInfo.userid = null;
        loadTestTreeInfo.bioOrMathModelKey = null;
        String progress = "";
        if (loadTestInfoOpResults.getLoadTestInfoEmptyCounts()[i] != null) {
            double progPercent = (double) (loadTestInfoOpResults.getLoadTestInfoCounts()[i] - loadTestInfoOpResults.getLoadTestInfoEmptyCounts()[i]) / (double) loadTestInfoOpResults.getLoadTestInfoCounts()[i];
            progress = " [working " + NumberUtils.formatNumber(progPercent * 100, 3) + "%]";
        }
        loadTestTreeInfo.treeDisplayText = loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i].getSoftwareVersion() + " " + loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i].getRunTimeStamp() + " testSize=" + loadTestInfoOpResults.getLoadTestInfoCounts()[i] + " (all BM/MM =" + loadTestInfoOpResults.getTotalBioAndMathmodelCount() + ")" + progress;
        BioModelNode detailsNode = new BioModelNode(loadTestTreeInfo, true);
        // 
        // Create Fail subtree
        // 
        Vector<LoadTestInfoOpResults.LoadTestFailDetails> failDetailsV = loadTestInfoOpResults.getLoadTestFailHash().get(loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i]);
        BioModelNode loadTestFailNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_FAIL_NAME + (failDetailsV == null ? " (0)" : " (" + failDetailsV.size() + ")"), failDetailsV != null);
        if (failDetailsV != null) {
            LoadTestInfoOpResults.LoadTestFailDetails[] sortedDetails = failDetailsV.toArray(new LoadTestInfoOpResults.LoadTestFailDetails[0]);
            Arrays.sort(sortedDetails, new Comparator<LoadTestInfoOpResults.LoadTestFailDetails>() {

                public int compare(LoadTestInfoOpResults.LoadTestFailDetails o1, LoadTestInfoOpResults.LoadTestFailDetails o2) {
                    return o1.errorMessage.compareToIgnoreCase(o2.errorMessage);
                }
            });
            for (int j = 0; j < sortedDetails.length; j++) {
                LoadTestTreeInfo loadTestFailTreeInfo = new LoadTestTreeInfo();
                loadTestFailTreeInfo.loadTestSoftwareVersionTimeStamp = loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i];
                loadTestFailTreeInfo.userid = sortedDetails[j].userid;
                loadTestFailTreeInfo.bioOrMathModelKey = sortedDetails[j].modelKeyValue;
                loadTestFailTreeInfo.modelType = sortedDetails[j].modelType;
                loadTestFailTreeInfo.treeDisplayText = sortedDetails[j].userid + " [" + sortedDetails[j].modelType + "] '" + sortedDetails[j].modelName + "'     " + sortedDetails[j].errorMessage;
                BioModelNode detailNode = new BioModelNode(loadTestFailTreeInfo, false);
                loadTestFailNode.add(detailNode);
            }
        }
        // Add fail nodes to detailsNode
        detailsNode.add(loadTestFailNode);
        // 
        if (loadTestInfoOpResults.getLoadTestSlowHash() != null) {
            Vector<LoadTestInfoOpResults.LoadTestSlowDetails> slowDetailsV = loadTestInfoOpResults.getLoadTestSlowHash().get(loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i]);
            if (slowDetailsV != null) {
                BioModelNode loadTestSlowNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_SLOW_NAME + " (" + slowDetailsV.size() + " loaded slower than " + loadTestInfoOpResults.getSlowLoadThresholdMillisec() + " miilsecs)", true);
                LoadTestInfoOpResults.LoadTestSlowDetails[] sortedDetails = slowDetailsV.toArray(new LoadTestInfoOpResults.LoadTestSlowDetails[0]);
                Arrays.sort(sortedDetails, new Comparator<LoadTestInfoOpResults.LoadTestSlowDetails>() {

                    public int compare(LoadTestInfoOpResults.LoadTestSlowDetails o1, LoadTestInfoOpResults.LoadTestSlowDetails o2) {
                        return o1.loadTime.compareTo(o2.loadTime);
                    }
                });
                for (int j = 0; j < sortedDetails.length; j++) {
                    LoadTestTreeInfo loadTestSlowTreeInfo = new LoadTestTreeInfo();
                    loadTestSlowTreeInfo.loadTestSoftwareVersionTimeStamp = loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i];
                    loadTestSlowTreeInfo.userid = sortedDetails[j].userid;
                    loadTestSlowTreeInfo.bioOrMathModelKey = sortedDetails[j].modelKeyValue;
                    loadTestSlowTreeInfo.modelType = sortedDetails[j].modelType;
                    loadTestSlowTreeInfo.treeDisplayText = sortedDetails[j].userid + " [" + sortedDetails[j].modelType + "] '" + sortedDetails[j].modelName + "'     millisec=" + sortedDetails[j].loadTime;
                    BioModelNode detailNode = new BioModelNode(loadTestSlowTreeInfo, false);
                    loadTestSlowNode.add(detailNode);
                    // Add slow load nodes to detailsNode
                    detailsNode.add(loadTestSlowNode);
                }
            } else {
                BioModelNode loadTestSlowNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_SLOW_NAME + " (All loaded in < " + loadTestInfoOpResults.getSlowLoadThresholdMillisec() + " miilisecs)", false);
                detailsNode.add(loadTestSlowNode);
            }
        } else {
            BioModelNode loadTestSlowNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_SLOW_NAME + " (No Threshold)", false);
            detailsNode.add(loadTestSlowNode);
        }
        // 
        if (loadTestInfoOpResults.getLoadTestUserQueryHash() != null) {
            Vector<LoadTestInfoOpResults.LoadTestDetails> userQueryDetailsV = loadTestInfoOpResults.getLoadTestUserQueryHash().get(loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i]);
            if (userQueryDetailsV != null) {
                BioModelNode loadTestUserQueryNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_USERQUERY_NAME + " (" + userQueryDetailsV.size() + " records found)", true);
                LoadTestInfoOpResults.LoadTestDetails[] sortedDetails = userQueryDetailsV.toArray(new LoadTestInfoOpResults.LoadTestDetails[0]);
                Arrays.sort(sortedDetails, new Comparator<LoadTestInfoOpResults.LoadTestDetails>() {

                    public int compare(LoadTestInfoOpResults.LoadTestDetails o1, LoadTestInfoOpResults.LoadTestDetails o2) {
                        return o1.userid.compareToIgnoreCase(o2.userid);
                    }
                });
                for (int j = 0; j < sortedDetails.length; j++) {
                    LoadTestTreeInfo loadTestUserQueryTreeInfo = new LoadTestTreeInfo();
                    loadTestUserQueryTreeInfo.loadTestSoftwareVersionTimeStamp = loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i];
                    loadTestUserQueryTreeInfo.userid = sortedDetails[j].userid;
                    loadTestUserQueryTreeInfo.bioOrMathModelKey = sortedDetails[j].modelKeyValue;
                    loadTestUserQueryTreeInfo.modelType = sortedDetails[j].modelType;
                    loadTestUserQueryTreeInfo.treeDisplayText = sortedDetails[j].userid + " [" + sortedDetails[j].modelType + "] '" + sortedDetails[j].modelName + "' id=" + sortedDetails[j].modelKeyValue.toString();
                    BioModelNode detailNode = new BioModelNode(loadTestUserQueryTreeInfo, false);
                    loadTestUserQueryNode.add(detailNode);
                    // Add user query nodes to detailsNode
                    detailsNode.add(loadTestUserQueryNode);
                }
            } else {
                BioModelNode loadTestSlowNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_USERQUERY_NAME + " (No Results For Query)", false);
                detailsNode.add(loadTestSlowNode);
            }
        } else {
            BioModelNode loadTestUserQueryNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_USERQUERY_NAME + " (No User Query)", false);
            detailsNode.add(loadTestUserQueryNode);
        }
        // Save detail nodes for adding to versionTimestamp node
        infoNodeArr[i] = detailsNode;
    }
    // Add versionTimestamp nodes to LoadTest tree
    BioModelNode loadXMLTestRoot = (BioModelNode) getLoadTestRoot(TestingFrmwkTreeModel.this);
    while (loadXMLTestRoot.getChildCount() != 0) {
        removeNodeFromParent((MutableTreeNode) loadXMLTestRoot.getLastChild());
    }
    for (int j = 0; j < infoNodeArr.length; j++) {
        insertNodeInto(infoNodeArr[j], loadXMLTestRoot, j);
    }
}
Also used : LoadTestInfoOpResults(cbit.vcell.numericstest.LoadTestInfoOpResults) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 29 with BioModelNode

use of cbit.vcell.desktop.BioModelNode 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 30 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class CSGObjectPropertiesPanel method showPopupMenu.

private void showPopupMenu(MouseEvent e) {
    if (!e.isPopupTrigger()) {
        return;
    }
    if (popupMenu == null) {
        popupMenu = new JPopupMenu();
    }
    if (popupMenu.isShowing()) {
        return;
    }
    selectClickPath(e);
    TreePath[] selectedPaths = csgObjectTree.getSelectionPaths();
    boolean bShowPopup = true;
    boolean bTransform = false;
    boolean bApplySetOperator = false;
    boolean bAddPrimitive = false;
    boolean bAddTransformation = false;
    boolean bAddOperator = false;
    boolean bEdit = false;
    boolean bDelete = true;
    if (selectedPaths == null) {
        return;
    }
    for (TreePath tp : selectedPaths) {
        Object obj = tp.getLastPathComponent();
        if (obj == null || !(obj instanceof BioModelNode)) {
            continue;
        }
        BioModelNode selectedNode = (BioModelNode) obj;
        Object userObject = selectedNode.getUserObject();
        if (userObject == csgObject) {
            bDelete = false;
            if (csgObject.getRoot() == null) {
                bAddPrimitive = true;
                bAddOperator = true;
                bAddTransformation = true;
            }
        } else if (userObject instanceof CSGPrimitive) {
            bApplySetOperator = true;
            bTransform = true;
            bAddPrimitive = false;
            bAddOperator = false;
            bAddTransformation = false;
        } else if (userObject instanceof CSGSetOperator) {
            bApplySetOperator = true;
            bTransform = true;
            bAddPrimitive = true;
            bAddOperator = true;
            bAddTransformation = true;
        } else if (userObject instanceof CSGTransformation) {
            bApplySetOperator = true;
            bTransform = true;
            bEdit = true;
            if (((CSGTransformation) userObject).getChild() == null) {
                bAddPrimitive = true;
                bAddOperator = true;
                bAddTransformation = true;
            }
        }
    }
    if (bShowPopup) {
        popupMenu.removeAll();
        if (bAddPrimitive || bAddTransformation || bAddOperator) {
            getAddPrimitiveMenu().setEnabled(bAddPrimitive);
            getAddTransformationMenu().setEnabled(bAddTransformation);
            getAddSetOperatorMenu().setEnabled(bAddOperator);
            popupMenu.add(getAddMenu());
        }
        if (popupMenu.getComponents().length > 0) {
            popupMenu.add(new JSeparator());
        }
        // everything can be renamed
        popupMenu.add(getRenameMenuItem());
        if (bEdit) {
            popupMenu.add(getEditMenuItem());
        }
        if (bDelete) {
            popupMenu.add(getDeleteMenuItem());
        }
        if (bTransform) {
            if (popupMenu.getComponents().length > 0) {
                popupMenu.add(new JSeparator());
            }
            popupMenu.add(getTransformMenu());
        }
        if (bApplySetOperator) {
            if (popupMenu.getComponents().length > 0 && !bTransform) {
                popupMenu.add(new JSeparator());
            }
            popupMenu.add(getApplySetOperatorMenu());
        }
        Point mousePoint = e.getPoint();
        popupMenu.show(csgObjectTree, mousePoint.x, mousePoint.y);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) CSGTransformation(cbit.vcell.geometry.CSGTransformation) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGObject(cbit.vcell.geometry.CSGObject) BioModelNode(cbit.vcell.desktop.BioModelNode) Point(java.awt.Point) CSGSetOperator(cbit.vcell.geometry.CSGSetOperator) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator)

Aggregations

BioModelNode (cbit.vcell.desktop.BioModelNode)82 TreePath (javax.swing.tree.TreePath)22 MolecularComponent (org.vcell.model.rbm.MolecularComponent)17 CSGObject (cbit.vcell.geometry.CSGObject)12 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 MolecularType (org.vcell.model.rbm.MolecularType)10 Point (java.awt.Point)9 Icon (javax.swing.Icon)8 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)8 TestSuiteInfoNew (cbit.vcell.numericstest.TestSuiteInfoNew)7 TreeNode (javax.swing.tree.TreeNode)7 DocumentEditorTreeFolderClass (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)6 DocumentEditorTreeFolderNode (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode)6 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)6 TestCriteriaNew (cbit.vcell.numericstest.TestCriteriaNew)6 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)6 BioPaxObject (org.vcell.pathway.BioPaxObject)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 Component (java.awt.Component)5