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