Search in sources :

Example 1 with JaretTable

use of de.jaret.util.ui.table.JaretTable 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();
        }
    });
}
Also used : JaretTable(de.jaret.util.ui.table.JaretTable) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) JaretTableActionFactory(de.jaret.util.ui.table.util.action.JaretTableActionFactory) Scale(org.eclipse.swt.widgets.Scale) DefaultHierarchicalTableModel(de.jaret.util.ui.table.model.DefaultHierarchicalTableModel) TableHierarchyRenderer(de.jaret.util.ui.table.renderer.TableHierarchyRenderer) GridLayout(org.eclipse.swt.layout.GridLayout) IColumn(de.jaret.util.ui.table.model.IColumn) HierarchyColumn(de.jaret.util.ui.table.model.HierarchyColumn) PropCol(de.jaret.util.ui.table.model.PropCol) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IHierarchicalJaretTableModel(de.jaret.util.ui.table.model.IHierarchicalJaretTableModel) StdHierarchicalTableModel(de.jaret.util.ui.table.model.StdHierarchicalTableModel) ITableNode(de.jaret.util.ui.table.model.ITableNode) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 2 with JaretTable

use of de.jaret.util.ui.table.JaretTable 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 3 with JaretTable

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

the class SimpleModelExample 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) {
        SimpleJaretTableModel model = new SimpleJaretTableModel();
        for (int x = 0; x <= NUMCOLS; x++) {
            model.setHeaderLabel(x, "" + x);
            for (int y = 0; y <= NUMROWS; y++) {
                model.setValueAt(x, y, x + "/" + y);
            }
        }
        _tableModel = model;
    }
    _jt.setTableModel(_tableModel);
    // set rowheight mode to variable .. optimal would be quite expensive on each col resize
    _jt.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
    for (int i = 0; i < NUMCOLS; i++) {
        IColumn col = _tableModel.getColumn(i);
        _jt.getTableViewState().setColumnWidth(col, 40);
    }
    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 : GridLayout(org.eclipse.swt.layout.GridLayout) IColumn(de.jaret.util.ui.table.model.IColumn) JaretTable(de.jaret.util.ui.table.JaretTable) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) SimpleJaretTableModel(de.jaret.util.ui.table.model.simple.SimpleJaretTableModel) JaretTableActionFactory(de.jaret.util.ui.table.util.action.JaretTableActionFactory)

Example 4 with JaretTable

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

the class ConcordanceSearchDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    tparent = (Composite) super.createDialogArea(parent);
    GridLayoutFactory.swtDefaults().spacing(0, 0).extendedMargins(SWT.DEFAULT, SWT.DEFAULT, 0, 0).applyTo(tparent);
    // tparent.setLayout(new GridLayout());
    GridData parentData = new GridData(GridData.FILL_BOTH);
    parentData.widthHint = 1058;
    tparent.setLayoutData(parentData);
    Group groupSearch = new Group(tparent, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(5, 5).numColumns(3).equalWidth(false).applyTo(groupSearch);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupSearch);
    groupSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupSearch"));
    Label lblSearch = new Label(groupSearch, SWT.NONE);
    lblSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.lblSearch"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSearch);
    cmbSearch = new Combo(groupSearch, SWT.BORDER | SWT.DROP_DOWN);
    cmbSearch.setText(strSearchText == null ? "" : InnerTagUtil.resolveTag(strSearchText));
    GridData txtData = new GridData();
    // 解决在 Windows 下文本框高度太小的问题
    // txtData.heightHint = 20;
    txtData.widthHint = 610;
    cmbSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnSearch = new Button(groupSearch, SWT.PUSH);
    btnSearch.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnSearch"));
    new Label(groupSearch, SWT.NONE);
    Composite compCondition = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(compCondition);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compCondition);
    btnIsCaseSensitive = new Button(compCondition, SWT.CHECK);
    btnIsCaseSensitive.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnIsCaseSensitive"));
    GridDataFactory.swtDefaults().applyTo(btnIsCaseSensitive);
    btnIsIgnoreMark = new Button(compCondition, SWT.CHECK);
    btnIsIgnoreMark.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnIsIgnoreMark"));
    btnIsIgnoreMark.setSelection(true);
    GridDataFactory.swtDefaults().applyTo(btnIsIgnoreMark);
    btnApplyRegularExpression = new Button(compCondition, SWT.CHECK);
    btnApplyRegularExpression.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnApplyRegularExpression"));
    GridDataFactory.swtDefaults().applyTo(btnApplyRegularExpression);
    Label lblTM = new Label(groupSearch, SWT.NONE);
    lblTM.setText(Messages.getString("dialog.ConcordanceSearchDialog.lblDB"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTM);
    Composite compDB = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(compDB);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compDB);
    cmbDatabase = new Combo(compDB, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).applyTo(cmbDatabase);
    initDatabaseCombo();
    btnSelectLang = new Button(compDB, SWT.RIGHT);
    // GridData data = new GridData();
    // data.widthHint = 150;
    // data.heightHint = 27;
    // btnSelectLang.setLayoutData(data);
    // btnSelectLang.setImage(Activator.getImageDescriptor(ImageConstants.CONCORDANCE_SELECT_LANG).createImage());
    // btnSelectLang.addPaintListener(new PaintListener() {
    // public void paintControl(PaintEvent e) {
    // e.gc.drawText(Messages.getString("dialog.ConcordanceSearchDialog.btnSelectLang"), 5, 5,
    // SWT.DRAW_TRANSPARENT);
    // }
    // });
    btnSelectLang.setText(Messages.getString("dialog.ConcordanceSearchDialog.btnSelectLang"));
    initLanguageMenu();
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Group groupFilter = new Group(tparent, SWT.None);
    GridLayoutFactory.swtDefaults().margins(5, 5).applyTo(groupFilter);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupFilter);
    groupFilter.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupFilter"));
    cmpExpandableFilter = toolkit.createExpandableComposite(groupFilter, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
    cmpExpandableFilter.setText(Messages.getString("dialog.ConcordanceSearchDialog.cmpExpandableFilter"));
    Composite cmpFilter = toolkit.createComposite(cmpExpandableFilter);
    cmpFilter.setLayout(new GridLayout(3, false));
    GridDataFactory.fillDefaults().grab(true, false).applyTo(cmpFilter);
    cmpExpandableFilter.setBackground(tparent.getBackground());
    cmpExpandableFilter.setClient(cmpFilter);
    cmpFilter.setBackground(tparent.getBackground());
    cmbSrcOrTgt = new Combo(cmpFilter, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(cmbSrcOrTgt);
    cmbSrcOrTgt.setItems(new String[] { Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt1"), Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt2") });
    cmbSrcOrTgt.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt1"), strSrcLang);
    cmbSrcOrTgt.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbSrcOrTgt2"), strTgtLang);
    cmbContain = new Combo(cmpFilter, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).applyTo(cmbContain);
    cmbContain.setItems(new String[] { Messages.getString("dialog.ConcordanceSearchDialog.cmbContain1"), Messages.getString("dialog.ConcordanceSearchDialog.cmbContain2") });
    cmbContain.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbContain1"), "LIKE");
    cmbContain.setData(Messages.getString("dialog.ConcordanceSearchDialog.cmbContain2"), "NOT LIKE");
    cmbFilter = new Combo(cmpFilter, SWT.BORDER | SWT.DROP_DOWN);
    GridDataFactory.swtDefaults().hint(410, SWT.DEFAULT).applyTo(cmbFilter);
    cmpExpandableFilter.setExpanded(false);
    groupTable = new Group(tparent, SWT.None);
    GridLayoutFactory.swtDefaults().margins(5, 5).spacing(0, 2).numColumns(1).equalWidth(false).applyTo(groupTable);
    GridDataFactory.fillDefaults().hint(740, 450).applyTo(groupTable);
    groupTable.setText(Messages.getString("dialog.ConcordanceSearchDialog.groupTable"));
    groupTable.setBackground(groupTable.getParent().getBackground());
    groupTable.setBackgroundMode(SWT.INHERIT_FORCE);
    cmpExpandableFilter.addExpansionListener(new IExpansionListener() {

        public void expansionStateChanging(ExpansionEvent e) {
            layoutExpandable();
        }

        public void expansionStateChanged(ExpansionEvent e) {
            layoutExpandable();
        }
    });
    jTable = new JaretTable(groupTable, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL) {

        public void rowSelectionAdded(IRow row) {
            super.rowSelectionAdded(row);
        // XPropRow propRow = (XPropRow) row;
        // HashMap<String, String> map = (HashMap<String, String>) propRow.getDataMap();
        // String strChangeDate = map.get("changeDate");
        // // strChangeDate = checkString(strChangeDate == null || strChangeDate.equals("") ? "" :
        // CommonFunctions
        // // .retGMTdate(strChangeDate));
        // strChangeDate = checkString(strChangeDate == null || strChangeDate.equals("") ? "" : strChangeDate);
        // String strChangeId = checkString(map.get("changeId"));
        // String strDbInfo = checkString(map.get("dbType")) + "/" + checkString(map.get("severName")) + "/"
        // + checkString(map.get("dbName"));
        // String strProjectInfo = checkString(map.get("projectRef"));
        // String strJobInfo = checkString(map.get("jobRef"));
        // MessageFormat mf = new MessageFormat(strMsg);
        // lblInfo.setText(mf.format(new String[] { strChangeDate, strChangeId, strDbInfo, strProjectInfo,
        // strJobInfo }));
        }
    };
    jTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    ((DefaultTableHeaderRenderer) jTable.getHeaderRenderer()).setAlignment(DefaultTableHeaderRenderer.Alignment.LEFT);
    jTable.setHeaderResizeAllowed(false);
    jTable.setAllowSorting(false);
    jTable.registerCellEditor(String.class, new ReadOnlyTextCellEditor(true));
    PropListeningTableModel model = new PropListeningTableModel();
    ListPropCol colTag = new ListPropCol("Flag", Messages.getString("dialog.ConcordanceSearchDialog.colTag"), "Flag", -1);
    model.addColumn(colTag);
    jTable.getTableViewState().setColumnWidth(colTag, 55);
    if (strSrcLang != null) {
        PropCol ct1 = new PropCol("Source", strSrcLang, "Source");
        ct1.setEditable(false);
        model.addColumn(ct1);
        jTable.getTableViewState().setColumnWidth(ct1, 325);
    }
    if (strTgtLang != null) {
        PropCol col = new PropCol("Target", strTgtLang, "Target");
        model.addColumn(col);
        jTable.getTableViewState().setColumnWidth(col, 325);
    }
    for (int i = 0; i < lstLangs.size(); i++) {
        String strLang = lstLangs.get(i);
        ListPropCol col = new ListPropCol("Target", strLang, "LstTarget", i);
        col.setEditable(true);
        model.addColumn(col);
        jTable.getTableViewState().setColumnWidth(col, 0);
    }
    PropCol attrCol = new PropCol("Attribute", "Attribute", "Attribute");
    attrCol.setEditable(false);
    model.addColumn(attrCol);
    jTable.getTableViewState().setColumnWidth(attrCol, 325);
    tableModel = model;
    jTable.setHeaderHeight(20);
    jTable.setTableModel(tableModel);
    jTable.setDrawHeader(true);
    // jTable.getTableViewState().setRowHeightMode(ITableViewState.RowHeightMode.VARIABLE);
    jTable.registerCellRenderer(tableModel.getColumn(2), new TextCellRenderer());
    colCount = jTable.getColumnCount();
    for (int colNum = colCount - 2; colNum >= 3; colNum--) {
        IColumn column = jTable.getColumn(colNum);
        jTable.registerCellRenderer(tableModel.getColumn(colNum), new TextCellRenderer());
        jTable.getTableViewState().setColumnVisible(column, false);
    }
    ImageCellRender imgRender = new ImageCellRender();
    // 表示需要删除标记(记录有标记时要显示的图片)
    imgRender.addImageDescriptorMapping(Boolean.FALSE, "1", Activator.getImageDescriptor(ImageConstants.TAG_DELETE));
    // 表示需要添加标记(记录有标记时要显示的图片)
    imgRender.addImageDescriptorMapping(Boolean.TRUE, "2", Activator.getImageDescriptor(ImageConstants.TAG_ADD));
    jTable.registerCellRenderer(tableModel.getColumn(0), imgRender);
    jTable.getSelectionModel().setOnlyRowSelectionAllowed(true);
    jTable.getSelectionModel().setMultipleSelectionAllowed(false);
    Composite cmpPage = new Composite(groupTable, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(3, 0).extendedMargins(0, 5, 0, 0).numColumns(3).equalWidth(false).applyTo(cmpPage);
    cmpPage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    cmpPage.setBackground(cmpPage.getParent().getBackground());
    cmpPage.setBackgroundMode(SWT.INHERIT_FORCE);
    new Label(cmpPage, SWT.None).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar toolBar = new ToolBar(cmpPage, SWT.NO_FOCUS | SWT.FLAT);
    btnFirst = new ToolItem(toolBar, SWT.PUSH);
    btnFirst.setImage(firstImage);
    btnPre = new ToolItem(toolBar, SWT.NONE);
    btnPre.setImage(preImage);
    btnNext = new ToolItem(toolBar, SWT.NONE);
    btnNext.setImage(nextImage);
    btnLast = new ToolItem(toolBar, SWT.NONE);
    btnLast.setImage(lastImage);
    txtPage = new Text(cmpPage, SWT.BORDER);
    GridDataFactory.fillDefaults().hint(80, SWT.DEFAULT).applyTo(txtPage);
    readDialogSettings();
    updateCombo(cmbSearch, lstSearchHistory);
    updateCombo(cmbFilter, lstFilterHistory);
    if (!strSearchText.equals("")) {
        cmbSearch.setText(strSearchText);
    } else if (lstSearchHistory != null && lstSearchHistory.size() > 0) {
        cmbSearch.setText(lstSearchHistory.get(0));
    }
    cmbSearch.setSelection(new Point(0, cmbSearch.getText().length()));
    if (lstFilterHistory != null && lstFilterHistory.size() > 0) {
        cmbFilter.setText(lstFilterHistory.get(0));
        cmbFilter.setSelection(new Point(0, cmbFilter.getText().length()));
    }
    initListener();
    return parent;
}
Also used : StyleTextCellRenderer(net.heartsome.cat.ts.ui.jaret.renderer.StyleTextCellRenderer) TextCellRenderer(de.jaret.util.ui.table.renderer.TextCellRenderer) Group(org.eclipse.swt.widgets.Group) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) JaretTable(de.jaret.util.ui.table.JaretTable) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) PropListeningTableModel(de.jaret.util.ui.table.model.PropListeningTableModel) ImageCellRender(net.heartsome.cat.ts.ui.jaret.renderer.ImageCellRender) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ToolItem(org.eclipse.swt.widgets.ToolItem) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IRow(de.jaret.util.ui.table.model.IRow) IColumn(de.jaret.util.ui.table.model.IColumn) PropCol(de.jaret.util.ui.table.model.PropCol) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) DefaultTableHeaderRenderer(de.jaret.util.ui.table.renderer.DefaultTableHeaderRenderer) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 5 with JaretTable

use of de.jaret.util.ui.table.JaretTable 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)5 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 IColumn (de.jaret.util.ui.table.model.IColumn)4 PropCol (de.jaret.util.ui.table.model.PropCol)4 PropListeningTableModel (de.jaret.util.ui.table.model.PropListeningTableModel)3 JaretTableActionFactory (de.jaret.util.ui.table.util.action.JaretTableActionFactory)3 MenuManager (org.eclipse.jface.action.MenuManager)3 DefaultJaretTableModel (de.jaret.util.ui.table.model.DefaultJaretTableModel)2 DefaultCellStyle (de.jaret.util.ui.table.renderer.DefaultCellStyle)2 Date (java.util.Date)2 Label (org.eclipse.swt.widgets.Label)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 DefaultHierarchicalTableModel (de.jaret.util.ui.table.model.DefaultHierarchicalTableModel)1 HierarchyColumn (de.jaret.util.ui.table.model.HierarchyColumn)1 IHierarchicalJaretTableModel (de.jaret.util.ui.table.model.IHierarchicalJaretTableModel)1