Search in sources :

Example 51 with ListViewer

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;
}
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 52 with ListViewer

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);
    }
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) MalformedURLException(java.net.MalformedURLException) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) MyURLClassLoader(net.sourceforge.sqlexplorer.util.MyURLClassLoader) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ManagedDriver(net.sourceforge.sqlexplorer.dbproduct.ManagedDriver) Driver(java.sql.Driver) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) File(java.io.File)

Example 53 with ListViewer

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);
            }
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) Documentation(eu.esdihumboldt.hale.ui.util.bbr.Documentation) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 54 with ListViewer

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();
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ModifyListener(org.eclipse.swt.events.ModifyListener) QName(javax.xml.namespace.QName) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) Text(org.eclipse.swt.widgets.Text) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ListViewer(org.eclipse.jface.viewers.ListViewer) Viewer(org.eclipse.jface.viewers.Viewer) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 55 with ListViewer

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);
        }
    });
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

ListViewer (org.eclipse.jface.viewers.ListViewer)69 Composite (org.eclipse.swt.widgets.Composite)49 Viewer (org.eclipse.jface.viewers.Viewer)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 GridData (org.eclipse.swt.layout.GridData)29 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)26 FillLayout (org.eclipse.swt.layout.FillLayout)26 TableViewer (org.eclipse.jface.viewers.TableViewer)23 TreeViewer (org.eclipse.jface.viewers.TreeViewer)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)21 Table (org.eclipse.swt.widgets.Table)21 Tree (org.eclipse.swt.widgets.Tree)21 ViewerPane (org.eclipse.emf.common.ui.ViewerPane)20 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)20 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)20 ControlAdapter (org.eclipse.swt.events.ControlAdapter)20 ControlEvent (org.eclipse.swt.events.ControlEvent)20 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)19