@Override protected TreeViewer createTreeViewer(Composite parent) { TreeViewer result = super.createTreeViewer(parent); // Initialize the table. Tree tree = result.getTree(); tree.setHeaderVisible(true); tree.setToolTipText("Node Display Properties"); EditColTableDef.setupTree(TABLE_DEF, tree); // Configure cell editing. CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_SELECTED] = new CheckboxCellEditor(tree); cellEditors[INDEX_XPOS] = new TextCellEditor(tree); cellEditors[INDEX_YPOS] = new TextCellEditor(tree); cellEditors[INDEX_VISIBLE] = new CheckboxCellEditor(tree); cellEditors[INDEX_SIZE] = new ComboBoxCellEditor( tree, buildSizeOptions()); cellEditors[INDEX_COLOR] = new ColorCellEditor(tree); result.setCellEditors(cellEditors); result.setLabelProvider(new PartLabelProvider()); result.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); result.setCellModifier(new PartCellModifier()); return result; }
public EdgeDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Edge Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_HEAD] = null; cellEditors[INDEX_TAIL] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); propViewer.setContentProvider(ArrayContentProvider.getInstance()); configSorters(propTable); }
public RelationDisplayTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); propViewer = new TableViewer(this, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table propTable = propViewer.getTable(); propTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table propTable.setHeaderVisible(true); propTable.setToolTipText("Relations Display Properties"); EditColTableDef.setupTable(TABLE_DEF, propTable); // Configure cell editing CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_NAME] = null; cellEditors[INDEX_SOURCE] = null; cellEditors[INDEX_COLOR] = new ColorCellEditor(propTable); cellEditors[INDEX_STYLE] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.LineStyle.values(), true)); cellEditors[INDEX_ARROWHEAD] = new ComboBoxCellEditor(propTable, toString(EdgeDisplayProperty.ArrowheadStyle.values(), true)); propViewer.setCellEditors(cellEditors); propViewer.setLabelProvider(new EdgeDisplayLabelProvider()); propViewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); propViewer.setCellModifier(new EdgeDisplayCellModifier()); // TODO: Add column sorters, filters? configSorters(propTable); // Configure content last: use updateTable() to render relations propViewer.setContentProvider(ArrayContentProvider.getInstance()); }
@Override public Control construct(Composite parent) { // TODO Auto-generated method stub parent.setLayout(new GridLayout(1, false)); Button newPerson = new Button(parent, SWT.PUSH); newPerson.setText("Create New Person"); final TableViewer tv = new TableViewer(parent, SWT.FULL_SELECTION); tv.setContentProvider(new PersonContentProvider()); tv.setLabelProvider(new StudentLabelProvider()); tv.setInput(studentList); Table table = tv.getTable(); table.setLayoutData(new GridData(GridData.FILL_BOTH)); new TableColumn(table, SWT.CENTER).setText(NAME); new TableColumn(table, SWT.CENTER).setText(MALE); new TableColumn(table, SWT.CENTER).setText(AGE); new TableColumn(table, SWT.CENTER).setText(SHIRT_COLOR); for (int i = 0, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } table.setHeaderVisible(true); table.setLinesVisible(true); newPerson.addSelectionListener(new SelectionAdapter() { @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent event) { Student p = new Student(); p.setName("Name"); p.setMale(true); p.setAgeRange(Integer.valueOf("0")); p.setShirtColor(new RGB(255, 0, 0)); studentList.add(p); tv.refresh(); } }); CellEditor[] editors = new CellEditor[4]; editors[0] = new TextCellEditor(table); editors[1] = new CheckboxCellEditor(table); editors[2] = new ComboBoxCellEditor(table, AgeRange.INSTANCES, SWT.READ_ONLY); editors[3] = new ColorCellEditor(table); tv.setColumnProperties(PROPS); tv.setCellModifier(new StudentCellModifier(tv)); tv.setCellEditors(editors); return null; }