本文整理汇总了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();
}
}