List of usage examples for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION
int SINGLE_TREE_SELECTION
To view the source code for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION.
Click Source Link
From source file:org.intermine.modelviewer.swing.ModelViewer.java
/** * Lays out the components within this panel and wires up the relevant * event listeners.//from w w w.java2s . c o m */ private void init() { FileFilter xmlFilter = new XmlFileFilter(); projectFileChooser = new JFileChooser(); projectFileChooser.addChoosableFileFilter(xmlFilter); projectFileChooser.setAcceptAllFileFilterUsed(false); projectFileChooser.setFileFilter(xmlFilter); File lastProjectFile = MineManagerBackingStore.getInstance().getLastProjectFile(); if (lastProjectFile != null) { projectFileChooser.setSelectedFile(lastProjectFile); } initButtonPanel(); classTreeModel = new ClassTreeModel(); classTree = new JTree(classTreeModel); classTree.setCellRenderer(new ClassTreeCellRenderer()); classTree.setRootVisible(false); classTree.setShowsRootHandles(true); Box vbox = Box.createVerticalBox(); vbox.add(new JScrollPane(classTree)); vbox.add(buttonPanel); DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel(); selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); classTree.setSelectionModel(selectionModel); classTree.addTreeSelectionListener(new ClassTreeSelectionListener()); attributeTableModel = new AttributeTableModel(); attributeTable = new AttributeTable(attributeTableModel); referenceTableModel = new ReferenceTableModel(); referenceTable = new ReferenceTable(referenceTableModel); graphModel = new mxGraphModel(); graph = new CustomisedMxGraph(graphModel); graphComponent = new mxGraphComponent(graph); graphComponent.setEscapeEnabled(true); JTabbedPane tableTab = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); tableTab.add(Messages.getMessage("tab.attributes"), new JScrollPane(attributeTable)); tableTab.add(Messages.getMessage("tab.references"), new JScrollPane(referenceTable)); JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableTab, graphComponent); JSplitPane mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, vbox, rightSplit); setOpaque(true); setLayout(new BorderLayout()); add(mainSplit, BorderLayout.CENTER); rightSplit.setDividerLocation(150); mainSplit.setDividerLocation(200); }
From source file:org.kepler.gui.ComponentLibraryTab.java
/** * Set the selection of the JTree (result) in this panel to single * selection, and add a selection listener to it. * /* w w w .j a v a2s . c o m*/ * @param listener */ public void addTreeSingleSelectionListener(TreeSelectionListener listener) { if (_library != null) { _library.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); _library.addTreeSelectionListener(listener); } if (_libraryPanel != null) { _libraryPanel.setSingleTreeSelectionListener(listener); } }
From source file:org.kepler.gui.ResultTreeRebuilder.java
/** Update the tree to display only a specific root. */ public void update(EntityLibrary root) throws IllegalActionException { if (isDebugging) { log.debug("update(" + root.getName() + " " + root.getClass().getName() + ")"); }/* w w w .j av a2 s . c o m*/ this.removeAll(); trimmedLibrary = new VisibleTreeModel(root); AnnotatedPTree rTree = new AnnotatedPTree(trimmedLibrary, this); MouseListener mListener = new LibraryPopupListener(rTree); rTree.setMouseListener(mListener); if (treeSingleSelectionlistener != null) { rTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); rTree.addTreeSelectionListener(treeSingleSelectionlistener); } rTree.initAnotatedPTree(); resultsTree = rTree; JScrollPane newpane = new JScrollPane(resultsTree); newpane.setPreferredSize(new Dimension(200, 200)); this.add(newpane, BorderLayout.CENTER); // add the search results counter stuff resultCounterPane = new JPanel(); resultCounterPane.setBackground(TabManager.BGCOLOR); resultCounterPane.setLayout(new BorderLayout()); resultCounterLabel = new JLabel(""); resultCounterPane.removeAll(); resultCounterPane.add(resultCounterLabel, BorderLayout.CENTER); this.add(resultCounterPane, BorderLayout.SOUTH); this.repaint(); this.validate(); }
From source file:org.kepler.gui.ResultTreeRebuilder.java
/** * this method allows the search results to be updated in the panel * /* w w w.j av a2 s. c om*/ *@param results * the results to update to *@exception IllegalActionException * Description of the Exception */ public void update(LibrarySearchResults results) throws IllegalActionException { if (isDebugging) { log.debug("update(" + results + ")"); } this.results = results; int resultcount; if (results == null || results.size() == 0) { resultcount = 0; } else { resultcount = results.size(); } this.removeAll(); // add the results if there are any if (resultcount > 0) { // add the results tree. EntityLibrary newRoot = new SearchEntityLibrary(workspace); try { newRoot.setName(StaticResources.getDisplayString("components.searchResults", "Search Results")); } catch (IllegalActionException iae) { throw iae; } catch (NameDuplicationException nde) { throw new IllegalActionException("name duplication exception: " + nde); } buildResultTree(newRoot); trimmedLibrary = new VisibleTreeModel(newRoot); AnnotatedPTree rTree = new AnnotatedPTree(trimmedLibrary, this); MouseListener mListener = new LibraryPopupListener(rTree); rTree.setMouseListener(mListener); if (treeSingleSelectionlistener != null) { rTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); rTree.addTreeSelectionListener(treeSingleSelectionlistener); } rTree.initAnotatedPTree(); resultsTree = rTree; rTree.setShowsRootHandles(false); JScrollPane newpane = new JScrollPane(resultsTree); newpane.setPreferredSize(new Dimension(200, 200)); this.add(newpane, BorderLayout.CENTER); expandAll(resultsTree); } else { // if there are no results, just add the library back if (library.getModel() != null) { library.setModel(new NoRemoteComponentsTreeModel(library.getModel())); } this.add(new JScrollPane(library), BorderLayout.CENTER); } // add the search results counter stuff resultCounterPane = new JPanel(); resultCounterPane.setBackground(TabManager.BGCOLOR); resultCounterPane.setLayout(new BorderLayout()); resultCounterLabel = new JLabel( resultcount + " " + StaticResources.getDisplayString("components.resultsFound", "results found.")); resultCounterPane.removeAll(); resultCounterPane.add(resultCounterLabel, BorderLayout.CENTER); this.add(resultCounterPane, BorderLayout.SOUTH); this.repaint(); this.validate(); }
From source file:org.mbari.aved.ui.classifier.knowledgebase.ConceptTree.java
/** * Initialize the properties of this <code>ConceptTree</code>. *//*from www .ja v a 2s . c om*/ protected void initTreeProperties() { putClientProperty("JTree.lineStyle", "Angled"); getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // don't allow edits to the Concept names directly in this tree setEditable(false); setCellRenderer(new ConceptTreeCellRenderer()); setRootVisible(true); }
From source file:org.objectpocket.viewer.Viewer.java
/** * Initialize the contents of the frame. *///from w ww . j av a2 s . c om private void initialize() { viewerFrame = new JFrame(); viewerFrame.setTitle("ObjectPocketViewer"); viewerFrame.setBounds(100, 100, 1427, 524); viewerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); splitPane = new JSplitPane(); splitPane.setResizeWeight(0.2); viewerFrame.getContentPane().add(splitPane, BorderLayout.CENTER); classTree = new JTree(); classTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); classTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { updateTable(); } }); splitPane.setLeftComponent(classTree); panel = new JPanel(); splitPane.setRightComponent(panel); panel.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); panel.add(scrollPane); objectTable = new JTable(); objectTable.setAutoCreateRowSorter(true); objectTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.setViewportView(objectTable); panel.add(scrollPane, BorderLayout.CENTER); filterPanel = new JPanel(); panel.add(filterPanel, BorderLayout.NORTH); filterPanel.setLayout(new BorderLayout(0, 0)); filterTextField = new JTextField(); filterTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { updateTable(); } } }); filterPanel.add(filterTextField, BorderLayout.CENTER); filterTextField.setColumns(10); filterButton = new JButton("apply filter"); filterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTable(); } }); filterPanel.add(filterButton, BorderLayout.EAST); statusLabel = new JLabel(""); panel.add(statusLabel, BorderLayout.SOUTH); }
From source file:org.objectstyle.cayenne.modeler.ProjectTreeView.java
private void initFromModel(Project project) { // build model ProjectTreeModel model = new ProjectTreeModel(project); setRootVisible(false);/*from w w w .ja va2 s . c o m*/ setModel(model); // expand top level getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); Enumeration level = model.getRootNode().children(); while (level.hasMoreElements()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) level.nextElement(); TreePath path = new TreePath(node.getPath()); expandPath(path); } }
From source file:org.openconcerto.erp.panel.ITreeSelection.java
public ITreeSelection(SQLElement element) { super();//from ww w. j av a 2s. c o m DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setOpenIcon(null); renderer.setClosedIcon(null); renderer.setLeafIcon(null); this.setCellRenderer(renderer); this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.element = element; this.supp = new PropertyChangeSupport(this); // Value changed this.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { ITreeSelection.this.supp.firePropertyChange("value", null, getUncheckedValue()); } }); }
From source file:org.piraso.ui.base.RequestTreeTopComponent.java
public RequestTreeTopComponent() { setName(Bundle.CTL_RequestTreeTopComponent()); setToolTipText(Bundle.HINT_RequestTreeTopComponent()); initComponents();/* www. j a v a2 s . com*/ InstanceContent content = new InstanceContent(); associateLookup(new AbstractLookup(content)); this.entryContent = new SingleClassInstanceContent<Entry>(content); jTree.setFont(FontProviderManager.INSTANCE.getEditorDefaultFont()); jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int selRow = jTree.getRowForLocation(e.getX(), e.getY()); TreePath selPath = jTree.getPathForLocation(e.getX(), e.getY()); if (selRow != -1 && selPath != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Child child = null; if (Child.class.isInstance(node.getUserObject())) { child = (Child) node.getUserObject(); } if (child != null && e.getClickCount() == 1) { child.select(); } } } }); jTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { if (e.getPath() != null && e.getPath().getLastPathComponent() != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); if (node.getUserObject() != null && Child.class.isInstance(node.getUserObject())) { Child child = (Child) node.getUserObject(); child.showRequestView(); } } } }); }
From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.java
/** * Initialize the contents of the frame. *///from w w w . ja v a 2 s . c o m 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); 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("ActiveRules", null, activeRuleTab, null); activeRuleEditor = new JEditorPane(); activeRuleTab.setViewportView(activeRuleEditor); 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(); }