Example usage for org.eclipse.jface.viewers TableViewer TableViewer

List of usage examples for org.eclipse.jface.viewers TableViewer TableViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TableViewer TableViewer.

Prototype

public TableViewer(Table table) 

Source Link

Document

Creates a table viewer on the given table control.

Usage

From source file:com.android.ide.eclipse.adt.internal.wizards.exportgradle.ConfirmationPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);/*from   w w  w.j a  va2  s  . com*/
    GridData data;

    Composite workArea = new Composite(parent, SWT.NONE);
    setControl(workArea);

    workArea.setLayout(new GridLayout());
    workArea.setLayoutData(
            new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));

    Label title = new Label(workArea, SWT.NONE);
    title.setText("Please review the export options.");

    Group group = new Group(workArea, SWT.NONE);
    group.setText("Project root");
    group.setLayout(new GridLayout());
    group.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    mProjectRootLabel = new Label(group, SWT.NONE);
    mProjectRootLabel.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    mProjectRootWarning = new Label(group, SWT.NONE);
    mProjectRootWarning.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    Group group2 = new Group(workArea, SWT.NONE);
    group2.setText("Exported Modules");
    group2.setLayout(new GridLayout());
    group2.setLayoutData(data = new GridData(SWT.FILL, SWT.FILL, true, true));
    data.heightHint = 300;

    Table table = new Table(group2, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    mTableViewer = new TableViewer(table);
    table.setLayout(new TableLayout());
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    mTableViewer.setContentProvider(new IStructuredContentProvider() {
        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ProjectSetupBuilder) {
                ProjectSetupBuilder builder = (ProjectSetupBuilder) inputElement;
                Collection<GradleModule> modules = builder.getModules();
                Object[] array = new Object[modules.size()];
                int i = 0;
                for (GradleModule module : modules) {
                    array[i++] = module.getJavaProject();
                }

                return array;
            }

            return null;
        }

        @Override
        public void dispose() {
        }

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

    });
    mTableViewer.setLabelProvider(new WorkbenchLabelProvider() {
        @Override
        protected String decorateText(String input, Object element) {
            if (element instanceof IJavaProject) {
                IJavaProject javaProject = (IJavaProject) element;
                StringBuilder sb = new StringBuilder(input);
                if (!mBuilder.isOriginalProject(javaProject)) {
                    sb.append('*');
                }
                // TODO: decorate icon instead?
                if (mOverrideProjects.contains(javaProject)) {
                    sb.append(" (1 warning)");
                }

                return sb.toString();
            }

            return input;
        }
    });
    mTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Object firstElement = selection.getFirstElement();
            if (firstElement instanceof IJavaProject) {
                GradleModule module = mBuilder.getModule((IJavaProject) firstElement);
                if (mBuilder.getOriginalModules().contains(module)) {
                    mModuleDescription1.setText("Exported because selected in previous page.");
                } else {
                    List<GradleModule> list = mBuilder.getShortestDependencyTo(module);
                    StringBuilder sb = new StringBuilder();
                    for (GradleModule m : list) {
                        if (sb.length() > 0) {
                            sb.append(" > ");
                        }
                        sb.append(m.getJavaProject().getProject().getName());
                    }
                    mModuleDescription1.setText("Dependency chain: " + sb);
                }
                mModuleDescription2.setText("Path: " + module.getPath());

                if (mOverrideProjects.contains(module.getJavaProject())) {
                    mModuleDescription3.setText("WARNING: build.gradle already exists for this project");
                } else {
                    mModuleDescription3.setText("");
                }
            } else {
                mModuleDescription1.setText("");
                mModuleDescription2.setText("");
                mModuleDescription3.setText("");
            }
        }
    });

    mModuleDescription1 = new Label(group2, SWT.NONE);
    mModuleDescription1.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    mModuleDescription2 = new Label(group2, SWT.NONE);
    mModuleDescription2.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    mModuleDescription3 = new Label(group2, SWT.NONE);
    mModuleDescription3.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    mForceOverride = new Button(workArea, SWT.CHECK);
    mForceOverride.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    mForceOverride.setText("Force overriding of existing files");
    mForceOverride.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateEnablement();
        }
    });

    setControl(workArea);
    Dialog.applyDialogFont(parent);
}

From source file:com.android.ide.eclipse.adt.launch.DeviceChooserDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout(1, true));

    mDeviceRadioButton = new Button(top, SWT.RADIO);
    mDeviceRadioButton.setText("Choose a running Android device");
    mDeviceRadioButton.addSelectionListener(new SelectionAdapter() {
        @Override//from  w  ww  .jav a 2s  .c o  m
        public void widgetSelected(SelectionEvent e) {
            boolean deviceMode = mDeviceRadioButton.getSelection();

            mDeviceTable.setEnabled(deviceMode);
            mPreferredAvdSelector.setEnabled(!deviceMode);

            if (deviceMode) {
                handleDeviceSelection();
            } else {
                mResponse.setAvdToLaunch(mPreferredAvdSelector.getFirstSelected());
            }

            enableOkButton();
        }
    });
    mDeviceRadioButton.setSelection(true);

    // offset the selector from the radio button
    Composite offsetComp = new Composite(top, SWT.NONE);
    offsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout(1, false);
    layout.marginRight = layout.marginHeight = 0;
    layout.marginLeft = 30;
    offsetComp.setLayout(layout);

    IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
    mDeviceTable = new Table(offsetComp, SWT.SINGLE | SWT.FULL_SELECTION);
    GridData gd;
    mDeviceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
    gd.heightHint = 100;

    mDeviceTable.setHeaderVisible(true);
    mDeviceTable.setLinesVisible(true);

    TableHelper.createTableColumn(mDeviceTable, "Serial Number", SWT.LEFT, "AAA+AAAAAAAAAAAAAAAAAAA", //$NON-NLS-2$
            PREFS_COL_SERIAL, store);

    TableHelper.createTableColumn(mDeviceTable, "AVD Name", SWT.LEFT, "engineering", //$NON-NLS-2$
            PREFS_COL_AVD, store);

    TableHelper.createTableColumn(mDeviceTable, "Target", SWT.LEFT, "AAA+Android 9.9.9", //$NON-NLS-2$
            PREFS_COL_TARGET, store);

    TableHelper.createTableColumn(mDeviceTable, "Debug", SWT.LEFT, "Debug", //$NON-NLS-2$
            PREFS_COL_DEBUG, store);

    TableHelper.createTableColumn(mDeviceTable, "State", SWT.LEFT, "bootloader", //$NON-NLS-2$
            PREFS_COL_STATE, store);

    // create the viewer for it
    mViewer = new TableViewer(mDeviceTable);
    mViewer.setContentProvider(new ContentProvider());
    mViewer.setLabelProvider(new LabelProvider());
    mViewer.setInput(AndroidDebugBridge.getBridge());

    mDeviceTable.addSelectionListener(new SelectionAdapter() {
        /**
         * Handles single-click selection on the device selector.
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleDeviceSelection();
        }

        /**
         * Handles double-click selection on the device selector.
         * Note that the single-click handler will probably already have been called.
         * {@inheritDoc}
         */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleDeviceSelection();
            if (isOkButtonEnabled()) {
                okPressed();
            }
        }
    });

    Button radio2 = new Button(top, SWT.RADIO);
    radio2.setText("Launch a new Android Virtual Device");

    // offset the selector from the radio button
    offsetComp = new Composite(top, SWT.NONE);
    offsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout(1, false);
    layout.marginRight = layout.marginHeight = 0;
    layout.marginLeft = 30;
    offsetComp.setLayout(layout);

    mPreferredAvdSelector = new AvdSelector(offsetComp, getNonRunningAvds(), mProjectTarget);
    mPreferredAvdSelector.setTableHeightHint(100);
    mPreferredAvdSelector.setEnabled(false);
    mPreferredAvdSelector.setSelectionListener(new SelectionAdapter() {
        /**
         * Handles single-click selection on the AVD selector.
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (mDisableAvdSelectionChange == false) {
                mResponse.setAvdToLaunch(mPreferredAvdSelector.getFirstSelected());
                enableOkButton();
            }
        }

        /**
         * Handles double-click selection on the AVD selector.
         * 
         * Note that the single-click handler will probably already have been called
         * but the selected item can have changed in between.
         * 
         * {@inheritDoc}
         */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
            if (isOkButtonEnabled()) {
                okPressed();
            }
        }
    });

    AndroidDebugBridge.addDeviceChangeListener(this);

    return top;
}

From source file:com.android.ide.eclipse.adt.ui.ConfigurationSelector.java

License:Open Source License

public ConfigurationSelector(Composite parent) {
    super(parent, SWT.NONE);

    mBaseConfiguration.createDefault();//  w  ww . j  a va 2s. c o m

    GridLayout gl = new GridLayout(4, false);
    gl.marginWidth = gl.marginHeight = 0;
    setLayout(gl);

    // first column is the first table
    final Table fullTable = new Table(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    fullTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    fullTable.setHeaderVisible(true);
    fullTable.setLinesVisible(true);

    // create the column
    final TableColumn fullTableColumn = new TableColumn(fullTable, SWT.LEFT);
    // set the header
    fullTableColumn.setText("Available Qualifiers");

    fullTable.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = fullTable.getClientArea();
            fullTableColumn.setWidth(r.width);
        }
    });

    mFullTableViewer = new TableViewer(fullTable);
    mFullTableViewer.setContentProvider(new QualifierContentProvider());
    mFullTableViewer.setLabelProvider(new QualifierLabelProvider(false /* showQualifierValue */));
    mFullTableViewer.setInput(mBaseConfiguration);
    mFullTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structSelection = (IStructuredSelection) selection;
                Object first = structSelection.getFirstElement();

                if (first instanceof ResourceQualifier) {
                    mAddButton.setEnabled(true);
                    return;
                }
            }

            mAddButton.setEnabled(false);
        }
    });

    // 2nd column is the left/right arrow button
    Composite buttonComposite = new Composite(this, SWT.NONE);
    gl = new GridLayout(1, false);
    gl.marginWidth = gl.marginHeight = 0;
    buttonComposite.setLayout(gl);
    buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    new Composite(buttonComposite, SWT.NONE);
    mAddButton = new Button(buttonComposite, SWT.BORDER | SWT.PUSH);
    mAddButton.setText("->");
    mAddButton.setEnabled(false);
    mAddButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) mFullTableViewer.getSelection();

            Object first = selection.getFirstElement();
            if (first instanceof ResourceQualifier) {
                ResourceQualifier qualifier = (ResourceQualifier) first;

                mBaseConfiguration.removeQualifier(qualifier);
                mSelectedConfiguration.addQualifier(qualifier);

                mFullTableViewer.refresh();
                mSelectionTableViewer.refresh();
                mSelectionTableViewer.setSelection(new StructuredSelection(qualifier), true);

                onChange(false /* keepSelection */);
            }
        }
    });

    mRemoveButton = new Button(buttonComposite, SWT.BORDER | SWT.PUSH);
    mRemoveButton.setText("<-");
    mRemoveButton.setEnabled(false);
    mRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) mSelectionTableViewer.getSelection();

            Object first = selection.getFirstElement();
            if (first instanceof ResourceQualifier) {
                ResourceQualifier qualifier = (ResourceQualifier) first;

                mSelectedConfiguration.removeQualifier(qualifier);
                mBaseConfiguration.addQualifier(qualifier);

                mFullTableViewer.refresh();
                mSelectionTableViewer.refresh();

                onChange(false /* keepSelection */);
            }
        }
    });

    // 3rd column is the selected config table
    final Table selectionTable = new Table(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    selectionTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    selectionTable.setHeaderVisible(true);
    selectionTable.setLinesVisible(true);

    // create the column
    final TableColumn selectionTableColumn = new TableColumn(selectionTable, SWT.LEFT);
    // set the header
    selectionTableColumn.setText("Chosen Qualifiers");

    selectionTable.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = selectionTable.getClientArea();
            selectionTableColumn.setWidth(r.width);
        }
    });
    mSelectionTableViewer = new TableViewer(selectionTable);
    mSelectionTableViewer.setContentProvider(new QualifierContentProvider());
    mSelectionTableViewer.setLabelProvider(new QualifierLabelProvider(true /* showQualifierValue */));
    mSelectionTableViewer.setInput(mSelectedConfiguration);
    mSelectionTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            // ignore selection changes during resfreshes in some cases.
            if (mOnRefresh) {
                return;
            }

            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structSelection = (IStructuredSelection) selection;

                if (structSelection.isEmpty() == false) {
                    Object first = structSelection.getFirstElement();

                    if (first instanceof ResourceQualifier) {
                        mRemoveButton.setEnabled(true);

                        QualifierEditBase composite = mUiMap.get(first.getClass());

                        if (composite != null) {
                            composite.setQualifier((ResourceQualifier) first);
                        }

                        mStackLayout.topControl = composite;
                        mQualifierEditParent.layout();

                        return;
                    }
                } else {
                    mStackLayout.topControl = null;
                    mQualifierEditParent.layout();
                }
            }

            mRemoveButton.setEnabled(false);
        }
    });

    // 4th column is the detail of the selected qualifier 
    mQualifierEditParent = new Composite(this, SWT.NONE);
    mQualifierEditParent.setLayout(mStackLayout = new StackLayout());
    mQualifierEditParent.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    // create the UI for all the qualifiers, and associate them to the ResourceQualifer class.
    mUiMap.put(CountryCodeQualifier.class, new MCCEdit(mQualifierEditParent));
    mUiMap.put(NetworkCodeQualifier.class, new MNCEdit(mQualifierEditParent));
    mUiMap.put(LanguageQualifier.class, new LanguageEdit(mQualifierEditParent));
    mUiMap.put(RegionQualifier.class, new RegionEdit(mQualifierEditParent));
    mUiMap.put(ScreenOrientationQualifier.class, new OrientationEdit(mQualifierEditParent));
    mUiMap.put(PixelDensityQualifier.class, new PixelDensityEdit(mQualifierEditParent));
    mUiMap.put(TouchScreenQualifier.class, new TouchEdit(mQualifierEditParent));
    mUiMap.put(KeyboardStateQualifier.class, new KeyboardEdit(mQualifierEditParent));
    mUiMap.put(TextInputMethodQualifier.class, new TextInputEdit(mQualifierEditParent));
    mUiMap.put(NavigationMethodQualifier.class, new NavigationEdit(mQualifierEditParent));
    mUiMap.put(ScreenDimensionQualifier.class, new ScreenDimensionEdit(mQualifierEditParent));
}

From source file:com.android.ide.eclipse.auidt.internal.launch.DeviceChooserDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    // set dialog title
    getShell().setText("Android Device Chooser");

    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout(1, true));

    Label label = new Label(top, SWT.NONE);
    label.setText(String.format("Select a device compatible with target %s.", mProjectTarget.getFullName()));

    mDeviceRadioButton = new Button(top, SWT.RADIO);
    mDeviceRadioButton.setText("Choose a running Android device");
    mDeviceRadioButton.addSelectionListener(new SelectionAdapter() {
        @Override/*from w w  w.ja v a 2 s .  co  m*/
        public void widgetSelected(SelectionEvent e) {
            boolean deviceMode = mDeviceRadioButton.getSelection();

            mDeviceTable.setEnabled(deviceMode);
            mPreferredAvdSelector.setEnabled(!deviceMode);

            if (deviceMode) {
                handleDeviceSelection();
            } else {
                mResponse.setAvdToLaunch(mPreferredAvdSelector.getSelected());
            }

            enableOkButton();
        }
    });
    mDeviceRadioButton.setSelection(true);

    // offset the selector from the radio button
    Composite offsetComp = new Composite(top, SWT.NONE);
    offsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout(1, false);
    layout.marginRight = layout.marginHeight = 0;
    layout.marginLeft = 30;
    offsetComp.setLayout(layout);

    mDeviceTable = new Table(offsetComp, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    GridData gd;
    mDeviceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
    gd.heightHint = 100;

    mDeviceTable.setHeaderVisible(true);
    mDeviceTable.setLinesVisible(true);

    TableHelper.createTableColumn(mDeviceTable, "Serial Number", SWT.LEFT, "AAA+AAAAAAAAAAAAAAAAAAA", //$NON-NLS-2$
            null /* prefs name */, null /* prefs store */);

    TableHelper.createTableColumn(mDeviceTable, "AVD Name", SWT.LEFT, "AAAAAAAAAAAAAAAAAAA", //$NON-NLS-2$
            null /* prefs name */, null /* prefs store */);

    TableHelper.createTableColumn(mDeviceTable, "Target", SWT.LEFT, "AAA+Android 9.9.9", //$NON-NLS-2$
            null /* prefs name */, null /* prefs store */);

    TableHelper.createTableColumn(mDeviceTable, "Debug", SWT.LEFT, "Debug", //$NON-NLS-2$
            null /* prefs name */, null /* prefs store */);

    TableHelper.createTableColumn(mDeviceTable, "State", SWT.LEFT, "bootloader", //$NON-NLS-2$
            null /* prefs name */, null /* prefs store */);

    // create the viewer for it
    mViewer = new TableViewer(mDeviceTable);
    mViewer.setContentProvider(new ContentProvider());
    mViewer.setLabelProvider(new LabelProvider());
    mViewer.setInput(AndroidDebugBridge.getBridge());

    mDeviceTable.addSelectionListener(new SelectionAdapter() {
        /**
         * Handles single-click selection on the device selector.
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleDeviceSelection();
        }

        /**
         * Handles double-click selection on the device selector.
         * Note that the single-click handler will probably already have been called.
         * {@inheritDoc}
         */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleDeviceSelection();
            if (isOkButtonEnabled()) {
                okPressed();
            }
        }
    });

    Button radio2 = new Button(top, SWT.RADIO);
    radio2.setText("Launch a new Android Virtual Device");

    // offset the selector from the radio button
    offsetComp = new Composite(top, SWT.NONE);
    offsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout(1, false);
    layout.marginRight = layout.marginHeight = 0;
    layout.marginLeft = 30;
    offsetComp.setLayout(layout);

    mPreferredAvdSelector = new AvdSelector(offsetComp, mSdk.getSdkLocation(), mSdk.getAvdManager(),
            new NonRunningAvdFilter(), DisplayMode.SIMPLE_SELECTION, new AdtConsoleSdkLog());
    mPreferredAvdSelector.setTableHeightHint(100);
    mPreferredAvdSelector.setEnabled(false);
    mPreferredAvdSelector.setSelectionListener(new SelectionAdapter() {
        /**
         * Handles single-click selection on the AVD selector.
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (mDisableAvdSelectionChange == false) {
                mResponse.setAvdToLaunch(mPreferredAvdSelector.getSelected());
                enableOkButton();
            }
        }

        /**
         * Handles double-click selection on the AVD selector.
         *
         * Note that the single-click handler will probably already have been called
         * but the selected item can have changed in between.
         *
         * {@inheritDoc}
         */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
            if (isOkButtonEnabled()) {
                okPressed();
            }
        }
    });

    return top;
}

From source file:com.android.ide.eclipse.auidt.internal.ui.ConfigurationSelector.java

License:Open Source License

/**
 * Creates the selector.//from  www  .j a va2 s . c  om
 * <p/>
 * The {@link SelectorMode} changes the behavior of the selector depending on what is being
 * edited (a device config, a resource config, a given configuration).
 *
 * @param parent the composite parent.
 * @param mode the mode for the selector.
 */
public ConfigurationSelector(Composite parent, SelectorMode mode) {
    super(parent, SWT.NONE);

    mMode = mode;
    mBaseConfiguration.createDefault();

    GridLayout gl = new GridLayout(4, false);
    gl.marginWidth = gl.marginHeight = 0;
    setLayout(gl);

    // first column is the first table
    final Table fullTable = new Table(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    fullTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    fullTable.setHeaderVisible(true);
    fullTable.setLinesVisible(true);

    // create the column
    final TableColumn fullTableColumn = new TableColumn(fullTable, SWT.LEFT);
    // set the header
    fullTableColumn.setText("Available Qualifiers");

    fullTable.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = fullTable.getClientArea();
            fullTableColumn.setWidth(r.width);
        }
    });

    mFullTableViewer = new TableViewer(fullTable);
    mFullTableViewer.setContentProvider(new QualifierContentProvider());
    // the label provider must return the value of the label only if the mode is
    // CONFIG_ONLY
    mFullTableViewer.setLabelProvider(new QualifierLabelProvider(mMode == SelectorMode.CONFIG_ONLY));
    mFullTableViewer.setInput(mBaseConfiguration);
    mFullTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structSelection = (IStructuredSelection) selection;
                Object first = structSelection.getFirstElement();

                if (first instanceof ResourceQualifier) {
                    mAddButton.setEnabled(true);
                    return;
                }
            }

            mAddButton.setEnabled(false);
        }
    });

    // 2nd column is the left/right arrow button
    Composite buttonComposite = new Composite(this, SWT.NONE);
    gl = new GridLayout(1, false);
    gl.marginWidth = gl.marginHeight = 0;
    buttonComposite.setLayout(gl);
    buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    new Composite(buttonComposite, SWT.NONE);
    mAddButton = new Button(buttonComposite, SWT.BORDER | SWT.PUSH);
    mAddButton.setText("->");
    mAddButton.setEnabled(false);
    mAddButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) mFullTableViewer.getSelection();

            Object first = selection.getFirstElement();
            if (first instanceof ResourceQualifier) {
                ResourceQualifier qualifier = (ResourceQualifier) first;

                mBaseConfiguration.removeQualifier(qualifier);
                mSelectedConfiguration.addQualifier(qualifier);

                mFullTableViewer.refresh();
                mSelectionTableViewer.refresh();
                mSelectionTableViewer.setSelection(new StructuredSelection(qualifier), true);

                onChange(false /* keepSelection */);
            }
        }
    });

    mRemoveButton = new Button(buttonComposite, SWT.BORDER | SWT.PUSH);
    mRemoveButton.setText("<-");
    mRemoveButton.setEnabled(false);
    mRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) mSelectionTableViewer.getSelection();

            Object first = selection.getFirstElement();
            if (first instanceof ResourceQualifier) {
                ResourceQualifier qualifier = (ResourceQualifier) first;

                mSelectedConfiguration.removeQualifier(qualifier);
                mBaseConfiguration.addQualifier(qualifier);

                mFullTableViewer.refresh();
                mSelectionTableViewer.refresh();

                onChange(false /* keepSelection */);
            }
        }
    });

    // 3rd column is the selected config table
    final Table selectionTable = new Table(this, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
    selectionTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    selectionTable.setHeaderVisible(true);
    selectionTable.setLinesVisible(true);

    // create the column
    final TableColumn selectionTableColumn = new TableColumn(selectionTable, SWT.LEFT);
    // set the header
    selectionTableColumn.setText("Chosen Qualifiers");

    selectionTable.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = selectionTable.getClientArea();
            selectionTableColumn.setWidth(r.width);
        }
    });
    mSelectionTableViewer = new TableViewer(selectionTable);
    mSelectionTableViewer.setContentProvider(new QualifierContentProvider());
    // always show the qualifier value in this case.
    mSelectionTableViewer.setLabelProvider(new QualifierLabelProvider(true /* showQualifierValue */));
    mSelectionTableViewer.setInput(mSelectedConfiguration);
    mSelectionTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            // ignore selection changes during resfreshes in some cases.
            if (mOnRefresh) {
                return;
            }

            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structSelection = (IStructuredSelection) selection;

                if (structSelection.isEmpty() == false) {
                    Object first = structSelection.getFirstElement();

                    if (first instanceof ResourceQualifier) {
                        mRemoveButton.setEnabled(true);

                        if (mMode != SelectorMode.CONFIG_ONLY) {
                            QualifierEditBase composite = mUiMap.get(first.getClass());

                            if (composite != null) {
                                composite.setQualifier((ResourceQualifier) first);
                            }

                            mStackLayout.topControl = composite;
                            mQualifierEditParent.layout();
                        }

                        return;
                    }
                } else {
                    if (mMode != SelectorMode.CONFIG_ONLY) {
                        mStackLayout.topControl = null;
                        mQualifierEditParent.layout();
                    }
                }
            }

            mRemoveButton.setEnabled(false);
        }
    });

    if (mMode != SelectorMode.CONFIG_ONLY) {
        // 4th column is the detail of the selected qualifier
        mQualifierEditParent = new Composite(this, SWT.NONE);
        mQualifierEditParent.setLayout(mStackLayout = new StackLayout());
        mQualifierEditParent.setLayoutData(new GridData(GridData.FILL_VERTICAL));

        // create the UI for all the qualifiers, and associate them to the
        // ResourceQualifer class.
        mUiMap.put(CountryCodeQualifier.class, new MCCEdit(mQualifierEditParent));
        mUiMap.put(NetworkCodeQualifier.class, new MNCEdit(mQualifierEditParent));
        mUiMap.put(LanguageQualifier.class, new LanguageEdit(mQualifierEditParent));
        mUiMap.put(RegionQualifier.class, new RegionEdit(mQualifierEditParent));
        mUiMap.put(SmallestScreenWidthQualifier.class, new SmallestScreenWidthEdit(mQualifierEditParent));
        mUiMap.put(ScreenWidthQualifier.class, new ScreenWidthEdit(mQualifierEditParent));
        mUiMap.put(ScreenHeightQualifier.class, new ScreenHeightEdit(mQualifierEditParent));
        mUiMap.put(ScreenSizeQualifier.class, new ScreenSizeEdit(mQualifierEditParent));
        mUiMap.put(ScreenRatioQualifier.class, new ScreenRatioEdit(mQualifierEditParent));
        mUiMap.put(ScreenOrientationQualifier.class, new OrientationEdit(mQualifierEditParent));
        mUiMap.put(UiModeQualifier.class, new UiModeEdit(mQualifierEditParent));
        mUiMap.put(NightModeQualifier.class, new NightModeEdit(mQualifierEditParent));
        mUiMap.put(DensityQualifier.class, new DensityEdit(mQualifierEditParent));
        mUiMap.put(TouchScreenQualifier.class, new TouchEdit(mQualifierEditParent));
        mUiMap.put(KeyboardStateQualifier.class, new KeyboardEdit(mQualifierEditParent));
        mUiMap.put(TextInputMethodQualifier.class, new TextInputEdit(mQualifierEditParent));
        mUiMap.put(NavigationStateQualifier.class, new NavigationStateEdit(mQualifierEditParent));
        mUiMap.put(NavigationMethodQualifier.class, new NavigationEdit(mQualifierEditParent));
        mUiMap.put(ScreenDimensionQualifier.class, new ScreenDimensionEdit(mQualifierEditParent));
        mUiMap.put(VersionQualifier.class, new VersionEdit(mQualifierEditParent));
    }
}

From source file:com.android.ide.eclipse.gltrace.views.FrameSummaryViewPage.java

License:Apache License

private void createFrameStatisticsPart(Composite parent) {
    Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(c);

    Label l = new Label(c, SWT.NONE);
    l.setText("Cumulative call duration of all OpenGL Calls in this frame:");
    l.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
    GridDataFactory.fillDefaults().span(2, 1).applyTo(l);

    l = new Label(c, SWT.NONE);
    l.setText("Wall Clock Time: ");
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(l);

    mWallClockTimeLabel = new Label(c, SWT.NONE);
    GridDataFactory.defaultsFor(mWallClockTimeLabel).grab(true, false).applyTo(mWallClockTimeLabel);

    l = new Label(c, SWT.NONE);
    l.setText("Thread Time: ");
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(l);

    mThreadTimeLabel = new Label(c, SWT.NONE);
    GridDataFactory.defaultsFor(mThreadTimeLabel).grab(true, false).applyTo(mThreadTimeLabel);

    l = new Label(c, SWT.HORIZONTAL | SWT.SEPARATOR);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(l);

    l = new Label(c, SWT.NONE);
    l.setText("Per OpenGL Function Statistics:");
    l.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
    GridDataFactory.fillDefaults().span(2, 1).applyTo(l);

    final Table table = new Table(c, SWT.BORDER | SWT.FULL_SELECTION);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(table);

    table.setLinesVisible(true);//from www.jav  a2  s .  co m
    table.setHeaderVisible(true);

    mStatsTableViewer = new TableViewer(table);
    mStatsLabelProvider = new StatsLabelProvider();
    mStatsTableComparator = new StatsTableComparator(1);

    // when a column is selected, sort the table based on that column
    SelectionListener columnSelectionListener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TableColumn tc = (TableColumn) e.widget;
            String colText = tc.getText();
            for (int i = 0; i < STATS_TABLE_PROPERTIES.length; i++) {
                if (STATS_TABLE_PROPERTIES[i].equals(colText)) {
                    mStatsTableComparator.setSortColumn(i);
                    table.setSortColumn(tc);
                    table.setSortDirection(mStatsTableComparator.getDirection());
                    mStatsTableViewer.refresh();
                    break;
                }
            }
        }
    };

    for (int i = 0; i < STATS_TABLE_PROPERTIES.length; i++) {
        TableViewerColumn tvc = new TableViewerColumn(mStatsTableViewer, SWT.NONE);
        tvc.getColumn().setText(STATS_TABLE_PROPERTIES[i]);
        tvc.setLabelProvider(mStatsLabelProvider);
        tvc.getColumn().setAlignment(STATS_TABLE_COL_ALIGNMENT[i]);
        tvc.getColumn().addSelectionListener(columnSelectionListener);
    }
    mStatsTableViewer.setContentProvider(new StatsContentProvider());
    mStatsTableViewer.setInput(null);
    mStatsTableViewer.setComparator(mStatsTableComparator);

    // resize columns appropriately when the size of the widget changes
    table.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            int w = table.getClientArea().width;

            for (int i = 0; i < STATS_TABLE_COLWIDTH_RATIOS.length; i++) {
                table.getColumn(i).setWidth((int) (w * STATS_TABLE_COLWIDTH_RATIOS[i]));
            }
        }
    });
}

From source file:com.android.sdkuilib.internal.widgets.AvdCreationDialog.java

License:Apache License

/**
 * Creates the UI for the hardware properties table.
 * This creates the {@link Table}, and several viewers ({@link TableViewer},
 * {@link TableViewerColumn}) and adds edit support for the 2nd column
 *///from ww w.  j  a v  a  2 s.  c  om
private void createHardwareTable(Composite parent) {
    final Table hardwareTable = new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gd.widthHint = 200;
    gd.heightHint = 100;
    hardwareTable.setLayoutData(gd);
    hardwareTable.setHeaderVisible(true);
    hardwareTable.setLinesVisible(true);

    // -- Table viewer
    mHardwareViewer = new TableViewer(hardwareTable);
    mHardwareViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            // it's a single selection mode, we can just access the selection index
            // from the table directly.
            mDeleteHardwareProp.setEnabled(hardwareTable.getSelectionIndex() != -1);
        }
    });

    // only a content provider. Use viewers per column below (for editing support)
    mHardwareViewer.setContentProvider(new IStructuredContentProvider() {
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // we can just ignore this. we just use mProperties directly.
        }

        public Object[] getElements(Object arg0) {
            return mProperties.keySet().toArray();
        }

        public void dispose() {
            // pass
        }
    });

    // -- column 1: prop abstract name
    TableColumn col1 = new TableColumn(hardwareTable, SWT.LEFT);
    col1.setText("Property");
    col1.setWidth(150);
    TableViewerColumn tvc1 = new TableViewerColumn(mHardwareViewer, col1);
    tvc1.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            String name = cell.getElement().toString();
            HardwareProperty prop = mHardwareMap.get(name);
            if (prop != null) {
                cell.setText(prop.getAbstract());
            } else {
                cell.setText(String.format("%1$s (Unknown)", name));
            }
        }
    });

    // -- column 2: prop value
    TableColumn col2 = new TableColumn(hardwareTable, SWT.LEFT);
    col2.setText("Value");
    col2.setWidth(50);
    TableViewerColumn tvc2 = new TableViewerColumn(mHardwareViewer, col2);
    tvc2.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            String value = mProperties.get(cell.getElement());
            cell.setText(value != null ? value : "");
        }
    });

    // add editing support to the 2nd column
    tvc2.setEditingSupport(new EditingSupport(mHardwareViewer) {
        @Override
        protected void setValue(Object element, Object value) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            switch (property.getType()) {
            case INTEGER:
                mProperties.put((String) element, (String) value);
                break;
            case DISKSIZE:
                if (HardwareProperties.DISKSIZE_PATTERN.matcher((String) value).matches()) {
                    mProperties.put((String) element, (String) value);
                }
                break;
            case BOOLEAN:
                int index = (Integer) value;
                mProperties.put((String) element, HardwareProperties.BOOLEAN_VALUES[index]);
                break;
            }
            mHardwareViewer.refresh(element);
        }

        @Override
        protected Object getValue(Object element) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            String value = mProperties.get(hardwareName);
            switch (property.getType()) {
            case INTEGER:
                // intended fall-through.
            case DISKSIZE:
                return value;
            case BOOLEAN:
                return HardwareProperties.getBooleanValueIndex(value);
            }

            return null;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            switch (property.getType()) {
            // TODO: custom TextCellEditor that restrict input.
            case INTEGER:
                // intended fall-through.
            case DISKSIZE:
                return new TextCellEditor(hardwareTable);
            case BOOLEAN:
                return new ComboBoxCellEditor(hardwareTable, HardwareProperties.BOOLEAN_VALUES,
                        SWT.READ_ONLY | SWT.DROP_DOWN);
            }
            return null;
        }

        @Override
        protected boolean canEdit(Object element) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            return property != null;
        }
    });

    mHardwareViewer.setInput(mProperties);
}

From source file:com.android.sdkuilib.internal.widgets.LegacyAvdEditDialog.java

License:Apache License

/**
 * Creates the UI for the hardware properties table.
 * This creates the {@link Table}, and several viewers ({@link TableViewer},
 * {@link TableViewerColumn}) and adds edit support for the 2nd column
 *//*from  w  w  w .  j av  a  2 s. c om*/
private void createHardwareTable(Composite parent) {
    final Table hardwareTable = new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gd.widthHint = 200;
    gd.heightHint = 100;
    hardwareTable.setLayoutData(gd);
    hardwareTable.setHeaderVisible(true);
    hardwareTable.setLinesVisible(true);

    // -- Table viewer
    mHardwareViewer = new TableViewer(hardwareTable);
    mHardwareViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            // it's a single selection mode, we can just access the selection index
            // from the table directly.
            mDeleteHardwareProp.setEnabled(hardwareTable.getSelectionIndex() != -1);
        }
    });

    // only a content provider. Use viewers per column below (for editing support)
    mHardwareViewer.setContentProvider(new IStructuredContentProvider() {
        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // we can just ignore this. we just use mProperties directly.
        }

        @Override
        public Object[] getElements(Object arg0) {
            return mProperties.keySet().toArray();
        }

        @Override
        public void dispose() {
            // pass
        }
    });

    // -- column 1: prop abstract name
    TableColumn col1 = new TableColumn(hardwareTable, SWT.LEFT);
    col1.setText("Property");
    col1.setWidth(150);
    TableViewerColumn tvc1 = new TableViewerColumn(mHardwareViewer, col1);
    tvc1.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            String name = cell.getElement().toString();
            HardwareProperty prop = mHardwareMap.get(name);
            if (prop != null) {
                cell.setText(prop.getAbstract());
            } else {
                cell.setText(String.format("%1$s (Unknown)", name));
            }
        }
    });

    // -- column 2: prop value
    TableColumn col2 = new TableColumn(hardwareTable, SWT.LEFT);
    col2.setText("Value");
    col2.setWidth(50);
    TableViewerColumn tvc2 = new TableViewerColumn(mHardwareViewer, col2);
    tvc2.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            String value = mProperties.get(cell.getElement());
            cell.setText(value != null ? value : "");
        }
    });

    // add editing support to the 2nd column
    tvc2.setEditingSupport(new EditingSupport(mHardwareViewer) {
        @Override
        protected void setValue(Object element, Object value) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            int index;
            switch (property.getType()) {
            case INTEGER:
                mProperties.put((String) element, (String) value);
                break;
            case DISKSIZE:
                if (HardwareProperties.DISKSIZE_PATTERN.matcher((String) value).matches()) {
                    mProperties.put((String) element, (String) value);
                }
                break;
            case BOOLEAN:
                index = (Integer) value;
                mProperties.put((String) element, HardwareProperties.getBooleanValue(index));
                break;
            case STRING_ENUM:
            case INTEGER_ENUM:
                // For a combo, value is the index of the enum to use.
                index = (Integer) value;
                String[] values = property.getEnum();
                if (values != null && values.length > index) {
                    mProperties.put((String) element, values[index]);
                }
                break;
            }
            mHardwareViewer.refresh(element);
        }

        @Override
        protected Object getValue(Object element) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            String value = mProperties.get(hardwareName);
            switch (property.getType()) {
            case INTEGER:
                // intended fall-through.
            case DISKSIZE:
                return value;
            case BOOLEAN:
                return HardwareProperties.getBooleanValueIndex(value);
            case STRING_ENUM:
            case INTEGER_ENUM:
                // For a combo, we need to return the index of the value in the enum
                String[] values = property.getEnum();
                if (values != null) {
                    for (int i = 0; i < values.length; i++) {
                        if (values[i].equals(value)) {
                            return i;
                        }
                    }
                }
            }

            return null;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            switch (property.getType()) {
            // TODO: custom TextCellEditor that restrict input.
            case INTEGER:
                // intended fall-through.
            case DISKSIZE:
                return new TextCellEditor(hardwareTable);
            case BOOLEAN:
                return new ComboBoxCellEditor(hardwareTable, new String[] {
                        HardwareProperties.getBooleanValue(0), HardwareProperties.getBooleanValue(1), },
                        SWT.READ_ONLY | SWT.DROP_DOWN);
            case STRING_ENUM:
            case INTEGER_ENUM:
                String[] values = property.getEnum();
                if (values != null && values.length > 0) {
                    return new ComboBoxCellEditor(hardwareTable, values, SWT.READ_ONLY | SWT.DROP_DOWN);
                }
            }
            return null;
        }

        @Override
        protected boolean canEdit(Object element) {
            String hardwareName = (String) element;
            HardwareProperty property = mHardwareMap.get(hardwareName);
            return property != null;
        }
    });

    mHardwareViewer.setInput(mProperties);
}

From source file:com.aptana.editor.common.preferences.ValidationPreferencePage.java

License:Open Source License

private Control createValidators(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());

    Composite labelComp = new Composite(main, SWT.NONE);
    labelComp.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(5, 0, 0, 0).numColumns(2)
            .spacing(2, SWT.DEFAULT).create());
    labelComp.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).create());
    Label label = new Label(labelComp, SWT.NONE);
    label.setText(Messages.ValidationPreferencePage_LBL_Validators);
    Label helpImage = new Label(labelComp, SWT.NONE);
    helpImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_LCL_LINKTO_HELP));
    helpImage.setToolTipText(Messages.ValidationPreferencePage_EnablingValidatorWarning);

    Group group = new Group(main, SWT.NONE);
    group.setLayout(GridLayoutFactory.swtDefaults().margins(4, 4).create());
    group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Table table = new Table(group, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    table.setLayoutData(GridDataFactory.fillDefaults().hint(300, 100).grab(true, false).create());
    table.setLinesVisible(true);/*from  w  ww.  ja v a 2s .c o m*/
    table.setHeaderVisible(true);

    // set up columns
    // Name column
    TableColumn name = new TableColumn(table, SWT.LEFT);
    name.setWidth(250);
    name.setText(Messages.ValidationPreferencePage_NameColumn);
    name.setToolTipText(Messages.ValidationPreferencePage_NameColumn);

    // Build column
    TableColumn build = new TableColumn(table, SWT.CENTER);
    build.setWidth(40);
    build.setText(Messages.ValidationPreferencePage_BuildColumn);
    build.setToolTipText(Messages.ValidationPreferencePage_BuildColumn);

    // Reconcile column
    TableColumn reconcile = new TableColumn(table, SWT.CENTER);
    reconcile.setWidth(75);
    reconcile.setText(Messages.ValidationPreferencePage_ReconcileColumn);
    reconcile.setToolTipText(Messages.ValidationPreferencePage_ReconcileColumn);

    // Now set up table viewer!
    validatorsViewer = new TableViewer(table);
    // validatorsViewer.setUseHashlookup(true);
    validatorsViewer.setColumnProperties(new String[] { NAME, BUILD, RECONCILE });

    // Assign the cell editors to the viewer
    validatorsViewer.setCellEditors(
            new CellEditor[] { null, new CheckboxCellEditor(table), new CheckboxCellEditor(table) });

    // Set the cell modifier for the viewer
    validatorsViewer.setCellModifier(new ParticipantCellModifier(validatorsViewer));

    // Now set up content/label providers
    validatorsViewer.setContentProvider(ArrayContentProvider.getInstance());
    validatorsViewer.setLabelProvider(new ParticipantLabelProvider());
    // Hide required participants
    validatorsViewer.addFilter(new RequiredParticipantFilter());
    // check the selected build participant, show it's filters
    validatorsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateFilterExpressions();
        }
    });

    // Now set input
    validatorsViewer.setInput(this.participants);

    return main;
}

From source file:com.aptana.ide.editors.internal.ui.preferences.TableViewerEditor.java

License:Open Source License

protected TableViewer createTableViewer(Composite parent) {
    Table table = new Table(parent, getTableStyle());
    return new TableViewer(table);
}