List of usage examples for javax.swing.tree TreeSelectionModel DISCONTIGUOUS_TREE_SELECTION
int DISCONTIGUOUS_TREE_SELECTION
To view the source code for javax.swing.tree TreeSelectionModel DISCONTIGUOUS_TREE_SELECTION.
Click Source Link
From source file:org.rdv.ui.ChannelListPanel.java
/** * Create the channel tree panel./*from www. jav a 2 s . co m*/ * * @return the component containing the channel tree */ private JComponent createTreePanel() { treeModel = new ChannelTreeModel(); treeModel.addPropertyChangeListener(new FilterPropertyChangeListener()); tree = new JTree(treeModel); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setExpandsSelectedPaths(true); tree.setCellRenderer(new ChannelTreeCellRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.addTreeSelectionListener(new ChannelTreeSelectionListener()); tree.addMouseListener(new ChannelTreeMouseListener()); tree.setBorder(new EmptyBorder(0, 5, 5, 5)); JScrollPane treeView = new JScrollPane(tree); treeView.setBorder(null); treeView.setViewportBorder(null); tree.setDragEnabled(true); tree.setTransferHandler(new ChannelTransferHandler()); DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_LINK, new ChannelDragGestureListener()); return treeView; }
From source file:ro.nextreports.designer.wizpublish.DownloadListWizardPanel.java
private void createSelectionDialog(final byte type) { WebServiceClient client = (WebServiceClient) context.getAttribute(PublishWizard.CLIENT); final JcrBrowserTree jcrBrowserTree = new JcrBrowserTree(type, client); jcrBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JPanel selectionPanel = JcrBrowserTreeUtil.createSelectionPanel(jcrBrowserTree, type); JDialog dialog = new BaseDialog(selectionPanel, I18NSupport.getString("wizard.publish.file.path.select"), true) {/*from w ww .ja v a 2 s. co m*/ protected boolean ok() { return selection(jcrBrowserTree, type); } }; dialog.pack(); Show.centrateComponent((JDialog) context.getAttribute(PublishWizard.MAIN_FRAME), dialog); dialog.setVisible(true); }
From source file:ro.nextreports.designer.wizpublish.SelectEntityWizardPanel.java
private void add() { // ignore double click listener for tree (which opens the query) // and create our own listener (which just selects the path) final DBBrowserTree dbBrowserTree = new DBBrowserTree(type, false); dbBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); dbBrowserTree.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { job(e, true);/*from w w w. j av a2 s . co m*/ } public void mouseReleased(MouseEvent e) { job(e, false); } private void job(MouseEvent e, boolean pressed) { TreePath[] paths = dbBrowserTree.getSelectionPaths(); if (paths == null) { return; } dbBrowserTree.setSelectionPaths(paths); } }); JScrollPane scroll = new JScrollPane(dbBrowserTree); scroll.setPreferredSize(scrTreeDim); JPanel panel = new JPanel(); panel.add(scroll); JDialog dialog = new BaseDialog(panel, I18NSupport.getString("wizard.publish.entities.select"), true) { protected boolean ok() { TreePath[] paths = dbBrowserTree.getSelectionPaths(); if (paths == null) { return false; } for (TreePath selPath : paths) { final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent(); if (!selectedNode.getDBObject().isFolder()) { String path = selectedNode.getDBObject().getAbsolutePath(); if (!listModel.contains(path)) { // convert xml if needed before add to list if (selectedNode.getDBObject().getType() == DBObject.REPORTS) { byte result = ConverterUtil.convertIfNeeded(path); if (result != ConverterUtil.TYPE_CONVERSION_EXCEPTION) { listModel.addElement(path); } } else { listModel.addElement(path); } } } } return true; } }; dialog.setBackground(Color.WHITE); dialog.pack(); Show.centrateComponent(Globals.getMainFrame(), dialog); dialog.setVisible(true); }
From source file:tufts.vue.OutlineViewTree.java
/** Creates a new instance of OverviewTree */ public OutlineViewTree() { setModel(null);// w w w .j av a 2 s. c o m setEditable(true); setFocusable(true); getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); setCellRenderer(new OutlineViewTreeRenderer()); //setCellRenderer(new DefaultTreeCellRenderer()); setCellEditor(new OutlineViewTreeEditor()); setInvokesStopCellEditing(true); // so focus-loss during edit triggers a save instead of abort edit setRowHeight(-1); // ahah: must do this to force variable row height //tree selection listener to keep track of the selected node addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { ArrayList selectedComponents = new ArrayList(); TreePath[] paths = getSelectionPaths(); //if there is no selected nodes if (paths == null) { valueChangedState = false; selectionFromVUE = false; return; } for (int i = 0; i < paths.length; i++) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent(); Object o = treeNode.getUserObject(); if (DEBUG.FOCUS) System.out.println(this + " valueChanged in treeNode[" + treeNode + "] userObject=" + o.getClass() + "[" + o + "]"); tufts.oki.hierarchy.HierarchyNode hierarchyNode = (tufts.oki.hierarchy.HierarchyNode) o; LWComponent component = hierarchyNode.getLWComponent(); //if it is not LWMap, add to the selected components list if (!(component instanceof LWMap)) { selectedComponents.add(component); } } if (!selectionFromVUE) { valueChangedState = true; // if(selectedComponents.size() != 0) // VUE.getSelection().setTo(selectedComponents.iterator()); // else // VUE.getSelection().clear(); } valueChangedState = false; selectionFromVUE = false; } }); }