JTree tree = (JTree)support.getComponent(); int dropRow = tree.getRowForPath(dl.getPath()); int[] selRows = tree.getSelectionRows(); for(int i = 0; i < selRows.length; i++) { if(selRows[i] == dropRow) { int[] selRows = tree.getSelectionRows(); TreePath path = tree.getPathForRow(selRows[0]); DefaultMutableTreeNode first =
/** * {@inheritDoc} * <p> * * Overridden to always return a not-null array (following SwingX * convention). */ @Override public int[] getSelectionRows() { int[] rows = super.getSelectionRows(); return rows != null ? rows : EMPTY_INT_ARRAY; }
/** * {@inheritDoc} * <p> * * Overridden to always return a not-null array (following SwingX * convention). */ @Override public int[] getSelectionRows() { int[] rows = super.getSelectionRows(); return rows != null ? rows : EMPTY_INT_ARRAY; }
/** * {@inheritDoc} * <p> * * Overridden to always return a not-null array (following SwingX * convention). */ @Override public int[] getSelectionRows() { int[] rows = super.getSelectionRows(); return rows != null ? rows : EMPTY_INT_ARRAY; }
/** * {@inheritDoc} * <p> * * Overridden to always return a not-null array (following SwingX * convention). */ @Override public int[] getSelectionRows() { int[] rows = super.getSelectionRows(); return rows != null ? rows : EMPTY_INT_ARRAY; }
/** * {@inheritDoc} * <p> * * Overridden to always return a not-null array (following SwingX * convention). */ @Override public int[] getSelectionRows() { int[] rows = super.getSelectionRows(); return rows != null ? rows : EMPTY_INT_ARRAY; }
@Override public void actionPerformed(ActionEvent e) { int row = arvoreExemplos.getSelectionRows()[0]; arvoreExemplos.setSelectionRow(Math.max(0,row-1)); } };
@Override public void actionPerformed(ActionEvent e) { int row = arvoreExemplos.getSelectionRows()[0]; arvoreExemplos.setSelectionRow(Math.min(row+1, arvoreExemplos.getRowCount()-1)); } };
@RunsInCurrentThread private static void checkSelection(@Nonnull JTree tree, @Nonnull int[] selection, @Nonnull Description errMsg) { int[] selectionRows = tree.getSelectionRows(); if (selectionRows == null || selectionRows.length == 0) { failNoSelection(errMsg); return; } sort(selection); if (Arrays.equals(selectionRows, selection)) { return; } failNotEqualSelection(errMsg, selection, selectionRows); }
@Override public void actionPerformed( ActionEvent e ) { int[] selectionRows = _tree.getSelectionRows(); if( selectionRows != null ) { int selectionRow = selectionRows[0]; selectionRow = Math.max( 0, selectionRow - 10 ); _tree.setSelectionRow( selectionRow ); _tree.scrollRowToVisible( selectionRow ); } } } );
@Override public void actionPerformed( ActionEvent e ) { int[] selectionRows = _tree.getSelectionRows(); if( selectionRows != null ) { int selectionRow = selectionRows[0]; selectionRow = Math.max( 0, selectionRow - 10 ); _tree.setSelectionRow( selectionRow ); _tree.scrollRowToVisible( selectionRow ); } } } );
@Override public void textUpdated() { int[] selectedRows = symbolTree.getSelectionRows(); populateSLD(); symbolTree.setSelectionRows(selectedRows); }
@Override public void keyReleased(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_ENTER){ int selectedRow = arvore.getSelectionRows()[0]; if(arvore.isCollapsed(selectedRow)){ arvore.expandRow(selectedRow); }else{ arvore.collapseRow(selectedRow); } } }
@Override public void actionPerformed( ActionEvent e ) { int[] selectionRows = _tree.getSelectionRows(); if( selectionRows != null ) { int selectionRow = selectionRows[0]; selectionRow = Math.min( _tree.getRowCount() - 1, selectionRow + 10 ); _tree.setSelectionRow( selectionRow ); _tree.scrollRowToVisible( selectionRow ); } } } );
@Override public void actionPerformed( ActionEvent e ) { int[] selectionRows = _tree.getSelectionRows(); if( selectionRows != null ) { int selectionRow = selectionRows[0]; selectionRow = Math.min( _tree.getRowCount() - 1, selectionRow + 10 ); _tree.setSelectionRow( selectionRow ); _tree.scrollRowToVisible( selectionRow ); } } } );
@Override protected int getSelectedIndex() { if (!isRecursive()) { int ai[] = ((JTree) _component).getSelectionRows(); return (ai != null && ai.length != 0) ? ai[0] : -1; } else { TreePath[] treePaths = ((JTree) _component).getSelectionPaths(); if (treePaths != null && treePaths.length > 0) { return getTreePathes().indexOf(treePaths[0]); } else return -1; } }
@Override public void showPopup(MouseEvent mevt) { if (isPopupAllowed()) { if (mevt.getY() > treeTable.getHeight()) { // clear selection, if click under the table treeTable.clearSelection(); } else { int selRow = treeTable.rowAtPoint( mevt.getPoint() ); boolean isAlreadySelected = false; int[] currentSelection = tree.getSelectionRows(); for( int i=0; null != currentSelection && i<currentSelection.length; i++ ) { if( selRow == currentSelection[i] ) { isAlreadySelected = true; break; } } if( !isAlreadySelected ) tree.setSelectionRow( selRow ); } createPopup(mevt); } } };
private void handleCategoryTreeUpdate() { int[] selectedRows = treeCategories.getSelectionRows(); boolean existsASelectedCategory = selectedRows != null && selectedRows.length > 0; ActionManager actionManager = Application.getInstance().getContext().getActionManager(); actionManager.enable("delete-category", existsASelectedCategory); actionManager.enableLocal("delete", CATEGORIES, existsASelectedCategory); }
/** * Repopulate tree for a undo/redo operation. * * @param sldContents the sld contents */ private void repopulateTree(String sldContents) { int[] selectedRows = symbolTree.getSelectionRows(); SLDDataInterface sldData = new SLDData(null, sldContents); StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData); SelectedSymbol.getInstance().setSld(sld); populateSLD(); if ((selectedRows != null) && (selectedRows.length > 0)) { symbolTree.setSelectionRow(selectedRows[0]); } }
@Override public void actionPerformed(ActionEvent action) { String command = action.getActionCommand(); if (command.equalsIgnoreCase("CONFIG_BOT")) { PrincessBehaviorDialog pbd = new PrincessBehaviorDialog(frame, scenario.getBotForce(index).getBehaviorSettings(), scenario.getBotForce(index).getName()); pbd.setVisible(true); if (!pbd.dialogAborted) { scenario.getBotForce(index).setBehaviorSettings(pbd.getBehaviorSettings()); scenario.getBotForce(index).setName(pbd.getBotName()); } } else if (command.equalsIgnoreCase("EDIT_UNIT")) { if (tree.getSelectionCount() > 0) { // row 0 is root node int i = tree.getSelectionRows()[0] - 1; UnitEditorDialog med = new UnitEditorDialog(frame, scenario.getBotForce(index).getEntityList().get(i)); med.setVisible(true); } } }