use of javax.swing.event.TreeSelectionListener in project vcell by virtualcell.
the class AnnotationsPanel method initialize.
private void initialize() {
try {
setLayout(new GridBagLayout());
setBackground(Color.white);
int gridy = 0;
GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.SOUTHWEST;
add(getBottomPanel(), gbc);
// used just to initialize emptyText once
JTextPane tenpTextPane = new JTextPane();
tenpTextPane.setContentType("text/html");
tenpTextPane.setText(null);
emptyHtmlText = tenpTextPane.getText();
initializeComboBoxQualifier();
getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
TreePath tp = ((JTree) e.getSource()).getSelectionPath();
if (tp == null) {
getJButtonDeleteRef().setEnabled(false);
} else {
Object lastPathComponent = tp.getLastPathComponent();
getJButtonDeleteRef().setEnabled(tp != null && lastPathComponent instanceof LinkNode);
}
}
});
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of javax.swing.event.TreeSelectionListener in project vcell by virtualcell.
the class VCellConfigurationPanel method initialize.
private void initialize() {
generalConfigurationPanel = new GeneralConfigurationPanel();
generalConfigurationPanel.setName("generalConfigurationPanel");
pythonConfigurationPanel = new PythonConfigurationPanel3();
pythonConfigurationPanel.setName("pythonConfigurationPanel");
comsolConfigurationPanel = new ComsolConfigurationPanel();
comsolConfigurationPanel.setName("comsolConfigurationPanel");
bioNetGenConfigurationPanel = new BioNetGenConfigurationPanel();
bioNetGenConfigurationPanel.setName("bioNetGenConfigurationPanel");
configurationOptionsTree = new javax.swing.JTree();
configurationOptionsTreeModel = new ConfigurationOptionsTreeModel(configurationOptionsTree);
configurationOptionsTree.setModel(configurationOptionsTreeModel);
configurationOptionsTree.setEditable(false);
configurationOptionsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
configurationOptionsTree.setRootVisible(false);
configurationOptionsTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
ConfigurationModelNode cmn = (ConfigurationModelNode) e.getNewLeadSelectionPath().getLastPathComponent();
ConfigurationOptionsTreeFolderNode cotfn = (ConfigurationOptionsTreeFolderNode) cmn.getUserObject();
switch(cotfn.getFolderClass()) {
case GENERAL_NODE:
splitPane.setRightComponent(generalConfigurationPanel);
break;
case PYTHON_NODE:
splitPane.setRightComponent(pythonConfigurationPanel);
break;
case COMSOL_NODE:
splitPane.setRightComponent(comsolConfigurationPanel);
break;
case BIONETGEN_NODE:
splitPane.setRightComponent(bioNetGenConfigurationPanel);
break;
}
}
});
JScrollPane treePanel = new javax.swing.JScrollPane(configurationOptionsTree);
// Border margin = new EmptyBorder(5,3,1,1);
// treePanel.setBorder(margin);
Dimension dim = new Dimension(150, 300);
// code that contributes to prevent resizing horizontally
treePanel.setPreferredSize(dim);
treePanel.setMinimumSize(dim);
treePanel.setMaximumSize(dim);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT) {
// all code below to make it impossible to move the divider
private final int location = 150;
{
// so that the left component cannot be resized
setDividerLocation(location);
// left component is fixed width
setResizeWeight(0);
// this also makes resizing impossible
setDividerSize(0);
// no UI widget on the divider to quickly expand / collapse
setOneTouchExpandable(false);
}
@Override
public int getDividerLocation() {
return location;
}
@Override
public int getLastDividerLocation() {
return location;
}
};
splitPane.setLeftComponent(treePanel);
splitPane.setRightComponent(generalConfigurationPanel);
// ---------------------------------------------------------------------------
JPanel okCancelPanel = new JPanel();
okCancelPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;
// fake cell used for filling all the vertical empty space
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
gbc.anchor = GridBagConstraints.WEST;
okCancelPanel.add(new JLabel(""), gbc);
// gbc = new GridBagConstraints();
// gbc.gridx = 1;
// gbc.gridy = 0;
// gbc.insets = new Insets(0, 0, 4, 2); // top, left, bottom, right
// okCancelPanel.add(getOkButton(), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.insets = new Insets(0, 2, 4, 4);
okCancelPanel.add(getCloseButton(), gbc);
// --------------------------------------------------------------------------------
setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(1, 1, 1, 1);
add(splitPane, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(1, 1, 1, 1);
add(okCancelPanel, gbc);
// configurationOptionsTree.addTreeSelectionListener(eventHandler);
// configurationOptionsTree.addMouseListener(eventHandler);
configurationOptionsTreeModel.populateTree();
}
Aggregations