Search in sources :

Example 16 with ActiveView

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

the class BioModelEditor method copyApplication.

private void copyApplication(final boolean bSpatial, final SimulationContext.Application appType) {
    final SimulationContext simulationContext = getSelectedSimulationContext();
    if (simulationContext == null) {
        PopupGenerator.showErrorDialog(this, "Please select an application.");
        return;
    }
    if (appType == SimulationContext.Application.NETWORK_STOCHASTIC) {
        // check validity if copy to stochastic application
        String message = bioModel.getModel().isValidForStochApp();
        if (!message.equals("")) {
            PopupGenerator.showErrorDialog(this, message);
            return;
        }
    }
    AsynchClientTask[] copyTasks = ClientTaskManager.copyApplication(this, bioModel, simulationContext, bSpatial, appType);
    AsynchClientTask[] allTasks = new AsynchClientTask[copyTasks.length + 1];
    System.arraycopy(copyTasks, 0, allTasks, 0, copyTasks.length);
    allTasks[allTasks.length - 1] = new AsynchClientTask("showing", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            SimulationContext newSimulationContext = (SimulationContext) hashTable.get("newSimulationContext");
            selectionManager.setActiveView(new ActiveView(newSimulationContext, null, null));
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), allTasks, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) BioPaxObject(org.vcell.pathway.BioPaxObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) CSGObject(cbit.vcell.geometry.CSGObject) SimulationContext(cbit.vcell.mapping.SimulationContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) PropertyVetoException(java.beans.PropertyVetoException) UnsupportedOperationException(javax.help.UnsupportedOperationException)

Example 17 with ActiveView

use of cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView 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 ActiveView

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

the class ReactionPropertiesPanel method listLinkedPathwayObjects.

private String listLinkedPathwayObjects() {
    // Kinetics kinetics = reactionStep.getKinetics();
    if (reactionStep == null) {
        return "no selected reaction";
    }
    if (bioModel == null || bioModel.getModel() == null) {
        return "no biomodel";
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    String linkedPOlist = "";
    for (RelationshipObject relObject : bioModel.getRelationshipModel().getRelationshipObjects(reactionStep)) {
        if (relObject == null) {
            continue;
        }
        final BioPaxObject bpObject = relObject.getBioPaxObject();
        if (bpObject == null) {
            continue;
        }
        if (bpObject instanceof Entity) {
            String name = new String();
            if (((Entity) bpObject).getName().isEmpty()) {
                name = ((Entity) bpObject).getID();
            } else {
                name = ((Entity) bpObject).getName().get(0);
            }
            if (name.contains("#")) {
                name = name.substring(name.indexOf("#") + 1);
            }
            JLabel label = new JLabel("<html><u>" + name + "</u></html>");
            label.setForeground(Color.blue);
            label.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), new Object[] { bpObject });
                    }
                }
            });
            panel.add(label);
        }
    }
    Dimension dim = new Dimension(200, 20);
    panel.setMinimumSize(dim);
    panel.setPreferredSize(dim);
    linkedPOScrollPane.setViewportView(panel);
    return linkedPOlist;
}
Also used : JPanel(javax.swing.JPanel) Entity(org.vcell.pathway.Entity) MouseEvent(java.awt.event.MouseEvent) BioPaxObject(org.vcell.pathway.BioPaxObject) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BioPaxObject(org.vcell.pathway.BioPaxObject) RelationshipObject(org.vcell.relationship.RelationshipObject) Dimension(java.awt.Dimension) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 19 with ActiveView

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

the class IssuePanel method invokeHyperlink.

private void invokeHyperlink(Issue issue) {
    if (selectionManager != null) {
        // followHyperlink is no-op if selectionManger null, so no point in proceeding if it is
        IssueContext issueContext = issue.getIssueContext();
        IssueSource object = issue.getSource();
        if (object instanceof DecoratedIssueSource) {
            DecoratedIssueSource dis = (DecoratedIssueSource) object;
            dis.activateView(selectionManager);
        } else if (object instanceof Parameter) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.BIOMODEL_PARAMETERS_NODE, ActiveViewID.parameters_functions), new Object[] { object });
        } else if (object instanceof StructureMapping) {
            StructureMapping structureMapping = (StructureMapping) object;
            StructureMappingNameScope structureMappingNameScope = (StructureMappingNameScope) structureMapping.getNameScope();
            SimulationContext simulationContext = ((SimulationContextNameScope) (structureMappingNameScope.getParent())).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpatialObject) {
            SpatialObject spatialObject = (SpatialObject) object;
            SimulationContext simulationContext = spatialObject.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_objects), new Object[] { object });
        } else if (object instanceof SpatialProcess) {
            SpatialProcess spatialProcess = (SpatialProcess) object;
            SimulationContext simulationContext = spatialProcess.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.spatial_processes), new Object[] { object });
        } else if (object instanceof GeometryContext.UnmappedGeometryClass) {
            UnmappedGeometryClass unmappedGeometryClass = (UnmappedGeometryClass) object;
            SimulationContext simulationContext = unmappedGeometryClass.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof MicroscopeMeasurement) {
            SimulationContext simulationContext = ((MicroscopeMeasurement) object).getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.microscope_measuremments), new Object[] { object });
        } else if (object instanceof BioEvent) {
            BioEvent be = (BioEvent) object;
            SimulationContext simulationContext = be.getSimulationContext();
            followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.PROTOCOLS_NODE, ActiveViewID.events), new Object[] { object });
        } else if (object instanceof OutputFunctionIssueSource) {
            SimulationOwner simulationOwner = ((OutputFunctionIssueSource) object).getOutputFunctionContext().getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE, ActiveViewID.math_output_functions), new Object[] { ((OutputFunctionIssueSource) object).getAnnotatedFunction() });
            }
        } else if (object instanceof Simulation) {
            Simulation simulation = (Simulation) object;
            SimulationOwner simulationOwner = simulation.getSimulationOwner();
            if (simulationOwner instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) simulationOwner;
                followHyperlink(new ActiveView(simulationContext, DocumentEditorTreeFolderClass.SIMULATIONS_NODE, ActiveViewID.simulations), new Object[] { simulation });
            } else if (simulationOwner instanceof MathModel) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.math_simulations), new Object[] { simulation });
            }
        } else if (object instanceof GeometryContext) {
            setActiveView(new ActiveView(((GeometryContext) object).getSimulationContext(), DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition));
        } else if (object instanceof Structure) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.STRUCTURES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof MolecularType) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.structures), new Object[] { object });
        } else if (object instanceof ReactionStep) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof ReactionRule) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] { object });
        } else if (object instanceof SpeciesContextSpec) {
            SpeciesContextSpec scs = (SpeciesContextSpec) object;
            ActiveView av = new ActiveView(scs.getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.species_settings);
            followHyperlink(av, new Object[] { object });
        } else if (object instanceof ReactionCombo) {
            ReactionCombo rc = (ReactionCombo) object;
            followHyperlink(new ActiveView(rc.getReactionContext().getSimulationContext(), DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.reaction_setting), new Object[] { ((ReactionCombo) object).getReactionSpec() });
        } else if (object instanceof SpeciesContext) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] { object });
        } else if (object instanceof RbmObservable) {
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] { object });
        } else if (object instanceof MathDescription) {
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE, ActiveViewID.generated_math), new Object[] {object});
            followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.structure_mapping), new Object[] { object });
        } else if (object instanceof SpeciesPattern) {
            // if (issue.getIssueContext().hasContextType(ContextType.SpeciesContext)){
            // SpeciesContext thing = (SpeciesContext)issue.getIssueContext().getContextObject(ContextType.SpeciesContext);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.ReactionRule)) {
            // ReactionRule thing = (ReactionRule)issue.getIssueContext().getContextObject(ContextType.ReactionRule);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions), new Object[] {thing});
            // }else if(issue.getIssueContext().hasContextType(ContextType.RbmObservable)) {
            // RbmObservable thing = (RbmObservable)issue.getIssueContext().getContextObject(ContextType.RbmObservable);
            // followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.OBSERVABLES_NODE, ActiveViewID.observables), new Object[] {thing});
            // } else {
            System.err.println("SpeciesPattern object missing a proper issue context.");
        // }
        } else if (object instanceof SimulationContext) {
            SimulationContext sc = (SimulationContext) object;
            IssueCategory ic = issue.getCategory();
            switch(ic) {
                case RbmNetworkConstraintsBad:
                    NetworkConstraints nc = sc.getNetworkConstraints();
                    if (issue.getMessage() == SimulationContext.IssueInsufficientMolecules) {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxMoleculesName, NetworkConstraintsTableModel.sValueType, nc.getMaxMoleculesPerSpecies() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    } else {
                        NetworkConstraintsEntity nce = new NetworkConstraintsEntity(NetworkConstraintsTableModel.sMaxIterationName, NetworkConstraintsTableModel.sValueType, nc.getMaxIteration() + "");
                        followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { nce });
                    }
                    break;
                default:
                    followHyperlink(new ActiveView(sc, DocumentEditorTreeFolderClass.SPECIFICATIONS_NODE, ActiveViewID.network_setting), new Object[] { object });
                    break;
            }
        } else if (object instanceof Geometry) {
            if (issueContext.hasContextType(ContextType.SimContext)) {
                SimulationContext simContext = (SimulationContext) issueContext.getContextObject(ContextType.SimContext);
                followHyperlink(new ActiveView(simContext, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathModel)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE, ActiveViewID.math_geometry), new Object[] { object });
            } else if (issueContext.hasContextType(ContextType.MathDescription)) {
                followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.GEOMETRY_NODE, ActiveViewID.geometry_definition), new Object[] { object });
            }
        } else {
            System.err.println("unknown object type in IssuePanel.invokeHyperlink(): " + object.getClass() + ", context type: " + issueContext.getContextType());
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) IssueCategory(org.vcell.util.Issue.IssueCategory) MathDescription(cbit.vcell.math.MathDescription) NetworkConstraintsEntity(org.vcell.model.rbm.common.NetworkConstraintsEntity) SpeciesContext(cbit.vcell.model.SpeciesContext) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) StructureMappingNameScope(cbit.vcell.mapping.StructureMapping.StructureMappingNameScope) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) SimulationOwner(cbit.vcell.solver.SimulationOwner) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) IssueSource(org.vcell.util.Issue.IssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) OutputFunctionIssueSource(cbit.vcell.solver.OutputFunctionContext.OutputFunctionIssueSource) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) IssueContext(org.vcell.util.IssueContext) UnmappedGeometryClass(cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass) MicroscopeMeasurement(cbit.vcell.mapping.MicroscopeMeasurement) GeometryContext(cbit.vcell.mapping.GeometryContext) Structure(cbit.vcell.model.Structure) ReactionCombo(cbit.vcell.mapping.ReactionSpec.ReactionCombo) ReactionRule(cbit.vcell.model.ReactionRule) DecoratedIssueSource(cbit.vcell.client.desktop.DecoratedIssueSource) RbmObservable(cbit.vcell.model.RbmObservable) SimulationContextNameScope(cbit.vcell.mapping.SimulationContext.SimulationContextNameScope) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) Parameter(cbit.vcell.model.Parameter) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) BioEvent(cbit.vcell.mapping.BioEvent) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 20 with ActiveView

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

the class MolecularTypePropertiesPanel method listLinkedPathwayObjects.

private String listLinkedPathwayObjects() {
    if (molecularType == null) {
        return "no selected molecule";
    }
    if (bioModel == null || bioModel.getModel() == null) {
        return "no biomodel";
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    String linkedPOlist = "";
    for (RelationshipObject relObject : bioModel.getRelationshipModel().getRelationshipObjects(molecularType)) {
        final BioPaxObject bpObject = relObject.getBioPaxObject();
        if (bpObject instanceof Entity) {
            JLabel label = new JLabel("<html><u>" + ((Entity) bpObject).getName().get(0) + "</u></html>");
            label.setForeground(Color.blue);
            label.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_DIAGRAM_NODE, ActiveViewID.pathway_diagram), new Object[] { bpObject });
                    }
                }
            });
            panel.add(label);
        }
    }
    Dimension dim = new Dimension(200, 20);
    panel.setMinimumSize(dim);
    panel.setPreferredSize(dim);
    linkedPOScrollPane.setViewportView(panel);
    return linkedPOlist;
}
Also used : JPanel(javax.swing.JPanel) Entity(org.vcell.pathway.Entity) MouseEvent(java.awt.event.MouseEvent) BioPaxObject(org.vcell.pathway.BioPaxObject) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) Dimension(java.awt.Dimension) ActiveView(cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView) RelationshipObject(org.vcell.relationship.RelationshipObject)

Aggregations

ActiveView (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView)20 BioPaxObject (org.vcell.pathway.BioPaxObject)10 RelationshipObject (org.vcell.relationship.RelationshipObject)8 Component (java.awt.Component)5 MouseAdapter (java.awt.event.MouseAdapter)5 MouseEvent (java.awt.event.MouseEvent)5 Entity (org.vcell.pathway.Entity)5 ActiveViewID (cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveViewID)4 Dimension (java.awt.Dimension)4 ArrayList (java.util.ArrayList)4 BoxLayout (javax.swing.BoxLayout)4 JComponent (javax.swing.JComponent)4 JLabel (javax.swing.JLabel)4 JPanel (javax.swing.JPanel)4 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)3 SimulationContext (cbit.vcell.mapping.SimulationContext)2 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)2 MathModel (cbit.vcell.mathmodel.MathModel)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 HashSet (java.util.HashSet)2