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());
}
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;
}
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;
}
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;
}
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);
}
Aggregations