use of cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass in project vcell by virtualcell.
the class MathModelEditor method setRightTopPanel.
private void setRightTopPanel(Object selectedObject) {
JComponent newTopPanel = emptyPanel;
int dividerLocation = rightSplitPane.getDividerLocation();
if (selectedObject == mathModel) {
newTopPanel = mathModelPropertiesPanel;
mathModelPropertiesPanel.setMathModel(mathModel);
} else if (selectedObject instanceof DocumentEditorTreeFolderNode) {
DocumentEditorTreeFolderNode folderNode = (DocumentEditorTreeFolderNode) selectedObject;
DocumentEditorTreeFolderClass folderClass = folderNode.getFolderClass();
if (folderClass == DocumentEditorTreeFolderClass.MATH_ANNOTATION_NODE) {
newTopPanel = mathModelPropertiesPanel;
} else if (folderClass == DocumentEditorTreeFolderClass.MATH_VCML_NODE) {
newTopPanel = vcmlEditorPanel;
} else if (folderClass == DocumentEditorTreeFolderClass.MATH_GEOMETRY_NODE) {
newTopPanel = geometryViewer;
} else if (folderClass == DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE) {
newTopPanel = simulationListPanel;
} else if (folderClass == DocumentEditorTreeFolderClass.MATH_OUTPUT_FUNCTIONS_NODE) {
newTopPanel = outputFunctionsPanel;
outputFunctionsPanel.setSimulationWorkspace(mathModelWindowManager.getSimulationWorkspace());
}
}
Component rightTopComponent = rightSplitPane.getTopComponent();
if (rightTopComponent != newTopPanel) {
newTopPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
rightSplitPane.setTopComponent(newTopPanel);
}
rightSplitPane.setDividerLocation(dividerLocation);
}
use of cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass in project vcell by virtualcell.
the class MathModelEditorTreeCellRenderer method getTreeCellRendererComponent.
// public void setMathModel(MathModel mm) {
// mathModel = mm;
// }
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (regularFont == null) {
regularFont = getFont();
boldFont = regularFont.deriveFont(Font.BOLD);
}
Font font = regularFont;
Icon icon = null;
String labelText = null;
String toolTipPrefix = "";
String toolTipSuffix = "";
if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
if (node.getChildCount() > 0) {
icon = getIcon();
}
Object userObj = node.getUserObject();
if (userObj instanceof MathModel) {
font = boldFont;
icon = VCellIcons.documentIcon;
labelText = ((MathModel) userObj).getName();
toolTipPrefix = "MathModel: ";
} else if (userObj instanceof DocumentEditorTreeFolderNode) {
// --- 1st level folders
DocumentEditorTreeFolderNode folder = (DocumentEditorTreeFolderNode) userObj;
labelText = folder.getName();
if (folder.isBold()) {
font = boldFont;
}
DocumentEditorTreeFolderClass folderClass = folder.getFolderClass();
switch(folderClass) {
case MATH_VCML_NODE:
icon = VCellIcons.textNotesIcon;
break;
case MATH_GEOMETRY_NODE:
icon = VCellIcons.geometryIcon;
break;
case MATH_SIMULATIONS_NODE:
icon = VCellIcons.simulationIcon;
break;
case MATH_OUTPUT_FUNCTIONS_NODE:
icon = VCellIcons.getOutputFunctionIcon();
break;
}
}
}
setIcon(icon);
setFont(font);
setText(labelText);
if (toolTipSuffix.length() == 0) {
toolTipSuffix = labelText;
}
setToolTipText(toolTipPrefix + toolTipSuffix);
return this;
}
use of cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method onActiveViewChange.
@Override
protected void onActiveViewChange(ActiveView activeView) {
super.onActiveViewChange(activeView);
SimulationContext selectedSimContext = activeView.getSimulationContext();
DocumentEditorTreeFolderClass folderClass = activeView.getDocumentEditorTreeFolderClass();
if (selectedSimContext != null || folderClass == null) {
return;
}
switch(folderClass) {
case PATHWAY_DIAGRAM_NODE:
tabbedPane.setSelectedIndex(PathwayPanelTabID.pathway_diagram.ordinal());
break;
case PATHWAY_OBJECTS_NODE:
tabbedPane.setSelectedIndex(PathwayPanelTabID.pathway_objects.ordinal());
break;
case BIOPAX_SUMMARY_NODE:
tabbedPane.setSelectedIndex(PathwayPanelTabID.biopax_summary.ordinal());
break;
case BIOPAX_TREE_NODE:
tabbedPane.setSelectedIndex(PathwayPanelTabID.biopax_tree.ordinal());
break;
}
}
use of cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass in project vcell by virtualcell.
the class BioModelEditorTreeCellRenderer method getTreeCellRendererComponent.
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (regularFont == null) {
regularFont = getFont();
boldFont = regularFont.deriveFont(Font.BOLD);
}
Font font = regularFont;
Icon icon = null;
String labelText = null;
String toolTipPrefix = "";
String toolTipSuffix = "";
if (value instanceof LinkNode) {
LinkNode ln = (LinkNode) value;
String link = ln.getLink();
String text = ln.getText();
String qualifier = ln.getMiriamQualifier().getDescription();
if (link != null) {
String colorString = (sel) ? "white" : "blue";
toolTipPrefix = "double-click to open link " + link;
labelText = "<html>" + qualifier + " <font color=\"" + colorString + "\"><a href=" + link + ">" + text + "</a></font></html>";
} else {
String colorString = (sel) ? "white" : "black";
labelText = "<html>" + qualifier + " <font color=\"" + colorString + "\">" + text + "</font></html>";
}
} else if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
Object userObj = node.getUserObject();
if (userObj instanceof BioModel) {
font = boldFont;
icon = VCellIcons.documentIcon;
labelText = ((BioModel) userObj).getName();
toolTipPrefix = "BioModel: ";
} else if (userObj instanceof SimulationContext) {
// --- root: application name
font = boldFont;
// icon = VCellIcons.applicationIcon;
SimulationContext simContext = (SimulationContext) userObj;
if (simContext.isRuleBased()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appRbmNonspIcon;
toolTipSuffix = "Rule Based / Non spatial";
}
} else if (simContext.isStoch()) {
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appStoNonspIcon;
toolTipSuffix = "Stochastic / Non spatial";
} else {
icon = VCellIcons.appStoSpatialIcon;
toolTipSuffix = "Stochastic / Spatial";
}
} else {
// deterministic
if (simContext.getGeometry().getDimension() == 0) {
icon = VCellIcons.appDetNonspIcon;
toolTipSuffix = "Deterministic / Non spatial";
} else {
icon = VCellIcons.appDetSpatialIcon;
toolTipSuffix = "Deterministic / Spatial";
}
}
labelText = /*"Application: " + */
((SimulationContext) userObj).getName();
toolTipPrefix = "Application: ";
} else if (userObj instanceof DocumentEditorTreeFolderNode) {
// --- 1st level folders
DocumentEditorTreeFolderNode folder = (DocumentEditorTreeFolderNode) userObj;
labelText = folder.getName();
if (folder.isBold()) {
font = boldFont;
}
DocumentEditorTreeFolderClass folderClass = folder.getFolderClass();
switch(folderClass) {
// break;
case REACTIONS_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
int numReactions = bioModel.getModel().getNumReactions();
if (bioModel.getModel().getRbmModelContainer() != null) {
numReactions += bioModel.getModel().getRbmModelContainer().getReactionRuleList().size();
}
labelText = folder.getName() + " (" + numReactions + ")";
}
break;
case STRUCTURES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getModel().getNumStructures() + ")";
}
break;
case SPECIES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getModel().getNumSpeciesContexts() + ")";
}
break;
case MOLECULAR_TYPES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
if (rbmModelContainer == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + rbmModelContainer.getMolecularTypeList().size() + ")";
}
}
break;
case OBSERVABLES_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
if (rbmModelContainer == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + rbmModelContainer.getObservableList().size() + ")";
}
}
break;
case APPLICATIONS_NODE:
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getNumSimulationContexts() + ")";
}
break;
case REACTION_DIAGRAM_NODE:
icon = VCellIcons.diagramIcon;
break;
// break;
case GEOMETRY_NODE:
icon = VCellIcons.geometryIcon;
break;
case SPECIFICATIONS_NODE:
icon = VCellIcons.settingsIcon;
break;
case PROTOCOLS_NODE:
icon = VCellIcons.protocolsIcon;
break;
case SIMULATIONS_NODE:
icon = VCellIcons.simulationIcon;
break;
case PARAMETER_ESTIMATION_NODE:
icon = VCellIcons.fittingIcon;
break;
case PATHWAY_DIAGRAM_NODE:
icon = VCellIcons.diagramIcon;
break;
case PATHWAY_OBJECTS_NODE:
icon = VCellIcons.tableIcon;
if (bioModel == null) {
labelText = folder.getName() + "(00000)";
} else {
labelText = folder.getName() + " (" + bioModel.getPathwayModel().getBiopaxObjects().size() + ")";
}
break;
case BIOPAX_SUMMARY_NODE:
icon = VCellIcons.textNotesIcon;
break;
case BIOPAX_TREE_NODE:
icon = VCellIcons.tableIcon;
break;
}
}
}
setIcon(icon);
setFont(font);
setText(labelText);
if (toolTipSuffix.length() == 0) {
toolTipSuffix = labelText;
}
setToolTipText(toolTipPrefix + toolTipSuffix);
return this;
}
use of cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass in project vcell by virtualcell.
the class DocumentEditor method construcutPopupMenu.
private void construcutPopupMenu() {
popupMenu.removeAll();
TreePath[] selectedPaths = documentEditorTree.getSelectionPaths();
boolean bRename = false;
boolean bExpand = true;
boolean bAddNew = false;
boolean bAddNewApp = false;
boolean bCopyApp = false;
boolean bDelete = false;
boolean bNewBiomodel = false;
boolean bRemoveApps = false;
DocumentEditorTreeFolderClass folderClass = null;
for (TreePath tp : selectedPaths) {
Object obj = tp.getLastPathComponent();
if (obj == null || !(obj instanceof BioModelNode)) {
continue;
}
if (documentEditorTree.getModel().isLeaf(obj)) {
bExpand = false;
}
BioModelNode selectedNode = (BioModelNode) obj;
Object userObject = selectedNode.getUserObject();
if (userObject instanceof DocumentEditorTreeFolderNode) {
folderClass = ((DocumentEditorTreeFolderNode) userObject).getFolderClass();
if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
bAddNewApp = true;
if (selectedNode.getChildCount() > 0) {
bRemoveApps = true;
}
} else if (folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE || folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE || folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE || folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE || folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE || folderClass == DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE) {
bAddNew = (selectedPaths.length == 1);
bRename = false;
}
} else if (userObject instanceof SimulationContext) {
bRename = true;
bCopyApp = true;
bDelete = true;
bNewBiomodel = true;
}
}
if (selectedPaths.length != 1) {
bRename = false;
}
if (bAddNewApp) {
if (addNewAppMenu == null) {
addNewAppMenu = new JMenu("New Application");
addNewAppDeterministicMenuItem = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
addNewAppDeterministicMenuItem.addActionListener(eventHandler);
addNewAppStochasticMenuItem = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
addNewAppStochasticMenuItem.addActionListener(eventHandler);
addNewAppRulebasedMenuItem = new JMenuItem(GuiConstants.MENU_TEXT_RULEBASED_APPLICATION);
addNewAppRulebasedMenuItem.addActionListener(eventHandler);
addNewAppMenu.add(addNewAppDeterministicMenuItem);
addNewAppMenu.add(addNewAppStochasticMenuItem);
addNewAppMenu.add(addNewAppRulebasedMenuItem);
}
popupMenu.add(addNewAppMenu);
}
if (bRemoveApps) {
if (removeAppsMenu == null) {
removeAppsMenu = new JMenuItem("Remove Apps...");
removeAppsMenu.addActionListener(eventHandler);
}
popupMenu.add(removeAppsMenu);
}
if (bAddNew) {
String addText = "New";
if (folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) {
addText += " Reaction";
} else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
addText += " Compartment";
} else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
addText += " Species";
} else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
addText += " Molecule";
} else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
addText += " Observable";
} else if (folderClass == DocumentEditorTreeFolderClass.MATH_SIMULATIONS_NODE) {
addText += " Simulation";
}
addNewMenuItem = new javax.swing.JMenuItem(addText);
addNewMenuItem.addActionListener(eventHandler);
popupMenu.add(addNewMenuItem);
}
if (bRename) {
if (renameMenuItem == null) {
renameMenuItem = new javax.swing.JMenuItem("Rename");
renameMenuItem.addActionListener(eventHandler);
}
popupMenu.add(renameMenuItem);
}
if (bDelete) {
if (deleteMenuItem == null) {
deleteMenuItem = new javax.swing.JMenuItem("Delete");
deleteMenuItem.addActionListener(eventHandler);
}
popupMenu.add(deleteMenuItem);
}
if (bCopyApp) {
if (menuItemAppCopy == null) {
menuItemAppCopy = new JMenuItem(GuiConstants.MENU_TEXT_APP_COPY);
menuItemAppCopy.addActionListener(eventHandler);
menuItemAppCopy.setActionCommand(GuiConstants.ACTIONCMD_COPY_APPLICATION);
}
if (menuAppCopyAs == null) {
menuAppCopyAs = new JMenu(GuiConstants.MENU_TEXT_APP_COPYAS);
}
menuAppCopyAs.removeAll();
SimulationContext selectedSimContext = getSelectedSimulationContext();
if (selectedSimContext != null) {
if (selectedSimContext.getGeometry().getDimension() == 0) {
if (menuItemNonSpatialCopyDeterministic == null) {
menuItemNonSpatialCopyStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
menuItemNonSpatialCopyStochastic.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_STOCHASTIC_APPLICATION);
menuItemNonSpatialCopyStochastic.addActionListener(eventHandler);
menuItemNonSpatialCopyDeterministic = new javax.swing.JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
menuItemNonSpatialCopyDeterministic.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_DETERMINISTIC_APPLICATION);
menuItemNonSpatialCopyDeterministic.addActionListener(eventHandler);
menuItemNonSpatialCopyRulebased = new javax.swing.JMenuItem(GuiConstants.MENU_TEXT_RULEBASED_APPLICATION);
menuItemNonSpatialCopyRulebased.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_RULEBASED_APPLICATION);
menuItemNonSpatialCopyRulebased.addActionListener(eventHandler);
}
menuAppCopyAs.add(menuItemNonSpatialCopyDeterministic);
menuAppCopyAs.add(menuItemNonSpatialCopyStochastic);
menuAppCopyAs.add(menuItemNonSpatialCopyRulebased);
} else {
if (menuSpatialCopyAsNonSpatial == null) {
menuSpatialCopyAsNonSpatial = new JMenu(GuiConstants.MENU_TEXT_NON_SPATIAL_APPLICATION);
menuItemSpatialCopyAsNonSpatialDeterministic = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
menuItemSpatialCopyAsNonSpatialDeterministic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_DETERMINISTIC_APPLICATION);
menuItemSpatialCopyAsNonSpatialDeterministic.addActionListener(eventHandler);
menuItemSpatialCopyAsNonSpatialStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
menuItemSpatialCopyAsNonSpatialStochastic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_STOCHASTIC_APPLICATION);
menuItemSpatialCopyAsNonSpatialStochastic.addActionListener(eventHandler);
menuItemSpatialCopyAsNonSpatialRulebased = new JMenuItem(GuiConstants.MENU_TEXT_RULEBASED_APPLICATION);
menuItemSpatialCopyAsNonSpatialRulebased.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_RULEBASED_APPLICATION);
menuItemSpatialCopyAsNonSpatialRulebased.addActionListener(eventHandler);
menuSpatialCopyAsNonSpatial.add(menuItemSpatialCopyAsNonSpatialDeterministic);
menuSpatialCopyAsNonSpatial.add(menuItemSpatialCopyAsNonSpatialStochastic);
menuSpatialCopyAsNonSpatial.add(menuItemSpatialCopyAsNonSpatialRulebased);
menuSpatialCopyAsSpatial = new JMenu(GuiConstants.MENU_TEXT_SPATIAL_APPLICATION);
menuItemSpatialCopyAsSpatialDeterministic = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
menuItemSpatialCopyAsSpatialDeterministic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_DETERMINISTIC_APPLICATION);
menuItemSpatialCopyAsSpatialDeterministic.addActionListener(eventHandler);
menuItemSpatialCopyAsSpatialStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
menuItemSpatialCopyAsSpatialStochastic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_STOCHASTIC_APPLICATION);
menuItemSpatialCopyAsSpatialStochastic.addActionListener(eventHandler);
menuItemSpatialCopyAsSpatialRulebased = new JMenuItem(GuiConstants.MENU_TEXT_RULEBASED_APPLICATION);
menuItemSpatialCopyAsSpatialRulebased.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_RULEBASED_APPLICATION);
menuItemSpatialCopyAsSpatialRulebased.addActionListener(eventHandler);
menuSpatialCopyAsSpatial.add(menuItemSpatialCopyAsSpatialDeterministic);
menuSpatialCopyAsSpatial.add(menuItemSpatialCopyAsSpatialStochastic);
// menuSpatialCopyAsSpatial.add(menuItemSpatialCopyAsSpatialRulebased); // not supported yet, uncomment when time comes
}
menuAppCopyAs.add(menuSpatialCopyAsNonSpatial);
menuAppCopyAs.add(menuSpatialCopyAsSpatial);
}
}
if (popupMenu.getComponents().length > 0) {
popupMenu.add(new JSeparator());
}
popupMenu.add(menuItemAppCopy);
popupMenu.add(menuAppCopyAs);
}
if (bNewBiomodel) {
menuItemNewBiomodelFromApp = new JMenuItem(GuiConstants.MENU_TEXT_APP_NEWBIOMODEL);
menuItemNewBiomodelFromApp.addActionListener(eventHandler);
popupMenu.add(menuItemNewBiomodelFromApp);
}
if (bExpand) {
if (expandAllMenuItem == null) {
popupMenuSeparator = new JSeparator();
expandAllMenuItem = new javax.swing.JMenuItem("Expand All");
collapseAllMenuItem = new javax.swing.JMenuItem("Collapse All");
expandAllMenuItem.addActionListener(eventHandler);
collapseAllMenuItem.addActionListener(eventHandler);
}
if (popupMenu.getComponents().length > 0) {
popupMenu.add(popupMenuSeparator);
}
popupMenu.add(expandAllMenuItem);
popupMenu.add(collapseAllMenuItem);
}
}
Aggregations