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();
}
};
}
Aggregations