本文整理汇总了Java中org.eclipse.jface.viewers.ViewerSorter类的典型用法代码示例。如果您正苦于以下问题:Java ViewerSorter类的具体用法?Java ViewerSorter怎么用?Java ViewerSorter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewerSorter类属于org.eclipse.jface.viewers包,在下文中一共展示了ViewerSorter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inputChanged
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput == null){
return;
}
if (viewer instanceof TableViewer){
TableViewer tableViewer = (TableViewer) viewer;
if (tableViewer.getTable().isDisposed()) {
return;
}
tableViewer.setSorter(new ViewerSorter() {
public int compare(Viewer iviewer, Object e1, Object e2) {
if (e1 == null) {
return -1;
} else if (e2 == null) {
return 1;
} else {
return ((EnvironmentVariable)e1).getName().compareToIgnoreCase(((EnvironmentVariable)e2).getName());
}
}
});
}
}
示例2: inputChanged
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput == null){
return;
}
if (viewer instanceof TableViewer){
TableViewer tableViewer = (TableViewer) viewer;
if (tableViewer.getTable().isDisposed()) {
return;
}
tableViewer.setSorter(new ViewerSorter() {
public int compare(Viewer iviewer, Object e1, Object e2) {
if (e1 == null) {
return -1;
} else if (e2 == null) {
return 1;
} else {
return ((SmartKeyVariable)e1).getName().compareToIgnoreCase(((SmartKeyVariable)e2).getName());
}
}
});
}
}
示例3: createListContents
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
private ListDialogField createListContents(PathListElement entryToEdit, String key,
String label, ImageDescriptor descriptor, String[] buttonLabels) {
ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
ListDialogField patternList = new ListDialogField(adapter, buttonLabels,
new ExclusionInclusionLabelProvider(key, descriptor));
patternList.setDialogFieldListener(adapter);
patternList.setLabelText(label);
patternList.setRemoveButtonIndex(IDX_REMOVE);
patternList.enableButton(IDX_EDIT, false);
IPath[] pattern = (IPath[]) entryToEdit.getAttribute(key);
ArrayList elements = new ArrayList(pattern.length);
for (int i = 0; i < pattern.length; i++) {
elements.add(pattern[i].toString());
}
patternList.setElements(elements);
patternList.selectFirstElement();
patternList.enableButton(IDX_ADD_MULTIPLE, currSourceFolder != null);
patternList.setViewerSorter(new ViewerSorter());
return patternList;
}
示例4: sortTable
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
private void sortTable(final TableColumn column, final boolean asc)
{
Table table = tableViewer.getTable();
table.setSortColumn(column);
table.setSortDirection(asc? SWT.UP : SWT.DOWN);
tableViewer.setSorter(new ViewerSorter() {
public int compare(Viewer viewer, Object o1, Object o2)
{
int result;
switch(tableViewer.getTable().indexOf(column))
{
case 0: default:
result = ( (ItemContent) o1 ).getDisplayName().compareTo(( (ItemContent) o2 ).getDisplayName());
break;
case 1:
result = ( (ItemContent) o1 ).getCustomName().compareTo(( (ItemContent) o2 ).getCustomName());
break;
case 2:
result = ( (ItemContent) o1 ).getDescription().compareTo(( (ItemContent) o2 ).getDescription());
break;
}
return asc? result : result * -1;
}
});
}
示例5: init
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
@PostConstruct
public void init(final EMenuService inService) {
inService.registerContextMenu(viewer.getControl(), getPopupID());
viewer.setContentProvider(new ObservableListContentProvider());
viewer.setSorter(new ViewerSorter(languageService.getContentLanguage()));
viewer.setInput(getDBInput());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent inEvent) {
selectionService.setSelection(((IStructuredSelection) inEvent
.getSelection()).getFirstElement());
}
});
hookDoubleClickAction();
hookDragnDrop();
}
示例6: createPartControl
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent) {
shell = parent.getShell();
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new MapContentProvider());
viewer.setLabelProvider(new RegistryLabelProvider());
viewer.setSorter(new ViewerSorter());
viewer.setInput(registry);
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
if (registry instanceof Observable) {
Observable observable = (Observable) registry;
observable.addObserver(registryObserver);
}
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
unregisterAction.setEnabled(!event.getSelection().isEmpty());
}
});
viewer.refresh();
}
示例7: init
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
@Override
public void init(){
if (slp == null) {
slp = (SelectorPanelProvider) cv.getConfigurer().getControlFieldProvider();
}
if (filter == null) {
filter = new TreeFilter(slp.getPanel());
}
tv = (TreeViewer) cv.getViewerWidget();
if (orderBy != null) {
tv.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2){
String c1 = ((PersistentObject) e1).get(orderBy);
String c2 = ((PersistentObject) e2).get(orderBy);
return c1.compareTo(c2);
}
});
}
tv.setFilters(new ViewerFilter[] {
filter
});
}
示例8: createListSection
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
public void createListSection ( final ScrolledForm form, final ConfigurationEditorInput input, final String attribute, final String label, final String delimiter, final String pattern )
{
final IObservableList list = StringSplitListObservable.observeString ( Observables.observeMapEntry ( input.getDataMap (), attribute, String.class ), delimiter, pattern );
// section
final Section section = this.toolkit.createSection ( form.getBody (), ExpandableComposite.TITLE_BAR );
section.setText ( label );
final Composite client = this.toolkit.createComposite ( section, SWT.NONE );
section.setClient ( client );
this.toolkit.paintBordersFor ( client );
client.setLayout ( new GridLayout ( 1, true ) );
final GridData gd = new GridData ( GridData.FILL_BOTH );
gd.horizontalSpan = 2;
section.setLayoutData ( gd );
// fields
final ListViewer viewer = new ListViewer ( client );
viewer.setContentProvider ( new ObservableListContentProvider () );
viewer.setInput ( list );
viewer.getControl ().setLayoutData ( new GridData ( GridData.FILL_BOTH ) );
viewer.setSorter ( new ViewerSorter () );
}
示例9: run
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
public void run() {
TreeViewer v = getTreeViewer();
boolean checked = isChecked();
if (checked) {
v.setSorter(new ViewerSorter());
v.setInput(v.getInput());
} else {
v.setSorter(null);
redraw();
}
}
示例10: createSorter
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
private ViewerSorter createSorter() {
final TableViewerSorter sorter = new TableViewerSorter(getViewer());
sorter.setComparator(0, new RPC());
sorter.sort(0, SortDirection.ASCENDING);
return sorter;
}
示例11: createPartControl
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
@Override
public void createPartControl(final Composite parent) {
NavigationTreeService navigationTree;
try {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setContentProvider(new NavigationViewContentProvider());
ColumnViewerToolTipSupport.enableFor(viewer);
viewer.setLabelProvider(new NavigationViewLabelProvider());
viewer.addDoubleClickListener(new TreeCollapseExpandListener(viewer));
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent event) {
CommandExecutor.executeCommand(ICommandIds.CMD_MANAGE_BORROWER_MEDIUM);
}
});
viewer.setSorter(new ViewerSorter());
viewer.setAutoExpandLevel(2);
navigationTree = new NavigationTreeService(viewer);
viewer.setInput(navigationTree.getRoot());
// popup menu related stuff
final MenuManager manager = new MenuManager();
viewer.getTree().setMenu(manager.createContextMenu(viewer.getTree()));
getSite().registerContextMenu(manager, viewer);
getSite().setSelectionProvider(viewer);
} catch (final ConnectException e) {
e.printStackTrace();
}
}
示例12: createPartControl
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
/**
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
@Override
public void createPartControl(Composite parent) {
// | SWT.VIRTUAL
setViewer(new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL));
updateFilter(DataHierarchyPlugin.getDefault().getPreferenceStore().getString(
IPrefConstants.PREF_ACTIVE_FILTERS_LIST));
setLabelProvider(new ViewLabelProvider());
contentProvider = new ViewContentProvider(this);
getViewer().setContentProvider(contentProvider);
selectionProvider = new SelectionListener(getViewer());
getSite().setSelectionProvider(selectionProvider);
getViewer().setLabelProvider(getLabelProvider());
getViewer().setSorter(new ViewerSorter(){
@Override
public int category(Object element) {
if(element instanceof TreeElement<?, ?>){
TreeElement<?, ?> treeElement = (TreeElement<?, ?>) element;
if(treeElement.isVirtual()){
return 42;
}
Object data = treeElement.getData();
if(data instanceof IJavaElement){
IJavaElement javaElement = (IJavaElement) data;
return javaElement.getElementType();
}
}
return 0;
}
});
getViewer().setInput(DataHierarchyView.class);
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
}
示例13: setTreeViewerAlphabeticalSorter
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
protected void setTreeViewerAlphabeticalSorter() {
treeViewer.setSorter(new ViewerSorter() {
@Override
protected Comparator getComparator() {
return new Comparator() {
@Override
public int compare(Object o1, Object o2) {
return String.CASE_INSENSITIVE_ORDER.compare(String.valueOf(o1), String.valueOf(o2));
}
};
}
});
}
示例14: createPartControl
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
public void createPartControl(final Composite parent) {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
vcp = new ViewContentProvider();
viewer.setContentProvider(vcp);
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setSorter(new ViewerSorter());
viewer.setInput(getViewSite());
// Create the help context id for the viewer's control
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), HELP_TEXT);
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
}
示例15: configure
import org.eclipse.jface.viewers.ViewerSorter; //导入依赖的package包/类
final void configure() {
adapterFactory = createAdapterFactory();
viewer.addDoubleClickListener(listener);
viewer.setSorter(new ViewerSorter());
ColumnViewerToolTipSupport.enableFor(viewer);
doConfigure();
}