use of org.eclipse.jface.viewers.ViewerComparator in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method createProjectsList.
/**
* Create the checkbox list for the found projects.
*
* @param workArea
*/
private void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(DataTransferMessages.WizardProjectsImportPage_ProjectsListTitle);
Composite listComposite = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
listComposite.setLayout(layout);
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java
* .lang.Object)
*/
public Object[] getChildren(Object parentElement) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements
* (java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java
* .lang.Object)
*/
public boolean hasChildren(Object element) {
return false;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ITreeContentProvider#getParent(java
* .lang.Object)
*/
public Object getParent(Object element) {
return null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
* (org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts) {
projectsList.setChecked(element, false);
}
setPageComplete(projectsList.getCheckedElements().length > 0);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
}
use of org.eclipse.jface.viewers.ViewerComparator in project translationstudio8 by heartsome.
the class ConverterUtil method bindValue.
/**
* 对下拉列表和转换器列表进行绑定
* @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));
}
use of org.eclipse.jface.viewers.ViewerComparator in project eclipse.platform.text by eclipse.
the class LinkedModeConfigurationBlock method createControl.
/**
* Creates page for hover preferences.
*
* @param parent the parent composite
* @return the control for the preference page
*/
@Override
public Control createControl(Composite parent) {
OverlayPreferenceStore store = getPreferenceStore();
store.load();
store.start();
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
Label label = new Label(composite, SWT.LEFT);
label.setText(TextEditorMessages.LinkedModeConfigurationBlock_annotationPresentationOptions);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
label.setLayoutData(gd);
Composite editorComposite = new Composite(composite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
editorComposite.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
editorComposite.setLayoutData(gd);
fAnnotationTypeViewer = new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
fAnnotationTypeViewer.setLabelProvider(new ItemLabelProvider());
fAnnotationTypeViewer.setContentProvider(new ItemContentProvider());
gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
gd.heightHint = convertHeightInCharsToPixels(5);
fAnnotationTypeViewer.getControl().setLayoutData(gd);
Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
optionsComposite.setLayout(layout);
optionsComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
// we only allow to set either "show in text" or "highlight in text", but not both
fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
fShowInTextCheckBox.setText(TextEditorMessages.LinkedModeConfigurationBlock_labels_showIn);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
fShowInTextCheckBox.setLayoutData(gd);
fDecorationViewer = new ComboViewer(optionsComposite, SWT.READ_ONLY);
fDecorationViewer.setContentProvider(new ArrayContentProvider());
fDecorationViewer.setLabelProvider(new ArrayLabelProvider());
fDecorationViewer.setComparator(new ViewerComparator(Collator.getInstance()));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
fDecorationViewer.getControl().setLayoutData(gd);
fDecorationViewer.setInput(new Object[] { HIGHLIGHT, SQUIGGLES, BOX, DASHED_BOX, UNDERLINE, IBEAM });
label = new Label(optionsComposite, SWT.LEFT);
label.setText(TextEditorMessages.LinkedModeConfigurationBlock_color);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
fAnnotationForegroundColorEditor = new ColorSelector(optionsComposite);
Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
createDependency(fShowInTextCheckBox, new Control[] { label, foregroundColorButton });
fAnnotationTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleAnnotationListSelection();
}
});
fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(SelectionEvent e) {
ListItem item = getSelectedItem();
final boolean value = fShowInTextCheckBox.getSelection();
if (value) {
// enable whatever is in the combo
String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
if (HIGHLIGHT.equals(decoration))
getPreferenceStore().setValue(item.highlightKey, true);
else
getPreferenceStore().setValue(item.textKey, true);
} else {
// disable both
getPreferenceStore().setValue(item.textKey, false);
getPreferenceStore().setValue(item.highlightKey, false);
}
getPreferenceStore().setValue(item.textKey, value);
updateDecorationViewer(item, false);
}
});
foregroundColorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(SelectionEvent e) {
ListItem item = getSelectedItem();
PreferenceConverter.setValue(getPreferenceStore(), item.colorKey, fAnnotationForegroundColorEditor.getColorValue());
}
});
fDecorationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
ListItem item = getSelectedItem();
if (fShowInTextCheckBox.getSelection()) {
if (HIGHLIGHT.equals(decoration)) {
getPreferenceStore().setValue(item.highlightKey, true);
getPreferenceStore().setValue(item.textKey, false);
getPreferenceStore().setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
} else {
getPreferenceStore().setValue(item.highlightKey, false);
getPreferenceStore().setValue(item.textKey, true);
getPreferenceStore().setValue(item.textStyleKey, decoration[1]);
}
}
}
});
return composite;
}
use of org.eclipse.jface.viewers.ViewerComparator in project knime-core by knime.
the class AbstractRepositoryView method onSearchQueryChanged.
/* called whenever the search query changes (no matter in what search mode, i.e. fuzzy or text) */
private void onSearchQueryChanged() {
if (m_fuzzySearchButton.isChecked()) {
// if the query string is empty, use the category tree, otherwise show the node list (in case fuzzy search is activated)
if (m_fuzzyTextInfoFilter.getDelegateFilter().hasNonEmptyQuery()) {
if (!(m_viewer.getContentProvider() instanceof ListRepositoryContentProvider)) {
// only change the content provider if its not a list content provider already
m_viewer.setContentProvider(new ListRepositoryContentProvider());
// sync the additional info to be shown
onShowAdditionalInfoClicked();
}
m_viewer.setComparator(new ViewerComparator(m_fuzzyTextInfoFilter.getDelegateFilter().createComparator()));
} else {
if (!(m_viewer.getContentProvider() instanceof RepositoryContentProvider)) {
// only change the content provider if its not a tree content provider already
m_viewer.setContentProvider(new RepositoryContentProvider());
m_viewer.setComparator(null);
// sync the additional info to be shown
onShowAdditionalInfoClicked();
}
}
}
}
use of org.eclipse.jface.viewers.ViewerComparator in project knime-core by knime.
the class AbstractRepositoryView method onFuzzySearchButtonClicked.
/* action to be performed if the "Fuzzy Search" button is clicked */
private void onFuzzySearchButtonClicked(final AdditionalInfoViewFilter extFuzzyFilter, final AdditionalInfoViewFilter extTextFilter) {
if (m_fuzzySearchButton.isChecked()) {
m_viewer.setFilters(new ViewerFilter[] { extFuzzyFilter });
m_toolbarSearchText.setFilter(extFuzzyFilter.getDelegateFilter());
// sync streamable filter settings
extTextFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
extFuzzyFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
// transfer the search query
extFuzzyFilter.getDelegateFilter().setQueryString(extTextFilter.getDelegateFilter().getQueryString());
// set the content provider. If search query is empty, show the tree, otherwise the list
if (extTextFilter.getDelegateFilter().hasNonEmptyQuery()) {
m_viewer.setContentProvider(new ListRepositoryContentProvider());
m_viewer.setComparator(new ViewerComparator(extFuzzyFilter.getDelegateFilter().createComparator()));
} else {
m_viewer.setContentProvider(new RepositoryContentProvider());
m_viewer.setComparator(null);
}
} else {
m_viewer.setContentProvider(new RepositoryContentProvider());
m_viewer.setFilters(new ViewerFilter[] { extTextFilter });
m_toolbarSearchText.setFilter(extTextFilter.getDelegateFilter());
// sync streamable filter settings
extTextFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
extFuzzyFilter.setDoFilter(m_filterStreamNodesButton.isChecked());
// transfer the search query
extTextFilter.getDelegateFilter().setQueryString(extFuzzyFilter.getDelegateFilter().getQueryString());
m_viewer.setComparator(null);
}
// sync the additional info info
// mainly to set the right label provider
onShowAdditionalInfoClicked();
if (extTextFilter.getDelegateFilter().hasNonEmptyQuery()) {
TreeViewerUpdater.update(m_viewer, true, true);
}
}
Aggregations