Search in sources :

Example 16 with BioModelEntityObject

use of cbit.vcell.model.BioModelEntityObject in project vcell by virtualcell.

the class BioModelEditorModelPanel method refreshButtons.

private void refreshButtons() {
    int selectedIndex = tabbedPane.getSelectedIndex();
    newMemButton.setVisible(false);
    newButton2.setVisible(false);
    duplicateButton.setVisible(false);
    if (selectedIndex == ModelPanelTabID.reaction_diagram.ordinal() || // || selectedIndex == ModelPanelTabID.structure_diagram.ordinal()
    selectedIndex == ModelPanelTabID.species_table.ordinal() && (bioModel == null || bioModel.getModel().getNumStructures() < 1)) {
        newButton.setVisible(false);
    } else {
        Icon downArrow = null;
        if (bioModel.getModel().getNumStructures() > 1) {
            downArrow = new DownArrowIcon();
        }
        newButton.setVisible(true);
        if (selectedIndex == ModelPanelTabID.structure_table.ordinal()) {
            newButton.setText("New Compartment");
            newButton.setIcon(null);
            newMemButton.setVisible(true);
            newMemButton.setIcon(null);
        } else if (selectedIndex == ModelPanelTabID.reaction_table.ordinal()) {
            newButton.setText("New Reaction");
            if (bioModel.getModel().getRbmModelContainer().getMolecularTypeList().isEmpty()) {
                // show rule-related buttons only if rules are possible
                newButton2.setVisible(false);
                duplicateButton.setVisible(false);
            } else {
                newButton2.setVisible(true);
                duplicateButton.setVisible(true);
            }
            newButton2.setText("New Rule");
            newButton2.setIcon(downArrow);
            newButton2.setHorizontalTextPosition(SwingConstants.LEFT);
            duplicateButton.setIcon(downArrow);
            duplicateButton.setHorizontalTextPosition(SwingConstants.LEFT);
        } else if (selectedIndex == ModelPanelTabID.species_table.ordinal()) {
            newButton.setVisible(true);
            newButton.setIcon(downArrow);
            newButton.setHorizontalTextPosition(SwingConstants.LEFT);
            if (bioModel.getModel().getRbmModelContainer().getMolecularTypeList().isEmpty()) {
                duplicateButton.setVisible(false);
            } else {
                duplicateButton.setVisible(true);
            }
            duplicateButton.setIcon(downArrow);
            duplicateButton.setHorizontalTextPosition(SwingConstants.LEFT);
            newButton.setText("New Species");
        } else if (selectedIndex == ModelPanelTabID.observables_table.ordinal()) {
            newButton.setVisible(true);
            newButton.setIcon(downArrow);
            newButton.setText("New Observable");
            if (bioModel.getModel().getRbmModelContainer().getMolecularTypeList().isEmpty()) {
                duplicateButton.setVisible(false);
            } else {
                duplicateButton.setVisible(true);
            }
            duplicateButton.setIcon(downArrow);
            duplicateButton.setHorizontalTextPosition(SwingConstants.LEFT);
        } else if (selectedIndex == ModelPanelTabID.species_definitions_table.ordinal()) {
            newButton.setText("New Molecule");
        }
    }
    deleteButton.setEnabled(false);
    pathwayButton.setEnabled(false);
    duplicateButton.setEnabled(false);
    getShowPathwayMenuItem().setEnabled(false);
    Object[] selectedObjects = null;
    if (selectedIndex == ModelPanelTabID.reaction_diagram.ordinal()) {
        selectedObjects = reactionCartoonEditorPanel.getReactionCartoon().getSelectedObjects();
    // } else if (selectedIndex == ModelPanelTabID.structure_diagram.ordinal()) {
    // selectedObjects = cartoonEditorPanel.getStructureCartoon().getSelectedObjects();
    } else {
        computeCurrentSelectedTable();
        if (currentSelectedTableModel != null) {
            int[] rows = currentSelectedTable.getSelectedRows();
            ArrayList<Object> objectList = new ArrayList<Object>();
            for (int r = 0; r < rows.length; r++) {
                Object object = currentSelectedTableModel.getValueAt(rows[r]);
                if (object != null) {
                    objectList.add(object);
                }
            }
            selectedObjects = objectList.toArray(new Object[0]);
        }
    }
    if (selectedObjects != null) {
        deleteButton.setEnabled(selectedObjects.length > 0);
        if (selectedObjects.length == 1 && (selectedObjects[0] instanceof ReactionRule || selectedObjects[0] instanceof RbmObservable)) {
            duplicateButton.setEnabled(true);
        } else if (selectedObjects.length == 1 && selectedObjects[0] instanceof SpeciesContext) {
            SpeciesContext sp = (SpeciesContext) selectedObjects[0];
            if (sp.hasSpeciesPattern()) {
                duplicateButton.setEnabled(true);
            } else {
                duplicateButton.setEnabled(false);
            }
        }
        if (selectedObjects.length == 1 && selectedObjects[0] instanceof BioModelEntityObject) {
            pathwayButton.setEnabled(true);
            if (bioModel.getRelationshipModel().getRelationshipObjects((BioModelEntityObject) selectedObjects[0]).size() > 0) {
                getShowPathwayMenuItem().setEnabled(true);
            }
        }
    }
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) RbmObservable(cbit.vcell.model.RbmObservable) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) ArrayList(java.util.ArrayList) RelationshipObject(org.vcell.relationship.RelationshipObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) BioPaxObject(org.vcell.pathway.BioPaxObject) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) Icon(javax.swing.Icon) StructureToolShapeIcon(cbit.vcell.graph.gui.StructureToolShapeIcon) SpeciesContext(cbit.vcell.model.SpeciesContext) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject)

Example 17 with BioModelEntityObject

use of cbit.vcell.model.BioModelEntityObject in project vcell by virtualcell.

the class BioModelEditorModelPanel method showPathwayLinks.

private void showPathwayLinks() {
    BioModelEntityObject selectedBioModelEntityObject = getSelectedBioModelEntityObject();
    if (selectedBioModelEntityObject != null) {
        Set<RelationshipObject> relationshipSet = bioModel.getRelationshipModel().getRelationshipObjects(selectedBioModelEntityObject);
        if (relationshipSet.size() > 0) {
            ArrayList<BioPaxObject> selectedBioPaxObjects = new ArrayList<BioPaxObject>();
            for (RelationshipObject re : relationshipSet) {
                selectedBioPaxObjects.add(re.getBioPaxObject());
            }
            selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_NODE, ActiveViewID.pathway), selectedBioPaxObjects.toArray(new BioPaxObject[0]));
        }
    }
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) ArrayList(java.util.ArrayList) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 18 with BioModelEntityObject

use of cbit.vcell.model.BioModelEntityObject in project vcell by virtualcell.

the class RelationshipObject method createRelationshipObject.

public static RelationshipObject createRelationshipObject(VCID bioModelObjectID, VCID bioPaxObjectID, IdentifiableProvider provider) {
    if (bioModelObjectID == null || bioPaxObjectID == null) {
        return null;
    }
    BioModelEntityObject bmo = (BioModelEntityObject) provider.getIdentifiableObject(bioModelObjectID);
    BioPaxObject bpo = (BioPaxObject) provider.getIdentifiableObject(bioPaxObjectID);
    return new RelationshipObject(bmo, bpo);
}
Also used : BioPaxObject(org.vcell.pathway.BioPaxObject) BioModelEntityObject(cbit.vcell.model.BioModelEntityObject)

Example 19 with BioModelEntityObject

use of cbit.vcell.model.BioModelEntityObject in project vcell by virtualcell.

the class RelationshipModel method removeRelationshipObjects.

public boolean removeRelationshipObjects(Set<BioModelEntityObject> biomodelEntityObjects) {
    // propertyChange() in bioModel
    if (biomodelEntityObjects == null) {
        throw new RuntimeException("remove a null object from relationship model");
    }
    boolean bRemoved = false;
    for (BioModelEntityObject bmObject : biomodelEntityObjects) {
        Iterator<RelationshipObject> iter = relationshipObjects.iterator();
        while (iter.hasNext()) {
            RelationshipObject relationshipObject = iter.next();
            if (relationshipObject.getBioModelEntityObject() == bmObject) {
                iter.remove();
                fireRelationshipChanged(new RelationshipEvent(this, relationshipObject, RelationshipEvent.REMOVED));
                bRemoved = true;
            }
        }
    }
    return bRemoved;
}
Also used : BioModelEntityObject(cbit.vcell.model.BioModelEntityObject)

Aggregations

BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)19 RelationshipObject (org.vcell.relationship.RelationshipObject)9 BioPaxObject (org.vcell.pathway.BioPaxObject)8 ArrayList (java.util.ArrayList)7 SpeciesContext (cbit.vcell.model.SpeciesContext)6 ReactionRule (cbit.vcell.model.ReactionRule)4 ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)3 ReactionStep (cbit.vcell.model.ReactionStep)3 Point (java.awt.Point)3 Shape (cbit.gui.graph.Shape)2 Kinetics (cbit.vcell.model.Kinetics)2 Model (cbit.vcell.model.Model)2 Product (cbit.vcell.model.Product)2 RbmObservable (cbit.vcell.model.RbmObservable)2 ReactionParticipant (cbit.vcell.model.ReactionParticipant)2 Structure (cbit.vcell.model.Structure)2 BorderLayout (java.awt.BorderLayout)2 Dimension (java.awt.Dimension)2 PropertyVetoException (java.beans.PropertyVetoException)2 HashMap (java.util.HashMap)2