Search in sources :

Example 1 with DefaultCellStyle

use of de.jaret.util.ui.table.renderer.DefaultCellStyle in project translationstudio8 by heartsome.

the class MultiLineListExample method createControls.

/**
     * Create the controls that compose the console test.
     * 
     */
protected void createControls() {
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    _shell.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    _jt = new JaretTable(_shell, SWT.V_SCROLL);
    _jt.setLayoutData(gd);
    if (_tableModel == null) {
        DefaultJaretTableModel model = new PropListeningTableModel();
        model.addRow(new DummyRow("r1", "line 1", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r2", "another first line", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r3", "and yet another one", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r5", "4444444444", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r6", "555555555", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r7", "6666666666", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r8", "7777777777", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        model.addRow(new DummyRow("r9", "88888888888", "line 2 adds more text", true, new Date(), MultiLineListExample.getImageRegistry().get("icon")));
        PropCol ct1 = new PropCol("t1", "column 1", "T1");
        ct1.setEditable(false);
        model.addColumn(ct1);
        _tableModel = model;
    }
    DefaultCellStyle cs = (DefaultCellStyle) _jt.getTableViewState().getCellStyleProvider().getDefaultCellStyle().copy();
    cs.setBorderConfiguration(new DefaultBorderConfiguration(0, 0, 0, 0));
    _jt.getTableViewState().getCellStyleProvider().setColumnCellStyle(_tableModel.getColumn(0), cs);
    _jt.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.FIXED);
    // has to be replaced
    for (int i = 0; i < _tableModel.getRowCount(); i++) {
        _jt.getTableViewState().setRowHeight(_tableModel.getRow(i), 60);
    }
    // _jt.getTableViewState().setColumnResizeMode(ITableViewState.ColumnResizeMode.ALL);
    _jt.setHeaderHeight(0);
    _jt.registerCellRenderer(_tableModel.getColumn(0), new MultilineListCellRenderer());
    _jt.setTableModel(_tableModel);
    _jt.getTableViewState().setColumnWidth(_tableModel.getColumn(0), 230);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) DummyRow(de.jaret.examples.table.DummyRow) DefaultCellStyle(de.jaret.util.ui.table.renderer.DefaultCellStyle) PropCol(de.jaret.util.ui.table.model.PropCol) JaretTable(de.jaret.util.ui.table.JaretTable) DefaultJaretTableModel(de.jaret.util.ui.table.model.DefaultJaretTableModel) GridData(org.eclipse.swt.layout.GridData) PropListeningTableModel(de.jaret.util.ui.table.model.PropListeningTableModel) DefaultBorderConfiguration(de.jaret.util.ui.table.renderer.DefaultBorderConfiguration) Date(java.util.Date)

Example 2 with DefaultCellStyle

use of de.jaret.util.ui.table.renderer.DefaultCellStyle in project translationstudio8 by heartsome.

the class TableExample method createControls.

/**
     * Create the controls that compose the console test.
     * 
     */
protected void createControls() {
    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);
    if (_tableModel == null) {
        DefaultJaretTableModel model = new PropListeningTableModel();
        model.addRow(new DummyRow("r1", "The quick brown fox jumps over the crazy dog.", "Mars", true, new Date(), TableExample.getImageRegistry().get("splash")));
        model.addRow(new DummyRow("r2", "Dogma i am god", "Venus", true, new Date()));
        model.addRow(new DummyRow("r3", "Wenn der kleine Blindtext einmal gro� und wichtig geworden ist, wird er bedeutungsschwanger die Welt erorbern.", "Jupiter", true, new Date(), TableExample.getImageRegistry().get("keyboard")));
        model.addRow(new DummyRow("r4", "wewe we wew e we we we w ewe", "Uranus", true, new Date()));
        model.addRow(new DummyRow("r5", "sdjg sd jhgd dsh hjsgfjhgdf", "Pluto", true, new Date()));
        model.addRow(new DummyRow("r6", "wewe we wew e we we we w ewe", "Earth", true, new Date()));
        model.addRow(new DummyRow("r7", "wewe we wew e we we we w ewe", "Mars", false, new Date()));
        model.addRow(new DummyRow("r8", "wewe we wew e we we we w ewe", "Sun", false, new Date()));
        model.addRow(new DummyRow("r9", "wewe we wew e we we we w ewe", "Earth", true, new Date()));
        model.addRow(new DummyRow("ra", "wewe we wew e we we we w ewe", "Saturn", true, new Date()));
        model.addRow(new DummyRow("rb", "wewe we wew e we we we w ewe", "Saturn", true, new Date()));
        model.addRow(new DummyRow("rc", "wewe we wew e we we we w ewe", "Pluto", true, new Date()));
        model.addRow(new DummyRow("rd", "wewe we wew e we we we w ewe", "Jupiter", true, new Date()));
        model.addRow(new DummyRow("re", "This is the last row in the sort order of the model!", "Mars", true, new Date()));
        IColumn ct1 = new PropCol("t1", "column 1", "T1");
        model.addColumn(ct1);
        model.addColumn(new PropCol("d1", "Date", "D1"));
        model.addColumn(new PropCol("t2", "column 2", "T2"));
        model.addColumn(new PropCol("t3", "column 3", "T3"));
        model.addColumn(new PropCol("b1", "column 4", "B1"));
        model.addColumn(new PropCol("i1", "column 5", "Img"));
        model.addColumn(new PropCol("integer", "column 6", "Integer", Integer.class));
        model.addColumn(new PropCol("integer2", "Integer", "Integer", Integer.class));
        model.addColumn(new PropCol("integer3", "Smiley", "Integer", Integer.class));
        model.addColumn(new PropCol("Risk", "Risk", "Risk"));
        model.addColumn(new PropCol("RiskProb", "RProb", "RiskProb"));
        model.addColumn(new PropCol("RiskSeverity", "RSeverity", "RiskSeverity"));
        model.addColumn(new PropCol("Enum", "EnumTest", "EnumProperty"));
        model.addColumn(new PropCol("double", "Double", "Adouble"));
        model.addColumn(new PropCol("x1", "ComboEdit", "X1"));
        model.addColumn(new PropCol("Enum2", "EnumImage", "EnumProperty"));
        _tableModel = model;
    }
    DefaultCellStyle cs = (DefaultCellStyle) _jt.getTableViewState().getCellStyleProvider().getDefaultCellStyle().copy();
    cs.setHorizontalAlignment(ITableViewState.HAlignment.RIGHT);
    _jt.getTableViewState().getCellStyleProvider().setColumnCellStyle(_tableModel.getColumn(0), cs);
    _jt.getTableViewState().getCellStyleProvider().setColumnCellStyle(_tableModel.getColumn(7), cs);
    _jt.getTableViewState().getCellStyleProvider().setColumnCellStyle(_tableModel.getColumn(10), cs);
    _jt.registerCellRenderer(_tableModel.getColumn(2), new StyleTextCellRenderer("we", false));
    _jt.registerCellRenderer(_tableModel.getColumn(6), new BarCellRenderer());
    _jt.registerCellRenderer(_tableModel.getColumn(8), new SmileyCellRenderer());
    // risk renderer and editor
    _jt.registerCellRenderer(DummyRow.Risk.class, new RiskRenderer());
    _jt.registerCellEditor(DummyRow.Risk.class, new RiskCellEditor());
    // risk values 1 to 3
    _jt.registerCellEditor(_tableModel.getColumn(10), new IntegerCellEditor(1, 3));
    _jt.registerCellEditor(_tableModel.getColumn(11), new IntegerCellEditor(1, 3));
    ObjectImageRenderer oiRenderer = new ObjectImageRenderer();
    oiRenderer.addObjectRessourceNameMapping(DummyRow.TestEnum.ENUMVAL1, "1", "/de/jaret/examples/table/warning.gif");
    oiRenderer.addObjectRessourceNameMapping(DummyRow.TestEnum.ENUMVAL2, "2", "/de/jaret/examples/table/error.gif");
    oiRenderer.addObjectRessourceNameMapping(DummyRow.TestEnum.ENUMVAL3, "3", "/de/jaret/examples/table/information.gif");
    _jt.registerCellRenderer(_tableModel.getColumn(15), oiRenderer);
    List<Object> l = new ArrayList<Object>();
    l.add("first text");
    l.add("second text");
    l.add("third text");
    ObjectComboEditor oce = new ObjectComboEditor(l, null, true, "this is null");
    _jt.registerCellEditor(((DefaultJaretTableModel) _tableModel).getColumn("x1"), oce);
    _jt.setTableModel(_tableModel);
    // register autofilters
    _jt.registerAutoFilterForClass(Integer.class, SampleIntegerAutoFilter.class);
    _jt.registerAutoFilterForColumn(_tableModel.getColumn(2), SampleTextAutoFilter.class);
    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);
}
Also used : JaretTable(de.jaret.util.ui.table.JaretTable) DefaultJaretTableModel(de.jaret.util.ui.table.model.DefaultJaretTableModel) ArrayList(java.util.ArrayList) PropListeningTableModel(de.jaret.util.ui.table.model.PropListeningTableModel) JaretTableActionFactory(de.jaret.util.ui.table.util.action.JaretTableActionFactory) RiskCellEditor(de.jaret.examples.table.renderer.RiskCellEditor) GridLayout(org.eclipse.swt.layout.GridLayout) SmileyCellRenderer(de.jaret.util.ui.table.renderer.SmileyCellRenderer) IntegerCellEditor(de.jaret.util.ui.table.editor.IntegerCellEditor) ObjectImageRenderer(de.jaret.util.ui.table.renderer.ObjectImageRenderer) ObjectComboEditor(de.jaret.util.ui.table.editor.ObjectComboEditor) Date(java.util.Date) IColumn(de.jaret.util.ui.table.model.IColumn) DefaultCellStyle(de.jaret.util.ui.table.renderer.DefaultCellStyle) PropCol(de.jaret.util.ui.table.model.PropCol) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) BarCellRenderer(de.jaret.util.ui.table.renderer.BarCellRenderer) RiskRenderer(de.jaret.examples.table.renderer.RiskRenderer)

Aggregations

JaretTable (de.jaret.util.ui.table.JaretTable)2 DefaultJaretTableModel (de.jaret.util.ui.table.model.DefaultJaretTableModel)2 PropCol (de.jaret.util.ui.table.model.PropCol)2 PropListeningTableModel (de.jaret.util.ui.table.model.PropListeningTableModel)2 DefaultCellStyle (de.jaret.util.ui.table.renderer.DefaultCellStyle)2 Date (java.util.Date)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 DummyRow (de.jaret.examples.table.DummyRow)1 RiskCellEditor (de.jaret.examples.table.renderer.RiskCellEditor)1 RiskRenderer (de.jaret.examples.table.renderer.RiskRenderer)1 IntegerCellEditor (de.jaret.util.ui.table.editor.IntegerCellEditor)1 ObjectComboEditor (de.jaret.util.ui.table.editor.ObjectComboEditor)1 IColumn (de.jaret.util.ui.table.model.IColumn)1 BarCellRenderer (de.jaret.util.ui.table.renderer.BarCellRenderer)1 DefaultBorderConfiguration (de.jaret.util.ui.table.renderer.DefaultBorderConfiguration)1 ObjectImageRenderer (de.jaret.util.ui.table.renderer.ObjectImageRenderer)1 SmileyCellRenderer (de.jaret.util.ui.table.renderer.SmileyCellRenderer)1 JaretTableActionFactory (de.jaret.util.ui.table.util.action.JaretTableActionFactory)1 ArrayList (java.util.ArrayList)1