use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class DocumentEditor method initialize.
/**
* Initialize the class.
*/
private void initialize() {
try {
setLayout(new BorderLayout());
getToolkit().addAWTEventListener(new AWTEventListener() {
public void eventDispatched(AWTEvent event) {
try {
switch(event.getID()) {
case KeyEvent.KEY_RELEASED:
documentEditor_eventDispatched(event);
break;
case MouseEvent.MOUSE_RELEASED:
documentEditor_eventDispatched(event);
break;
}
} catch (Exception e) {
e.printStackTrace();
// consume any exception ... don't screw up the swing event queue.
}
}
}, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
documentEditorTree = new javax.swing.JTree() {
@Override
public boolean isPathEditable(TreePath path) {
Object object = path.getLastPathComponent();
return (object instanceof BioModelNode) && (((BioModelNode) object).getUserObject() instanceof SimulationContext);
}
};
documentEditorTree.setEditable(true);
documentEditorTree.setLargeModel(true);
documentEditorTreeCellEditor = new DocumentEditorTreeCellEditor(documentEditorTree);
documentEditorTree.setCellEditor(documentEditorTreeCellEditor);
documentEditorTree.setName("bioModelEditorTree");
ToolTipManager.sharedInstance().registerComponent(documentEditorTree);
int rowHeight = documentEditorTree.getRowHeight();
if (rowHeight < 10) {
rowHeight = 20;
}
documentEditorTree.setRowHeight(rowHeight + 2);
documentEditorTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
JSplitPane leftSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
databaseWindowPanel = new DatabaseWindowPanel(false, false);
leftBottomTabbedPane = new JTabbedPaneEnhanced();
leftBottomTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
leftBottomTabbedPane.addTab("VCell DB", databaseWindowPanel);
JScrollPane treePanel = new javax.swing.JScrollPane(documentEditorTree);
leftSplitPane.setTopComponent(treePanel);
leftBottomTabbedPane.setMinimumSize(new java.awt.Dimension(198, 148));
leftSplitPane.setBottomComponent(leftBottomTabbedPane);
leftSplitPane.setResizeWeight(0.5);
leftSplitPane.setDividerLocation(300);
leftSplitPane.setDividerSize(8);
leftSplitPane.setOneTouchExpandable(true);
rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
rightSplitPane.setResizeWeight(0.7);
rightSplitPane.setDividerLocation(400);
rightSplitPane.setDividerSize(8);
rightSplitPane.setOneTouchExpandable(true);
rightBottomEmptyPanel = new JPanel(new GridBagLayout());
rightBottomEmptyPanel.setBackground(Color.white);
treeNodeDescriptionLabel = new JLabel(generalTreeNodeDescription);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.insets = new Insets(10, 10, 4, 4);
gbc.gridy = 0;
gbc.weighty = 1.0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.PAGE_START;
rightBottomEmptyPanel.add(treeNodeDescriptionLabel, gbc);
issuePanel = new IssuePanel();
rightBottomTabbedPane = new JTabbedPaneEnhanced();
rightBottomTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
rightBottomEmptyPanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
issuePanel.setBorder(GuiConstants.TAB_PANEL_BORDER);
rightBottomTabbedPane.addTab(TAB_TITLE_OBJECT_PROPERTIES, rightBottomEmptyPanel);
rightBottomTabbedPane.addTab(TAB_TITLE_PROBLEMS, issuePanel);
rightBottomTabbedPane.setMinimumSize(new java.awt.Dimension(198, 148));
rightSplitPane.setBottomComponent(rightBottomTabbedPane);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setDividerLocation(270);
splitPane.setOneTouchExpandable(true);
splitPane.setResizeWeight(0.3);
splitPane.setDividerSize(8);
splitPane.setLeftComponent(leftSplitPane);
splitPane.setRightComponent(rightSplitPane);
add(splitPane, BorderLayout.CENTER);
issueManager.addIssueEventListener(eventHandler);
selectionManager.addPropertyChangeListener(eventHandler);
databaseWindowPanel.setSelectionManager(selectionManager);
documentEditorTree.addTreeSelectionListener(eventHandler);
documentEditorTree.addMouseListener(eventHandler);
bioModelMetaDataPanel = new BioModelMetaDataPanel();
bioModelMetaDataPanel.setSelectionManager(selectionManager);
mathModelMetaDataPanel = new MathModelMetaDataPanel();
mathModelMetaDataPanel.setSelectionManager(selectionManager);
geometryMetaDataPanel = new GeometryMetaDataPanel();
geometryMetaDataPanel.setSelectionManager(selectionManager);
issuePanel.setSelectionManager(selectionManager);
issuePanel.setIssueManager(issueManager);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class DocumentEditor method treeSelectionChanged0.
private void treeSelectionChanged0(TreeSelectionEvent treeSelectionEvent) {
try {
treeSelectionChanged();
Object selectedNode = documentEditorTree.getLastSelectedPathComponent();
if (selectedNode != null && (selectedNode instanceof BioModelNode)) {
Object selectedObject = ((BioModelNode) selectedNode).getUserObject();
DocumentEditorTreeFolderClass folderClass = null;
if (selectedObject instanceof DocumentEditorTreeFolderNode) {
folderClass = ((DocumentEditorTreeFolderNode) selectedObject).getFolderClass();
}
ActiveView activeView = new ActiveView(getSelectedSimulationContext(), folderClass, null);
selectionManager.setActiveView(activeView);
if (/*selectedObject instanceof SimulationContext
|| */
selectedObject instanceof BioModel || selectedObject instanceof MathModel) {
selectionManager.setSelectedObjects(new Object[] { selectedObject });
}
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class DocumentEditor method getSelectedSimulationContext.
protected SimulationContext getSelectedSimulationContext() {
if (this instanceof MathModelEditor) {
return null;
}
// make sure only one simulation context is selected
TreePath[] selectedPaths = documentEditorTree.getSelectionPaths();
SimulationContext simulationContext = null;
for (TreePath path : selectedPaths) {
Object node = path.getLastPathComponent();
if (!(node instanceof BioModelNode)) {
return null;
}
BioModelNode n = (BioModelNode) node;
while (true) {
Object userObject = n.getUserObject();
if (userObject instanceof SimulationContext) {
if (simulationContext == null) {
simulationContext = (SimulationContext) userObject;
break;
} else if (simulationContext != userObject) {
return null;
}
}
TreeNode parent = n.getParent();
if (parent == null || !(parent instanceof BioModelNode)) {
break;
}
n = (BioModelNode) parent;
}
}
return simulationContext;
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class DocumentEditorTreeCellEditor method getTreeCellEditorComponent.
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
Component component = null;
if (value instanceof BioModelNode) {
Object userObject = ((BioModelNode) value).getUserObject();
if (userObject instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) userObject;
if (sc.isRuleBased()) {
if (sc.getGeometry().getDimension() == 0) {
renderer.setOpenIcon(VCellIcons.appRbmNonspIcon);
renderer.setClosedIcon(VCellIcons.appRbmNonspIcon);
renderer.setLeafIcon(VCellIcons.appRbmNonspIcon);
}
} else if (sc.isStoch()) {
if (sc.getGeometry().getDimension() == 0) {
renderer.setOpenIcon(VCellIcons.appStoNonspIcon);
renderer.setClosedIcon(VCellIcons.appStoNonspIcon);
renderer.setLeafIcon(VCellIcons.appStoNonspIcon);
} else {
renderer.setOpenIcon(VCellIcons.appStoSpatialIcon);
renderer.setClosedIcon(VCellIcons.appStoSpatialIcon);
renderer.setLeafIcon(VCellIcons.appStoSpatialIcon);
}
} else {
// deterministic
if (sc.getGeometry().getDimension() == 0) {
renderer.setOpenIcon(VCellIcons.appDetNonspIcon);
renderer.setClosedIcon(VCellIcons.appDetNonspIcon);
renderer.setLeafIcon(VCellIcons.appDetNonspIcon);
} else {
renderer.setOpenIcon(VCellIcons.appDetSpatialIcon);
renderer.setClosedIcon(VCellIcons.appDetSpatialIcon);
renderer.setLeafIcon(VCellIcons.appDetSpatialIcon);
}
}
component = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
if (editingComponent instanceof JTextField) {
String text = null;
JTextField textField = (JTextField) editingComponent;
text = ((SimulationContext) userObject).getName();
textField.setText(text);
}
}
}
return component;
}
use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.
the class DocumentEditorTreeModel method findNodeByFolderClass.
private BioModelNode findNodeByFolderClass(BioModelNode startNode, DocumentEditorTreeFolderClass folderClass) {
Object userObject = startNode.getUserObject();
if (userObject instanceof DocumentEditorTreeFolderNode && folderClass.equals(((DocumentEditorTreeFolderNode) userObject).getFolderClass())) {
return startNode;
}
for (int i = 0; i < startNode.getChildCount(); i++) {
BioModelNode childNode = (BioModelNode) startNode.getChildAt(i);
BioModelNode node = findNodeByFolderClass(childNode, folderClass);
if (node != null) {
return node;
}
}
return null;
}
Aggregations