use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class DefaultAutoFilter method update.
/**
* {@inheritDoc}
*/
public void update() {
if (_combo == null) {
_combo = new CCombo(_table, SWT.BORDER | SWT.READ_ONLY);
_combo.addSelectionListener(this);
}
IColumn col = _column;
Set<String> colFilterStrings = getColFilterStrings(col, MAX_AUTOFILTERLENGTH);
String[] items = new String[colFilterStrings.size() + 3];
int idx = 0;
items[idx++] = TEXT_FILTER_ALL;
items[idx++] = TEXT_FILTER_EMPTY;
items[idx++] = TEXT_FILTER_NONEMPTY;
for (String s : colFilterStrings) {
items[idx++] = s;
}
_combo.setItems(items);
_combo.select(0);
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class ConfigureColumnsAction method restore.
/**
* Restore viewstate to previously saved state.
*/
private void restore() {
_tvs.setSortedColumns(_saveOrder);
for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
IColumn col = _table.getTableModel().getColumn(i);
boolean visible = _saveVisibility.get(col);
_tvs.setColumnVisible(col, visible);
}
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class ConfigureColumnsAction method save.
/**
* Save the current properties of the viewstate.
*/
private void save() {
_saveOrder = new ArrayList<IColumn>();
_saveOrder.addAll(_tvs.getSortedColumns());
_saveVisibility = new HashMap<IColumn, Boolean>();
for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
IColumn col = _table.getTableModel().getColumn(i);
_saveVisibility.put(col, _tvs.getColumnVisible(col));
}
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class ConfigureColumnsAction method createColumnControlPanel.
/**
* Create the dialog area. TODO can be done much nicer ... but works for the first draft
*
* @param parent parent composite
* @return initialized control
*/
private Control createColumnControlPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NULL);
panel.setLayout(new RowLayout());
Label l = new Label(panel, SWT.NULL);
l.setText("Configure the columns");
Table table = new Table(parent, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
_chkBoxViewer = new CheckboxTableViewer(table);
_chkBoxViewer.setContentProvider(new ColTableContentProvider());
_chkBoxViewer.setLabelProvider(new ColTableLabelProvider());
TableColumn column = new TableColumn(_chkBoxViewer.getTable(), SWT.LEFT);
column.setText("Column");
column.setWidth(100);
_chkBoxViewer.getTable().setHeaderVisible(true);
_chkBoxViewer.setInput("x");
final int firstColIdx = _allowFixedColumns ? 0 : _table.getFixedColumns();
for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
IColumn col = _table.getTableModel().getColumn(i);
_chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
}
table.getColumn(0).pack();
table.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
TableItem item = (TableItem) event.item;
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (_allowFixedColumns || idx >= _table.getFixedColumns()) {
_tvs.setColumnVisible(col, item.getChecked());
} else {
_chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
}
}
}
});
Button upButton = new Button(panel, SWT.PUSH);
upButton.setText("up");
upButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (idx > firstColIdx) {
_tvs.getSortedColumns().remove(col);
_tvs.getSortedColumns().add(idx - 1, col);
_table.updateColumnList();
_table.redraw();
_chkBoxViewer.refresh();
}
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
Button downButton = new Button(panel, SWT.PUSH);
downButton.setText("down");
downButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (idx < _tvs.getSortedColumns().size() - 1) {
_tvs.getSortedColumns().remove(col);
_tvs.getSortedColumns().add(idx + 1, col);
_table.updateColumnList();
_table.redraw();
_chkBoxViewer.refresh();
}
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
return panel;
}
use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.
the class TableHierarchicalExample method createControls.
/**
* Create the controls that compose the console test.
*
*/
protected void createControls(IHierarchicalJaretTableModel hierarchicalModel) {
GridLayout gl = new GridLayout();
gl.numColumns = 1;
_shell.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
_jt = new JaretTable(_shell, SWT.V_SCROLL | SWT.H_SCROLL);
_jt.setLayoutData(gd);
IHierarchicalJaretTableModel hmodel = hierarchicalModel;
if (hierarchicalModel == null) {
ITableNode root = new DummyTableNode("tn1", "tn1", "Root", "This the root node");
ITableNode r1 = new DummyTableNode("tn11", "tn12", "1", "Child 1 of the root");
ITableNode r2 = new DummyTableNode("tn12", "tn12", "2", "Child 2 of the root");
ITableNode r3 = new DummyTableNode("tn13", "tn13", "3", "Child 3 of the root");
root.addNode(r1);
root.addNode(r2);
root.addNode(r3);
r1.addNode(new DummyTableNode("tn111", "tn111", "1", "A second level child"));
r1.addNode(new DummyTableNode("tn112", "tn112", "2", "Another second level child"));
ITableNode n1 = new DummyTableNode("tn131", "tn131", "1", "A second level child");
r3.addNode(n1);
ITableNode n2 = new DummyTableNode("tn132", "tn132", "2", "Another second level child");
r3.addNode(n2);
n1.addNode(new DummyTableNode("tn1311", "tn1311", "1", "A third level child"));
n1.addNode(new DummyTableNode("tn1312", "tn1312", "2", "Another third level child"));
DefaultHierarchicalTableModel dhmodel = new DefaultHierarchicalTableModel(root);
hmodel = dhmodel;
if (SUPPORT_DND) {
// init the simple drag and drop handling
initDND(_jt, _shell);
}
}
_jt.setTableModel(hmodel);
StdHierarchicalTableModel model = (StdHierarchicalTableModel) _jt.getTableModel();
IColumn hcol = new HierarchyColumn();
// create and setup hierarchy renderer
final TableHierarchyRenderer hierarchyRenderer = new TableHierarchyRenderer();
hierarchyRenderer.setLabelProvider(new LabelProvider());
hierarchyRenderer.setDrawIcons(true);
hierarchyRenderer.setDrawLabels(true);
_jt.registerCellRenderer(hcol, hierarchyRenderer);
model.addColumn(hcol);
model.addColumn(new PropCol("b1", "column 1", "B1"));
model.addColumn(new PropCol("t1", "column 2", "T1"));
model.addColumn(new PropCol("t2", "column 3", "T2"));
model.addColumn(new PropCol("t3", "column 4", "T3"));
JaretTableActionFactory af = new JaretTableActionFactory();
MenuManager mm = new MenuManager();
mm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_CONFIGURECOLUMNS));
_jt.setHeaderContextMenu(mm.createContextMenu(_jt));
MenuManager rm = new MenuManager();
rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTROWHEIGHT));
rm.add(af.createStdAction(_jt, JaretTableActionFactory.ACTION_OPTALLROWHEIGHTS));
_jt.setRowContextMenu(rm.createContextMenu(_jt));
TableControlPanel ctrlPanel = new TableControlPanel(_shell, SWT.NULL, _jt);
Label l = new Label(_shell, SWT.NONE);
l.setText("Level width:");
final Scale levelWidthScale = new Scale(_shell, SWT.HORIZONTAL);
levelWidthScale.setMaximum(40);
levelWidthScale.setMinimum(0);
levelWidthScale.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent ev) {
int val = levelWidthScale.getSelection();
hierarchyRenderer.setLevelWidth(val);
_jt.redraw();
}
});
}
Aggregations