@Override public void sort(Viewer viewer, Object[] elements) { if (elements.length > 0 && elements[0] instanceof GenModel) { super.sort(viewer, elements); } } });
public void selectFirstElement() { Object element = null; if (fViewerComparator != null) { Object[] arr = fElements.toArray(); fViewerComparator.sort(fTable, arr); if (arr.length > 0) { element = arr[0]; } } else { if (fElements.size() > 0) { element = fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
@Override public void sort(final Viewer viewer, Object[] elements) { /* * https://bugs.eclipse.org/371354 * * This ordering is inherently unstable, since it relies on * modifiable properties of the elements: E.g. the default * implementation in JobTreeElement compares getDisplayString(), * many of whose implementations use getPercentDone(). * * JavaSE 7+'s TimSort introduced a breaking change: It now throws a * new IllegalArgumentException for bad comparators. Workaround is * to retry a few times. */ for (int retries = 3; retries > 0; retries--) { try { Arrays.sort(elements, (a, b) -> ProgressViewerComparator.this.compare(viewer, a, b)); return; // success } catch (IllegalArgumentException e) { // retry } } // One last try that will log and throw TimSort's IAE if it happens: super.sort(viewer, elements); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTree, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTable, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTree, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTable, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTable, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTree, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
public void selectFirstElement() { Object element= null; if (fViewerComparator != null) { Object[] arr= fElements.toArray(); fViewerComparator.sort(fTable, arr); if (arr.length > 0) { element= arr[0]; } } else { if (fElements.size() > 0) { element= fElements.get(0); } } if (element != null) { selectElements(new StructuredSelection(element)); } }
/** * {@inheritDoc} * * For performance reasons this implementation first checks if sorting is enabled * and if the number of elements is less than the sort limit. */ public void sort( final Viewer viewer, final Object[] elements ) { if ( elements != null && ( preferences.getSortLimit() <= 0 || elements.length < preferences.getSortLimit() ) ) { BrowserSorter.super.sort( viewer, elements ); } }
/** * Returns the sorted and filtered set of children of the given element. The * resulting array must not be modified, as it may come directly from the * model's internal state. * * @param parent * the parent element * @return a sorted and filtered array of child elements */ protected Object[] getSortedChildren(Object parent) { Object[] result = getFilteredChildren(parent); if (sorter != null) { // be sure we're not modifying the original array from the model result = (Object[]) result.clone(); sorter.sort(this, result); } return result; }
/** * Returns the sorted and filtered set of children of the given element. The * resulting array must not be modified, as it may come directly from the * model's internal state. * * @param parent * the parent element * @return a sorted and filtered array of child elements */ protected Object[] getSortedChildren(Object parent) { Object[] result = getFilteredChildren(parent); if (sorter != null) { // be sure we're not modifying the original array from the model result = result.clone(); sorter.sort(this, result); } return result; }
/** * Returns the sorted and filtered set of children of the given element. The * resulting array must not be modified, as it may come directly from the * model's internal state. * * @param parent * the parent element * @return a sorted and filtered array of child elements */ protected Object[] getSortedChildren(Object parent) { Object[] result = getFilteredChildren(parent); if (sorter != null) { // be sure we're not modifying the original array from the model result = result.clone(); sorter.sort(this, result); } return result; }
private PreviewNode getFirstNonCompositeChange(ITreeContentProvider provider, ViewerComparator comparator, AbstractChangeNode input) { PreviewNode focus= input; Change change= input.getChange(); while (change != null && change instanceof CompositeChange) { PreviewNode[] children= (PreviewNode[])provider.getElements(focus); if (children == null || children.length == 0) return null; comparator.sort(fTreeViewer, children); focus= children[0]; change= (focus instanceof AbstractChangeNode) ? ((AbstractChangeNode)focus).getChange() : null; } return focus; }
private void setProjectViewerSelectionAfterDeletion() { Object[] children = getProjects(); if (children.length > 0) { ViewerComparator comparator = projectViewer.getComparator(); comparator.sort(projectViewer, children); IStructuredSelection selection = new StructuredSelection(children[0]); projectViewer.setSelection(selection); handleSelectionChanged(selection); } }
protected Object[] getSortedChildren(Object parentElementOrTreePath) { Object[] result = getFilteredChildren(parentElementOrTreePath); ViewerComparator comparator = getComparator(); if (parentElementOrTreePath != null && comparator instanceof TreePathViewerSorter) { TreePathViewerSorter tpvs = (TreePathViewerSorter) comparator; // be sure we're not modifying the original array from the model result = (Object[]) result.clone(); TreePath path = null; if (parentElementOrTreePath instanceof TreePath) { path = (TreePath) parentElementOrTreePath; } else { Object parent = parentElementOrTreePath; Widget w = internalGetWidgetToSelect(parent); if (w != null) { path = internalGetSorterParentPath(w, comparator); } } tpvs.sort(this, path, result); } else if (comparator != null) { // be sure we're not modifying the original array from the model result = (Object[]) result.clone(); comparator.sort(this, result); } return result; }
@Override protected Object[] getSortedChildren(Object parentElementOrTreePath) { Object[] result = getFilteredChildren(parentElementOrTreePath); ViewerComparator comparator = getComparator(); if (parentElementOrTreePath != null && comparator instanceof TreePathViewerSorter) { TreePathViewerSorter tpvs = (TreePathViewerSorter) comparator; // be sure we're not modifying the original array from the model result = result.clone(); TreePath path = null; if (parentElementOrTreePath instanceof TreePath) { path = (TreePath) parentElementOrTreePath; } else { Object parent = parentElementOrTreePath; Widget w = internalGetWidgetToSelect(parent); if (w != null) { path = internalGetSorterParentPath(w, comparator); } } tpvs.sort(this, path, result); } else if (comparator != null) { // be sure we're not modifying the original array from the model result = result.clone(); comparator.sort(this, result); } return result; }
@Override protected Object[] getSortedChildren(Object parentElementOrTreePath) { Object[] result = getFilteredChildren(parentElementOrTreePath); ViewerComparator comparator = getComparator(); if (parentElementOrTreePath != null && comparator instanceof TreePathViewerSorter) { TreePathViewerSorter tpvs = (TreePathViewerSorter) comparator; // be sure we're not modifying the original array from the model result = result.clone(); TreePath path = null; if (parentElementOrTreePath instanceof TreePath) { path = (TreePath) parentElementOrTreePath; } else { Object parent = parentElementOrTreePath; Widget w = internalGetWidgetToSelect(parent); if (w != null) { path = internalGetSorterParentPath(w, comparator); } } tpvs.sort(this, path, result); } else if (comparator != null) { // be sure we're not modifying the original array from the model result = result.clone(); comparator.sort(this, result); } return result; }
ViewerComparator comparator = getTreeViewer().getComparator(); if (comparator != null) { comparator.sort(null, nodes);