use of javax.swing.event.TreeSelectionListener in project qi4j-sdk by Qi4j.
the class TreeModelPane method initQi4J.
/**
* Initialize Qi4J for this component
*
* @param descriptor the Application descriptor
*/
public void initQi4J(ApplicationDetailDescriptor descriptor) {
this.descriptor = descriptor;
// Application Application = (Application) application;
// ApplicationDetailDescriptor descriptor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor( Application );
// traverse the model and build JTree representation
MutableTreeNode rootNode1 = StructureModelBuilder.build(descriptor);
MutableTreeNode rootNode2 = TypeModelBuilder.build(descriptor);
structureTree.setModel(new DefaultTreeModel(rootNode1));
typeTree.setModel(new DefaultTreeModel(rootNode2));
structureTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
structureTreeValueChanged();
}
});
typeTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
typeTreeValueChanged();
}
});
}
use of javax.swing.event.TreeSelectionListener in project binnavi by google.
the class TypeSubstitutionDialog method createControls.
private void createControls(final BaseType stackFrame) {
setBounds(100, 100, 691, 470);
final JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.SOUTH);
panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
final JButton buttonOk = new JButton("OK");
buttonOk.addActionListener(new OkActionListener());
panel.add(buttonOk);
final JButton buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
dispose();
}
});
buttonCancel.setActionCommand("Cancel");
panel.add(buttonCancel);
final JPanel panel1 = new JPanel();
getContentPane().add(panel1, BorderLayout.NORTH);
final GridBagLayout gblPanel1 = new GridBagLayout();
gblPanel1.columnWidths = new int[] { 0, 143, 114, 0 };
gblPanel1.rowHeights = new int[] { 23, 0 };
gblPanel1.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
gblPanel1.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
panel1.setLayout(gblPanel1);
JCheckBox onlyFitting = new JCheckBox("Only show structs that fit immediate offset");
onlyFitting.setEnabled(false);
GridBagConstraints gbcOnlyFitting = new GridBagConstraints();
gbcOnlyFitting.anchor = GridBagConstraints.WEST;
gbcOnlyFitting.insets = new Insets(0, 0, 0, 5);
gbcOnlyFitting.gridx = 0;
gbcOnlyFitting.gridy = 0;
panel1.add(onlyFitting, gbcOnlyFitting);
types = new TypesTree();
types.setModel(new TypesTreeModel(typeManager, new LocalTypesFilter(stackFrame)));
types.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
types.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent event) {
final TypeSelectionPath path = types.determineTypePath();
if (validateUserInput(path)) {
updatePreview(path);
}
}
});
final JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));
centerPanel.add(new JScrollPane(types));
centerPanel.add(preview);
getContentPane().add(centerPanel, BorderLayout.CENTER);
}
use of javax.swing.event.TreeSelectionListener in project sonarqube by SonarSource.
the class ScannerReportViewerApp method initialize.
/**
* Initialize the contents of the frame.
*/
private void initialize() {
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
splitPane = new JSplitPane();
frame.getContentPane().add(splitPane, BorderLayout.CENTER);
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setPreferredSize(new Dimension(500, 7));
splitPane.setRightComponent(tabbedPane);
componentDetailsTab = new JScrollPane();
tabbedPane.addTab("Component details", null, componentDetailsTab, null);
componentEditor = new JEditorPane();
componentDetailsTab.setViewportView(componentEditor);
sourceTab = new JScrollPane();
tabbedPane.addTab("Source", null, sourceTab, null);
sourceEditor = createSourceEditor();
sourceEditor.setEditable(false);
sourceTab.setViewportView(sourceEditor);
textLineNumber = createTextLineNumber();
sourceTab.setRowHeaderView(textLineNumber);
highlightingTab = new JScrollPane();
tabbedPane.addTab("Highlighting", null, highlightingTab, null);
highlightingEditor = new JEditorPane();
highlightingTab.setViewportView(highlightingEditor);
symbolTab = new JScrollPane();
tabbedPane.addTab("Symbol references", null, symbolTab, null);
symbolEditor = new JEditorPane();
symbolTab.setViewportView(symbolEditor);
coverageTab = new JScrollPane();
tabbedPane.addTab("Coverage", null, coverageTab, null);
coverageEditor = new JEditorPane();
coverageTab.setViewportView(coverageEditor);
duplicationTab = new JScrollPane();
tabbedPane.addTab("Duplications", null, duplicationTab, null);
duplicationEditor = new JEditorPane();
duplicationTab.setViewportView(duplicationEditor);
testsTab = new JScrollPane();
tabbedPane.addTab("Tests", null, testsTab, null);
testsEditor = new JEditorPane();
testsTab.setViewportView(testsEditor);
issuesTab = new JScrollPane();
tabbedPane.addTab("Issues", null, issuesTab, null);
issuesEditor = new JEditorPane();
issuesTab.setViewportView(issuesEditor);
externalIssuesTab = new JScrollPane();
tabbedPane.addTab("External Issues", null, externalIssuesTab, null);
externalIssuesEditor = new JEditorPane();
externalIssuesTab.setViewportView(externalIssuesEditor);
measuresTab = new JScrollPane();
tabbedPane.addTab("Measures", null, measuresTab, null);
measuresEditor = new JEditorPane();
measuresTab.setViewportView(measuresEditor);
scmTab = new JScrollPane();
tabbedPane.addTab("SCM", null, scmTab, null);
scmEditor = new JEditorPane();
scmTab.setViewportView(scmEditor);
activeRuleTab = new JScrollPane();
tabbedPane.addTab("Active Rules", null, activeRuleTab, null);
activeRuleEditor = new JEditorPane();
activeRuleTab.setViewportView(activeRuleEditor);
adHocRuleTab = new JScrollPane();
tabbedPane.addTab("Add Hoc Rules", null, adHocRuleTab, null);
adHocRuleEditor = new JEditorPane();
adHocRuleTab.setViewportView(adHocRuleEditor);
qualityProfileTab = new JScrollPane();
tabbedPane.addTab("Quality Profiles", null, qualityProfileTab, null);
qualityProfileEditor = new JEditorPane();
qualityProfileTab.setViewportView(qualityProfileEditor);
pluginTab = new JScrollPane();
tabbedPane.addTab("Plugins", null, pluginTab, null);
pluginEditor = new JEditorPane();
pluginTab.setViewportView(pluginEditor);
cpdTextBlocksTab = new JScrollPane();
tabbedPane.addTab("CPD Text Blocks", null, cpdTextBlocksTab, null);
cpdTextBlocksEditor = new JEditorPane();
cpdTextBlocksTab.setViewportView(cpdTextBlocksEditor);
significantCodeTab = new JScrollPane();
tabbedPane.addTab("Significant Code Ranges", null, significantCodeTab, null);
significantCodeEditor = new JEditorPane();
significantCodeTab.setViewportView(significantCodeEditor);
metadataTab = new JScrollPane();
tabbedPane.addTab("Metadata", null, metadataTab, null);
metadataEditor = new JEditorPane();
metadataTab.setViewportView(metadataEditor);
treeScrollPane = new JScrollPane();
treeScrollPane.setPreferredSize(new Dimension(200, 400));
splitPane.setLeftComponent(treeScrollPane);
componentTree = new JTree();
componentTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("empty") {
{
}
}));
treeScrollPane.setViewportView(componentTree);
componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
componentTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) componentTree.getLastSelectedPathComponent();
if (node == null) {
// Nothing is selected.
return;
}
frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
updateDetails((Component) node.getUserObject());
frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
});
frame.pack();
}
use of javax.swing.event.TreeSelectionListener in project jPOS by jpos.
the class JTreeFactory method create.
public JComponent create(UI ui, Element e) {
final UI parentUI = ui;
final Map map = new HashMap();
final JTree tree = new JTree(getNode(e, map));
String font = e.getAttributeValue("font");
if (font != null)
tree.setFont(Font.decode(font));
tree.setRootVisible(e.getTextTrim().length() > 0);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent evt) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node != null) {
String s = (String) map.get(node);
if (s != null) {
StringTokenizer st = new StringTokenizer(s);
String action = st.nextToken();
String command = null;
if (st.hasMoreTokens())
command = st.nextToken();
ActionListener al = (ActionListener) parentUI.get(action);
if (al != null) {
al.actionPerformed(new ActionEvent(node, 0, command));
}
// System.out.println ("ACTION: " + action);
// System.out.println ("COMMAND: " + command);
}
}
}
});
return tree;
}
use of javax.swing.event.TreeSelectionListener in project vcell by virtualcell.
the class BioModelEditorPathwayCommonsPanel method initialize.
private void initialize() {
searchTextField = new TextFieldAutoCompletion();
searchTextField.addActionListener(eventHandler);
searchTextField.putClientProperty("JTextField.variant", "search");
filterTextField = new TextFieldAutoCompletion();
filterTextField.addActionListener(eventHandler);
filterTextField.addKeyListener(eventHandler);
filterTextField.putClientProperty("JTextField.variant", "filter");
searchButton = new JButton("Search");
searchButton.addActionListener(eventHandler);
sortButton = new JButton("Sort");
sortButton.addActionListener(eventHandler);
showPathwayButton = new JButton("Preview");
showPathwayButton.addActionListener(eventHandler);
showPathwayButton.setEnabled(false);
gotoPathwayButton = new JButton("Open Web Link");
gotoPathwayButton.addActionListener(eventHandler);
gotoPathwayButton.setEnabled(false);
responseTree = new JTree();
responseTreeModel = new ResponseTreeModel();
responseTree.setModel(responseTreeModel);
ToolTipManager.sharedInstance().registerComponent(responseTree);
CollapsiblePanel searchPanel = new CollapsiblePanel("Search", true);
searchPanel.getContentPanel().setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.LINE_START;
searchPanel.getContentPanel().add(searchTextField, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.insets = new Insets(0, 4, 0, 0);
searchPanel.getContentPanel().add(searchButton, gbc);
setPreferredSize(new Dimension(475, 300));
setLayout(new GridBagLayout());
int gridy = 0;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
add(searchPanel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.fill = GridBagConstraints.BOTH;
add(new JScrollPane(responseTree), gbc);
gridy++;
CollapsiblePanel filterPanel = new CollapsiblePanel("Filter", true);
filterPanel.getContentPanel().setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.insets = new Insets(2, 2, 2, 2);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.LINE_START;
filterPanel.getContentPanel().add(filterTextField, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.insets = new Insets(0, 4, 0, 0);
filterPanel.getContentPanel().add(sortButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
filterPanel.expand(true);
add(filterPanel, gbc);
// JPanel optionsField = new JPanel(new GridLayout());
// ButtonGroup buttonGroup = new ButtonGroup();
// JRadioButton o1, o2, o3;
// o1 = new JRadioButton(" Entity ");
// buttonGroup.add(o1);
// optionsField.add(o1);
// o2 = new JRadioButton(" Database ");
// buttonGroup.add(o2);
// optionsField.add(o2);
// o3 = new JRadioButton(" Organism ");
// buttonGroup.add(o3);
// optionsField.add(o3);
// o3.setSelected(true);
//
// gridy ++;
// CollapsiblePanel optionsPanel = new CollapsiblePanel("Group by... ", true);
// optionsPanel.getContentPanel().setLayout(new GridBagLayout());
// gbc = new GridBagConstraints();
// gbc.gridx = 0;
// gbc.gridy = gridy;
// gbc.weightx = 1.0;
// gbc.fill = GridBagConstraints.HORIZONTAL;
// gbc.anchor = GridBagConstraints.LINE_START;
// optionsPanel.getContentPanel().add(optionsField, gbc);
//
// gbc = new GridBagConstraints();
// gbc.gridx = 0;
// gbc.gridy = gridy;
// gbc.weightx = 1.0;
// gbc.gridwidth = GridBagConstraints.REMAINDER;
// gbc.fill = GridBagConstraints.HORIZONTAL;
// gbc.insets = new Insets(4,4,4,4);
// optionsPanel.expand(false);
// add(optionsPanel, gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 1);
add(showPathwayButton, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 1, 4, 4);
add(gotoPathwayButton, gbc);
sortButton.setIcon(bAscending ? VCellIcons.sortDownIcon : VCellIcons.sortUpIcon);
ResponseTreeCellRenderer renderer = new ResponseTreeCellRenderer();
// renderer.setLeafIcon(null);
// renderer.setClosedIcon(null);
// renderer.setOpenIcon(null);
renderer.setLeafIcon(VCellIcons.pathwayLeafIcon);
responseTree.setCellRenderer(renderer);
responseTree.setRootVisible(false);
responseTree.getSelectionModel().addTreeSelectionListener(eventHandler);
responseTree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() <= 1) {
return;
}
showPathway();
}
});
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 });
}
});
}
Aggregations