use of javax.swing.event.TreeSelectionEvent in project cayenne by apache.
the class ProjectTreeView method initTreeSelectionListener.
private void initTreeSelectionListener() {
treeSelectionListener = new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
TreePath[] paths = getSelectionPaths();
if (paths != null) {
if (paths.length > 1) {
ConfigurationNode projectParentPath = null;
ConfigurationNode[] projectPaths = new ConfigurationNode[paths.length];
boolean commonParentPath = true;
for (int i = 0; i < paths.length; i++) {
projectPaths[i] = createProjectPath(paths[i]);
TreePath parentPath = paths[i].getParentPath();
if (i > 0 && parentPath != null && !parentPath.equals(paths[i - 1].getParentPath())) {
commonParentPath = false;
}
}
if (commonParentPath) {
TreePath parentPath = paths[0].getParentPath();
projectParentPath = createProjectPath(parentPath);
}
mediator.fireMultipleObjectsDisplayEvent(new MultipleObjectsDisplayEvent(this, projectPaths, projectParentPath));
} else if (paths.length == 1) {
processSelection(paths[0]);
}
}
}
/**
* Converts TreePath to Object
*/
private ConfigurationNode createProjectPath(TreePath treePath) {
Object[] path = treePath.getPath();
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path[path.length - 1];
return (ConfigurationNode) treeNode.getUserObject();
}
};
addTreeSelectionListener(treeSelectionListener);
}
use of javax.swing.event.TreeSelectionEvent in project vcell by virtualcell.
the class BioModelEditorSabioPanel method initialize.
private void initialize() {
responseTree = new JTree();
responseTreeModel = new ResponseTreeModel();
responseTree.setModel(responseTreeModel);
ToolTipManager.sharedInstance().registerComponent(responseTree);
setLayout(new BorderLayout());
GridBagConstraints gbc = new GridBagConstraints();
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
// ------- panel 1 ---------------
JLabel categoryLabel1 = new JLabel("Role: ");
panel1 = new JPanel();
panel1.setBorder(BorderFactory.createTitledBorder(" Search "));
panel1.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
panel1.add(categoryLabel1, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
panel1.add(entityName1, gbc);
gbc = new GridBagConstraints();
searchSabioDatabaseButton = new JButton("Search");
searchSabioDatabaseButton.addActionListener(eventHandler);
searchSabioDatabaseButton.setEnabled(true);
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets(2, 4, 4, 4);
panel1.add(searchSabioDatabaseButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
p.add(panel1);
// ------- panel 2 -----------------
panel2 = new CollapsiblePanel(" Advanced Search ", false, BorderFactory.createLineBorder(new Color(213, 223, 229)));
panel2.getContentPanel().setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.insets = new Insets(4, 4, 4, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.LINE_START;
JLabel categoryLabel2 = new JLabel("Category");
categoryList2.setSelectedIndex(3);
categoryList2.addActionListener(eventHandler);
JLabel entityLabel2 = new JLabel("Entity");
entityName2.addActionListener(eventHandler);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(2, 2, 2, 0);
panel2.getContentPanel().add(categoryLabel2, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 2, 2, 0);
panel2.getContentPanel().add(categoryList2, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(2, 2, 2, 0);
panel2.getContentPanel().add(entityLabel2, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(0, 0, 2, 2);
panel2.getContentPanel().add(entityName2, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
p.add(panel2, gbc);
// ------- tree ------------------
JPanel p1 = new JPanel(new BorderLayout());
p1.add(new JScrollPane(responseTree));
// ------- the panels -------------
add(p, BorderLayout.NORTH);
add(p1, BorderLayout.CENTER);
ResponseTreeCellRenderer renderer = new ResponseTreeCellRenderer();
// also available kineticLaw2Icon more colorful
renderer.setLeafIcon(VCellIcons.kineticLawIcon);
responseTree.setCellRenderer(renderer);
responseTree.setRootVisible(false);
responseTree.getSelectionModel().addTreeSelectionListener(eventHandler);
// responseTree.addMouseListener( new MouseAdapter(){
// public void mouseClicked(MouseEvent e){
// if (e.getClickCount() <= 1) {
// return;
// }
// treeSelectionChanged(); // for double click
// }
// });
responseTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
Object obj = responseTree.getLastSelectedPathComponent();
if (obj == null || !(obj instanceof BioModelNode)) {
return;
}
BioModelNode selectedNode = (BioModelNode) obj;
Object userObject = selectedNode.getUserObject();
setSelectedObjects(new Object[] { userObject });
}
});
}
use of javax.swing.event.TreeSelectionEvent in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method initialize.
/**
* This method initializes this
*/
private void initialize() {
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.gridx = 0;
gridBagConstraints5.fill = GridBagConstraints.NONE;
gridBagConstraints5.insets = new Insets(4, 4, 4, 4);
gridBagConstraints5.gridy = 2;
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.fill = GridBagConstraints.BOTH;
gridBagConstraints1.weighty = 1.0;
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.weightx = 1.0;
this.setLayout(new GridBagLayout());
this.setSize(new Dimension(627, 333));
this.add(getJScrollPane(), gridBagConstraints1);
this.add(getJPanel(), gridBagConstraints5);
getJButtonAdd().setEnabled(false);
getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
getJButtonAdd().setEnabled(((JTree) e.getSource()).getSelectionPath() != null && ((JTree) e.getSource()).getSelectionPath().getLastPathComponent() instanceof IdentifiableNode);
// getJButtonAdd().setEnabled(e.getPath().getLastPathComponent() instanceof IdentifiableNode);
}
});
}
use of javax.swing.event.TreeSelectionEvent in project sldeditor by robward-scisys.
the class FilterPanelv2 method createUI.
/**
* Creates the ui.
*/
private void createUI() {
JPanel treePanel = new JPanel();
getContentPane().add(treePanel, BorderLayout.WEST);
treePanel.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane = new JScrollPane();
treePanel.add(scrollPane);
Dimension preferredSize = new Dimension(400, 350);
scrollPane.setPreferredSize(preferredSize);
model = new ExpressionTreeModel(rootNode);
tree = new JTree(model);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
treeSelected();
}
});
scrollPane.setViewportView(tree);
JPanel rightPanel = new JPanel(new BorderLayout());
JPanel optionPanel = new JPanel(new BorderLayout());
rightPanel.add(optionPanel, BorderLayout.NORTH);
optionalCheckBox = new JCheckBox("Optional");
optionalCheckBox.setVisible(false);
optionalCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
optionalCheckBoxSelected();
}
});
optionPanel.add(optionalCheckBox, BorderLayout.NORTH);
dataPanel = new JPanel(new CardLayout());
dataPanel.add(emptyPanel, EMPTY_PANEL);
expressionPanel = new ExpressionSubPanel(this);
dataPanel.add(expressionPanel, ExpressionSubPanel.class.getName());
filterPanel = new FilterSubPanel(this);
dataPanel.add(filterPanel, FilterSubPanel.class.getName());
literalPanel = new LiteralPanel(this);
dataPanel.add(literalPanel, LiteralPanel.class.getName());
propertyPanel = new PropertyPanel(this);
dataPanel.add(propertyPanel, PropertyPanel.class.getName());
envVarPanel = new EnvVarPanel(this);
dataPanel.add(envVarPanel, EnvVarPanel.class.getName());
rightPanel.add(dataPanel, BorderLayout.CENTER);
getContentPane().add(rightPanel, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.TRAILING);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
btnOk = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.ok"));
btnOk.setEnabled(false);
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
closeDialog(true);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
closeDialog(false);
}
});
buttonPanel.add(btnCancel);
JPanel resultPanel = new JPanel();
getContentPane().add(resultPanel, BorderLayout.NORTH);
resultPanel.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane1 = new JScrollPane();
resultPanel.add(scrollPane1);
textArea = new JTextArea();
textArea.setRows(2);
textArea.setEditable(false);
scrollPane1.setViewportView(textArea);
}
use of javax.swing.event.TreeSelectionEvent in project sldeditor by robward-scisys.
the class ExpressionPanelv2 method createUI.
/**
* Creates the ui.
*/
private void createUI() {
JPanel treePanel = new JPanel();
getContentPane().add(treePanel, BorderLayout.WEST);
treePanel.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane = new JScrollPane();
treePanel.add(scrollPane);
Dimension preferredSize = new Dimension(400, 350);
scrollPane.setPreferredSize(preferredSize);
model = new ExpressionTreeModel(rootNode);
tree = new JTree(model);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
treeSelected(selectedNode);
}
});
scrollPane.setViewportView(tree);
dataPanel = new JPanel(new CardLayout());
dataPanel.add(emptyPanel, EMPTY_PANEL);
expressionPanel = new ExpressionSubPanel(this);
dataPanel.add(expressionPanel, ExpressionSubPanel.class.getName());
FilterSubPanel filterPanel = new FilterSubPanel(this);
dataPanel.add(filterPanel, FilterSubPanel.class.getName());
literalPanel = new LiteralPanel(this);
dataPanel.add(literalPanel, LiteralPanel.class.getName());
propertyPanel = new PropertyPanel(this);
dataPanel.add(propertyPanel, PropertyPanel.class.getName());
envVarPanel = new EnvVarPanel(this);
dataPanel.add(envVarPanel, EnvVarPanel.class.getName());
getContentPane().add(dataPanel, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.TRAILING);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
btnOk = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.ok"));
btnOk.setEnabled(false);
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = true;
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(ExpressionPanelv2.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
JPanel resultPanel = new JPanel();
getContentPane().add(resultPanel, BorderLayout.NORTH);
resultPanel.setLayout(new BorderLayout(0, 0));
JScrollPane scrollPane1 = new JScrollPane();
scrollPane1.setPreferredSize(new Dimension(800, 30));
resultPanel.add(scrollPane1);
textArea = new JTextArea();
textArea.setEditable(false);
scrollPane1.setViewportView(textArea);
}
Aggregations