use of de.janrufmonitor.ui.jface.application.rendering.ITableCellEditorRenderer in project janrufmonitor by tbrandt77.
the class AbstractTableApplication method buildTableColumns.
private void buildTableColumns() {
Table t = ((TableViewer) viewer).getTable();
int columnCount = this.getTableColumnCount();
String[] columnHeader = new String[columnCount];
CellEditor[] editors = new CellEditor[columnCount];
ITableCellRenderer r = null;
for (int i = 0; i < columnCount; i++) {
columnHeader[i] = this.getColumnID(i);
// check renderer type
r = RendererRegistry.getInstance().getRenderer(columnHeader[i]);
if (r instanceof ITableCellEditorRenderer) {
switch(((ITableCellEditorRenderer) r).getType()) {
case 1:
editors[i] = new ComboBoxCellEditor(t, ((ITableCellEditorRenderer) r).getValues(), SWT.READ_ONLY);
break;
case 2:
editors[i] = new CheckboxCellEditor(t);
break;
default:
// editors[i] = new TextCellEditor(t);
editors[i] = new TextCellEditor(t);
}
} else {
// editors[i] = new TextCellEditor(t);
editors[i] = new TextCellEditor(t, SWT.WRAP);
}
}
((TableViewer) this.viewer).setColumnProperties(columnHeader);
((TableViewer) this.viewer).setCellEditors(editors);
((TableViewer) this.viewer).setCellModifier(new TableCellModifier(((TableViewer) viewer), this));
TableColumn[] cols = t.getColumns();
for (int i = 0; i < cols.length; i++) {
cols[i].dispose();
}
int columns = this.getTableColumnCount();
String id = "";
for (int i = 0; i < columns; i++) {
TableViewerColumn tc = new TableViewerColumn(((TableViewer) this.viewer), SWT.LEFT);
id = getColumnID(i);
ITableCellRenderer tr = RendererRegistry.getInstance().getRenderer(id);
tc.getColumn().setText((tr != null ? tr.getHeader() : ""));
tc.getColumn().setData(id);
if (tr != null && tr.isRenderImage())
tc.setLabelProvider(this.getImageCellLabelProvider(id));
else
tc.setLabelProvider(this.getTextCellLabelProvider(id));
tc.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
de.janrufmonitor.ui.jface.application.action.IAction action = getOrderAction();
if (action != null && action instanceof org.eclipse.jface.action.IAction) {
Event ev = new Event();
ev.widget = e.widget;
((org.eclipse.jface.action.IAction) action).runWithEvent(ev);
}
}
});
int width = Integer.parseInt(getConfiguration().getProperty(CFG_COLUMN_SIZE + id, "50"));
if (width > -1) {
tc.getColumn().setWidth(width);
}
tc.getColumn().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
if (e.widget instanceof TableColumn) {
TableColumn tc = (TableColumn) e.widget;
if (tc.getData() != null) {
String column = (String) tc.getData();
int width = tc.getWidth();
getConfiguration().setProperty(CFG_COLUMN_SIZE + column, Integer.toString(width));
storeConfiguration();
m_logger.info("Set column size to " + width);
}
}
}
});
}
OwnerDrawLabelProvider.setUpOwnerDraw(((TableViewer) this.viewer));
}
use of de.janrufmonitor.ui.jface.application.rendering.ITableCellEditorRenderer in project janrufmonitor by tbrandt77.
the class AbstractTreeTableApplication method buildTableColumns.
private void buildTableColumns() {
Tree t = ((TreeViewer) viewer).getTree();
int columnCount = this.getTableColumnCount();
String[] columnHeader = new String[columnCount];
CellEditor[] editors = new CellEditor[columnCount];
ITableCellRenderer r = null;
for (int i = 0; i < columnCount; i++) {
columnHeader[i] = this.getColumnID(i);
// check renderer type
r = RendererRegistry.getInstance().getRenderer(columnHeader[i]);
if (r instanceof ITableCellEditorRenderer) {
switch(((ITableCellEditorRenderer) r).getType()) {
case 1:
editors[i] = new ComboBoxCellEditor(t, ((ITableCellEditorRenderer) r).getValues(), SWT.READ_ONLY);
break;
case 2:
editors[i] = new CheckboxCellEditor(t);
break;
default:
// editors[i] = new TextCellEditor(t);
editors[i] = new TextCellEditor(t);
}
} else {
// editors[i] = new TextCellEditor(t);
editors[i] = new TextCellEditor(t, SWT.WRAP);
}
}
((TreeViewer) this.viewer).setColumnProperties(columnHeader);
((TreeViewer) this.viewer).setCellEditors(editors);
((TreeViewer) this.viewer).setCellModifier(new TableCellModifier(((TreeViewer) viewer), this));
TreeColumn[] cols = t.getColumns();
for (int i = 0; i < cols.length; i++) {
cols[i].dispose();
}
int columns = this.getTableColumnCount();
String id = "";
for (int i = 0; i < columns; i++) {
TreeViewerColumn tc = new TreeViewerColumn((TreeViewer) viewer, SWT.LEFT);
id = getColumnID(i);
ITableCellRenderer tr = RendererRegistry.getInstance().getRenderer(id);
tc.getColumn().setText((tr != null ? tr.getHeader() : ""));
tc.getColumn().setData(id);
tc.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
de.janrufmonitor.ui.jface.application.action.IAction action = getOrderAction();
if (action != null && action instanceof org.eclipse.jface.action.IAction) {
Event ev = new Event();
ev.widget = e.widget;
((org.eclipse.jface.action.IAction) action).runWithEvent(ev);
}
}
});
tc.setLabelProvider(this.getTextCellLabelProvider(id));
int width = Integer.parseInt(getConfiguration().getProperty(CFG_COLUMN_SIZE + id, "50"));
if (width > -1) {
tc.getColumn().setWidth(width);
}
tc.getColumn().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
if (e.widget instanceof TreeColumn) {
TreeColumn tc = (TreeColumn) e.widget;
if (tc.getData() != null) {
String column = (String) tc.getData();
int width = tc.getWidth();
getConfiguration().setProperty(CFG_COLUMN_SIZE + column, Integer.toString(width));
storeConfiguration();
m_logger.info("Set column size to " + width);
}
}
}
});
}
}
Aggregations