private void displaySearchResult() { int sz = searchResults.size(); if (sz > 0) { if (currentSelectionIndex < 0) { currentSelectionIndex = sz - 1; } else if (currentSelectionIndex >= sz) { currentSelectionIndex = 0; } TreePath path = searchResults.get(currentSelectionIndex); setSelectionPath(path); scrollPathToVisible(path); } else { if (lastSearchText.isEmpty() && origSelectionPaths != null) { setSelectionPaths(origSelectionPaths); scrollPathToVisible(origSelectionPaths[0]); } else { clearSelection(); } } }
private void calcRowHeight(Graphics g) { int height = Math.max(18, 2 + g.getFontMetrics(getFont()).getHeight()); //Issue 42743/"Jesse mode" String s = System.getProperty("nb.cellrenderer.fixedheight"); //NOI18N if (s != null) { try { height = Integer.parseInt(s); } catch (Exception e) { //do nothing, height not changed } } if (getRowHeight() != height) { setRowHeight(height); } else { revalidate(); repaint(); } }
ExplorerTree(TreeModel model) { super(model); toggleClickCount = 0; // fix for #18292 // default action map for JTree defines these shortcuts // but we use our own mechanism for handling them // following lines disable default L&F handling (if it is // defined on Ctrl-c, Ctrl-v and Ctrl-x) getInputMap().put(KeyStroke.getKeyStroke("control C"), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke("control V"), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke("control X"), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke("COPY"), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke("PASTE"), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke("CUT"), "none"); // NOI18N if (Utilities.isMac()) { getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_MASK), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.META_MASK), "none"); // NOI18N getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_MASK), "none"); // NOI18N } setupSearch(); if (!GraphicsEnvironment.isHeadless()) { setDragEnabled(true); } }
int startIndex = origSelectionPaths != null ? Math.max(0, getRowForPath(origSelectionPaths[0])) : 0; int size = getRowCount(); startIndex = startIndex % size; SubstringSearchResult substringSearchResult = getNextSubstringMatch(prefix, startIndex, true); TreePath path = substringSearchResult != null? substringSearchResult.treePath: null;
if (keyCode == KeyEvent.VK_ESCAPE) { removeSearchField(); ExplorerTree.this.requestFocus(); } else if (keyCode == KeyEvent.VK_UP) { currentSelectionIndex--; removeSearchField(); TreePath selectedTPath = getSelectionPath (); if (selectedTPath != null) { TreeNode selectedTNode = (TreeNode)selectedTPath.getLastPathComponent(); selectedNode.getPreferredAction ().actionPerformed (new ActionEvent (this, ActionEvent.ACTION_PERFORMED, "")); } else { expandPath (getSelectionPath ()); ExplorerTree.this.requestFocus(); ExplorerTree.this.dispatchEvent(e);
if (keyCode == KeyEvent.VK_ESCAPE) { removeSearchField(); ExplorerTree.this.requestFocus(); } else if (keyCode == KeyEvent.VK_UP) { currentSelectionIndex--; removeSearchField(); TreePath selectedTPath = getSelectionPath (); if (selectedTPath != null) { TreeNode selectedTNode = (TreeNode)selectedTPath.getLastPathComponent(); selectedNode.getPreferredAction ().actionPerformed (new ActionEvent (this, ActionEvent.ACTION_PERFORMED, "")); } else { expandPath (getSelectionPath ()); ExplorerTree.this.requestFocus(); ExplorerTree.this.dispatchEvent(e);
treeModel.addView(this); tree = new ExplorerTree(treeModel);
tree = new ExplorerTree(treeModel);
tree = new ExplorerTree(treeModel);
int rows[] = getSelectionRows(); int startIndex = (rows == null || rows.length == 0) ? 0 : rows[0]; int size = getRowCount (); if (size == 0) { TreePath path = getNextMatch(prefix, startIndex, Position.Bias.Forward); if (path != null && !results.contains (path)) { startIndex = tree.getRowForPath (path); maxPrefix = findMaxPrefix(maxPrefix, elementName);
String substring, int startingRow, boolean forward) { int max = getRowCount(); if (substring == null) { throw new IllegalArgumentException("Substring is null"); int row = startingRow; do { TreePath path = getPathForRow(row); String text = convertValueToText( path.getLastPathComponent(), isRowSelected(row), isExpanded(row), true, row, false);
int rows[] = getSelectionRows(); int startIndex = (rows == null || rows.length == 0) ? 0 : rows[0]; int size = getRowCount (); if (size == 0) { TreePath path = getNextMatch(prefix, startIndex, Position.Bias.Forward); if (path != null && !results.contains (path)) { startIndex = tree.getRowForPath (path); maxPrefix = findMaxPrefix(maxPrefix, elementName);
private void repaintSelection() { int first = getSelectionModel().getMinSelectionRow(); int last = getSelectionModel().getMaxSelectionRow(); if (first != -1) { if (first == last) { Rectangle r = getRowBounds(first); if (r == null) { repaint(); return; } repaint(r.x, r.y, r.width, r.height); } else { Rectangle top = getRowBounds(first); Rectangle bottom = getRowBounds(last); if (top == null || bottom == null) { repaint(); return; } Rectangle r = new Rectangle(); r.x = Math.min(top.x, bottom.x); r.y = top.y; r.width = getWidth(); r.height = (bottom.y + bottom.height) - top.y; repaint(r.x, r.y, r.width, r.height); } } }
public void treeStructureChanged(TreeModelEvent e) { // Remember selections and expansions TreePath selectionPaths[] = getSelectionPaths(); java.util.Enumeration expanded = getExpandedDescendants( e.getTreePath() ); // Restructure the node super.treeStructureChanged( e ); // Expand previously expanded paths if ( expanded != null ) { while( expanded.hasMoreElements() ) { expandPath( (TreePath)expanded.nextElement() ); } } // Select previously selected paths if ( selectionPaths != null && selectionPaths.length > 0 ) { boolean wasSelected = isPathSelected(selectionPaths[0]); setSelectionPaths( selectionPaths ); if (!wasSelected) { // do not scroll if the first selection path survived structure change scrollPathToVisible( selectionPaths[0] ); } } }
@Override public void treeStructureChanged(TreeModelEvent e) { // Remember selections and expansions TreePath[] selectionPaths = getSelectionPaths(); java.util.Enumeration expanded = getExpandedDescendants(e.getTreePath()); // Restructure the node super.treeStructureChanged(e); // Expand previously expanded paths if (expanded != null) { while (expanded.hasMoreElements()) { expandPath((TreePath) expanded.nextElement()); } } // Select previously selected paths if ((selectionPaths != null) && (selectionPaths.length > 0)) { boolean wasSelected = isPathSelected(selectionPaths[0]); setSelectionPaths(selectionPaths); if (!wasSelected) { // do not scroll if the first selection path survived structure change scrollPathToVisible(selectionPaths[0]); } } }
/** * Adds the search field to the tree. */ private void displaySearchField() { if (!searchTextField.isDisplayable()) { JViewport viewport = TreeView.this.getViewport(); originalScrollMode = viewport.getScrollMode(); viewport.setScrollMode(JViewport.SIMPLE_SCROLL_MODE); searchTextField.setFont (ExplorerTree.this.getFont()); prepareSearchPanel(); add(searchpanel); doLayout(); searchpanel.repaint(); // bugfix #28501, avoid the chars duplicated on jdk1.3 SwingUtilities.invokeLater (new Runnable () { public void run () { searchTextField.requestFocus (); } }); } }
/** * Adds the search field to the tree. */ private void displaySearchField() { if (!searchTextField.isDisplayable()) { JViewport viewport = TreeView.this.getViewport(); originalScrollMode = viewport.getScrollMode(); viewport.setScrollMode(JViewport.SIMPLE_SCROLL_MODE); searchTextField.setFont (ExplorerTree.this.getFont()); prepareSearchPanel(); add(searchpanel); doLayout(); searchpanel.repaint(); // bugfix #28501, avoid the chars duplicated on jdk1.3 SwingUtilities.invokeLater (new Runnable () { public void run () { searchTextField.requestFocus (); } }); } }
public void treeStructureChanged(TreeModelEvent e) { // Remember selections and expansions TreePath selectionPaths[] = getSelectionPaths(); java.util.Enumeration expanded = getExpandedDescendants( e.getTreePath() ); // Restructure the node super.treeStructureChanged( e ); // Expand previously expanded paths if ( expanded != null ) { while( expanded.hasMoreElements() ) { expandPath( (TreePath)expanded.nextElement() ); } } // Select previously selected paths if ( selectionPaths != null && selectionPaths.length > 0 ) { boolean wasSelected = isPathSelected(selectionPaths[0]); setSelectionPaths( selectionPaths ); if (!wasSelected) { // do not scroll if the first selection path survived structure change scrollPathToVisible( selectionPaths[0] ); } } }
private void repaintSelection () { int first = getSelectionModel().getMinSelectionRow(); int last = getSelectionModel().getMaxSelectionRow(); if (first != -1) { if (first == last) { Rectangle r = getRowBounds(first); repaint (r.x,r.y,r.width,r.height); } else { Rectangle top = getRowBounds(first); Rectangle bottom = getRowBounds(last); Rectangle r = new Rectangle(); r.x = Math.min (top.x, bottom.x); r.y = top.y; r.width = getWidth(); r.height = bottom.y + bottom.height - top.y; repaint(r.x,r.y,r.width,r.height); } } }
private void repaintSelection () { int first = getSelectionModel().getMinSelectionRow(); int last = getSelectionModel().getMaxSelectionRow(); if (first != -1) { if (first == last) { Rectangle r = getRowBounds(first); repaint (r.x,r.y,r.width,r.height); } else { Rectangle top = getRowBounds(first); Rectangle bottom = getRowBounds(last); Rectangle r = new Rectangle(); r.x = Math.min (top.x, bottom.x); r.y = top.y; r.width = getWidth(); r.height = bottom.y + bottom.height - top.y; repaint(r.x,r.y,r.width,r.height); } } }