@Override public void valueChanged(javax.swing.event.ListSelectionEvent listSelectionEvent) { int selectedRows[] = outline.getSelectedRows(); ArrayList<Node> selectedNodes = new ArrayList<Node> (selectedRows.length); for (int i = 0; i < selectedRows.length;i++) { Node n = getNodeFromRow(selectedRows[i]); if (n != null) { selectedNodes.add(n); } } callSelectionChanged(selectedNodes.toArray (new Node[selectedNodes.size ()])); }
/** Get a node on given point or null if there none*/ private Node getNodeForDrop(Point p) { int row = view.getOutline().rowAtPoint(p); return view.getNodeFromRow(row); }
private boolean needToSynchronize () { boolean doSync = false; Node [] arr = manager.getSelectedNodes (); if (outline.getSelectedRows ().length != arr.length) { doSync = true; } else if (arr.length > 0) { List<Node> nodes = Arrays.asList (arr); for (int idx : outline.getSelectedRows ()) { Node n = getNodeFromRow (idx); if (n == null || ! nodes.contains (n)) { doSync = true; break; } } } return doSync; }
ArrayList<Node> al = new ArrayList<Node> (selRows.length); for (int i = 0; i < selRows.length; i++) { Node n = view.getNodeFromRow(selRows[i]); if (n != null) { al.add(n);
/** * Find relevant actions and call the factory to create a popup. */ private JPopupMenu createPopup(Point p) { int[] selRows = outline.getSelectedRows(); ArrayList<Node> al = new ArrayList<Node> (selRows.length); for (int i = 0; i < selRows.length; i++) { Node n = getNodeFromRow(selRows[i]); if (n != null) { al.add(n); } } Node[] arr = al.toArray (new Node[al.size ()]); if (arr.length == 0) { if (manager.getRootContext() != null) { // display the context menu of the root node JPopupMenu popup = manager.getRootContext().getContextMenu(); if (popup != null && popup.getSubElements().length > 0) { popupFactory.addNoFilterItem(outline, popup); return popup; } } // we'll have an empty popup } p = SwingUtilities.convertPoint(this, p, outline); int column = outline.columnAtPoint(p); int row = outline.rowAtPoint(p); return popupFactory.createPopupMenu(row, column, arr, outline); }
int firstSelection = -1; for (int i = 0; i < size; i++) { Node n = getNodeFromRow(i); for (int j = 0; j < arr.length; j++) { if ((n != null) && (n.equals(arr[j]))) {