Search in sources :

Example 1 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project hale by halestudio.

the class InstanceValidationReportDetailsPage method createControls.

/**
 * @see CustomReportDetailsPage#createControls(Composite)
 */
@Override
public Control createControls(Composite parent) {
    // filtered tree sets itself GridData, so set layout to gridlayout
    parent.setLayout(GridLayoutFactory.fillDefaults().create());
    // create pattern filter for FilteredTree
    PatternFilter filter = new TreePathPatternFilter();
    filter.setIncludeLeadingWildcard(true);
    // create FilteredTree
    FilteredTree filteredTree = new TreePathFilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
    treeViewer = filteredTree.getViewer();
    // set content provider
    contentProvider = new InstanceValidationReportDetailsContentProvider();
    treeViewer.setContentProvider(contentProvider);
    // set label provider
    treeViewer.setLabelProvider(new InstanceValidationReportDetailsLabelProvider(contentProvider));
    // set comparator
    treeViewer.setComparator(new ViewerComparator() {

        /**
         * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
         */
        @Override
        public int category(Object element) {
            if (element instanceof QName || element instanceof Definition<?>)
                // Path
                return 0;
            else if (element instanceof String)
                // Category
                return 1;
            else
                // InstanceValidationMessage
                return 2;
        }
    });
    // add menu on right-click
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            if (getValidSelection() == null)
                return;
            // selection is valid, offer link to transformed data view
            manager.add(new ShowExampleAction());
        }
    });
    // remove previous menus
    menuMgr.setRemoveAllWhenShown(true);
    // add menu to tree
    treeViewer.getTree().setMenu(menu);
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            showSelectionInDataView();
        }
    });
    Image noReportBaseImage = InstanceValidationUIPlugin.getDefault().getImageRegistry().get(InstanceValidationUIPlugin.IMG_INSTANCE_VALIDATION);
    reportImage = new DecorationOverlayIcon(noReportBaseImage, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING), IDecoration.BOTTOM_LEFT).createImage();
    return filteredTree;
}
Also used : DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) TreePathPatternFilter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) QName(javax.xml.namespace.QName) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) Image(org.eclipse.swt.graphics.Image) IMenuListener(org.eclipse.jface.action.IMenuListener) TreePathPatternFilter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 2 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project hale by halestudio.

the class ReportList method createViewControl.

/**
 * Create contents of the view part.
 *
 * @param parent parent element
 */
@Override
public void createViewControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    TreeColumnLayout layout = new TreeColumnLayout();
    composite.setLayout(layout);
    {
        _treeViewer = new TreeViewer(composite, SWT.BORDER);
        final Tree tree = _treeViewer.getTree();
        tree.setHeaderVisible(false);
        tree.setLinesVisible(false);
        // create column for reports
        TreeViewerColumn col1 = new TreeViewerColumn(_treeViewer, SWT.NONE);
        // add the label provider
        col1.setLabelProvider(new TreeColumnViewerLabelProvider(new ReportListLabelProvider()));
        // and layout
        layout.setColumnData(col1.getColumn(), new ColumnWeightData(3));
        // create column for reports
        TreeViewerColumn col2 = new TreeViewerColumn(_treeViewer, SWT.NONE);
        // add the label provider
        col2.setLabelProvider(new TreeColumnViewerLabelProvider(new ReportListLabelDateProvider()));
        // create column for reports
        layout.setColumnData(col2.getColumn(), new ColumnWeightData(1));
        new ReportListMenu(getSite(), _treeViewer);
    }
    createActions();
    initializeToolBar();
    initializeMenu();
    // set label provider
    // _treeViewer.setLabelProvider(new ReportListLabelProvider());
    // set content provider
    _treeViewer.setContentProvider(new ReportListContentProvider());
    // disable this if it uses too much memory
    // but should maintain the list much faster
    _treeViewer.setUseHashlookup(true);
    // order the sessions from latest to oldest
    _treeViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof ReportSession && e2 instanceof ReportSession) {
                long first = ((ReportSession) e1).getId();
                long second = ((ReportSession) e2).getId();
                if (first > second) {
                    return -1;
                } else if (first < second) {
                    return 1;
                } else {
                    return 0;
                }
            } else if (e1 instanceof Report<?> && e2 instanceof Report<?>) {
                Report<?> first = (Report<?>) e1;
                Report<?> second = (Report<?>) e2;
                if (first.getStartTime() == null && second.getStartTime() == null) {
                    return 0;
                } else if (first.getStartTime() == null) {
                    return 1;
                } else if (second.getStartTime() == null) {
                    return -1;
                } else if (first.getStartTime().getTime() > second.getStartTime().getTime()) {
                    return -1;
                } else if (first.getStartTime().getTime() < second.getStartTime().getTime()) {
                    return 1;
                } else {
                    return 0;
                }
            }
            return 0;
        }
    });
    // set selection provider
    getSite().setSelectionProvider(_treeViewer);
    _treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            OpenPropertiesHandler.unpinAndOpenPropertiesView(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
        }
    });
    // load all added reports
    this.loadReports();
}
Also used : TreeColumnViewerLabelProvider(org.eclipse.jface.viewers.TreeColumnViewerLabelProvider) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) Report(eu.esdihumboldt.hale.common.core.report.Report) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Tree(org.eclipse.swt.widgets.Tree) ReportSession(eu.esdihumboldt.hale.common.core.report.ReportSession)

Example 3 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project archi by archimatetool.

the class GeneralPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    Composite client = new Composite(parent, SWT.NULL);
    client.setLayout(new GridLayout());
    GridData gd;
    Group fileGroup = new Group(client, SWT.NULL);
    fileGroup.setText(Messages.GeneralPreferencePage_0);
    fileGroup.setLayout(new GridLayout(2, false));
    fileGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Automatically open views when opening a model file
    fOpenDiagramsOnLoadButton = new Button(fileGroup, SWT.CHECK);
    fOpenDiagramsOnLoadButton.setText(Messages.GeneralPreferencePage_1);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fOpenDiagramsOnLoadButton.setLayoutData(gd);
    // Backup file on save
    fBackupOnSaveButton = new Button(fileGroup, SWT.CHECK);
    fBackupOnSaveButton.setText(Messages.GeneralPreferencePage_5);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fBackupOnSaveButton.setLayoutData(gd);
    // Size of recently opened file list
    Label label = new Label(fileGroup, SWT.NULL);
    label.setText(Messages.GeneralPreferencePage_2);
    fMRUSizeSpinner = new Spinner(fileGroup, SWT.BORDER);
    fMRUSizeSpinner.setMinimum(3);
    fMRUSizeSpinner.setMaximum(15);
    // Appearance
    Group appearanceGroup = new Group(client, SWT.NULL);
    appearanceGroup.setText(Messages.GeneralPreferencePage_3);
    appearanceGroup.setLayout(new GridLayout(2, false));
    appearanceGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Themes
    label = new Label(appearanceGroup, SWT.NULL);
    label.setText(Messages.GeneralPreferencePage_4);
    fThemeComboViewer = new ComboViewer(appearanceGroup, SWT.READ_ONLY);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fThemeComboViewer.getCombo().setLayoutData(gd);
    fThemeComboViewer.setContentProvider(new IStructuredContentProvider() {

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return (Object[]) inputElement;
        }
    });
    fThemeComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((ITheme) element).getLabel();
        }
    });
    fThemeComboViewer.setComparator(new ViewerComparator());
    // Show Status Line
    fShowStatusLineButton = new Button(appearanceGroup, SWT.CHECK);
    fShowStatusLineButton.setText(Messages.GeneralPreferencePage_9);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fShowStatusLineButton.setLayoutData(gd);
    label = new Label(appearanceGroup, SWT.NULL);
    label.setText(Messages.GeneralPreferencePage_8);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    // Model Tree
    Group modelTreeGroup = new Group(client, SWT.NULL);
    modelTreeGroup.setText(Messages.GeneralPreferencePage_10);
    modelTreeGroup.setLayout(new GridLayout(2, false));
    modelTreeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fShowUnusedElementsInModelTreeButton = new Button(modelTreeGroup, SWT.CHECK);
    fShowUnusedElementsInModelTreeButton.setText(Messages.GeneralPreferencePage_11);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fShowUnusedElementsInModelTreeButton.setLayoutData(gd);
    // Visualiser
    Group visualiserGroup = new Group(client, SWT.NULL);
    visualiserGroup.setText(Messages.GeneralPreferencePage_6);
    visualiserGroup.setLayout(new GridLayout(2, false));
    visualiserGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fAnimateVisualiserNodesButton = new Button(visualiserGroup, SWT.CHECK);
    fAnimateVisualiserNodesButton.setText(Messages.GeneralPreferencePage_7);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fAnimateVisualiserNodesButton.setLayoutData(gd);
    fAnimateVisualiserNodesButton.setEnabled(AnimationUtil.supportsAnimation());
    setValues();
    fThemeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ITheme theme = (ITheme) ((IStructuredSelection) fThemeComboViewer.getSelection()).getFirstElement();
            if (theme != null && theme != fThemeEngine.getActiveTheme()) {
                setTheme(theme, false);
            }
        }
    });
    return client;
}
Also used : Group(org.eclipse.swt.widgets.Group) ITheme(org.eclipse.e4.ui.css.swt.theme.ITheme) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 4 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project archi by archimatetool.

the class UserPropertiesManagerDialog method createTableControl.

private void createTableControl(Composite parent) {
    Composite tableComp = new Composite(parent, SWT.BORDER);
    TableColumnLayout tableLayout = new TableColumnLayout();
    tableComp.setLayout(tableLayout);
    tableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer = new TableViewer(tableComp, SWT.MULTI | SWT.FULL_SELECTION);
    fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer.getTable().setHeaderVisible(true);
    fTableViewer.getTable().setLinesVisible(true);
    fTableViewer.setComparator(new ViewerComparator());
    // Columns
    TableViewerColumn columnOldKey = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
    columnOldKey.getColumn().setText(Messages.UserPropertiesManagerDialog_6);
    tableLayout.setColumnData(columnOldKey.getColumn(), new ColumnWeightData(40, true));
    TableViewerColumn columnNewKey = new TableViewerColumn(fTableViewer, SWT.NONE, 1);
    columnNewKey.getColumn().setText(Messages.UserPropertiesManagerDialog_7);
    tableLayout.setColumnData(columnNewKey.getColumn(), new ColumnWeightData(40, true));
    columnNewKey.setEditingSupport(new KeyEditingSupport(fTableViewer));
    TableViewerColumn columnUsedNumber = new TableViewerColumn(fTableViewer, SWT.NONE, 2);
    // $NON-NLS-1$
    columnUsedNumber.getColumn().setText("# " + Messages.UserPropertiesManagerDialog_8);
    tableLayout.setColumnData(columnUsedNumber.getColumn(), new ColumnWeightData(20, true));
    // Content Provider
    fTableViewer.setContentProvider(new IStructuredContentProvider() {

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return fKeysTable.entrySet().toArray();
        }
    });
    // Label Provider
    fTableViewer.setLabelProvider(new LabelCellProvider());
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            fActionDelete.setEnabled(!event.getSelection().isEmpty());
            fButtonDelete.setEnabled(!event.getSelection().isEmpty());
            fActionRename.setEnabled(!event.getSelection().isEmpty());
            fButtonRename.setEnabled(!event.getSelection().isEmpty());
        }
    });
    // anything will do //$NON-NLS-1$
    fTableViewer.setInput("");
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) ColumnViewer(org.eclipse.jface.viewers.ColumnViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) EObject(org.eclipse.emf.ecore.EObject) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 5 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project eclipse.platform.text by eclipse.

the class AnnotationsConfigurationBlock method createControl.

@Override
public Control createControl(Composite parent) {
    PixelConverter pixelConverter = new PixelConverter(parent);
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    Label label = new Label(composite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_annotationPresentationOptions);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    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(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    gd.horizontalSpan = 2;
    editorComposite.setLayoutData(gd);
    fAnnotationTypeViewer = new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    fAnnotationTypeViewer.setLabelProvider(new ItemLabelProvider());
    fAnnotationTypeViewer.setContentProvider(new ItemContentProvider());
    gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
    gd.heightHint = pixelConverter.convertHeightInCharsToPixels(20);
    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(GridData.FILL_BOTH));
    label = new Label(optionsComposite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_labels_showIn);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInVerticalRulerCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInVerticalRuler);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    fShowInVerticalRulerCheckBox.setLayoutData(gd);
    fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInOverviewRulerCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInOverviewRuler);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    fShowInOverviewRulerCheckBox.setLayoutData(gd);
    fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInTextCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInText);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalIndent = 20;
    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, PROBLEM_UNDERLINE, IBEAM });
    fDecorationViewer.getCombo().setVisibleItemCount(fDecorationViewer.getCombo().getItemCount());
    label = new Label(optionsComposite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_color);
    gd = new GridData();
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalIndent = 20;
    label.setLayoutData(gd);
    fAnnotationForegroundColorEditor = new ColorSelector(optionsComposite);
    Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    foregroundColorButton.setLayoutData(gd);
    addFiller(optionsComposite);
    fIsNextPreviousTargetCheckBox = new Button(optionsComposite, SWT.CHECK);
    fIsNextPreviousTargetCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_isNavigationTarget);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 0;
    fIsNextPreviousTargetCheckBox.setLayoutData(gd);
    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))
                    fStore.setValue(item.highlightKey, true);
                else
                    fStore.setValue(item.textKey, true);
            } else {
                // disable both
                if (item.textKey != null)
                    fStore.setValue(item.textKey, false);
                if (item.highlightKey != null)
                    fStore.setValue(item.highlightKey, false);
            }
            fStore.setValue(item.textKey, value);
            updateDecorationViewer(item, false);
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.overviewRulerKey, fShowInOverviewRulerCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.verticalRulerKey, fShowInVerticalRulerCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fIsNextPreviousTargetCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.isNextPreviousNavigationKey, fIsNextPreviousTargetCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    foregroundColorButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            PreferenceConverter.setValue(fStore, item.colorKey, fAnnotationForegroundColorEditor.getColorValue());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    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)) {
                    fStore.setValue(item.highlightKey, true);
                    if (item.textKey != null) {
                        fStore.setValue(item.textKey, false);
                        if (item.textStyleKey != null)
                            fStore.setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
                    }
                } else {
                    if (item.highlightKey != null)
                        fStore.setValue(item.highlightKey, false);
                    if (item.textKey != null) {
                        fStore.setValue(item.textKey, true);
                        if (item.textStyleKey != null)
                            fStore.setValue(item.textStyleKey, decoration[1]);
                    }
                }
            }
            fAnnotationTypeViewer.refresh(item);
        }
    });
    composite.layout();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) PixelConverter(org.eclipse.jface.layout.PixelConverter) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColorSelector(org.eclipse.jface.preference.ColorSelector) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)101 Viewer (org.eclipse.jface.viewers.Viewer)56 Composite (org.eclipse.swt.widgets.Composite)50 GridData (org.eclipse.swt.layout.GridData)43 TableViewer (org.eclipse.jface.viewers.TableViewer)42 GridLayout (org.eclipse.swt.layout.GridLayout)30 Label (org.eclipse.swt.widgets.Label)29 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)22 LabelProvider (org.eclipse.jface.viewers.LabelProvider)21 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)19 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)19 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)17 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)16 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)16 Button (org.eclipse.swt.widgets.Button)15 Table (org.eclipse.swt.widgets.Table)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)14 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)13