Search in sources :

Example 71 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.

the class Bug217988Test method testBug217988.

public void testBug217988() {
    GalleryTreeViewer viewer = new GalleryTreeViewer(s);
    viewer.setContentProvider(new GalleryTestContentProvider());
    viewer.setLabelProvider(new GalleryTestLabelProvider());
    viewer.setComparator(new ViewerComparator());
    viewer.setInput(new Object());
    // Setting input raised a NPE
    viewer.setInput(new Object());
}
Also used : ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) GalleryTreeViewer(org.netxms.nebula.jface.galleryviewer.GalleryTreeViewer)

Example 72 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.

the class SelectSummaryTableDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    dialogArea.setLayout(layout);
    new Label(dialogArea, SWT.NONE).setText(Messages.get().SelectSummaryTableDialog_Label);
    viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((DciSummaryTableDescriptor) element).getTitle();
        }
    });
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            DciSummaryTableDescriptor s1 = (DciSummaryTableDescriptor) e1;
            DciSummaryTableDescriptor s2 = (DciSummaryTableDescriptor) e2;
            return s1.getTitle().compareToIgnoreCase(s2.getTitle());
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            SelectSummaryTableDialog.this.okPressed();
        }
    });
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.heightHint = 300;
    gd.widthHint = 400;
    viewer.getControl().setLayoutData(gd);
    viewer.setInput(SummaryTablesCache.getInstance().getTables());
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 73 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project netxms by netxms.

the class Notifications method createContents.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
	 * .swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    job = (ReportingJob) getElement().getAdapter(ReportingJob.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout dialogLayout = new GridLayout();
    dialogLayout.marginWidth = 0;
    dialogLayout.marginHeight = 0;
    dialogArea.setLayout(dialogLayout);
    sendNotify = new Button(dialogArea, SWT.CHECK);
    sendNotify.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 1));
    sendNotify.setText("Send notification on job completion");
    sendNotify.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            job.setNotifyOnCompletion(sendNotify.getSelection());
            recursiveSetEnabled(emailGroup, sendNotify.getSelection());
            xlsFormat.setEnabled(sendReport.isEnabled() && sendReport.getSelection());
            pdfFormat.setEnabled(sendReport.isEnabled() && sendReport.getSelection());
            emailGroup.layout(true, true);
        }
    });
    emailGroup = new Composite(dialogArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    emailGroup.setLayout(layout);
    emailGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    Label lblMail = new Label(emailGroup, SWT.NONE);
    lblMail.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 1));
    lblMail.setText("Recipients");
    listViewer = new ListViewer(emailGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    listViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    listViewer.setContentProvider(new ArrayContentProvider());
    listViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((String) e1).compareToIgnoreCase(((String) e2));
        }
    });
    Button buttonAdd = new Button(emailGroup, SWT.PUSH);
    GridData gd = new GridData(SWT.FILL, SWT.TOP, false, false);
    gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonAdd.setLayoutData(gd);
    buttonAdd.setText("Add...");
    buttonAdd.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addMail();
        }
    });
    final Button buttonRemove = new Button(emailGroup, SWT.PUSH);
    gd = new GridData(SWT.FILL, SWT.TOP, false, false);
    gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonRemove.setLayoutData(gd);
    buttonRemove.setText("Remove");
    buttonRemove.setEnabled(false);
    buttonRemove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeMail();
        }
    });
    final Composite attachmentGroup = new Composite(emailGroup, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    layout.horizontalSpacing = 10;
    attachmentGroup.setLayout(layout);
    attachmentGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    sendReport = new Button(attachmentGroup, SWT.CHECK);
    sendReport.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false, 2, 1));
    sendReport.setText("Attach rendered report to notification email as");
    sendReport.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            xlsFormat.setEnabled(sendReport.getSelection());
            pdfFormat.setEnabled(sendReport.getSelection());
        }
    });
    pdfFormat = new Button(attachmentGroup, SWT.RADIO);
    pdfFormat.setEnabled(sendReport.getSelection());
    // $NON-NLS-1$
    pdfFormat.setText("PDF");
    pdfFormat.setSelection(true);
    xlsFormat = new Button(attachmentGroup, SWT.RADIO);
    xlsFormat.setEnabled(sendReport.getSelection());
    // $NON-NLS-1$
    xlsFormat.setText("XLS");
    recursiveSetEnabled(emailGroup, false);
    return dialogArea;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) ListViewer(org.eclipse.jface.viewers.ListViewer) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider)

Example 74 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project n4js by eclipse.

the class CustomElementSelectionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    CustomElementSelectionForm form = new CustomElementSelectionForm(parent, SWT.FILL);
    form.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    TreeViewer v = form.getTreeViewer();
    for (ViewerFilter filter : filters) {
        v.addFilter(filter);
    }
    this.treeViewer = v;
    WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
    ILabelProvider labelProvider = new WorkbenchLabelProvider();
    this.treeViewer.setContentProvider(contentProvider);
    this.treeViewer.setLabelProvider(labelProvider);
    this.treeViewer.setComparator(new ViewerComparator());
    this.treeViewer.setAutoExpandLevel(this.getAutoExpandLevel());
    form.setElementLabel(this.elementLabel);
    this.elementNameInput = form.getElementInput();
    form.getElementInput().addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(SuffixText.TEXT_PROPERTY) || evt.getPropertyName().equals(SuffixText.SUFFIX_PROPERTY)) {
                validateElementInput();
                elementInputChanged();
            }
        }
    });
    return form;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) PropertyChangeEvent(java.beans.PropertyChangeEvent) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) PropertyChangeListener(java.beans.PropertyChangeListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 75 with ViewerComparator

use of org.eclipse.jface.viewers.ViewerComparator in project n4js by eclipse.

the class AbstractExportToSingleFileWizardPage method createProjectList.

/**
 * Creates the checkbox tree and list for selecting resources.
 *
 * @param parent
 *            the parent control
 */
protected void createProjectList(Composite parent) {
    // create the input element, which has the root resource
    // as its only child
    List<IProject> input = new ArrayList<>();
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
        if (projects[i].isOpen()) {
            input.add(projects[i]);
        }
    }
    listViewer = CheckboxTableViewer.newCheckList(parent, SWT.TOP | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    listViewer.getTable().setLayoutData(data);
    listViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    listViewer.setContentProvider(getContentProvider());
    listViewer.setComparator(new ViewerComparator());
    // check for initial modification to avoid work if no changes are made
    listViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                for (Object currentlyChecked : listViewer.getCheckedElements()) {
                    if (currentlyChecked != event.getElement()) {
                        listViewer.setChecked(currentlyChecked, false);
                    }
                }
            }
            updateWidgetEnablements();
        }
    });
    listViewer.setInput(workspace);
}
Also used : ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ArrayList(java.util.ArrayList) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IProject(org.eclipse.core.resources.IProject)

Aggregations

ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)110 Viewer (org.eclipse.jface.viewers.Viewer)64 Composite (org.eclipse.swt.widgets.Composite)59 TableViewer (org.eclipse.jface.viewers.TableViewer)50 GridData (org.eclipse.swt.layout.GridData)50 GridLayout (org.eclipse.swt.layout.GridLayout)34 Label (org.eclipse.swt.widgets.Label)29 LabelProvider (org.eclipse.jface.viewers.LabelProvider)23 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)22 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)21 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)19 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)18 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)17 Button (org.eclipse.swt.widgets.Button)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)16 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)15 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)15