Search in sources :

Example 1 with BioModelEditor

use of cbit.vcell.client.desktop.biomodel.BioModelEditor in project vcell by virtualcell.

the class NetworkConstraintsPanel method activateConsole.

public void activateConsole() {
    boolean found = false;
    Container parent = getParent();
    while (parent != null) {
        parent = parent.getParent();
        if (parent instanceof BioModelEditor) {
            found = true;
            break;
        }
    }
    if (found) {
        System.out.println("Parent Found");
        BioModelEditor e = (BioModelEditor) parent;
        // e.getRightBottomTabbedPane().setSelectedComponent(e.getSimulationConsolePanel());
        Component[] cList = e.getRightBottomTabbedPane().getComponents();
        for (Component c : cList) {
            if (c instanceof SimulationConsolePanel) {
                e.getRightBottomTabbedPane().setSelectedComponent(c);
                break;
            }
        }
    }
}
Also used : RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) Container(java.awt.Container) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) SimulationConsolePanel(cbit.vcell.client.desktop.biomodel.SimulationConsolePanel) Component(java.awt.Component)

Example 2 with BioModelEditor

use of cbit.vcell.client.desktop.biomodel.BioModelEditor in project vcell by virtualcell.

the class DatabaseWindowPanel method dbTreePanelActionPerformed.

private void dbTreePanelActionPerformed(java.awt.event.ActionEvent e) {
    String actionCommand = e.getActionCommand();
    if (actionCommand.equals("Open") || actionCommand.equals(DatabaseWindowManager.BM_MM_GM_DOUBLE_CLICK_ACTION)) {
        // check to see if open in new or this window
        BioModelEditor bioModelEditor = null;
        Container c = this;
        while (c != null) {
            if (c instanceof BioModelEditor) {
                bioModelEditor = (BioModelEditor) c;
                break;
            }
            c = c.getParent();
        }
        if (bioModelEditor != null && getSelectedDocumentInfo() instanceof BioModelInfo) {
            if (bioModelEditor.getBioModelWindowManager().hasBlankDocument()) {
                getDatabaseWindowManager().openSelected(bioModelEditor.getBioModelWindowManager(), false);
            } else {
                getDatabaseWindowManager().openSelected(bioModelEditor.getBioModelWindowManager(), true);
            }
        } else {
            getDatabaseWindowManager().openSelected();
        }
    } else if (actionCommand.equals("Delete")) {
        getDatabaseWindowManager().deleteSelected();
    } else if (actionCommand.equals("Permission")) {
        getDatabaseWindowManager().accessPermissions();
    } else if (actionCommand.equals("Export")) {
        getDatabaseWindowManager().exportDocument();
    } else if (actionCommand.equals("Latest Edition")) {
        getDatabaseWindowManager().compareLatestEdition();
    } else if (actionCommand.equals("Previous Edition")) {
        getDatabaseWindowManager().comparePreviousEdition();
    } else if (actionCommand.equals("Another Edition...")) {
        getDatabaseWindowManager().compareAnotherEdition();
    } else if (actionCommand.equals("Another Model...")) {
        getDatabaseWindowManager().compareAnotherModel();
    } else if (actionCommand.equals("Models Using Geometry")) {
        getDatabaseWindowManager().findModelsUsingSelectedGeometry();
    } else if (actionCommand.equals("Archive")) {
        getDatabaseWindowManager().archive();
    } else if (actionCommand.equals("Publish")) {
        getDatabaseWindowManager().publish();
    } else if (actionCommand.equals(NEW_GEOMETRY)) {
        getDatabaseWindowManager().createNewGeometry();
    }
}
Also used : Container(java.awt.Container) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 3 with BioModelEditor

use of cbit.vcell.client.desktop.biomodel.BioModelEditor in project vcell by virtualcell.

the class ReactionCartoonTool method detailsDeleteSpecies.

private static DeleteSpeciesInfo detailsDeleteSpecies(Component requester, SpeciesContext[] speciesContextArr, ReactionStep[] toBeDeletedReactStepArr, ReactionCartoon rxCartoon) throws Exception, UserCancelException {
    if (speciesContextArr == null || speciesContextArr.length == 0) {
        return null;
    }
    // Warn user that there may be some BioModel components that reference speciesContext to be removed
    // Get ReactionParticipant list
    Collection<Shape> rxPartColl = rxCartoon.getShapes();
    HashMap<SpeciesContext, HashSet<ReactionParticipant>> rxPartHashMap = new HashMap<SpeciesContext, HashSet<ReactionParticipant>>();
    for (Shape objShape : rxPartColl) {
        if (objShape instanceof ReactionParticipantShape) {
            ReactionParticipant objReactionParticipant = ((ReactionParticipantShape) objShape).getReactionParticipant();
            if (Arrays.asList(speciesContextArr).contains(objReactionParticipant.getSpeciesContext())) {
                if (!rxPartHashMap.containsKey(objReactionParticipant.getSpeciesContext())) {
                    rxPartHashMap.put(objReactionParticipant.getSpeciesContext(), new HashSet<ReactionParticipant>());
                }
                if (!rxPartHashMap.get(objReactionParticipant.getSpeciesContext()).contains(objReactionParticipant)) {
                    rxPartHashMap.get(objReactionParticipant.getSpeciesContext()).add(objReactionParticipant);
                }
            }
        }
    }
    int reactionParticipantCount = 0;
    for (HashSet<ReactionParticipant> objReactPart : rxPartHashMap.values()) {
        reactionParticipantCount += objReactPart.size();
    }
    // find bioModel and get SymbolTable references to SpeciesContext
    BioModelEditor bioModelEditor = (BioModelEditor) BeanUtils.findTypeParentOfComponent(requester, BioModelEditor.class);
    if (bioModelEditor == null) {
        throw new Exception("Error deleting Speciescontext, Can't find BiomodelEditor");
    }
    BioModel bioModel = bioModelEditor.getBioModelWindowManager().getVCDocument();
    HashMap<SpeciesContext, HashSet<SymbolTableEntry>> referencingSymbolsHashMap = new HashMap<SpeciesContext, HashSet<SymbolTableEntry>>();
    for (int i = 0; i < speciesContextArr.length; i++) {
        List<SymbolTableEntry> referencingSymbolsList = bioModel.findReferences(speciesContextArr[i]);
        if (referencingSymbolsList != null && referencingSymbolsList.size() > 0) {
            if (!referencingSymbolsHashMap.containsKey(speciesContextArr[i])) {
                referencingSymbolsHashMap.put(speciesContextArr[i], new HashSet<SymbolTableEntry>());
            }
            referencingSymbolsHashMap.get(speciesContextArr[i]).addAll(referencingSymbolsList);
        }
    }
    int referencingSymbolsCount = 0;
    for (HashSet<SymbolTableEntry> objSimTableEntry : referencingSymbolsHashMap.values()) {
        referencingSymbolsCount += objSimTableEntry.size();
    }
    // Warn user about delete
    HashMap<SpeciesContext, Boolean> bUnresolvableHashMap = new HashMap<SpeciesContext, Boolean>();
    for (int i = 0; i < speciesContextArr.length; i++) {
        bUnresolvableHashMap.put(speciesContextArr[i], Boolean.FALSE);
    }
    String[][] rowData = null;
    if (rxPartHashMap.size() == 0 && referencingSymbolsHashMap.size() == 0) {
        rowData = new String[speciesContextArr.length][4];
        for (int i = 0; i < speciesContextArr.length; i++) {
            rowData[i][0] = speciesContextArr[i].getName();
            rowData[i][1] = "";
            rowData[i][2] = "";
            rowData[i][3] = "";
        }
        Arrays.sort(rowData, new Comparator<String[]>() {

            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[0].compareToIgnoreCase(o2[0]);
            }
        });
    } else {
        // find SpeciesContext that had no reference warnings
        Vector<SpeciesContext> speciesContextNoReferences = new Vector<SpeciesContext>();
        for (int i = 0; i < speciesContextArr.length; i++) {
            if (!rxPartHashMap.containsKey(speciesContextArr[i]) && !referencingSymbolsHashMap.containsKey(speciesContextArr[i])) {
                speciesContextNoReferences.add(speciesContextArr[i]);
            }
        }
        rowData = new String[reactionParticipantCount + referencingSymbolsCount + speciesContextNoReferences.size()][4];
        int count = 0;
        for (SpeciesContext objSpeciesContext : speciesContextNoReferences) {
            rowData[count][0] = objSpeciesContext.getName();
            rowData[count][1] = "";
            rowData[count][2] = "";
            rowData[count][3] = "";
            count++;
        }
        for (SpeciesContext objSpeciesContext : rxPartHashMap.keySet()) {
            Iterator<ReactionParticipant> iterRxPart = rxPartHashMap.get(objSpeciesContext).iterator();
            while (iterRxPart.hasNext()) {
                rowData[count][0] = objSpeciesContext.getName();
                rowData[count][1] = "";
                rowData[count][2] = "Reaction Diagram stoichiometry '" + iterRxPart.next().getReactionStep().getName() + "'";
                rowData[count][3] = "";
                count++;
            }
        }
        for (SpeciesContext objSpeciesContext : referencingSymbolsHashMap.keySet()) {
            Iterator<SymbolTableEntry> iterSymbolTableEntry = referencingSymbolsHashMap.get(objSpeciesContext).iterator();
            while (iterSymbolTableEntry.hasNext()) {
                rowData[count][0] = objSpeciesContext.getName();
                rowData[count][1] = "";
                SymbolTableEntry objSymbolTableEntry = iterSymbolTableEntry.next();
                boolean bKineticsParameter = objSymbolTableEntry instanceof KineticsParameter;
                if (bKineticsParameter) {
                    KineticsParameter kp = (KineticsParameter) objSymbolTableEntry;
                    boolean isOK = kp.isRegenerated();
                    for (int i = 0; toBeDeletedReactStepArr != null && i < toBeDeletedReactStepArr.length; i++) {
                        if (toBeDeletedReactStepArr[i] == kp.getKinetics().getReactionStep()) {
                            // OK to delete this Speciescontext if were deleting the reaction that contained the reference
                            isOK = true;
                        }
                    }
                    rowData[count][1] = (isOK ? "" : RXSPECIES_ERROR);
                    bUnresolvableHashMap.put(objSpeciesContext, bUnresolvableHashMap.get(objSpeciesContext) || !isOK);
                }
                boolean bReaction = objSymbolTableEntry.getNameScope() instanceof ReactionNameScope;
                rowData[count][2] = (bReaction ? "Reaction" : objSymbolTableEntry.getNameScope().getClass().getName()) + "( " + objSymbolTableEntry.getNameScope().getName() + " )";
                rowData[count][3] = (bKineticsParameter ? "Parameter" : objSymbolTableEntry.getClass().getName()) + "( " + objSymbolTableEntry.getName() + " )";
                count++;
            }
        }
        // for (SymbolTableEntry referencingSTE : referencingSymbols) {
        // System.out.println("REFERENCE   "+referencingSTE.getClass().getName()+"("+referencingSTE.getName()+") nameScope "+referencingSTE.getNameScope().getClass().getName()+"("+referencingSTE.getNameScope().getName()+")");
        // }
        Arrays.sort(rowData, new Comparator<String[]>() {

            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[0].compareToIgnoreCase(o2[0]);
            }
        });
    }
    if (rowData == null || rowData.length == 0) {
        return null;
    }
    return new DeleteSpeciesInfo(rxPartHashMap, bUnresolvableHashMap, rowData);
}
Also used : SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RubberBandRectShape(cbit.gui.graph.RubberBandRectShape) ProductShape(cbit.vcell.graph.ProductShape) ContainerShape(cbit.gui.graph.ContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactantShape(cbit.vcell.graph.ReactantShape) ElipseShape(cbit.gui.graph.ElipseShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) SpeciesContext(cbit.vcell.model.SpeciesContext) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) Vector(java.util.Vector) ReactionNameScope(cbit.vcell.model.ReactionStep.ReactionNameScope) HashSet(java.util.HashSet) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) BioModel(cbit.vcell.biomodel.BioModel) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 4 with BioModelEditor

use of cbit.vcell.client.desktop.biomodel.BioModelEditor in project vcell by virtualcell.

the class NetworkFreePanel method activateConsole.

public void activateConsole() {
    boolean found = false;
    Container parent = getParent();
    while (parent != null) {
        parent = parent.getParent();
        if (parent instanceof BioModelEditor) {
            found = true;
            break;
        }
    }
    if (found) {
        System.out.println("Parent Found");
        BioModelEditor e = (BioModelEditor) parent;
        // e.getRightBottomTabbedPane().setSelectedComponent(e.getSimulationConsolePanel());
        Component[] cList = e.getRightBottomTabbedPane().getComponents();
        for (Component c : cList) {
            if (c instanceof SimulationConsolePanel) {
                e.getRightBottomTabbedPane().setSelectedComponent(c);
                break;
            }
        }
    }
}
Also used : RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) Container(java.awt.Container) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) SimulationConsolePanel(cbit.vcell.client.desktop.biomodel.SimulationConsolePanel) Component(java.awt.Component)

Example 5 with BioModelEditor

use of cbit.vcell.client.desktop.biomodel.BioModelEditor in project vcell by virtualcell.

the class SimulationListPanel method activateConsole.

public void activateConsole() {
    boolean found = false;
    Container parent = getParent();
    while (parent != null) {
        parent = parent.getParent();
        if (parent instanceof BioModelEditor) {
            found = true;
            break;
        }
    }
    if (found) {
        System.out.println("Parent Found");
        BioModelEditor e = (BioModelEditor) parent;
        // e.getRightBottomTabbedPane().setSelectedComponent(e.getSimulationConsolePanel());
        Component[] cList = e.getRightBottomTabbedPane().getComponents();
        for (Component c : cList) {
            if (c instanceof SimulationConsolePanel) {
                e.getRightBottomTabbedPane().setSelectedComponent(c);
                break;
            }
        }
    }
}
Also used : Container(java.awt.Container) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) SimulationConsolePanel(cbit.vcell.client.desktop.biomodel.SimulationConsolePanel) Component(java.awt.Component)

Aggregations

BioModelEditor (cbit.vcell.client.desktop.biomodel.BioModelEditor)5 Container (java.awt.Container)4 SimulationConsolePanel (cbit.vcell.client.desktop.biomodel.SimulationConsolePanel)3 Component (java.awt.Component)3 RbmModelContainer (cbit.vcell.model.Model.RbmModelContainer)2 ContainerShape (cbit.gui.graph.ContainerShape)1 ElipseShape (cbit.gui.graph.ElipseShape)1 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)1 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)1 Shape (cbit.gui.graph.Shape)1 BioModel (cbit.vcell.biomodel.BioModel)1 CatalystShape (cbit.vcell.graph.CatalystShape)1 ContainerContainerShape (cbit.vcell.graph.ContainerContainerShape)1 FluxReactionShape (cbit.vcell.graph.FluxReactionShape)1 ProductShape (cbit.vcell.graph.ProductShape)1 ReactantShape (cbit.vcell.graph.ReactantShape)1 ReactionContainerShape (cbit.vcell.graph.ReactionContainerShape)1 ReactionParticipantShape (cbit.vcell.graph.ReactionParticipantShape)1 ReactionRuleDiagramShape (cbit.vcell.graph.ReactionRuleDiagramShape)1 ReactionStepShape (cbit.vcell.graph.ReactionStepShape)1