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);
}
}
}
}
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]));
}
}
}
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);
}
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;
}
Aggregations