use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class BioModelEditor method setRightBottomPanelOnSelection.
@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
if (selections == null) {
return;
}
// TODO: here
JComponent bottomComponent = rightBottomEmptyPanel;
JComponent annotationComponent = rightBottomEmptyAnnotationsPanel;
// properties panel
int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
// annotations panel
int annComponentIndex = DocumentEditorTabID.annotations.ordinal();
boolean bShowInDatabaseProperties = false;
boolean bShowPathway = false;
if (selections.length == 1) {
annotationComponent = getAnnotationsPanel();
Object singleSelection = selections[0];
if (singleSelection instanceof ReactionStep) {
bottomComponent = getReactionPropertiesPanel();
} else if (singleSelection instanceof ReactionRule) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (singleSelection instanceof SpeciesContext) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (singleSelection instanceof MolecularType) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (singleSelection instanceof RbmObservable) {
bottomComponent = getObservablePropertiesPanel();
} else if (singleSelection instanceof Structure) {
bottomComponent = getStructurePropertiesPanel();
getStructurePropertiesPanel().setModel(bioModel.getModel());
} else if (singleSelection instanceof Parameter) {
bottomComponent = getParameterPropertiesPanel();
} else if (singleSelection instanceof SimulationContext) {
bottomComponent = getApplicationPropertiesPanel();
} else if (singleSelection instanceof ParameterEstimationTask) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
} else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
bottomComponent = getReactionParticipantPropertiesPanel();
} else if (singleSelection instanceof BioModelNode.PublicationInfoNode) {
bShowInDatabaseProperties = true;
bottomComponent = bioModelMetaDataPanel;
} else if (singleSelection instanceof BioModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = bioModelMetaDataPanel;
} else if (singleSelection instanceof MathModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = mathModelMetaDataPanel;
} else if (singleSelection instanceof GeometryInfo) {
bShowInDatabaseProperties = true;
bottomComponent = geometryMetaDataPanel;
} else if (singleSelection instanceof SpeciesContextSpec) {
bottomComponent = getSpeciesContextSpecPanel();
} else if (singleSelection instanceof ReactionSpec) {
bottomComponent = getKineticsTypeTemplatePanel();
} else if (singleSelection instanceof ReactionRuleSpec) {
//
bottomComponent = getReactionRuleSpecPropertiesPanel();
} else if (singleSelection instanceof BioModelsNetModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = getBioModelsNetPropertiesPanel();
} else if (singleSelection instanceof Simulation) {
bottomComponent = getSimulationSummaryPanel();
} else if (singleSelection instanceof DataSymbol) {
bottomComponent = getDataSymbolsSpecPanel();
} else if (singleSelection instanceof BioEvent) {
bottomComponent = getEventPanel();
} else if (singleSelection instanceof SpatialObject) {
bottomComponent = getSpatialObjectPropertyPanel();
} else if (singleSelection instanceof SpatialProcess) {
bottomComponent = getSpatialProcessPropertyPanel();
} else if (singleSelection instanceof BioPaxObject) {
bottomComponent = bioPaxObjectPropertiesPanel;
} else if (singleSelection instanceof BioModel) {
// only contains Notes, is displayed in the Object Properties Panel
bottomComponent = bioModelEditorAnnotationPanel;
} else if (singleSelection instanceof VCMetaData) {
bottomComponent = bioModelEditorAnnotationPanel;
} else if (singleSelection instanceof PathwayData) {
bShowPathway = true;
bottomComponent = getBioModelEditorPathwayPanel();
} else if (singleSelection instanceof Model) {
} else if (singleSelection instanceof RuleParticipantSignature) {
bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
} else if (singleSelection instanceof CSGObject) {
bottomComponent = csgObjectPropertiesPanel;
csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
} else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionPropertiesPanel();
} else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
bottomComponent = getStructurePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
bottomComponent = getObservablePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
bottomComponent = getApplicationsPropertiesPanel();
getApplicationsPropertiesPanel().setBioModel(bioModel);
} else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
}
} else if (singleSelection instanceof SelectionManager.AnnotationNavigator) {
Object entity = ((SelectionManager.AnnotationNavigator) singleSelection).getEntity();
if (entity instanceof ReactionStep) {
bottomComponent = getReactionPropertiesPanel();
} else if (entity instanceof SpeciesContext) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (entity instanceof Structure) {
// Observables. MolecularType, Structures
bottomComponent = getStructurePropertiesPanel();
} else if (entity instanceof MolecularType) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (entity instanceof RbmObservable) {
bottomComponent = getObservablePropertiesPanel();
} else {
bottomComponent = bioModelEditorAnnotationPanel;
}
}
}
if (bShowPathway) {
int numTabs = rightBottomTabbedPane.getTabCount();
for (destComponentIndex = 0; destComponentIndex < numTabs; destComponentIndex++) {
Component current = rightBottomTabbedPane.getComponentAt(destComponentIndex);
if (current == bottomComponent) {
break;
}
}
String tabTitle = "Pathway Preview";
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
}
} else if (bShowInDatabaseProperties) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
break;
}
}
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
}
}
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
annotationComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
rightBottomTabbedPane.setComponentAt(annComponentIndex, annotationComponent);
rightSplitPane.repaint();
}
Component selectedComponent = rightBottomTabbedPane.getSelectedComponent();
if (selections.length == 1 && selections[0] instanceof BioModel && bottomComponent instanceof BioModelEditorAnnotationPanel) {
// if the biomodel name is selected in the upper left tree, we select the Annotations tab
rightBottomTabbedPane.setSelectedComponent(annotationComponent);
} else if (selections.length == 1 && selections[0] instanceof SelectionManager.AnnotationNavigator && selections[0] instanceof SelectionManager.AnnotationNavigator) {
// we want to navigate to the AnnotationPanel
rightBottomTabbedPane.setSelectedComponent(annotationComponent);
// } else if(selections.length == 1 && selections[0] instanceof SelectionManager.AnnotationNavigator && bottomComponent instanceof BioModelEditorAnnotationPanel) {
// // we want to navigate to the AnnotationPanel (old way)
// rightBottomTabbedPane.setSelectedComponent(annotationComponent);
} else if (selectedComponent != bottomComponent) /* && rightBottomTabbedPane.getSelectedComponent() != annotationComponent */
{
rightBottomTabbedPane.setSelectedComponent(bottomComponent);
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class BioModelEditorReactionTableModel method setValueAt.
public void setValueAt(Object value, int row, int column) {
if (getModel() == null || value == null) {
return;
}
try {
ModelProcess modelProcess = getValueAt(row);
if (modelProcess != null) {
switch(column) {
case COLUMN_NAME:
{
String inputValue = ((String) value);
inputValue = inputValue.trim();
modelProcess.setName(inputValue);
break;
}
case COLUMN_EQUATION:
{
String inputValue = (String) value;
inputValue = inputValue.trim();
if (modelProcess instanceof ReactionStep) {
ReactionStep reactionStep = (ReactionStep) modelProcess;
ReactionParticipant[] rpArray = ModelProcessEquation.parseReaction(reactionStep, getModel(), inputValue);
for (ReactionParticipant rp : rpArray) {
SpeciesContext speciesContext = rp.getSpeciesContext();
if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
bioModel.getModel().addSpecies(speciesContext.getSpecies());
bioModel.getModel().addSpeciesContext(speciesContext);
}
}
reactionStep.setReactionParticipants(rpArray);
} else if (modelProcess instanceof ReactionRule) {
ReactionRule oldReactionRule = (ReactionRule) modelProcess;
// when editing an existing reaction rule
ReactionRule newReactionRule = (ReactionRule) RbmUtils.parseReactionRule(inputValue, oldReactionRule.getStructure(), bioModel);
if (newReactionRule != null) {
oldReactionRule.setProductPatterns(newReactionRule.getProductPatterns(), false, false);
oldReactionRule.setReactantPatterns(newReactionRule.getReactantPatterns(), false, false);
// String name = oldReactionRule.getName();
// RbmKineticLaw kl = oldReactionRule.getKineticLaw();
// Structure st = oldReactionRule.getStructure();
// getModel().getRbmModelContainer().removeReactionRule(oldReactionRule);
// newReactionRule.setName(name);
// newReactionRule.setKineticLaw(kl);
// newReactionRule.setStructure(st);
// getModel().getRbmModelContainer().addReactionRule(newReactionRule);
}
}
break;
}
case COLUMN_STRUCTURE:
{
Structure s = (Structure) value;
modelProcess.setStructure(s);
break;
}
}
} else {
switch(column) {
case COLUMN_EQUATION:
{
if (getModel().getNumStructures() == 1) {
String inputValue = ((String) value);
inputValue = inputValue.trim();
if (inputValue.contains("(") && inputValue.contains(")")) {
ReactionRule reactionRule = (ReactionRule) RbmUtils.parseReactionRule(inputValue, getModel().getStructure(0), bioModel);
getModel().getRbmModelContainer().addReactionRule(reactionRule);
} else {
if (BioModelEditorRightSideTableModel.ADD_NEW_HERE_REACTION_TEXT.equals(inputValue)) {
return;
}
ReactionStep reactionStep = getModel().createSimpleReaction(getModel().getStructure(0));
ReactionParticipant[] rpArray = ModelProcessEquation.parseReaction(reactionStep, getModel(), inputValue);
for (ReactionParticipant rp : rpArray) {
SpeciesContext speciesContext = rp.getSpeciesContext();
if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
bioModel.getModel().addSpecies(speciesContext.getSpecies());
bioModel.getModel().addSpeciesContext(speciesContext);
}
}
reactionStep.setReactionParticipants(rpArray);
}
}
break;
}
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
DialogUtils.showErrorDialog(ownerTable, e.getMessage(), e);
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class BioModelEditorReactionTableModel method propertyChange.
// public boolean isCellEditable(int row, int column) {
// if (bioModel == null) {
// return false;
// }
// ModelProcess process = getValueAt(row);
// if (column == COLUMN_NAME && process != null) {
// return true;
// }
// if (column == COLUMN_EQUATION) {
// // if(bioModel.getModel().getNumStructures() != 1) {
// // return false;
// // }
// Object o = getValueAt(row);
// if(o instanceof ReactionRule) {
// ReactionRule rr = (ReactionRule)o;
// final List<ReactantPattern> rpList = rr.getReactantPatterns();
// for(ReactantPattern rp : rpList) {
// final List<MolecularTypePattern> mtpList = rp.getSpeciesPattern().getMolecularTypePatterns();
// for(MolecularTypePattern mtp : mtpList) {
// MolecularType mt = mtp.getMolecularType();
// if(mt.getComponentList().size() != 0) {
// return false;
// }
// }
// }
// final List<ProductPattern> ppList = rr.getProductPatterns();
// for(ProductPattern pp : ppList) {
// final List<MolecularTypePattern> mtpList = pp.getSpeciesPattern().getMolecularTypePatterns();
// for(MolecularTypePattern mtp : mtpList) {
// MolecularType mt = mtp.getMolecularType();
// if(mt.getComponentList().size() != 0) {
// return false;
// }
// }
// }
// }
// return true;
// }
// return false;
// }
@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
super.propertyChange(evt);
if (evt.getSource() == bioModel.getModel()) {
if (evt.getPropertyName().equals(Model.PROPERTY_NAME_STRUCTURES)) {
// updateStructureComboBox();
} else if (evt.getPropertyName().equals(Model.PROPERTY_NAME_REACTION_STEPS)) {
ReactionStep[] oldValue = (ReactionStep[]) evt.getOldValue();
if (oldValue != null) {
for (ReactionStep rs : oldValue) {
rs.removePropertyChangeListener(this);
}
}
ReactionStep[] newValue = (ReactionStep[]) evt.getNewValue();
if (newValue != null) {
for (ReactionStep rs : newValue) {
rs.addPropertyChangeListener(this);
}
}
refreshData();
}
} else if (evt.getSource() instanceof ReactionStep) {
ReactionStep reactionStep = (ReactionStep) evt.getSource();
int changeRow = getRowIndex(reactionStep);
if (changeRow >= 0) {
fireTableRowsUpdated(changeRow, changeRow);
}
}
// if (evt.getSource() == bioModel.getModel().getRbmModelContainer()) {
if (evt.getSource() == bioModel.getModel()) {
if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_REACTION_RULE_LIST)) {
List<ReactionRule> oldValue = (List<ReactionRule>) evt.getOldValue();
if (oldValue != null) {
for (ReactionRule rs : oldValue) {
rs.removePropertyChangeListener(this);
}
}
List<ReactionRule> newValue = (List<ReactionRule>) evt.getNewValue();
if (newValue != null) {
for (ReactionRule rs : newValue) {
rs.addPropertyChangeListener(this);
}
}
refreshData();
}
} else if (evt.getSource() instanceof ReactionRule) {
ReactionRule reactionRule = (ReactionRule) evt.getSource();
int changeRow = getRowIndex(reactionRule);
if (changeRow >= 0) {
fireTableRowsUpdated(changeRow, changeRow);
}
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class AnnotationsPanel method addIdentifier.
// -------------------------------------------------------------------------------------------------------
private void addIdentifier() {
if (PopupGenerator.showComponentOKCancelDialog(AnnotationsPanel.this, getJPanelNewIdentifier(), "Define New Formal Identifier") != JOptionPane.OK_OPTION) {
return;
}
MIRIAMQualifier qualifier = (MIRIAMQualifier) getJComboBoxQualifier().getSelectedItem();
MiriamManager.DataType objectNamespace = (MiriamManager.DataType) getJComboBoxURI().getSelectedItem();
String objectID = getJTextFieldFormalID().getText();
if (objectID.compareTo("NewID") == 0) {
return;
}
MiriamManager miriamManager = vcMetaData.getMiriamManager();
HashSet<MiriamResource> miriamResources = new HashSet<MiriamResource>();
try {
Identifiable entity = getIdentifiable(selectedObject);
MiriamResource mr = miriamManager.createMiriamResource(objectNamespace.getBaseURN() + ":" + objectID);
miriamResources.add(mr);
miriamManager.addMiriamRefGroup(entity, qualifier, miriamResources);
// System.out.println(vcMetaData.printRdfStatements());
updateInterface();
if (selectedObject instanceof ReactionStep) {
// we tell ReactionPropertiesPanel to refresh the annotation icon
((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true);
}
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "Add Identifier failed:\n" + e.getMessage(), e);
}
}
use of cbit.vcell.model.ReactionStep in project vcell by virtualcell.
the class VCellCopyPasteHelper method chooseApplyPaste.
/**
* Insert the method's description here.
* Creation date: (7/10/2006 11:05:19 AM)
*/
public static void chooseApplyPaste(Component requester, String[] pasteDetails, Parameter[] changingParamters, Expression[] newParameterExpression) {
if (pasteDetails.length != changingParamters.length || changingParamters.length != newParameterExpression.length) {
throw new IllegalArgumentException(VCellCopyPasteHelper.class.getName() + ".chooseApplyPaste(...) arguments must have unequal lengths");
}
// Only present things that will actually change
boolean bAtLeatOneDifferent = false;
boolean[] bEnableDisplay = new boolean[changingParamters.length];
for (int i = 0; i < changingParamters.length; i += 1) {
// bEnableDisplay[i] = !changingParamters[i].getExpression().equals(newParameterExpression[i]);
bEnableDisplay[i] = !Compare.isEqualOrNull(changingParamters[i].getExpression(), newParameterExpression[i]);
bAtLeatOneDifferent = bAtLeatOneDifferent || bEnableDisplay[i];
}
if (!bAtLeatOneDifferent) {
PopupGenerator.showInfoDialog(requester, "All valid paste values are equal to the destination values.\nNo paste needed.");
return;
}
boolean[] bChoices = showChoices(requester, pasteDetails, bEnableDisplay);
if (bChoices != null) {
StringBuffer statusMessages = new StringBuffer();
boolean bFailure = false;
for (int i = 0; i < changingParamters.length; i += 1) {
try {
if (bChoices[i]) {
if (changingParamters[i] instanceof Kinetics.KineticsParameter) {
Kinetics kinetics = ((ReactionStep) changingParamters[i].getNameScope().getScopedSymbolTable()).getKinetics();
kinetics.setParameterValue((Kinetics.KineticsParameter) changingParamters[i], newParameterExpression[i]);
} else {
throw new Exception("Changing " + changingParamters[i].getNameScope().getName() + " " + changingParamters[i].getName() + " not yet implemented");
}
}
statusMessages.append("(OK) " + pasteDetails + "\n");
} catch (Exception e) {
bFailure = true;
statusMessages.append("(Failed) " + pasteDetails + " " + e.getMessage() + " " + e.getClass().getName() + "\n");
}
}
if (bFailure) {
PopupGenerator.showErrorDialog(requester, "Paste Results:\n" + statusMessages.toString());
}
}
}
Aggregations