/** * Sets a new selection for this viewer and optionally makes it visible. * <p> * <b>Currently the <code>reveal</code> parameter is not honored because * {@link Tree} does not provide an API to only select an item without * scrolling it into view</b> * </p> * * @param selection * the new selection * @param reveal * <code>true</code> if the selection is to be made visible, * and <code>false</code> otherwise */ @Override public void setSelection(ISelection selection, boolean reveal) { super.setSelection(selection, reveal); }
/** * Sets a new selection for this viewer and optionally makes it visible. * <p> * <b>Currently the <code>reveal</code> parameter is not honored because * {@link Tree} does not provide an API to only select an item without * scrolling it into view</b> * </p> * * @param selection * the new selection * @param reveal * <code>true</code> if the selection is to be made visible, * and <code>false</code> otherwise */ @Override public void setSelection(ISelection selection, boolean reveal) { super.setSelection(selection, reveal); }
/** * Sets a new selection for this viewer and optionally makes it visible. * <p> * <b>Currently the <code>reveal</code> parameter is not honored because * {@link Tree} does not provide an API to only select an item without * scrolling it into view</b> * </p> * * @param selection * the new selection * @param reveal * <code>true</code> if the selection is to be made visible, * and <code>false</code> otherwise */ public void setSelection(ISelection selection, boolean reveal) { super.setSelection(selection, reveal); }
protected void setSelectionToWidget(List v, boolean reveal) { if (v == null) { setSelection(new ArrayList<>(0)); return; setSelection(newSelection);
setSelection(new ArrayList(0)); return; setSelection(newSelection);
protected void setSelectionToWidget(List v, boolean reveal) { if (v == null) { setSelection(new ArrayList(0)); return; setSelection(newSelection);
/** * Updates the viewer in response to the current frame changing. * * @param frame the new value for the current frame */ protected void frameChanged(TreeFrame frame) { viewer.getControl().setRedraw(false); viewer.setInput(frame.getInput()); viewer.setExpandedElements(frame.getExpandedElements()); viewer.setSelection(frame.getSelection(), true); viewer.getControl().setRedraw(true); }
/** * Moves the specified element from the specified old position to the * specified new position, whenever it appears as a child of the specified * parent element. No action is taken if the viewer has a sorter or * filter(s). * * @param parent * the parent of the element being moved * @param element * the element being moved * @param oldPosition * the position of the element before it is moved * @param newPosition * the position of the element after it is moved */ public void move(Object parent, Object element, int oldPosition, int newPosition) { if (isElementOrderPreserved()) { ITreeSelection selection = (ITreeSelection) viewer.getSelection(); remove(parent, element, oldPosition); insert(parent, element, newPosition); // If the moved element is selected (or is an ancestor of a selected // element), restore the selection. if (selectionContains(selection, getPathParent(parent), element)) viewer.setSelection(selection); } }
/** * TODO: if the oldElement was expanded and no child element selected, the * newElement will appear collapsed, but selected */ private void replaceElementInSelection(final Object parent, final Object oldElement, final Object newElement, final ITreeSelection selection) { IElementComparer comparer = viewer.getComparer(); TreePath[] paths = selection.getPaths(); for (int i = 0; i < paths.length; i++) { TreePath path = paths[i]; Object[] segments = new Object[path.getSegmentCount()]; boolean replacePath = false; for (int j = 0; j < path.getSegmentCount(); j++) { segments[j] = path.getSegment(j); Object pathParent = j > 0 ? path.getSegment(j - 1) : null; Object pathElement = path.getSegment(j); if (!replacePath && eq(comparer, parent, pathParent) && eq(comparer, oldElement, pathElement)) { segments[j] = newElement; replacePath = true; } } if (replacePath) { paths[i] = new TreePath(segments); } } viewer.setSelection(new TreeSelection(paths, viewer.getComparer())); }