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.emf.validation.ui.preferences.ConstraintsSelectionBlock.java

License:Open Source License

/**
 * Helper method to create the constraint-list part of the GUI.  The result
 * is a form containing the constraints list and a prompt label.
 * //from   w  w  w.  j a v a2s .  co  m
 * @param parent the parent composite in which to create the list
 * @return the list part of the GUI (itself a composite form)
 */
private Control createConstraintList(Composite parent) {
    Composite form = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    form.setLayout(layout);

    Label prompt = new Label(form, SWT.NONE);
    prompt.setText(CONSTRAINTS_PROMPT);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    prompt.setLayoutData(data);

    constraintList = CheckboxTableViewer.newCheckList(form, SWT.CHECK | SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(prompt, 4);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    constraintList.getControl().setLayoutData(data);

    constraintList.setContentProvider(new ConstraintListContents());

    constraintList.setLabelProvider(new LabelProvider() {
        private final Image lockImage = ValidationUIPlugin.getImageDescriptor(LOCK_ICON).createImage(true);

        // extends the inherited method
        @Override
        public void dispose() {
            lockImage.dispose();
            super.dispose();
        }

        // redefines the inherited method
        @Override
        public Image getImage(Object element) {
            IConstraintNode constraint = (IConstraintNode) element;

            if (constraint.isErrored()) {
                return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
            } else if (constraint.isMandatory()) {
                return lockImage;
            } else {
                return null;
            }
        }

        // redefines the inherited method
        @Override
        public String getText(Object element) {
            return ((IConstraintNode) element).getName();
        }
    });

    constraintList.setSorter(new ViewerSorter());

    constraintList.addCheckStateListener(getMediator());
    constraintList.addSelectionChangedListener(getMediator());

    return constraintList.getControl();
}

From source file:org.eclipse.epf.authoring.ui.wizards.NewPluginMainPage.java

License:Open Source License

protected void createReferencedModelsViewer(Composite composite) {
    referencedPluginsLabel = createVerticallyAlignedLabel(composite,
            AuthoringUIText.REFERENCED_PLUGINS_SECTION_NAME);

    referencedPluginsViewer = CheckboxTableViewer.newCheckList(composite,
            SWT.BORDER | SWT.FILL | SWT.HORIZONTAL);
    GridData referencedPluginsGridData = new GridData(GridData.FILL_HORIZONTAL);
    referencedPluginsGridData.heightHint = 150;
    referencedPluginsViewer.getTable().setLayoutData(referencedPluginsGridData);
}

From source file:org.eclipse.epf.authoring.ui.wizards.SaveAllEditorsPage.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
 *//*from  ww  w .j av  a2s.  c  o m*/
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(2, false));

    ctrl_chkboxTableViewer = CheckboxTableViewer.newCheckList(container,
            SWT.BORDER | SWT.FILL | SWT.HORIZONTAL);
    ctrl_chkboxTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    ctrl_chkboxTableViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            IEditorReference ref = (IEditorReference) element;
            return ref.getEditor(false).getTitle();
        }

        public Image getImage(Object element) {
            IEditorReference ref = (IEditorReference) element;
            return ref.getEditor(false).getTitleImage();
        }
    });
    ctrl_chkboxTableViewer.setContentProvider(new ArrayContentProvider());
    ctrl_chkboxTableViewer.setInput(EditorChooser.getInstance().getOpenMethodEditors().toArray());
    ctrl_chkboxTableViewer.addFilter(new ViewerFilter() {
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IEditorReference) {
                if (((IEditorReference) element).isDirty())
                    return true;
            }
            return false;
        }
    });
    ctrl_chkboxTableViewer.setAllChecked(true);

    Composite buttonContainer = new Composite(container, SWT.NONE);
    buttonContainer.setLayout(new GridLayout(1, true));
    buttonContainer.setLayoutData(new GridData(SWT.DEFAULT, SWT.BEGINNING, false, true));

    selectAll = new Button(buttonContainer, SWT.PUSH);
    selectAll.setText(AuthoringUIResources.AuthoringUIPlugin_SaveAllEditorsPage_SelectAllButtonLabel);
    selectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, true));

    deselectAll = new Button(buttonContainer, SWT.PUSH);
    deselectAll.setText(AuthoringUIResources.AuthoringUIPlugin_SaveAllEditorsPage_DeselectAllButtonLabel);
    deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, true));

    addListeners();

    setControl(container);
    setPageComplete(true);
}

From source file:org.eclipse.epf.ui.util.SWTUtil.java

License:Open Source License

/**
 * Creates a checkbox table viewer./*w  ww. ja  v  a 2  s .c  o  m*/
 * 
 * @param parent
 *            the parent composite
 * @param widthHint
 *            the preferred width (in pixels) for the control
 * @param heightHint
 *            the preferred height (in pixels) for the control
 * @param column
 *            the number of column cells that the control will take up
 * @return a <code>CheckboxTableViewer</code> object
 */
public static CheckboxTableViewer createCheckboxTableViewer(Composite parent, int widthHint, int heightHint,
        int column) {
    CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(parent,
            SWT.BORDER | SWT.FILL | SWT.HORIZONTAL);
    Table table = checkboxTableViewer.getTable();
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = column;
    gd.widthHint = widthHint;
    gd.heightHint = heightHint;
    table.setLayoutData(gd);
    return checkboxTableViewer;
}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.SelectableIUsPage.java

License:Open Source License

protected CheckboxTableViewer createTableViewer(Composite parent) {
    // The viewer allows selection of IU's for browsing the details,
    // and checking to include in the provisioning operation.
    CheckboxTableViewer v = CheckboxTableViewer.newCheckList(parent,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    return v;/* www. j av  a  2  s .c om*/
}

From source file:org.eclipse.gmf.runtime.emf.ui.preferences.PathmapsPreferencePage.java

License:Open Source License

protected Control createContents(Composite parent) {
    GridData gridData = null;/*from  w w w . ja  va  2  s  .c o m*/
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(parent.getFont());

    composite.setLayout(new GridLayout(2, false));

    PreferenceLinkArea pathVariablesArea = new PreferenceLinkArea(composite, SWT.NONE,
            "org.eclipse.ui.preferencePages.LinkedResources", //$NON-NLS-1$
            EMFUIMessages.PathmapsPreferencePage_mainDescription,
            (IWorkbenchPreferenceContainer) getContainer(), null);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    gridData.horizontalSpan = 2;
    pathVariablesArea.getControl().setLayoutData(gridData);

    Label pathVariablesLabel = new Label(composite, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    gridData.horizontalSpan = 2;
    gridData.verticalIndent = 20;
    pathVariablesLabel.setLayoutData(gridData);
    pathVariablesLabel.setText(EMFUIMessages.PathmapsPreferencePage_availablePathVariables);

    pathVariablesComposite = new Composite(composite, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 1;
    pathVariablesComposite.setLayoutData(gridData);
    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    pathVariablesComposite.setLayout(gridLayout);

    pathVariables = CheckboxTableViewer.newCheckList(pathVariablesComposite, SWT.MULTI);

    pathVariablesContent = new PathVariableContentProvider();
    pathVariables.setContentProvider(pathVariablesContent);
    pathVariables.setLabelProvider(new PathVariableLabelProvider());
    pathVariables.setComparator(new PathVariableViewerComparator());
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    // These two hard coded values were borrowed from similar code in
    // org.eclipse.ui.internal.ide.dialogs.PathVariablesGroup
    gridData.heightHint = pathVariables.getTable().getItemHeight() * 7;
    gridData.widthHint = 332;
    pathVariables.getTable().setLayoutData(gridData);

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    buttonComposite.setLayout(new GridLayout(1, false));
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = false;
    gridData.grabExcessVerticalSpace = false;
    gridData.horizontalSpan = 1;
    gridData.verticalAlignment = GridData.BEGINNING;
    buttonComposite.setLayoutData(gridData);

    newVariable = new Button(buttonComposite, SWT.CENTER);
    newVariable.setText(EMFUIMessages.PathmapsPreferencePage_newVariable);
    setButtonLayoutData(newVariable);

    editVariable = new Button(buttonComposite, SWT.CENTER);
    editVariable.setText(EMFUIMessages.PathmapsPreferencePage_editVariable);
    setButtonLayoutData(editVariable);

    removeVariable = new Button(buttonComposite, SWT.CENTER);
    removeVariable.setText(EMFUIMessages.PathmapsPreferencePage_removeVariable);
    setButtonLayoutData(removeVariable);

    pathVariables.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            pathVariableSelected(event.getSelection());
        }
    });

    pathVariables.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            pathVariableChecked(event, (PathVariableEntry) event.getElement());
        }
    });

    newVariable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            addPathVariable();
        }
    });

    editVariable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            editPathVariable(pathVariables.getSelection());
        }
    });

    removeVariable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            removePathVariable(pathVariables.getSelection());
        }
    });

    initializeContents();

    applyDialogFont(composite);

    pathVariableSelected(pathVariables.getSelection());

    return composite;
}

From source file:org.eclipse.ice.client.widgets.moose.MOOSETreePropertySection.java

License:Open Source License

/**
 * Creates the table that displays properties for viewing and editing.
 * //from w  w w .  j  a  v a  2s  .c  o  m
 * @param client
 *            The client <code>Composite</code> that should contain the
 *            table of properties.
 * @return The <code>TableViewer</code> for the table of properties.
 */
@Override
protected TableViewer createTableViewer(Composite client) {

    CheckboxTableViewer tableViewer = null;

    if (client != null) {
        Table table;

        // Create the TableViewer and the underlying Table Control.
        tableViewer = CheckboxTableViewer.newCheckList(client, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
        // Set some properties for the table.
        table = tableViewer.getTable();
        table.setHeaderVisible(true);
        table.setLinesVisible(true);

        // Set up the content provider for the table viewer. Now the table
        // viewer's input can be set.
        tableViewer.setContentProvider(new TreePropertyContentProvider());

        // Enable tool tips for the Table's cells.
        ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);

        // Populate the TableViewer with its columns.
        addTableViewerColumns(tableViewer);
    }

    return tableViewer;
}

From source file:org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersPreferencePage.java

License:Open Source License

/**
 * Create a group to contain the detail formatters related widgetry
 *///www  .ja  v  a2 s  .  c  om
private Control createDetailFormatsPreferences(Composite parent) {
    Font font = parent.getFont();

    //table label
    fTableLabel = new Label(parent, SWT.NONE);
    fTableLabel.setText(DebugUIMessages.JavaDetailFormattersPreferencePage__Types_with_detail_formatters__2);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalSpan = 2;
    fTableLabel.setLayoutData(gd);
    fTableLabel.setFont(font);

    fFormatterListViewer = CheckboxTableViewer.newCheckList(parent,
            SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    Table table = (Table) fFormatterListViewer.getControl();
    gd = new GridData(GridData.FILL_BOTH);
    //gd.heightHint= convertHeightInCharsToPixels(5);
    gd.widthHint = convertWidthInCharsToPixels(10);
    table.setLayoutData(gd);
    table.setFont(font);
    fFormatViewerContentProvider = new FormatterListViewerContentProvider(fFormatterListViewer);
    fFormatterListViewer.setContentProvider(fFormatViewerContentProvider);
    fFormatterListViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof DetailFormatter) {
                return ((DetailFormatter) element).getTypeName();
            }
            return null;
        }
    });
    fFormatterListViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            ((DetailFormatter) event.getElement()).setEnabled(event.getChecked());
        }
    });
    fFormatterListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updatePage((IStructuredSelection) event.getSelection());
        }
    });
    fFormatterListViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            if (!event.getSelection().isEmpty()) {
                editType();
            }
        }
    });
    table.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent event) {
            if (event.character == SWT.DEL && event.stateMask == 0) {
                removeTypes();
            }
        }
    });
    fFormatterListViewer.setInput(this);

    createDetailFormatsButtons(parent);

    Label label = new Label(parent, SWT.NONE);
    label.setText(
            DebugUIMessages.JavaDetailFormattersPreferencePage_Detail_formatter_code_snippet_defined_for_selected_type__3);
    label.setFont(font);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    createSourceViewer(parent);

    fFormatViewerContentProvider.refreshViewer();
    return parent;
}

From source file:org.eclipse.jdt.internal.debug.ui.JavaStepFilterPreferencePage.java

License:Open Source License

/**
 * Create a group to contain the step filter related widgetry
 *//*w  ww. ja va2s  .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,
            DebugUIMessages.JavaStepFilterPreferencePage__Use_step_filters, null,
            DebugUITools.isUseStepFilters(), 2);
    fUseStepFiltersButton.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            setPageEnablement(fUseStepFiltersButton.getSelection());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    SWTFactory.createLabel(container, DebugUIMessages.JavaStepFilterPreferencePage_Defined_step_fi_lters__8, 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(getAllStoredFilters(false));
    fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            ((Filter) event.getElement()).setChecked(event.getChecked());
        }
    });
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                fRemoveFilterButton.setEnabled(false);
            } else {
                fRemoveFilterButton.setEnabled(true);
            }
        }
    });
    fTableViewer.getControl().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent event) {
            handleFilterViewerKeyPress(event);
        }
    });

    createStepFilterButtons(container);
    createStepFilterCheckboxes(container);

    setPageEnablement(fUseStepFiltersButton.getSelection());
}

From source file:org.eclipse.jdt.internal.debug.ui.propertypages.InstanceFilterEditor.java

License:Open Source License

/**
 * Create and initialize the thread filter tree viewer.
 *//*w w w.  j a va2  s  .  c o m*/
protected void createViewer() {
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 100;

    fInstanceViewer = CheckboxTableViewer.newCheckList(fParent, SWT.BORDER);
    fInstanceViewer.addCheckStateListener(fCheckHandler);
    fInstanceViewer.getTable().setLayoutData(data);
    fInstanceViewer.setContentProvider(fContentProvider);
    IDebugModelPresentation pres = DebugUITools.newDebugModelPresentation();
    pres.setAttribute(JDIModelPresentation.DISPLAY_QUALIFIED_NAMES, Boolean.TRUE);
    fInstanceViewer.setLabelProvider(pres);
    fInstanceViewer.setInput(fBreakpoint);
    setInitialCheckedState();
}