Search in sources :

Example 1 with FormComponentPresentation

use of org.eclipse.sapphire.ui.forms.swt.FormComponentPresentation in project liferay-ide by liferay.

the class AbstractCheckboxCustomPart method createPresentation.

@Override
public FormComponentPresentation createPresentation(SwtPresentation parent, Composite composite) {
    return new FormComponentPresentation(this, parent, composite) {

        @Override
        public void render() {
            final Composite parent = SWTUtil.createComposite(composite(), 2, 2, GridData.FILL_BOTH);
            checkBoxViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
            checkBoxViewer.addCheckStateListener(new ICheckStateListener() {

                @Override
                public void checkStateChanged(CheckStateChangedEvent event) {
                    handleCheckStateChangedEvent(event);
                }
            });
            checkBoxViewer.setContentProvider(new CheckboxContentProvider());
            checkBoxViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(getLableProvider()));
            final Table table = checkBoxViewer.getTable();
            final GridData tableData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4);
            tableData.heightHint = 225;
            tableData.widthHint = 400;
            table.setLayoutData(tableData);
            final Button selectAllButton = new Button(parent, SWT.NONE);
            selectAllButton.setText("Select All");
            selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
            selectAllButton.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    handleSelectAllEvent();
                }
            });
            final Button deselectAllButton = new Button(parent, SWT.NONE);
            deselectAllButton.setText("Deselect All");
            deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
            deselectAllButton.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    handleDeSelectAllEvent();
                }
            });
            final Button refreshButton = new Button(parent, SWT.NONE);
            refreshButton.setText("Refresh");
            refreshButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
            refreshButton.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    checkAndUpdateCheckboxElement();
                }
            });
            _startCheckThread();
        }

        private void _startCheckThread() {
            final Thread t = new Thread() {

                @Override
                public void run() {
                    checkAndUpdateCheckboxElement();
                }
            };
            t.start();
        }
    };
}
Also used : Table(org.eclipse.swt.widgets.Table) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) FormComponentPresentation(org.eclipse.sapphire.ui.forms.swt.FormComponentPresentation) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) DelegatingStyledCellLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 DelegatingStyledCellLabelProvider (org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 FormComponentPresentation (org.eclipse.sapphire.ui.forms.swt.FormComponentPresentation)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 Table (org.eclipse.swt.widgets.Table)1