Example usage for org.eclipse.jface.viewers CheckboxTableViewer newCheckList

List of usage examples for org.eclipse.jface.viewers CheckboxTableViewer newCheckList

Introduction

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

Prototype

public static CheckboxTableViewer newCheckList(Composite parent, int style) 

Source Link

Document

Creates a table viewer on a newly-created table control under the given parent.

Usage

From source file:org.eclipse.pde.internal.ui.launcher.TracingBlock.java

License:Open Source License

private void createPluginViewer(Composite sashForm) {
    Composite composite = new Composite(sashForm, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = layout.marginHeight = 1;
    composite.setLayout(layout);/*from   www  .  j  av  a 2 s.  co  m*/

    fPluginViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    fPluginViewer.setContentProvider(ArrayContentProvider.getInstance());
    fPluginViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
    fPluginViewer.setComparator(new ListUtil.PluginComparator());
    fPluginViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent e) {
            CheckboxTableViewer tableViewer = (CheckboxTableViewer) e.getSource();
            boolean selected = tableViewer.getChecked(getSelectedModel());
            pluginSelected(getSelectedModel(), selected);
            storeSelectedModel();
        }
    });
    fPluginViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            CheckboxTableViewer tableViewer = (CheckboxTableViewer) event.getSource();
            tableViewer.setSelection(new StructuredSelection(event.getElement()));
            pluginSelected(getSelectedModel(), event.getChecked());
            fTab.updateLaunchConfigurationDialog();
        }
    });
    fPluginViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            CheckboxTableViewer tableViewer = (CheckboxTableViewer) event.getSource();
            Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
            boolean addingCheck = !tableViewer.getChecked(selection);
            tableViewer.setChecked(selection, addingCheck);
            pluginSelected(getSelectedModel(), addingCheck);
            fTab.updateLaunchConfigurationDialog();
        }
    });
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 125;
    gd.heightHint = 100;
    fPluginViewer.getTable().setLayoutData(gd);
}

From source file:org.eclipse.pde.internal.ui.nls.ExternalizeStringsWizardPage.java

License:Open Source License

private void createTableViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(parent.getFont());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout());

    Label label = new Label(composite, SWT.NONE);
    label.setText(PDEUIMessages.ExternalizeStringsWizardPage_propertiesLabel);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fPropertiesViewer = CheckboxTableViewer.newCheckList(composite,
            SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.BORDER);
    fTable = fPropertiesViewer.getTable();
    fTable.setFont(composite.getFont());
    fTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    fTable.setLayout(new GridLayout());
    fTable.setLinesVisible(true);//from  w  ww . j a  va 2s  .co  m
    fTable.setHeaderVisible(true);

    for (int i = 0; i < TABLE_COLUMNS.length; i++) {
        TableColumn tc = new TableColumn(fTable, SWT.NONE);
        tc.setText(TABLE_COLUMNS[i]);
        tc.setResizable(i != 0);
        tc.setWidth(i == 0 ? 20 : 200);
    }

    fPropertiesViewer.setUseHashlookup(true);
    fPropertiesViewer.setCellEditors(createCellEditors());
    fPropertiesViewer.setColumnProperties(TABLE_PROPERTIES);
    fPropertiesViewer.setCellModifier(new ExternalizeStringsCellModifier());
    fPropertiesViewer.setContentProvider(new IStructuredContentProvider() {
        public Object[] getElements(Object inputElement) {
            if (fInputViewer.getSelection() instanceof IStructuredSelection) {
                Object selection = ((IStructuredSelection) fInputViewer.getSelection()).getFirstElement();
                if (selection instanceof ModelChangeFile) {
                    ModelChangeFile cf = (ModelChangeFile) selection;
                    return (cf).getModel().getChangesInFile(cf.getFile()).toArray();
                }
            }
            return new Object[0];
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    fPropertiesViewer.setLabelProvider(new ExternalizeStringsLabelProvider());
    fPropertiesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handlePropertySelection();
        }
    });
    fPropertiesViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof ModelChangeElement) {
                ((ModelChangeElement) element).setExternalized(event.getChecked());
                fPropertiesViewer.update(element, null);
            }
        }
    });
    fPropertiesViewer.setInput(new Object());
}

From source file:org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage.java

License:Open Source License

private void createTargetProfilesGroup(Composite container) {

    // Start loading the default target as it is often fast enough to finish before UI is done rendering
    fLabelProvider = new TargetLabelProvider();
    LoadDefaultTargetJob job = new LoadDefaultTargetJob();
    job.addJobChangeListener(new JobChangeAdapter() {
        @Override//from  w  w w.jav  a  2  s.  com
        public void done(final IJobChangeEvent event) {
            UIJob job = new UIJob(Messages.UpdateTargetJob_UpdateJobName) {
                @Override
                public IStatus runInUIThread(IProgressMonitor monitor) {
                    TargetDefinition target = ((LoadDefaultTargetJob) event.getJob()).defaultTarget;
                    if (target != null && fLabelProvider != null) {
                        fLabelProvider.setDefaultTarget(target);
                        if (fTableViewer != null && !fTableViewer.getTable().isDisposed()) {
                            fTableViewer.refresh(true);
                        }
                    }
                    return Status.OK_STATUS;
                }
            };
            job.schedule();
        }
    });
    job.setPriority(Job.SHORT);
    job.schedule();

    Composite comp = SWTFactory.createComposite(container, 1, 1, GridData.FILL_BOTH, 0, 0);
    ((GridData) comp.getLayoutData()).widthHint = 350;
    SWTFactory.createWrapLabel(comp, PDEUIMessages.TargetPlatformPreferencePage2_0, 2);
    SWTFactory.createVerticalSpacer(comp, 1);

    Composite tableComposite = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH, 0, 0);
    SWTFactory.createLabel(tableComposite, PDEUIMessages.TargetPlatformPreferencePage2_2, 2);

    fTableViewer = CheckboxTableViewer.newCheckList(tableComposite, SWT.MULTI | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 250;
    fTableViewer.getControl().setLayoutData(gd);
    fTableViewer.setLabelProvider(fLabelProvider);
    fTableViewer.setContentProvider(ArrayContentProvider.getInstance());
    fTableViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                fTableViewer.setCheckedElements(new Object[] { event.getElement() });
                handleActivate();
            } else {
                handleActivate();
            }

        }
    });
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
            updateDetails();
        }
    });
    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            handleEdit();
        }
    });
    fTableViewer.getTable().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.DEL) {
                handleRemove();
            }
        }
    });

    // add the targets
    ITargetPlatformService service = getTargetService();
    if (service != null) {
        ITargetHandle[] targets = service.getTargets(null);
        for (int i = 0; i < targets.length; i++) {
            try {
                fTargets.add(targets[i].getTargetDefinition());
            } catch (CoreException e) {
                PDECore.log(e);
                setErrorMessage(e.getMessage());
            }
        }
        fTableViewer.setInput(fTargets);
    }

    fTableViewer.setComparator(new ViewerComparator() {
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            String name1 = ((TargetDefinition) e1).getName();
            String name2 = ((TargetDefinition) e2).getName();
            if (name1 == null) {
                return -1;
            }
            if (name2 == null) {
                return 1;
            }
            return name1.compareToIgnoreCase(name2);
        }
    });

    Composite buttonComposite = SWTFactory.createComposite(tableComposite, 1, 1,
            GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING, 0, 0);

    fReloadButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_16,
            null);
    fReloadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleReload();
        }
    });

    SWTFactory.createVerticalSpacer(buttonComposite, 1);

    fAddButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_3,
            null);
    fAddButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleAdd();
        }
    });

    fEditButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_5,
            null);
    fEditButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleEdit();
        }
    });

    fRemoveButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_7,
            null);
    fRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleRemove();
        }
    });

    fMoveButton = SWTFactory.createPushButton(buttonComposite, PDEUIMessages.TargetPlatformPreferencePage2_13,
            null);
    fMoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            handleMove();
        }
    });

    updateButtons();

    Composite detailsComposite = SWTFactory.createComposite(comp, 1, 1, GridData.FILL_HORIZONTAL, 0, 0);
    SWTFactory.createLabel(detailsComposite, PDEUIMessages.TargetPlatformPreferencePage2_25, 1);
    fDetails = new TreeViewer(detailsComposite);
    fDetails.setLabelProvider(new TargetLocationLabelProvider(true, true));
    fDetails.setContentProvider(new TargetLocationContentProvider());
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 50;
    fDetails.getControl().setLayoutData(gd);

    if (service != null) {
        try {
            fPrevious = service.getWorkspaceTargetDefinition();
            Iterator<ITargetDefinition> iterator = fTargets.iterator();
            while (iterator.hasNext()) {
                ITargetDefinition target = iterator.next();
                if (target.getHandle().equals(fPrevious.getHandle())) {
                    fActiveTarget = target;
                    fTableViewer.setCheckedElements(new Object[] { fActiveTarget });
                    fTableViewer.refresh(target);
                    break;
                }
            }
        } catch (CoreException e) {
            PDEPlugin.log(e);
            setErrorMessage(PDEUIMessages.TargetPlatformPreferencePage2_23);
        }
        if (getMessage() == null && fActiveTarget == null) {
            setMessage(PDEUIMessages.TargetPlatformPreferencePage2_22, IMessageProvider.INFORMATION);
        }
    }
}

From source file:org.eclipse.pde.internal.ui.properties.SelfHostingPropertyPage.java

License:Open Source License

/**
 * @see PreferencePage#createContents(Composite)
 *///from ww w  .  ja v  a  2  s .  c o m
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label label = new Label(composite, SWT.WRAP);
    label.setText(PDEUIMessages.SelfHostingPropertyPage_label);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 300;
    label.setLayoutData(gd);

    new Label(composite, SWT.NONE);

    label = new Label(composite, SWT.WRAP);
    label.setText(PDEUIMessages.SelfHostingPropertyPage_viewerLabel);

    fViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    fViewer.setContentProvider(new ContentProvider());
    fViewer.setLabelProvider(new FolderLabelProvider());
    fViewer.setInput(getElement());
    fViewer.setComparator(new ViewerComparator());
    fViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

    initialize();

    Dialog.applyDialogFont(composite);
    return composite;
}

From source file:org.eclipse.pde.internal.ui.shared.target.AddFeatureContainersPage.java

License:Open Source License

protected void createTableArea(Composite parent) {
    Composite tableComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);

    SWTFactory.createLabel(tableComp, Messages.AddFeatureContainersPage_2, 2);

    fFeatureTable = CheckboxTableViewer.newCheckList(tableComp, SWT.BORDER);
    // Connect the label provider
    PDEPlugin.getDefault().getLabelProvider().connect(this);
    fFeatureTable.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
    fFeatureTable.setContentProvider(new ArrayContentProvider());
    fFeatureTable.setSorter(new ViewerSorter());

    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 300;//from w w w  . j  a va  2 s  .  c  o m
    fFeatureTable.getControl().setLayoutData(data);
    fFeatureTable.getControl().setFont(tableComp.getFont());

    fFeatureTable.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            AddFeatureContainersPage.this.checkStateChanged();
        }
    });
    fFeatureTable.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            if (!event.getSelection().isEmpty()) {
                Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
                fFeatureTable.setChecked(selection, !fFeatureTable.getChecked(selection));
                checkStateChanged();
            }
        }
    });

    Composite buttonComp = SWTFactory.createComposite(tableComp, 1, 1, GridData.FILL_VERTICAL, 0, 0);
    fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.AddFeatureContainersPage_0, null);
    fSelectAllButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            fFeatureTable.setAllChecked(true);
            checkStateChanged();
        }
    });
    fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.AddFeatureContainersPage_1, null);
    fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            fFeatureTable.setAllChecked(false);
            checkStateChanged();
        }
    });

    fIncludeVersionButton = SWTFactory.createCheckButton(tableComp, Messages.AddFeatureContainerPage_3, null,
            false, 2);
}

From source file:org.eclipse.pde.internal.ui.wizards.tools.ConvertedProjectsPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite container = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH);

    SWTFactory.createLabel(container, PDEUIMessages.ConvertedProjectWizard_projectList, 2);

    fProjectViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER);
    fProjectViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    fProjectViewer.setContentProvider(new ArrayContentProvider());
    fProjectViewer.setLabelProvider(new ProjectLabelProvider());
    fProjectViewer.setInput(fAllUnconvertedProjects);
    fProjectViewer.setCheckedElements(fInitialSelection);
    fProjectViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateButtons();//from   w w w  .ja  va2 s .co m
        }
    });

    Composite buttonContainer = SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0);

    fSelectButton = SWTFactory.createPushButton(buttonContainer, PDEUIMessages.ConvertedProjectsPage_SelectAll,
            null);
    fSelectButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            fProjectViewer.setAllChecked(true);
            updateButtons();
        }
    });
    fDeselectButton = SWTFactory.createPushButton(buttonContainer,
            PDEUIMessages.ConvertedProjectsPage_DeselectAll, null);
    fDeselectButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            fProjectViewer.setAllChecked(false);
            updateButtons();
        }
    });
    updateButtons();

    fApiAnalysisButton = SWTFactory.createCheckButton(container,
            PDEUIMessages.PluginContentPage_enable_api_analysis, null, false, 2);

    loadSettings();

    setControl(container);
    Dialog.applyDialogFont(container);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.CONVERTED_PROJECTS);
}

From source file:org.eclipse.php.composer.ui.parts.composer.PackageSearch.java

License:Open Source License

protected void create(Composite parent, FormToolkit toolkit, String buttonText) {
    this.toolkit = toolkit;
    factory = new WidgetFactory(toolkit);

    body = factory.createComposite(parent);
    body.setLayout(new GridLayout());

    searchField = factory.createText(body,
            SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
    searchField.setEnabled(enabled);//from   w  ww .j  ava  2s  .  c  om
    searchField.setEditable(enabled);
    searchField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    searchField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            searchTextChanged();
        }
    });

    // clicking the cancel icon sets content to null and invokes
    // modifyText()
    // ... no need to to it manually
    //
    // searchField.addSelectionListener(new SelectionAdapter() {
    // public void widgetDefaultSelected(SelectionEvent e) {
    // if (e.detail == SWT.ICON_CANCEL) {
    // clearSearchText();
    // }
    // }
    // });

    // create search results viewer
    int style = SWT.H_SCROLL | SWT.V_SCROLL;
    if (toolkit == null)
        style |= SWT.BORDER;
    else
        style |= toolkit.getBorderStyle();

    searchController = getSearchResultsController();
    searchController.addPackageCheckStateChangedListener(this);
    searchResults = CheckboxTableViewer.newCheckList(body, style);
    searchResults.getTable().setEnabled(enabled);
    searchResults.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    searchResults.setCheckStateProvider(searchController);
    searchResults.addCheckStateListener(searchController);
    searchResults.setContentProvider(searchController);
    searchResults.setLabelProvider(searchController);
    searchResults.setInput(new ArrayList<ComposerPackage>());

    pickedResults = factory.createComposite(body);
    pickedResults.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout layout = new GridLayout();
    layout.marginTop = 0;
    layout.marginRight = -5;
    layout.marginBottom = 0;
    layout.marginLeft = -5;
    layout.verticalSpacing = FormLayoutFactory.SECTION_CLIENT_MARGIN_TOP;
    layout.horizontalSpacing = 0;
    pickedResults.setLayout(layout);

    if (buttonText != null) {
        addButton = factory.createButton(body);
        addButton.setText(buttonText);
        addButton.setEnabled(false);
        addButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
        addButton.addSelectionListener(addButtonListener);
    }

    // create downloader
    downloader.addPackageSearchListener(this);
}

From source file:org.eclipse.php.internal.debug.ui.preferences.stepFilter.PHPDebugStepFilterPreferencePage.java

License:Open Source License

/**
 * Create a group to contain the step filter related widgetry
 *///from  ww  w  . j  a  v  a2 s.c  o  m
private void createStepFilterPreferences(Composite parent) {
    Composite container = SWTFactory.createComposite(parent, parent.getFont(), 2, 1, GridData.FILL_BOTH, 0, 0);
    fUseStepFiltersButton = SWTFactory.createCheckButton(container,
            PHPDebugUIMessages.PHPDebugStepFilterPreferencePage_useStepFilters, null,
            DebugUITools.isUseStepFilters(), 2);
    fUseStepFiltersButton.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            setPageEnablement(fUseStepFiltersButton.getSelection());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    SWTFactory.createLabel(container, PHPDebugUIMessages.PHPDebugStepFilterPreferencePage_definedStepFilters,
            2);
    fTableViewer = CheckboxTableViewer.newCheckList(container,
            SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    fTableViewer.getTable().setFont(container.getFont());
    fTableViewer.setLabelProvider(new FilterLabelProvider());
    fTableViewer.setComparator(new FilterViewerComparator());
    fTableViewer.setContentProvider(new StepFilterContentProvider());

    fTableViewer.setInput(getAllPersistedFilters(false));
    fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            ((DebugStepFilter) event.getElement()).setEnabled(event.getChecked());
        }
    });
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                fRemoveFilterButton.setEnabled(false);
            } else {
                DebugStepFilter filter = (DebugStepFilter) ((StructuredSelection) selection).getFirstElement();
                if (filter.isReadOnly()) {
                    fRemoveFilterButton.setEnabled(false);
                } else {
                    fRemoveFilterButton.setEnabled(true);
                }
            }
        }
    });
    fTableViewer.getControl().addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent event) {
            handleFilterViewerKeyPress(event);
        }
    });

    createStepFilterButtons(container);
    fUseStepFiltersButton.setSelection(DebugPlugin.isUseStepFilters());
    setPageEnablement(fUseStepFiltersButton.getSelection());
}

From source file:org.eclipse.php.internal.ui.outline.CustomFiltersDialog.java

License:Open Source License

private void createCheckBoxList(Composite parent) {
    // Filler//from w  ww . j av  a  2s  .c o  m
    new Label(parent, SWT.NONE);

    Label info = new Label(parent, SWT.LEFT);
    info.setText(FilterMessages.CustomFiltersDialog_filterList_label);

    fCheckBoxList = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = fCheckBoxList.getTable().getItemHeight() * 10;
    fCheckBoxList.getTable().setLayoutData(data);

    fCheckBoxList.setLabelProvider(createLabelPrivder());
    fCheckBoxList.setContentProvider(new ArrayContentProvider());
    Arrays.sort(fBuiltInFilters);
    fCheckBoxList.setInput(fBuiltInFilters);
    setInitialSelections(getEnabledFilterDescriptors());

    List<?> initialSelection = getInitialElementSelections();
    if (initialSelection != null && !initialSelection.isEmpty())
        checkInitialSelections();

    // Description
    info = new Label(parent, SWT.LEFT);
    info.setText(FilterMessages.CustomFiltersDialog_description_label);
    final Text description = new Text(parent,
            SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = convertHeightInCharsToPixels(3);
    description.setLayoutData(data);
    fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
                if (selectedElement instanceof FilterDescriptor)
                    description.setText(((FilterDescriptor) selectedElement).getDescription());
            }
        }
    });
    fCheckBoxList.addCheckStateListener(new ICheckStateListener() {
        /*
         * @see
         * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
         * (org.eclipse.jface.viewers.CheckStateChangedEvent)
         */
        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof FilterDescriptor) {
                // renew if already touched
                FilterDescriptor fd = (FilterDescriptor) element;
                if (fFilterDescriptorChangeHistory.contains(fd)) {
                    fFilterDescriptorChangeHistory.remove(fd);
                }
                fFilterDescriptorChangeHistory.push(fd);
            }
        }
    });

    addSelectionButtons(parent);
}

From source file:org.eclipse.ptp.etfw.tau.papiselect.papic.PapiListSelectionDialog.java

License:Open Source License

/**
 * Creates the core UI of this dialog// w  w  w  . j a  va  2s  .  co  m
 */
@Override
protected Control createDialogArea(Composite parent) {
    // page group
    final Composite composite = (Composite) super.createDialogArea(parent);

    initializeDialogUnits(composite);

    createMessageArea(composite);

    listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    final GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    listViewer.getTable().setLayoutData(data);

    listViewer.setLabelProvider(labelProvider);
    listViewer.setContentProvider(contentProvider);

    class PapiCheckListener implements ICheckStateListener {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateGrey(event.getElement());
        }
    }

    listViewer.addCheckStateListener(new PapiCheckListener());
    addSelectionButtons(composite);

    initializeViewer();

    // initialize page
    if (!getInitialElementSelections().isEmpty()) {
        checkInitialSelections();
    }

    Dialog.applyDialogFont(composite);

    return composite;
}