Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Darkest-dark theme missing CheckboxTableViewer
package dialogtest.handlers;
import java.util.Arrays;
import javax.annotation.Generated;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
/**
* The CheckboxTableViewer is missing in case of this code in the darkest-dark theme, while present in regular dark theme.
* @author helospark
*/
@Generated("WindowBuilder")
public class TestDialog extends Dialog {
protected Shell shell;
private Table table;
private CheckboxTableViewer checkboxTableViewer;
public TestDialog(Shell parent) {
super(parent);
}
public Object open() {
createContents();
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return null;
}
private void createContents() {
shell = new Shell(getParent(), SWT.SHELL_TRIM | SWT.BORDER | SWT.PRIMARY_MODAL | SWT.SHEET);
shell.setSize(418, 444);
shell.setText("Content");
Label lblNewLabel = new Label(shell, SWT.WRAP);
lblNewLabel.setBounds(10, 10, 396, 20);
lblNewLabel.setText("The table should be visible under this text");
checkboxTableViewer = CheckboxTableViewer.newCheckList(shell, SWT.BORDER | SWT.FULL_SELECTION);
table = checkboxTableViewer.getTable();
table.setBounds(10, 30, 396, 228);
table.setHeaderVisible(true);
table.setLinesVisible(true);
checkboxTableViewer.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isGrayed(Object object) {
return false;
}
@Override
public boolean isChecked(Object object) {
return false;
}
});
TableViewerColumn fieldnameTableViewerColumn = new TableViewerColumn(checkboxTableViewer, SWT.NONE);
TableColumn fieldNameTableColumn = fieldnameTableViewerColumn.getColumn();
fieldNameTableColumn.setWidth(200);
fieldNameTableColumn.setText("FieldName");
fieldnameTableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object o) {
return (String) o;
}
});
initializeContents();
}
private void initializeContents() {
Arrays.asList("field1", "field2")
.stream()
.forEach(checkboxTableViewer::add);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.