本文整理匯總了Java中org.eclipse.jface.viewers.ViewerComparator.sort方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewerComparator.sort方法的具體用法?Java ViewerComparator.sort怎麽用?Java ViewerComparator.sort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.viewers.ViewerComparator
的用法示例。
在下文中一共展示了ViewerComparator.sort方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: selectSavedItem
import org.eclipse.jface.viewers.ViewerComparator; //導入方法依賴的package包/類
/**
* Selects the saved item in the tree of preference pages. If it cannot do this it saves the first one.
*/
protected void selectSavedItem() {
IPreferenceNode node = findNodeMatching(getSelectedNodePreference());
if (node == null) {
IPreferenceNode[] nodes = preferenceManager.getRootSubNodes();
ViewerComparator comparator = getTreeViewer().getComparator();
if (comparator != null) {
comparator.sort(null, nodes);
}
for (int i = 0; i < nodes.length; i++) {
IPreferenceNode selectedNode = nodes[i];
if (selectedNode != null) {
node = selectedNode;
break;
}
}
}
if (node != null) {
getTreeViewer().setSelection(new StructuredSelection(node), true);
// Keep focus in tree. See bugs 2692, 2621, and 6775.
getTreeViewer().getControl().setFocus();
boolean expanded = getTreeViewer().getExpandedState(node);
getTreeViewer().setExpandedState(node, !expanded);
}
}
示例2: add
import org.eclipse.jface.viewers.ViewerComparator; //導入方法依賴的package包/類
@Override
public void add(Object[] elements) {
ViewerComparator sorter = getComparator();
// Use a Set in case we are getting something added that exists
Set<Object> newItems = new HashSet<>(elements.length);
Control[] existingChildren = control.getChildren();
for (int i = 0; i < existingChildren.length; i++) {
if (existingChildren[i].getData() != null)
newItems.add(existingChildren[i].getData());
}
for (int i = 0; i < elements.length; i++) {
if (elements[i] != null)
newItems.add(elements[i]);
}
JobTreeElement[] infos = new JobTreeElement[newItems.size()];
newItems.toArray(infos);
if (sorter != null) {
sorter.sort(this, infos);
}
// Update with the new elements to prevent flash
for (int i = 0; i < existingChildren.length; i++) {
((ProgressInfoItem) existingChildren[i]).dispose();
}
int totalSize = Math.min(newItems.size(), MAX_DISPLAYED);
for (int i = 0; i < totalSize; i++) {
ProgressInfoItem item = createNewItem(infos[i]);
item.setColor(i);
}
control.layout(true);
updateForShowingProgress();
}
示例3: setProjectViewerSelectionAfterDeletion
import org.eclipse.jface.viewers.ViewerComparator; //導入方法依賴的package包/類
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);
}
}
示例4: selectSavedItem
import org.eclipse.jface.viewers.ViewerComparator; //導入方法依賴的package包/類
/**
* Selects the saved item in the tree of preference pages. If it cannot do
* this it saves the first one.
*/
protected void selectSavedItem() {
IPreferenceNode node = findNodeMatching(getSelectedNodePreference());
if (node == null) {
IPreferenceNode[] nodes = preferenceManager.getRootSubNodes();
ViewerComparator comparator = getTreeViewer().getComparator();
if (comparator != null) {
comparator.sort(null, nodes);
}
ViewerFilter[] filters = getTreeViewer().getFilters();
for (int i = 0; i < nodes.length; i++) {
IPreferenceNode selectedNode = nodes[i];
// See if it passes all filters
for (int j = 0; j < filters.length; j++) {
if (!filters[j].select(this.treeViewer, preferenceManager
.getRoot(), selectedNode)) {
selectedNode = null;
break;
}
}
// if it passes all filters select it
if (selectedNode != null) {
node = selectedNode;
break;
}
}
}
if (node != null) {
getTreeViewer().setSelection(new StructuredSelection(node), true);
// Keep focus in tree. See bugs 2692, 2621, and 6775.
getTreeViewer().getControl().setFocus();
}
}