org.eclipse.jface.viewers.ViewerComparator Java Examples
The following examples show how to use
org.eclipse.jface.viewers.ViewerComparator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaMethodFiltersTable.java From jdt-codemining with Eclipse Public License 1.0 | 6 votes |
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setFont(parent.getFont()); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout(layout); fFilterListField.doFillIntoGrid(composite, 3); LayoutUtil.setHorizontalSpan(fFilterListField.getLabelControl(null), 2); // LayoutUtil.setWidthHint(fFilterListField.getLabelControl(null), // convertWidthInCharsToPixels(40)); LayoutUtil.setHorizontalGrabbing(fFilterListField.getListControl(null)); fFilterListField.getTableViewer().setComparator(new ViewerComparator()); }
Example #2
Source File: CListTable.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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(); }
Example #3
Source File: AbstractSegmentsStatisticsViewer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private static TmfTreeColumnData createTmfTreeColumnData(@Nullable String name, Comparator<TmfTreeViewerEntry> comparator) { TmfTreeColumnData column = new TmfTreeColumnData(name); column.setAlignment(SWT.RIGHT); column.setComparator(new ViewerComparator() { @Override public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) { if ((e1 == null) || (e2 == null)) { return 0; } TmfTreeViewerEntry n1 = (TmfTreeViewerEntry) e1; TmfTreeViewerEntry n2 = (TmfTreeViewerEntry) e2; return comparator.compare(n1, n2); } }); return column; }
Example #4
Source File: CommonOutlinePage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } }
Example #5
Source File: NodeStatsTableControl.java From depan with Apache License 2.0 | 6 votes |
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; }
Example #6
Source File: NLSSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void configureTableViewer(TableViewer viewer) { viewer.setComparator(new ViewerComparator() { @Override public int category(Object element) { if (element instanceof FileEntry) { return 0; } else { return 1; } } }); viewer.setLabelProvider(new ColoringLabelProvider(new NLSSearchResultLabelProvider2(this))); fContentProvider= new TextSearchTableContentProvider(); viewer.setContentProvider(fContentProvider); }
Example #7
Source File: CallHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void updateView() { if (fInputElements != null) { showPage(PAGE_VIEWER); int includeMask= getIncludeMask(); CallHierarchy.getDefault().setSearchScope(getSearchScope(includeMask)); // set input to null so that setComparator does not cause a refresh on the old contents: fCallHierarchyViewer.setInput(null); if (fCurrentCallMode == CALL_MODE_CALLERS) { // sort caller hierarchy alphabetically (bug 111423) and make RealCallers the last in 'Expand With Constructors' mode fCallHierarchyViewer.setComparator(new ViewerComparator() { @Override public int category(Object element) { return element instanceof RealCallers ? 1 : 0; } }); fCallHierarchyViewer.setMethodWrappers(getCallerRoots()); } else { fCallHierarchyViewer.setComparator(null); fCallHierarchyViewer.setMethodWrappers(getCalleeRoots()); } setContentDescription(includeMask); } }
Example #8
Source File: FlowViewer.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override protected ViewerComparator getComparator() { return new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { LabelProvider label = getLabelProvider(); for (int col = 0; col < 3; col++) { String s1 = label.getColumnText(e1, col); String s2 = label.getColumnText(e2, col); int c = Strings.compare(s1, s2); if (c != 0) return c; } return 0; } }; }
Example #9
Source File: JavadocStandardWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void createListDialogField(Composite composite) { Composite c= new Composite(composite, SWT.NONE); c.setFont(composite.getFont()); c.setLayout(createGridLayout(3)); c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, 4, 0)); ((GridLayout) c.getLayout()).marginWidth= 0; String[] buttonlabels= new String[] { JavadocExportMessages.JavadocStandardWizardPage_selectallbutton_label, JavadocExportMessages.JavadocStandardWizardPage_clearallbutton_label, JavadocExportMessages.JavadocStandardWizardPage_configurebutton_label}; JavadocLinkDialogLabelProvider labelProvider= new JavadocLinkDialogLabelProvider(); ListAdapter adapter= new ListAdapter(); fListDialogField= new CheckedListDialogField<JavadocLinkRef>(adapter, buttonlabels, labelProvider); fListDialogField.setDialogFieldListener(adapter); fListDialogField.setCheckAllButtonIndex(0); fListDialogField.setUncheckAllButtonIndex(1); fListDialogField.setViewerComparator(new ViewerComparator()); createLabel(c, SWT.NONE, JavadocExportMessages.JavadocStandardWizardPage_referencedclasses_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 4, 0)); fListDialogField.doFillIntoGrid(c, 3); LayoutUtil.setHorizontalGrabbing(fListDialogField.getListControl(null)); fListDialogField.enableButton(2, false); }
Example #10
Source File: ProjectNaturesPage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } }); }
Example #11
Source File: WizardFolderImportPage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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); } }); }
Example #12
Source File: CodeAssistFavoritesConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void createFavoriteList(Composite parent) { String[] buttonLabels= new String[] { PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_newType_button, PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_newMember_button, PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_edit_button, PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_remove_button }; ListAdapter adapter= new ListAdapter(); fList= new ListDialogField<String>(adapter, buttonLabels, new ListLabelProvider()); fList.setDialogFieldListener(adapter); fList.setLabelText(PreferencesMessages.CodeAssistStaticMembersConfigurationBlock_description); fList.setRemoveButtonIndex(IDX_REMOVE); fList.enableButton(IDX_EDIT, false); fList.setViewerComparator(new ViewerComparator()); PixelConverter pixelConverter= new PixelConverter(parent); fList.doFillIntoGrid(parent, 3); LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2); LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60)); LayoutUtil.setHorizontalGrabbing(fList.getListControl(null)); }
Example #13
Source File: ExclusionInclusionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private ListDialogField<String> createListContents(CPListElement entryToEdit, String key, String label, ImageDescriptor descriptor, String[] buttonLabels) { ExclusionPatternAdapter adapter= new ExclusionPatternAdapter(); ListDialogField<String> patternList= new ListDialogField<String>(adapter, buttonLabels, new ExclusionInclusionLabelProvider(descriptor)); patternList.setDialogFieldListener(adapter); patternList.setLabelText(label); patternList.setRemoveButtonIndex(IDX_REMOVE); patternList.enableButton(IDX_EDIT, false); IPath[] pattern= (IPath[]) entryToEdit.getAttribute(key); ArrayList<String> elements= new ArrayList<String>(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, fCurrSourceFolder != null); patternList.setViewerComparator(new ViewerComparator()); return patternList; }
Example #14
Source File: SetFilterWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private ListDialogField<String> createListContents(CPListElement entryToEdit, String key, String label, ImageDescriptor descriptor, String[] buttonLabels) { ExclusionPatternAdapter adapter= new ExclusionPatternAdapter(); ListDialogField<String> patternList= new ListDialogField<String>(adapter, buttonLabels, new ExclusionInclusionLabelProvider(descriptor)); patternList.setDialogFieldListener(adapter); patternList.setLabelText(label); patternList.enableButton(IDX_EDIT, false); IPath[] pattern= (IPath[]) entryToEdit.getAttribute(key); ArrayList<String> elements= new ArrayList<String>(pattern.length); for (int i= 0; i < pattern.length; i++) { String patternName= pattern[i].toString(); if (patternName.length() > 0) elements.add(patternName); } patternList.setElements(elements); patternList.selectFirstElement(); patternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null); patternList.setViewerComparator(new ViewerComparator()); return patternList; }
Example #15
Source File: SelectBestellungDialog.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void setComparator(){ fTableViewer.setComparator(new ViewerComparator() { private TimeTool t1 = new TimeTool(); private TimeTool t2 = new TimeTool(); @Override public int compare(Viewer viewer, Object b1, Object b2){ setTimeTool((IOrder) b1, t1); setTimeTool((IOrder) b2, t2); if (t1.after(t2)) return -1; if (t2.after(t1)) return 1; return 0; } private void setTimeTool(IOrder order, TimeTool timeTool){ try { String[] i = order.getId().split(":"); //$NON-NLS-1$ timeTool.set(i[1]); } catch (Exception e) { timeTool.set("1.1.1970"); } } }); }
Example #16
Source File: SREsPreferencePage.java From sarl with Apache License 2.0 | 6 votes |
/** * Sorts by SRE name. */ private void sortByName() { this.sresList.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { if ((e1 instanceof ISREInstall) && (e2 instanceof ISREInstall)) { final ISREInstall left = (ISREInstall) e1; final ISREInstall right = (ISREInstall) e2; return left.getName().compareToIgnoreCase(right.getName()); } return super.compare(viewer, e1, e2); } @Override public boolean isSorterProperty(Object element, String property) { return true; } }); this.sortColumn = Column.NAME; }
Example #17
Source File: ProjectSelector.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
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); }
Example #18
Source File: E4PreferencesHandler.java From e4Preferences with Eclipse Public License 1.0 | 6 votes |
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Optional PreferenceManager pm, MApplication appli) { // Manage the possible null pm (case of pure E4 application. With E3 it // will be initialized by org.eclipse.ui.internal.WorkbenchPlugin // see line 1536 if (pm == null) { pm = new E4PrefManager(); E4PreferenceRegistry registry = new E4PreferenceRegistry(); IEclipseContext appliContext = appli.getContext(); registry.populatePrefManagerWithE4Extensions(pm, appliContext); appliContext.set(PreferenceManager.class, pm); } // Can display the standard dialog. PreferenceDialog dialog = new PreferenceDialog(shell, pm); dialog.create(); dialog.getTreeViewer().setComparator(new ViewerComparator()); dialog.getTreeViewer().expandAll(); dialog.open(); }
Example #19
Source File: SREsPreferencePage.java From sarl with Apache License 2.0 | 6 votes |
/** * Sorts by VM location. */ private void sortByLocation() { this.sresList.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { if ((e1 instanceof ISREInstall) && (e2 instanceof ISREInstall)) { final ISREInstall left = (ISREInstall) e1; final ISREInstall right = (ISREInstall) e2; return left.getLocation().compareToIgnoreCase(right.getLocation()); } return super.compare(viewer, e1, e2); } @Override public boolean isSorterProperty(Object element, String property) { return true; } }); this.sortColumn = Column.LOCATION; }
Example #20
Source File: AbstractConversionTable.java From sarl with Apache License 2.0 | 6 votes |
/** * Sorts the type conversions by target type. */ private void sortByTargetColumn() { this.list.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 != null && e2 != null) { return e1.toString().compareToIgnoreCase(e2.toString()); } return super.compare(viewer, e1, e2); } @Override public boolean isSorterProperty(Object element, String property) { return true; } }); this.sort = Column.TARGET; }
Example #21
Source File: ProjectSettingDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #22
Source File: NodeDisplayTableControl.java From depan with Apache License 2.0 | 6 votes |
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; }
Example #23
Source File: ConverterUtil.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 对下拉列表和转换器列表进行绑定 * @param context * @param comboViewer * @param model * ; */ public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null); context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE)); }
Example #24
Source File: ConverterUtil.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public static void bindValue(DataBindingContext context,ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class); context.bindValue(observableValue, BeansObservables .observeValue(model, "selectedType")); }
Example #25
Source File: ConverterUtil.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 对下拉列表和转换器列表进行绑定 * @param context * @param comboViewer * @param model * ; */ public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null); context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE)); }
Example #26
Source File: RelationDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
private void setSortColumn( TableColumn column, int colIndex, int direction) { ViewerComparator sorter = buildColumnSorter(colIndex); if (SWT.UP == direction) { sorter = new InverseSorter(sorter); } Table tableControl = (Table) propViewer.getControl(); propViewer.setComparator(sorter); tableControl.setSortColumn(column); tableControl.setSortDirection(direction); }
Example #27
Source File: HostPagePathSelectionDialog.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private HostPagePathSelectionDialog(Shell parent, IProject project) { super(parent, new HostPagePathLabelProvider(), new HostPagePathContentProvider()); setTitle("Existing Folder Selection"); setMessage("Choose a location for the HTML page"); rootTreeItems = HostPagePathTreeItem.createRootItems(project); setInput(rootTreeItems); setComparator(new ViewerComparator()); }
Example #28
Source File: RelationSetTableControl.java From depan with Apache License 2.0 | 5 votes |
private void setSortColumn( TableColumn column, int colIndex, int direction) { ViewerComparator sorter = buildColumnSorter(colIndex); if (SWT.UP == direction) { sorter = new InverseSorter(sorter); } Table tableControl = (Table) relSetViewer.getControl(); relSetViewer.setComparator(sorter); tableControl.setSortColumn(column); tableControl.setSortDirection(direction); }
Example #29
Source File: RelationDisplayTableControl.java From depan with Apache License 2.0 | 5 votes |
private ViewerComparator buildColumnSorter(int colIndex) { // 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; }
Example #30
Source File: ConverterUtil.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 对下拉列表和转换器列表进行绑定 * @param context * @param comboViewer * @param model * ; */ public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null); context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE)); }