use of org.eclipse.jface.viewers.ListViewer 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.ListViewer in project tdq-studio-se by Talend.
the class FileLabelProvider method createJavaClassPathPanel.
private void createJavaClassPathPanel(TabFolder tabFolder, TabItem tabItem) {
Composite parent = new Composite(tabFolder, SWT.NULL);
parent.setLayout(new FillLayout());
tabItem.setControl(parent);
Composite cmp = new Composite(parent, SWT.NULL);
GridLayout grid = new GridLayout();
grid.numColumns = 2;
cmp.setLayout(grid);
javaClassPathList = new ListViewer(cmp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
GridData data = new GridData();
data.grabExcessVerticalSpace = true;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
javaClassPathList.getControl().setLayoutData(data);
javaClassPathList.setContentProvider(new FileContentProvider());
javaClassPathList.setLabelProvider(new FileLabelProvider());
ClassPathListModel model = new ClassPathListModel();
javaClassPathList.setInput(model);
Composite left = new Composite(cmp, SWT.NULL);
data = new GridData();
data.horizontalSpan = 1;
data.grabExcessVerticalSpace = true;
data.widthHint = 100;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
left.setLayoutData(data);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
left.setLayout(gridLayout);
_javaClasspathListDriversBtn = new Button(left, SWT.NULL);
_javaClasspathListDriversBtn.setText(Messages.getString("List_Drivers_20"));
_javaClasspathListDriversBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
combo.removeAll();
File file = (File) ((IStructuredSelection) javaClassPathList.getSelection()).getFirstElement();
if (file != null) {
try {
MyURLClassLoader cl = new MyURLClassLoader(file.toURL());
Class[] classes = cl.getAssignableClasses(Driver.class);
for (int i = 0; i < classes.length; ++i) {
combo.add(classes[i].getName());
}
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
if (combo.getItemCount() > 0) {
combo.setText(combo.getItem(0));
}
}
});
data = new GridData();
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = GridData.FILL;
_javaClasspathListDriversBtn.setLayoutData(data);
javaClassPathList.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
File f = (File) selection.getFirstElement();
if (f != null) {
if (f.isFile())
_javaClasspathListDriversBtn.setEnabled(true);
else
_javaClasspathListDriversBtn.setEnabled(false);
} else
_javaClasspathListDriversBtn.setEnabled(false);
}
});
if (model.size() > 0) {
Object obj = (model.toArray())[0];
StructuredSelection sel = new StructuredSelection(obj);
javaClassPathList.setSelection(sel);
}
}
use of org.eclipse.jface.viewers.ListViewer in project hale by halestudio.
the class ValuesSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
Composite composite = getWidgetFactory().createFlatFormComposite(parent);
FormData data;
descriptionText = // $NON-NLS-1$
getWidgetFactory().createText(// $NON-NLS-1$
composite, // $NON-NLS-1$
"", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
descriptionText.setEditable(false);
data = new FormData();
data.width = 100;
data.height = 100;
// STANDARD_LABEL_WIDTH);
data.left = new FormAttachment(0, 250);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
descriptionText.setLayoutData(data);
values = new ListViewer(getWidgetFactory().createList(composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL));
data = new FormData();
data.height = 100;
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(descriptionText, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(descriptionText, 0, SWT.TOP);
values.getControl().setLayoutData(data);
values.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof Documentation) {
Documentation doc = (Documentation) element;
StringBuilder result = new StringBuilder();
boolean usable = (doc.isInUse() && !doc.getUseDiffers()) || (!doc.isInUse() && doc.getUseDiffers());
if (usable) {
result.append(doc.getCode());
} else {
// display values that are not in use in brackets
result.append('(');
result.append(doc.getCode());
result.append(')');
}
/*
* Mark use conflict with an asterisk. Only a conflict if
* something is wrongly classified as not in use.
*/
if (!doc.isInUse() && doc.getUseDiffers()) {
result.append('*');
}
return result.toString();
}
return super.getText(element);
}
});
values.setContentProvider(ArrayContentProvider.getInstance());
values.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// display documentation on selected value
ISelection sel = event.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
Documentation doc = (Documentation) ((IStructuredSelection) sel).getFirstElement();
String text = getDocumentationText(doc);
if (text != null) {
descriptionText.setText(text);
} else {
descriptionText.setText("");
}
descriptionText.setEnabled(text != null);
} else {
descriptionText.setText("");
descriptionText.setEnabled(false);
}
}
});
}
use of org.eclipse.jface.viewers.ListViewer in project hale by halestudio.
the class RootElementPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(1, false));
// add filter text
filterText = new Text(page, SWT.SINGLE | SWT.BORDER);
filterText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
// $NON-NLS-1$
filterText.setText("");
// add filtered list
list = new ListViewer(page, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
list.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XmlElement) {
QName name = ((XmlElement) element).getName();
return name.getLocalPart() + " (" + name.getNamespaceURI() + ")";
}
if (element instanceof Definition) {
return ((Definition<?>) element).getDisplayName();
}
return super.getText(element);
}
});
list.setContentProvider(ArrayContentProvider.getInstance());
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
layoutData.widthHint = SWT.DEFAULT;
layoutData.heightHint = 8 * list.getList().getItemHeight();
list.getControl().setLayoutData(layoutData);
// page status update
list.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
setPageComplete(!selection.isEmpty());
}
});
list.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (canFlipToNextPage()) {
getContainer().showPage(getNextPage());
return;
}
}
});
// search filter & update
list.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
String filter = filterText.getText();
// handle empty filter
if (filter == null || filter.isEmpty()) {
return true;
}
if (element instanceof Definition) {
Definition<?> def = (Definition<?>) element;
filter = filter.toLowerCase();
if (def.getDisplayName().toLowerCase().contains(filter)) {
return true;
}
}
return false;
}
});
list.setComparator(new ViewerComparator());
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
// refilter
list.refresh();
}
});
updateList();
}
use of org.eclipse.jface.viewers.ListViewer in project hale by halestudio.
the class ExportSelectProviderPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
page.setLayout(new GridLayout(1, false));
// create provider list viewer
providers = new ListViewer(page, SWT.BORDER);
providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
providers.setContentProvider(ArrayContentProvider.getInstance());
providers.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IOProviderDescriptor) {
return ((IOProviderDescriptor) element).getDisplayName();
}
return "Custom configuration: " + super.getText(element);
}
});
factories = getWizard().getFactories();
List<Object> input = new ArrayList<>();
// check for presets
Collection<String> presets = getWizard().getPresets();
if (presets != null && !presets.isEmpty()) {
input.addAll(presets);
}
input.addAll(factories);
providers.setInput(input);
providers.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (canFlipToNextPage()) {
getContainer().showPage(getNextPage());
return;
}
}
});
// set initial selection
// if (!factories.isEmpty()) {
// providers.setSelection(new StructuredSelection(factories.iterator().next()), true);
// }
// process current selection
ISelection selection = providers.getSelection();
setPageComplete(!selection.isEmpty());
updateWizard(selection);
// process selection changes
providers.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
setPageComplete(!selection.isEmpty());
updateWizard(selection);
}
});
}
Aggregations