Search in sources :

Example 1 with DummyRow

use of de.jaret.examples.table.DummyRow 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 DummyRow

use of de.jaret.examples.table.DummyRow in project translationstudio8 by heartsome.

the class RiskCellEditor method checkClick.

private boolean checkClick(JaretTable table, IRow row, IColumn column, Rectangle rect, int x, int y) {
    if (_forceSquare) {
        int a = Math.min(rect.width, rect.height);
        Rectangle nrect = new Rectangle(0, 0, a, a);
        nrect.x = rect.x + (rect.width - a) / 2;
        nrect.y = rect.y + (rect.height - a) / 2;
        rect = nrect;
    }
    if (!rect.contains(x, y)) {
        return false;
    }
    int width = rect.width;
    int height = rect.height;
    int sWidth = (width - RiskRenderer.AXISOFFSET) / 3;
    int sHeight = (height - RiskRenderer.AXISOFFSET) / 3;
    int xx = x - rect.x;
    int yy = y - rect.y;
    int prob = xx / sWidth;
    int sev = yy / sHeight;
    if (prob >= 0 && sev >= 0) {
        sev = 2 - sev;
        Risk risk = ((DummyRow) row).new Risk(prob + 1, sev + 1);
        column.setValue(row, risk);
        return true;
    }
    return false;
}
Also used : DummyRow(de.jaret.examples.table.DummyRow) Rectangle(org.eclipse.swt.graphics.Rectangle) Risk(de.jaret.examples.table.DummyRow.Risk)

Example 3 with DummyRow

use of de.jaret.examples.table.DummyRow in project translationstudio8 by heartsome.

the class MultilineListCellRenderer method draw.

public void draw(GC gc, JaretTable jaretTable, ICellStyle cellStyle, Rectangle drawingArea, IRow row, IColumn column, boolean drawFocus, boolean selected, boolean printing) {
    drawBackground(gc, drawingArea, cellStyle, selected, printing);
    Rectangle drect = drawBorder(gc, cellStyle, drawingArea, printing);
    Rectangle rect = applyInsets(drect);
    DummyRow dr = (DummyRow) row;
    Image img = dr.getImg();
    int x = rect.x + 4;
    int y = rect.y + (rect.height - img.getBounds().height) / 2;
    gc.drawImage(img, x, y);
    Font save = gc.getFont();
    gc.setFont(boldFont);
    gc.drawString(dr.getT2(), rect.x + 70, y + 5);
    gc.setFont(normalFont);
    gc.drawString(dr.getT3(), rect.x + 70, y + 25);
    gc.setFont(save);
    if (drawFocus) {
        drawFocus(gc, drawingArea);
    }
    drawSelection(gc, drawingArea, cellStyle, selected, printing);
}
Also used : DummyRow(de.jaret.examples.table.DummyRow) Rectangle(org.eclipse.swt.graphics.Rectangle) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font)

Example 4 with DummyRow

use of de.jaret.examples.table.DummyRow in project translationstudio8 by heartsome.

the class RiskCellEditor method rollSeverity.

private void rollSeverity(IRow row, IColumn column) {
    DummyRow.Risk risk = (Risk) column.getValue(row);
    int newSev = risk.getRiskSeverity() + 1;
    newSev = newSev > 3 ? 1 : newSev;
    column.setValue(row, ((DummyRow) row).new Risk(risk.getRiskProb(), newSev));
}
Also used : DummyRow(de.jaret.examples.table.DummyRow) Risk(de.jaret.examples.table.DummyRow.Risk) Risk(de.jaret.examples.table.DummyRow.Risk)

Example 5 with DummyRow

use of de.jaret.examples.table.DummyRow in project translationstudio8 by heartsome.

the class RiskCellEditor method rollProb.

private void rollProb(IRow row, IColumn column) {
    DummyRow.Risk risk = (Risk) column.getValue(row);
    int newProb = risk.getRiskProb() + 1;
    newProb = newProb > 3 ? 1 : newProb;
    column.setValue(row, ((DummyRow) row).new Risk(newProb, risk.getRiskSeverity()));
}
Also used : DummyRow(de.jaret.examples.table.DummyRow) Risk(de.jaret.examples.table.DummyRow.Risk) Risk(de.jaret.examples.table.DummyRow.Risk)

Aggregations

DummyRow (de.jaret.examples.table.DummyRow)5 Risk (de.jaret.examples.table.DummyRow.Risk)3 Rectangle (org.eclipse.swt.graphics.Rectangle)2 JaretTable (de.jaret.util.ui.table.JaretTable)1 DefaultJaretTableModel (de.jaret.util.ui.table.model.DefaultJaretTableModel)1 PropCol (de.jaret.util.ui.table.model.PropCol)1 PropListeningTableModel (de.jaret.util.ui.table.model.PropListeningTableModel)1 DefaultBorderConfiguration (de.jaret.util.ui.table.renderer.DefaultBorderConfiguration)1 DefaultCellStyle (de.jaret.util.ui.table.renderer.DefaultCellStyle)1 Date (java.util.Date)1 Font (org.eclipse.swt.graphics.Font)1 Image (org.eclipse.swt.graphics.Image)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1