Search in sources :

Example 36 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project tdq-studio-se by Talend.

the class ImportWizardPage method createErrorsList.

/**
 * DOC bZhou Comment method "createErrorsList".
 *
 * @param top
 */
private void createErrorsList(Composite top) {
    Group errorGroup = new Group(top, SWT.NONE);
    errorGroup.setLayout(new GridLayout());
    // $NON-NLS-1$
    errorGroup.setText(Messages.getString("ImportWizardPage.5"));
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = 100;
    errorGroup.setLayoutData(gridData);
    errorsList = new TableViewer(errorGroup, SWT.BORDER);
    errorsList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    errorsList.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

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

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

        @Override
        public String getText(Object element) {
            return element.toString();
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
             */
        @Override
        public Image getImage(Object element) {
            if (overwriteBTN.getSelection()) {
                return ImageLib.getImage(ImageLib.WARN_OVR);
            }
            return ImageLib.getImage(ImageLib.ICON_ERROR_INFO);
        }
    });
    errorsList.setInput(this);
    errorsList.setSorter(new ViewerSorter());
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Image(org.eclipse.swt.graphics.Image) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 37 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project tdq-studio-se by Talend.

the class EditSortMatchRuleNamesDialog method createTableViewer.

/**
 * create Table Viewer.
 *
 * @param parent
 * @return
 */
private void createTableViewer(Composite parent) {
    tableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table_1 = tableViewer.getTable();
    GridData gd_table_1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_table_1.heightHint = 217;
    table_1.setLayoutData(gd_table_1);
    Table table = (Table) tableViewer.getControl();
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(350));
    table.setLayout(tableLayout);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            return (OrderMatchRule[]) inputElement;
        }

        @Override
        public void dispose() {
        // do nothing here, until now
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // do nothing here, until now
        }
    });
    createMatchRuleNameColumn();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tableViewer.setInput(orderMatchRuleList.toArray(new OrderMatchRule[orderMatchRuleList.size()]));
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            // when the selection changed, update the up/down buttons status
            updateButtonsStatus();
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 38 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.servertools by eclipse.

the class ServerClasspathContainerPage method createControl.

public void createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    comp.setLayout(layout);
    Label label = new Label(comp, SWT.NONE);
    label.setText(Messages.classpathContainerRuntimeList);
    Table table = new Table(comp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(false);
    TableViewer tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            Object[] obj = runtimeMap.keySet().toArray();
            return obj;
        }

        public void dispose() {
        // ignore
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // ignore
        }
    });
    tableViewer.setLabelProvider(new RuntimeTableLabelProvider());
    tableViewer.setInput("root");
    if (selection != null) {
        Set<IRuntime> set = runtimeMap.keySet();
        IRuntime rt;
        for (Iterator<IRuntime> i = set.iterator(); i.hasNext(); ) {
            rt = i.next();
            if (runtimeMap.get(rt).getPath().equals(selection.getPath())) {
                tableViewer.setSelection(new StructuredSelection(new Object[] { rt }));
                setPageComplete(true);
                break;
            }
        }
    }
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                IStructuredSelection sel = (IStructuredSelection) event.getSelection();
                selection = runtimeMap.get(sel.getFirstElement());
                setPageComplete(true);
            } catch (Exception e) {
                selection = null;
                setPageComplete(false);
            }
        }
    });
    if (tableViewer.getTable().getItemCount() != 0)
        tableViewer.getTable().setFocus();
    setControl(comp);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRuntime(org.eclipse.wst.server.core.IRuntime) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) RuntimeTableLabelProvider(org.eclipse.wst.server.ui.internal.viewers.RuntimeTableLabelProvider)

Example 39 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project mdw-designer by CenturyLinkCloud.

the class ListComposer method createControls.

protected void createControls() {
    int buttonWidth = 30;
    // create the listener for the bunch of buttons
    SelectionListener buttonListener = new ButtonListener();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = isReadOnly() ? 2 : 3;
    gridLayout.marginWidth = 0;
    gridLayout.marginTop = 0;
    this.setLayout(gridLayout);
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    if (!isReadOnly()) {
        Label srcLabelWidget = new Label(this, SWT.LEFT);
        srcLabelWidget.setLayoutData(gd);
        if (unselectedTitle != null)
            srcLabelWidget.setText(unselectedTitle);
        else
            srcLabelWidget.setText(isReadOnly() ? "" : "Unselected " + title);
        gd = new GridData();
        Label destLabelWidget = new Label(this, SWT.LEFT);
        destLabelWidget.setLayoutData(gd);
        if (selectedTitle != null)
            destLabelWidget.setText(selectedTitle);
        else
            destLabelWidget.setText("Selected " + title);
    }
    gd = new GridData(SWT.LEFT | GridData.FILL_BOTH);
    gd.widthHint = getWidth();
    srcViewer = new ListViewer(this);
    srcViewer.getList().setLayoutData(gd);
    srcViewer.setContentProvider(new IStructuredContentProvider() {

        @SuppressWarnings("unchecked")
        public Object[] getElements(Object inputElement) {
            return ((List<String>) inputElement).toArray();
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    srcViewer.addFilter(new Filter());
    if (!isReadOnly()) {
        Composite buttons = new Composite(this, SWT.NULL);
        buttons.setLayout(new RowLayout(SWT.VERTICAL));
        addButton = new Button(buttons, SWT.PUSH);
        addButton.setText(">");
        Point size = addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        RowData rd = new RowData(buttonWidth, size.y);
        addButton.setLayoutData(rd);
        addButton.addSelectionListener(buttonListener);
        remButton = new Button(buttons, SWT.PUSH);
        remButton.setText("<");
        size = remButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        rd = new RowData(buttonWidth, size.y);
        remButton.setLayoutData(rd);
        remButton.addSelectionListener(buttonListener);
        gd = new GridData(SWT.LEFT | GridData.FILL_BOTH);
        gd.widthHint = getWidth();
        destViewer = new ListViewer(this);
        destViewer.getList().setLayoutData(gd);
    }
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) ListViewer(org.eclipse.jface.viewers.ListViewer) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 40 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project eclipse-integration-commons by spring-projects.

the class GenericWizardCommandListPage method createCommandTableArea.

protected synchronized void createCommandTableArea(Composite parent) {
    Composite tableArea = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tableArea);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tableArea);
    Label tableLabel = new Label(tableArea, SWT.LEFT);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(tableLabel);
    tableLabel.setText(SELECT_COMMAND_LABEL);
    final ViewerSearchPart part = createSearchControl(tableArea);
    Table table = new Table(tableArea, getViewerConfiguration());
    commandTableViewer = new TableViewer(table);
    part.connectViewer(commandTableViewer);
    setTableColumnAndLayout(commandTableViewer);
    commandTableViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection<?>) {
                Collection<?> topLevel = (Collection<?>) inputElement;
                return topLevel.toArray();
            }
            return null;
        }

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

        public void dispose() {
        // Nothing
        }
    });
    commandTableViewer.setLabelProvider(new ColumnLabelProvider() {

        public String getText(Object element) {
            if (element instanceof IFrameworkCommandDescriptor) {
                return ((IFrameworkCommandDescriptor) element).getName();
            }
            return null;
        }
    });
    commandTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) commandTableViewer.getSelection();
            if (selection != null) {
                Object selObj = selection.getFirstElement();
                if (selObj instanceof IFrameworkCommandDescriptor) {
                    GenericWizardCommandListPage.this.selectionChanged((IFrameworkCommandDescriptor) selObj);
                }
            }
            checkPageComplete();
        }
    });
    commandTableViewer.getTable().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            // arrow pressed
            if (e.keyCode == SWT.ARROW_UP) {
                Object topSelection = commandTableViewer.getElementAt(0);
                IFrameworkCommandDescriptor currentSelection = getSelectedCommandDescriptor();
                if (topSelection == currentSelection) {
                    part.getTextControl().setFocus();
                }
            }
        }
    });
    commandTableViewer.setInput(commandDescriptors);
    Text searchText = part.getTextControl();
    searchText.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            // down arrow is pressed
            if (e.keyCode == SWT.ARROW_DOWN) {
                commandTableViewer.getTable().setFocus();
                Object selection = commandTableViewer.getElementAt(0);
                if (selection instanceof IFrameworkCommandDescriptor) {
                    selectCommandInViewer((IFrameworkCommandDescriptor) selection);
                }
            }
        }
    });
    // STS 1251: Add filter listener to automatically select commands based
    // on the pattern that is typed
    searchText.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent event) {
            // STS 1251: If one element is left in the table after search is
            // performed, select it to enable
            // the appropriate wizard buttons
            int itemCount = commandTableViewer.getTable().getItemCount();
            if (itemCount == 1) {
                IFrameworkCommandDescriptor remainingDescriptor = (IFrameworkCommandDescriptor) commandTableViewer.getElementAt(0);
                if (remainingDescriptor != null) {
                    GenericWizardCommandListPage.this.selectCommandInViewer(remainingDescriptor);
                }
            } else {
                // else clear the selection nothing is found by search or
                // multiple matches are found
                GenericWizardCommandListPage.this.selectCommandInViewer(null);
            }
        }

        public void keyPressed(KeyEvent event) {
        }
    });
    searchText.setFocus();
    checkPageComplete();
}
Also used : ViewerSearchPart(org.springsource.ide.eclipse.commons.frameworks.ui.internal.swt.ViewerSearchPart) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Text(org.eclipse.swt.widgets.Text) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) Collection(java.util.Collection) KeyListener(org.eclipse.swt.events.KeyListener) TableViewer(org.eclipse.jface.viewers.TableViewer) IFrameworkCommandDescriptor(org.springsource.ide.eclipse.commons.frameworks.core.internal.commands.IFrameworkCommandDescriptor)

Aggregations

IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)89 Viewer (org.eclipse.jface.viewers.Viewer)69 Composite (org.eclipse.swt.widgets.Composite)52 GridData (org.eclipse.swt.layout.GridData)49 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)40 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)39 TableViewer (org.eclipse.jface.viewers.TableViewer)37 GridLayout (org.eclipse.swt.layout.GridLayout)37 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)36 Label (org.eclipse.swt.widgets.Label)29 LabelProvider (org.eclipse.jface.viewers.LabelProvider)26 Button (org.eclipse.swt.widgets.Button)26 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 Image (org.eclipse.swt.graphics.Image)25 ArrayList (java.util.ArrayList)23 Table (org.eclipse.swt.widgets.Table)23 ComboViewer (org.eclipse.jface.viewers.ComboViewer)19 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)18 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)17 Text (org.eclipse.swt.widgets.Text)17