Search in sources :

Example 31 with CheckboxTableViewer

use of org.eclipse.jface.viewers.CheckboxTableViewer in project linuxtools by eclipse.

the class ImageRunSelectionPage method createPortSettingsTable.

private CheckboxTableViewer createPortSettingsTable(final Composite container) {
    final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.CHECK);
    final CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    createTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
    "ImageRunSelectionPage.containerPortColumn"), 100);
    createTableViewerColum(tableViewer, // $NON-NLS-1$
    WizardMessages.getString("ImageRunSelectionPage.typeColumn"), 50);
    createTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
    "ImageRunSelectionPage.hostAddressColumn"), 100);
    createTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
    "ImageRunSelectionPage.hostPortColumn"), 100);
    tableViewer.setContentProvider(new ObservableListContentProvider());
    return tableViewer;
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Table(org.eclipse.swt.widgets.Table) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer)

Example 32 with CheckboxTableViewer

use of org.eclipse.jface.viewers.CheckboxTableViewer in project linuxtools by eclipse.

the class ImageRunSelectionPage method createPortSettingsSection.

private void createPortSettingsSection(final Composite container) {
    final Button publishAllPortsButton = new Button(container, SWT.CHECK);
    publishAllPortsButton.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImageRunSelectionPage.publishAllPorts"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).grab(true, false).applyTo(publishAllPortsButton);
    dbc.bindValue(WidgetProperties.selection().observe(publishAllPortsButton), BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.PUBLISH_ALL_PORTS).observe(model));
    // specify ports
    final Label portSettingsLabel = new Label(container, SWT.NONE);
    portSettingsLabel.setText(// $NON-NLS-1$
    WizardMessages.getString("ImageRunSelectionPage.portSettings"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(COLUMNS, 1).indent(INDENT, 0).applyTo(portSettingsLabel);
    final CheckboxTableViewer exposedPortsTableViewer = createPortSettingsTable(container);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(COLUMNS - 1, 1).indent(INDENT, 0).hint(200, 70).applyTo(exposedPortsTableViewer.getTable());
    // buttons
    final Composite buttonsContainers = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(false, false).applyTo(buttonsContainers);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(SWT.DEFAULT, 0).applyTo(buttonsContainers);
    final Button addButton = new Button(buttonsContainers, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(addButton);
    addButton.setText(WizardMessages.getString(// $NON-NLS-1$
    "ImageRunSelectionPage.addButton"));
    addButton.addSelectionListener(onAddPort(exposedPortsTableViewer));
    final Button editButton = new Button(buttonsContainers, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(editButton);
    editButton.setText(// $NON-NLS-1$
    WizardMessages.getString("ImageRunSelectionPage.editButton"));
    editButton.setEnabled(false);
    editButton.addSelectionListener(onEditPort(exposedPortsTableViewer));
    final Button removeButton = new Button(buttonsContainers, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(removeButton);
    removeButton.setText(// $NON-NLS-1$
    WizardMessages.getString("ImageRunSelectionPage.remove"));
    removeButton.addSelectionListener(onRemovePorts(exposedPortsTableViewer));
    BeanProperties.value(ImageRunSelectionModel.class, ImageRunSelectionModel.PUBLISH_ALL_PORTS).observe(model).addValueChangeListener(onPublishAllPortsChange(exposedPortsTableViewer.getTable(), addButton, removeButton));
    ViewerSupport.bind(exposedPortsTableViewer, model.getExposedPorts(), BeanProperties.values(ExposedPortModel.class, ExposedPortModel.CONTAINER_PORT, ExposedPortModel.PORT_TYPE, ExposedPortModel.HOST_ADDRESS, ExposedPortModel.HOST_PORT));
    dbc.bindSet(ViewersObservables.observeCheckedElements(exposedPortsTableViewer, ExposedPortModel.class), BeanProperties.set(ImageRunSelectionModel.SELECTED_PORTS).observe(model));
    checkAllElements(exposedPortsTableViewer);
    // disable the edit and removeButton if the table is empty
    exposedPortsTableViewer.addSelectionChangedListener(onSelectionChanged(editButton, removeButton));
    togglePortMappingControls(exposedPortsTableViewer.getTable(), addButton, removeButton);
}
Also used : ExposedPortModel(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel.ExposedPortModel) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Label(org.eclipse.swt.widgets.Label)

Example 33 with CheckboxTableViewer

use of org.eclipse.jface.viewers.CheckboxTableViewer in project erlide_eclipse by erlang.

the class CheckedListDialogField method createTableViewer.

/*
     * @see ListDialogField#createTableViewer
     */
@Override
protected TableViewer createTableViewer(final Composite parent) {
    final Table table = new Table(parent, SWT.CHECK + getListStyle());
    final CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent e) {
            doCheckStateChanged(e);
        }
    });
    return tableViewer;
}
Also used : Table(org.eclipse.swt.widgets.Table) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 34 with CheckboxTableViewer

use of org.eclipse.jface.viewers.CheckboxTableViewer in project erlide_eclipse by erlang.

the class LiveExpressionsView method createPartControl.

/**
 * This is a callback that will allow us to create the viewer and initialize it.
 */
@Override
public void createPartControl(final Composite parent) {
    label = new Label(parent, SWT.NULL);
    final Table t = new Table(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);
    viewer = new CheckboxTableViewer(t);
    final GridData labelLData = new GridData();
    labelLData.verticalAlignment = GridData.BEGINNING;
    labelLData.horizontalAlignment = GridData.FILL;
    labelLData.widthHint = 300;
    labelLData.heightHint = 14;
    labelLData.horizontalIndent = 0;
    labelLData.horizontalSpan = 1;
    labelLData.verticalSpan = 1;
    labelLData.grabExcessHorizontalSpace = true;
    labelLData.grabExcessVerticalSpace = false;
    label.setLayoutData(labelLData);
    label.setSize(new org.eclipse.swt.graphics.Point(319, 14));
    final GridData viewerLData = new GridData();
    viewerLData.verticalAlignment = GridData.FILL;
    viewerLData.horizontalAlignment = GridData.FILL;
    viewerLData.widthHint = 600;
    viewerLData.heightHint = 150;
    viewerLData.horizontalIndent = 0;
    viewerLData.horizontalSpan = 1;
    viewerLData.verticalSpan = 1;
    viewerLData.grabExcessHorizontalSpace = true;
    viewerLData.grabExcessVerticalSpace = true;
    t.setLayoutData(viewerLData);
    t.setSize(new org.eclipse.swt.graphics.Point(600, 200));
    final GridLayout thisLayout = new GridLayout(1, true);
    parent.setLayout(thisLayout);
    thisLayout.marginWidth = 5;
    thisLayout.marginHeight = 5;
    thisLayout.numColumns = 1;
    thisLayout.makeColumnsEqualWidth = false;
    thisLayout.horizontalSpacing = 0;
    thisLayout.verticalSpacing = 1;
    t.setLinesVisible(true);
    t.setHeaderVisible(true);
    // t.setFont();
    final TableColumn colExpr = new TableColumn(t, SWT.LEAD, 0);
    colExpr.setText("Expression");
    colExpr.setWidth(150);
    final TableColumn colValue = new TableColumn(t, SWT.LEAD, 1);
    colValue.setText("Value");
    colValue.setWidth(t.getSize().x - 50);
    viewer.setColumnProperties(new String[] { "expr", "val" });
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    if (!restoreState()) {
        /* Fill LiveExpressions for first time */
        exprs = new ArrayList<>(10);
        addExpr(new LiveExpr(backend, "erlide_time_compat:timestamp()"));
    }
    viewer.setInput(exprs);
    final TextCellEditor e = new TextCellEditor(t);
    viewer.setCellEditors(new CellEditor[] { e, null });
    viewer.setCellModifier(new LiveExprCellModifier(this));
    makeActions();
    hookContextMenu();
    contributeToActionBars();
    hookGlobalActions();
    final Listener tableListener = new ListenerImplementation(t);
    t.addListener(SWT.Dispose, tableListener);
    t.addListener(SWT.KeyDown, tableListener);
    t.addListener(SWT.MouseMove, tableListener);
    t.addListener(SWT.MouseHover, tableListener);
// /////////////
}
Also used : Table(org.eclipse.swt.widgets.Table) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) IMenuListener(org.eclipse.jface.action.IMenuListener) Listener(org.eclipse.swt.widgets.Listener) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor)

Example 35 with CheckboxTableViewer

use of org.eclipse.jface.viewers.CheckboxTableViewer in project tmdm-studio-se by Talend.

the class SelectImportedModulesDialog method createTableViewer.

CheckboxTableViewer createTableViewer(Composite parent, String columnName, IContentProvider contentProvider, ILabelProvider lableProvider) {
    Composite com = new Composite(parent, SWT.NONE);
    com.setLayout(new GridLayout(1, false));
    final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(com, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.BORDER);
    viewer.setCheckStateProvider(new ICheckStateProvider() {

        public boolean isChecked(Object element) {
            return true;
        }

        public boolean isGrayed(Object element) {
            return false;
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
    viewer.getTable().setLinesVisible(true);
    viewer.setContentProvider(contentProvider);
    viewer.getTable().setHeaderVisible(true);
    TableLayout lay = new TableLayout();
    TableColumn column = new TableColumn(viewer.getTable(), SWT.CENTER);
    column.setText(columnName);
    lay.addColumnData(new ColumnWeightData(200, 100));
    viewer.getTable().setLayout(lay);
    viewer.setLabelProvider(lableProvider);
    ToolBar toolBar = new ToolBar(com, SWT.HORIZONTAL | SWT.FLAT);
    createToolBarItem(toolBar, Messages.RepositoryCheckTreeViewer_SelectAll, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(true);
        }
    });
    createToolBarItem(toolBar, Messages.RepositoryCheckTreeViewer_DeselectAll, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            viewer.setAllChecked(false);
        }
    });
    return viewer;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TreeObject(com.amalto.workbench.models.TreeObject) TableLayout(org.eclipse.jface.viewers.TableLayout) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)45 Composite (org.eclipse.swt.widgets.Composite)29 Table (org.eclipse.swt.widgets.Table)28 GridData (org.eclipse.swt.layout.GridData)24 GridLayout (org.eclipse.swt.layout.GridLayout)21 Label (org.eclipse.swt.widgets.Label)20 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)19 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 TableColumn (org.eclipse.swt.widgets.TableColumn)17 Button (org.eclipse.swt.widgets.Button)15 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)10 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)8 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)8 SelectionListener (org.eclipse.swt.events.SelectionListener)7 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)6 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)6 Viewer (org.eclipse.jface.viewers.Viewer)6 Event (org.eclipse.swt.widgets.Event)6