本文整理汇总了Java中org.eclipse.jface.viewers.ViewerComparator类的典型用法代码示例。如果您正苦于以下问题:Java ViewerComparator类的具体用法?Java ViewerComparator怎么用?Java ViewerComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewerComparator类属于org.eclipse.jface.viewers包,在下文中一共展示了ViewerComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showJobDetails
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
/**
* This method creates a dialog area in the parent composite and displays a
* progress tree viewer of the running jobs.
*
* @param parent
* The parent Composite.
*/
void showJobDetails(Composite parent) {
viewer = new DetailedProgressViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.BORDER, progressService, finishedJobs);
viewer.setComparator(new ViewerComparator() {
@Override
@SuppressWarnings("unchecked")
public int compare(Viewer testViewer, Object e1, Object e2) {
return ((Comparable<Object>) e1).compareTo(e2);
}
});
ProgressViewerContentProvider provider = getContentProvider();
viewer.setContentProvider(provider);
viewer.setInput(provider);
viewer.setLabelProvider(new ProgressLabelProvider());
GridData data = new GridData(GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
data.horizontalSpan = 2;
int heightHint = convertHeightInCharsToPixels(10);
data.heightHint = heightHint;
viewer.getControl().setLayoutData(data);
}
示例2: setSortColumn
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private void setSortColumn(
TreeColumn column, int colIndex, int direction) {
ViewerComparator sorter = buildColumnSorter(colIndex);
if (SWT.UP == direction) {
sorter = new InverseSorter(sorter);
}
Tree tree = propViewer.getTree();
tree.setSortColumn(column);
tree.setSortDirection(direction);
propViewer.setComparator(sorter);
}
示例3: createDialogArea
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
@Override
protected Control createDialogArea(Composite parent)
{
Composite dialogArea = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(dialogArea, SWT.NONE);
createMessageArea(composite);
listViewer = new TableViewer(composite, SWT.TOP | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 400;
data.heightHint = 400;
listViewer.getTable().setLayoutData(data);
listViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
listViewer.setContentProvider(new JarProjectContentProvider(null));
listViewer.setComparator(new ViewerComparator());
listViewer.setInput(ResourcesPlugin.getWorkspace());
applyDialogFont(composite);
listViewer.setSelection(new StructuredSelection(initialSelection));
GridLayoutFactory.fillDefaults().generateLayout(composite);
return dialogArea;
}
示例4: inputChanged
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的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.setComparator(new ViewerComparator() {
public int compare(Viewer iviewer, Object e1, Object e2) {
if (e1 == null) {
return -1;
} else if (e2 == null) {
return 1;
} else {
return ((PropertyVariable) e1).getName()
.compareToIgnoreCase(((PropertyVariable) e2).getName());
}
}
});
}
}
示例5: create
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private void create(Composite parent) {
displayExecutor = DisplayExecutor.create(parent.getDisplay());
comboViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
comboViewer.setComparator(new ViewerComparator());
comboViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof GcpProject) {
GcpProject project = (GcpProject) element;
return project.getName() + " (" + project.getId() + ")";
}
return super.getText(element);
}
});
comboViewer.setContentProvider(ArrayContentProvider.getInstance());
comboViewer.setInput(EMPTY_PROJECTS);
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
cancelFetch();
}
});
fetch();
}
示例6: ProjectSelector
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
public ProjectSelector(Composite parent) {
super(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(this);
Composite tableComposite = new Composite(this, SWT.NONE);
TableColumnLayout tableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableColumnLayout);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tableComposite);
viewer = new TableViewer(tableComposite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
createColumns(tableColumnLayout);
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(false);
input = WritableList.withElementType(GcpProject.class);
projectProperties = PojoProperties.values(new String[] {"name", "id"}); //$NON-NLS-1$ //$NON-NLS-2$
ViewerSupport.bind(viewer, input, projectProperties);
viewer.setComparator(new ViewerComparator());
Composite linkComposite = new Composite(this, SWT.NONE);
statusLink = new Link(linkComposite, SWT.WRAP);
statusLink.addSelectionListener(
new OpenUriSelectionListener(new ErrorDialogErrorHandler(getShell())));
statusLink.setText("");
GridDataFactory.fillDefaults().span(2, 1).applyTo(linkComposite);
GridLayoutFactory.fillDefaults().generateLayout(linkComposite);
}
示例7: addMappingBaseCombo
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
/**
* Add the mapping base {@link ComboViewer} to the given header {@link Composite}.
*
* @param headerComposite
* the header {@link Composite}
* @return the mapping base {@link ComboViewer}
*/
private ComboViewer addMappingBaseCombo(Composite headerComposite) {
final Label selectMappingBaseLabel = new Label(headerComposite, SWT.NONE);
selectMappingBaseLabel.setToolTipText("Select a mapping base.");
selectMappingBaseLabel.setText("Mapping base:");
final ComboViewer mappingCombo = new ComboViewer(headerComposite, SWT.READ_ONLY);
Combo combo = mappingCombo.getCombo();
combo.setToolTipText("Select the mapping base to use.");
mappingCombo.setContentProvider(new MappingBaseRegistryContentProvider());
mappingCombo.setLabelProvider(new MappingLabelProvider(MappingLabelProvider.SOURCE));
mappingCombo.setComparator(new ViewerComparator());
mappingCombo.setInput(MappingUtils.getMappingRegistry());
mappingCombo.addSelectionChangedListener(new BaseComboSelectionChangedListener());
return mappingCombo;
}
示例8: execute
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg,
@Optional @Named("preferencePageId") String pageId)
{
PreferenceManager pm = prefReg.getPreferenceManager();
PreferenceDialog dialog = new PreferenceDialog(shell, pm);
if (pageId != null)
{
dialog.setSelectedNode(pageId);
}
dialog.create();
dialog.getTreeViewer().setComparator(new ViewerComparator());
// dialog.getTreeViewer().expandAll();
dialog.open();
}
示例9: buildColumnSorter
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private ViewerComparator buildColumnSorter(int columnIndex) {
switch (columnIndex) {
case INDEX_ROOT:
return new RootSorter();
case INDEX_RANK:
return new RankSorter();
case INDEX_PREDS:
return new PredecessorCountSorter();
case INDEX_SUCCS:
return new SuccessorCountSorter();
}
// By default, use an alphabetic sort over the column labels.
ITableLabelProvider labelProvider =
(ITableLabelProvider) propViewer.getLabelProvider();
ViewerComparator result = new AlphabeticSorter(
new LabelProviderToString(labelProvider, columnIndex));
return result;
}
示例10: setSortColumn
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private void setSortColumn(
TableColumn column, int colIndex, int direction) {
ITableLabelProvider labelProvider =
(ITableLabelProvider) kindViewer.getLabelProvider();
ViewerComparator sorter = new AlphabeticSorter(
new LabelProviderToString(labelProvider, colIndex));
if (SWT.UP == direction) {
sorter = new InverseSorter(sorter);
}
Table tableControl = (Table) kindViewer.getControl();
kindViewer.setComparator(sorter);
tableControl.setSortColumn(column);
tableControl.setSortDirection(direction);
}
示例11: buildColumnSorter
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private ViewerComparator buildColumnSorter(int colIndex) {
if (INDEX_VISIBLE == colIndex) {
return new BooleanVisibleSorter();
}
if (INDEX_XPOS == colIndex) {
return new PositionSorter(true);
}
if (INDEX_YPOS == colIndex) {
return new PositionSorter(false);
}
// By default, use an alphabetic sort over the column labels.
ITableLabelProvider labelProvider =
(ITableLabelProvider) propViewer.getLabelProvider();
ViewerComparator result = new AlphabeticSorter(
new LabelProviderToString(labelProvider, colIndex));
return result;
}
示例12: LegacyGWTHostPageSelectionDialog
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private LegacyGWTHostPageSelectionDialog(Shell parent, IProject project,
Map<String, Set<String>> hostPagesByModule, boolean isExternal) {
super(parent, new LegacyHostPageSelectionLabelProvider(),
new LegacyGWTHostPageSelectionContentProvider());
this.isExternal = isExternal;
this.project = project;
this.isEmpty = hostPagesByModule.isEmpty();
this.useHostPage = !isEmpty;
setValidator(new LegacyHostPageSelectionStatusValidator());
setTitle("Host page selection");
setMessage("Choose a host page to launch the application with:");
setInput(LegacyGWTHostPageSelectionTreeItem.buildTree(hostPagesByModule));
setComparator(new ViewerComparator());
}
示例13: getViewerComperator
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private ViewerComparator getViewerComperator()
{
return new ViewerComparator(new Comparator<String>()
{
public int compare(String o1, String o2)
{
// set Aptana natures ahead of others
if (ResourceUtil.isAptanaNature(o1))
{
return ResourceUtil.isAptanaNature(o2) ? o1.compareTo(o2) : -1;
}
return ResourceUtil.isAptanaNature(o2) ? 1 : o1.compareTo(o2);
}
});
}
示例14: createTable
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
private void createTable(Composite parent)
{
tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
tableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.setLabelProvider(new LabelProvider());
tableViewer.setComparator(new ViewerComparator());
tableViewer.setInput(items);
tableViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
public void selectionChanged(SelectionChangedEvent event)
{
updateStates();
}
});
updateStates();
}
示例15: propertyChange
import org.eclipse.jface.viewers.ViewerComparator; //导入依赖的package包/类
public void propertyChange(PropertyChangeEvent event)
{
String property = event.getProperty();
if (property.equals(IPreferenceConstants.LINK_OUTLINE_WITH_EDITOR))
{
boolean isLinked = Boolean.parseBoolean(StringUtil.getStringValue(event.getNewValue()));
fToggleLinkingAction.setChecked(isLinked);
TreeViewer viewer = getTreeViewer();
if (isLinked)
{
setEditorSelection((IStructuredSelection) viewer.getSelection(), false);
}
}
else if (property.equals(IPreferenceConstants.SORT_OUTLINE_ALPHABETIC))
{
boolean sort = Boolean.parseBoolean(StringUtil.getStringValue(event.getNewValue()));
getTreeViewer().setComparator(sort ? new ViewerComparator() : null);
}
}