Created
August 6, 2018 11:13
-
-
Save helospark/0a1c17db4a054bf45652a9eed2bb1d25 to your computer and use it in GitHub Desktop.
Darkest-dark theme missing CheckboxTableViewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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