Search in sources :

Example 1 with GridColumn

use of org.eclipse.nebula.widgets.grid.GridColumn in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    tparent.setLayout(new GridLayout());
    GridData parentData = new GridData(GridData.FILL_BOTH);
    parentData.heightHint = 600;
    parentData.widthHint = 775;
    tparent.setLayoutData(parentData);
    Group groupSearch = new Group(tparent, SWT.None);
    groupSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.groupSearch"));
    GridLayoutFactory.swtDefaults().margins(5, 5).numColumns(3).equalWidth(false).applyTo(groupSearch);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupSearch);
    Label lblSearch = new Label(groupSearch, SWT.NONE);
    lblSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.lblSearch"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSearch);
    cmbSearch = new Combo(groupSearch, SWT.DROP_DOWN | SWT.BORDER);
    cmbSearch.setText(strSearchText == null ? "" : strSearchText);
    GridData txtData = new GridData();
    // 解决在 Windows 下文本框高度太小的问题
    // txtData.heightHint = 20;
    txtData.widthHint = 590;
    cmbSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnSearch = new Button(groupSearch, SWT.PUSH);
    btnSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.btnSearch"));
    new Label(groupSearch, SWT.NONE);
    Composite compCondition = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(8, 0).numColumns(4).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.TermBaseSearchDialog.btnIsCaseSensitive"));
    GridDataFactory.swtDefaults().applyTo(btnIsCaseSensitive);
    btnIsIgnoreMark = new Button(compCondition, SWT.CHECK);
    btnIsIgnoreMark.setText(Messages.getString("dialog.TermBaseSearchDialog.btnIsIgnoreMark"));
    btnIsIgnoreMark.setSelection(true);
    GridDataFactory.swtDefaults().applyTo(btnIsIgnoreMark);
    btnApplyRegularExpression = new Button(compCondition, SWT.CHECK);
    btnApplyRegularExpression.setText(Messages.getString("dialog.TermBaseSearchDialog.btnApplyRegularExpression"));
    GridDataFactory.swtDefaults().applyTo(btnApplyRegularExpression);
    Composite compMatchQuality = new Composite(compCondition, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).margins(0, 0).spacing(0, 0).numColumns(3).equalWidth(false).applyTo(compMatchQuality);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(true, false).applyTo(compMatchQuality);
    new Label(compMatchQuality, SWT.NONE).setText(Messages.getString("dialog.TermBaseSearchDialog.lblQuality"));
    spiMatchQuality = new Spinner(compMatchQuality, SWT.BORDER);
    spiMatchQuality.setMaximum(100);
    spiMatchQuality.setMinimum(30);
    spiMatchQuality.setIncrement(5);
    spiMatchQuality.setSelection(100);
    GridData spinnaData = new GridData();
    spinnaData.widthHint = 23;
    spiMatchQuality.setLayoutData(spinnaData);
    new Label(compMatchQuality, SWT.NONE).setText("%");
    Label lblTB = new Label(groupSearch, SWT.NONE);
    lblTB.setText(Messages.getString("dialog.TermBaseSearchDialog.lblTB"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTB);
    Composite cmpTB = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(8, 0).numColumns(2).equalWidth(false).applyTo(cmpTB);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(cmpTB);
    cmbDatabase = new Combo(cmpTB, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(120, SWT.DEFAULT).applyTo(cmbDatabase);
    initDatabaseCombo();
    btnSelectLang = new Button(cmpTB, 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.TermBaseSearchDialog.btnSelectLang"), 5, 5,
    // SWT.DRAW_TRANSPARENT);
    // }
    // });
    btnSelectLang.setText(Messages.getString("dialog.TermBaseSearchDialog.btnSelectLang"));
    initLanguageMenu();
    Group groupTable = new Group(tparent, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(10, 10).applyTo(groupTable);
    groupTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    // GridDataFactory.fillDefaults().hint(700, 440).applyTo(groupTable);
    groupTable.setText(Messages.getString("dialog.TermBaseSearchDialog.groupTable"));
    grid = new Grid(groupTable, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    grid.setHeaderVisible(true);
    grid.setLinesVisible(true);
    grid.setLayoutData(new GridData(GridData.FILL_BOTH));
    grid.setAutoHeight(true);
    grid.setRowsResizeable(true);
    grid.setWordWrapHeader(true);
    if (strSrcLang != null) {
        columnSrcLang = new GridColumn(grid, SWT.NONE);
        srcCellRenderer.setVerticalAlignment(SWT.CENTER);
        srcCellRenderer.setStyleColumn(0);
        columnSrcLang.setCellRenderer(srcCellRenderer);
        columnSrcLang.setText(strSrcLang);
        columnSrcLang.setWidth(365);
        columnSrcLang.setWordWrap(true);
    }
    if (strTgtLang != null) {
        GridColumn columnTgtLang = new GridColumn(grid, SWT.NONE);
        TBSearchCellRenderer cellRenderer = new TBSearchCellRenderer();
        cellRenderer.setVerticalAlignment(SWT.CENTER);
        columnTgtLang.setCellRenderer(cellRenderer);
        columnTgtLang.setText(strTgtLang);
        columnTgtLang.setWidth(365);
        columnTgtLang.setWordWrap(true);
    }
    for (String strLang : lstLangs) {
        final GridColumn column = new GridColumn(grid, SWT.NONE);
        TBSearchCellRenderer cellRenderer = new TBSearchCellRenderer();
        cellRenderer.setVerticalAlignment(SWT.CENTER);
        column.setCellRenderer(cellRenderer);
        column.setText(strLang);
        column.setWidth(0);
        column.setWordWrap(true);
    }
    readDialogSettings();
    setEnabled();
    updateCombo(cmbSearch, lstSearchHistory);
    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()));
    initListener();
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) Grid(org.eclipse.nebula.widgets.grid.Grid) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn)

Example 2 with GridColumn

use of org.eclipse.nebula.widgets.grid.GridColumn in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method readDialogSettings.

private void readDialogSettings() {
    IDialogSettings ids = getDialogSettings();
    btnIsCaseSensitive.setSelection(ids.getBoolean("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.caseSensitive"));
    //	btnIsCaseSensitive.setSelection(preferenceStore.getBoolean(TBPreferenceConstants.TB_CASE_SENSITIVE));
    btnIsIgnoreMark.setSelection(!ids.getBoolean("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.ignoreMark"));
    btnApplyRegularExpression.setSelection(ids.getBoolean("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.regEx"));
    try {
        spiMatchQuality.setSelection(ids.getInt("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.matchQuality"));
    } catch (NumberFormatException e) {
        spiMatchQuality.setSelection(100);
    }
    String[] arrSearchHistory = ids.getArray("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.searchHistory");
    if (arrSearchHistory != null) {
        lstSearchHistory.clear();
        for (int i = 0; i < arrSearchHistory.length; i++) {
            lstSearchHistory.add(arrSearchHistory[i]);
        }
    }
    String selTM = ids.get("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.selTM");
    int selIndex = 0;
    if (selTM != null) {
        for (int i = 0; i < cmbDatabase.getItemCount(); i++) {
            if (selTM.equals(cmbDatabase.getItem(i))) {
                selIndex = i;
                break;
            }
        }
    }
    cmbDatabase.select(selIndex);
    String[] arrTarget = ids.getArray("net.heartsome.cat.database.ui.tb.dialog.TermBaseSearchDialog.selTgt");
    List<String> lstSelItem = new ArrayList<String>();
    if (arrTarget != null) {
        for (int i = 0; i < menu.getItemCount(); i++) {
            MenuItem item = menu.getItem(i);
            for (String target : arrTarget) {
                if (item.getText().equals(target)) {
                    item.setSelection(true);
                    break;
                }
            }
            if (item.getSelection()) {
                lstSelItem.add(item.getText());
            }
        }
    }
    // 重设表格列宽
    int totalWidth = 0;
    List<GridColumn> lstShowColumn = new ArrayList<GridColumn>();
    for (int index = 0; index < grid.getColumnCount(); index++) {
        GridColumn column = grid.getColumn(index);
        if (column.getWidth() > 0) {
            totalWidth += column.getWidth();
        }
        if (column.getWidth() > 0 || lstSelItem.indexOf(column.getText()) >= 0) {
            lstShowColumn.add(column);
        }
    }
    int width = (totalWidth + 100) / lstShowColumn.size();
    for (GridColumn column : lstShowColumn) {
        column.setWidth(width);
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ArrayList(java.util.ArrayList) MenuItem(org.eclipse.swt.widgets.MenuItem) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point)

Example 3 with GridColumn

use of org.eclipse.nebula.widgets.grid.GridColumn in project translationstudio8 by heartsome.

the class DefaultCellRenderer method paint.

/**
     * {@inheritDoc}
     */
public void paint(GC gc, Object value) {
    GridItem item = (GridItem) value;
    gc.setFont(item.getFont(getColumn()));
    boolean drawAsSelected = isSelected();
    boolean drawBackground = true;
    if (isCellSelected()) {
        //(!isCellFocus());
        drawAsSelected = true;
    }
    if (drawAsSelected) {
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    } else {
        if (item.getParent().isEnabled()) {
            Color back = item.getBackground(getColumn());
            if (back != null) {
                gc.setBackground(back);
            } else {
                drawBackground = false;
            }
        } else {
            gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
        }
        gc.setForeground(item.getForeground(getColumn()));
    }
    if (drawBackground)
        gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width, getBounds().height);
    int x = leftMargin;
    if (isTree()) {
        boolean renderBranches = item.getParent().getTreeLinesVisible();
        if (renderBranches) {
            branchRenderer.setBranches(getBranches(item));
            branchRenderer.setIndent(treeIndent);
            branchRenderer.setBounds(getBounds().x + x, getBounds().y, getToggleIndent(item), // Take into account border
            getBounds().height + 1);
        }
        x += getToggleIndent(item);
        toggleRenderer.setExpanded(item.isExpanded());
        toggleRenderer.setHover(getHoverDetail().equals("toggle"));
        toggleRenderer.setLocation(getBounds().x + x, (getBounds().height - toggleRenderer.getBounds().height) / 2 + getBounds().y);
        if (item.hasChildren())
            toggleRenderer.paint(gc, null);
        if (renderBranches) {
            branchRenderer.setToggleBounds(toggleRenderer.getBounds());
            branchRenderer.paint(gc, null);
        }
        x += toggleRenderer.getBounds().width + insideMargin;
    }
    if (isCheck()) {
        checkRenderer.setChecked(item.getChecked(getColumn()));
        checkRenderer.setGrayed(item.getGrayed(getColumn()));
        if (!item.getParent().isEnabled()) {
            checkRenderer.setGrayed(true);
        }
        checkRenderer.setHover(getHoverDetail().equals("check"));
        if (isCenteredCheckBoxOnly(item)) {
            //Special logic if this column only has a checkbox and is centered
            checkRenderer.setBounds(getBounds().x + ((getBounds().width - checkRenderer.getBounds().width) / 2), (getBounds().height - checkRenderer.getBounds().height) / 2 + getBounds().y, checkRenderer.getBounds().width, checkRenderer.getBounds().height);
        } else {
            checkRenderer.setBounds(getBounds().x + x, (getBounds().height - checkRenderer.getBounds().height) / 2 + getBounds().y, checkRenderer.getBounds().width, checkRenderer.getBounds().height);
            x += checkRenderer.getBounds().width + insideMargin;
        }
        checkRenderer.paint(gc, null);
    }
    Image image = item.getImage(getColumn());
    if (image != null) {
        int y = getBounds().y;
        y += (getBounds().height - image.getBounds().height) / 2;
        gc.drawImage(image, getBounds().x + x, y);
        x += image.getBounds().width + insideMargin;
    }
    int width = getBounds().width - x - rightMargin;
    if (drawAsSelected) {
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    } else {
        gc.setForeground(item.getForeground(getColumn()));
    }
    if (!isWordWrap()) {
        String text = TextUtils.getShortString(gc, item.getText(getColumn()), width);
        if (getAlignment() == SWT.RIGHT) {
            int len = gc.stringExtent(text).x;
            if (len < width) {
                x += width - len;
            }
        } else if (getAlignment() == SWT.CENTER) {
            int len = gc.stringExtent(text).x;
            if (len < width) {
                x += (width - len) / 2;
            }
        }
        gc.drawString(text, getBounds().x + x, getBounds().y + textTopMargin + topMargin, true);
    } else {
        if (textLayout == null) {
            textLayout = new TextLayout(gc.getDevice());
            item.getParent().addDisposeListener(new DisposeListener() {

                public void widgetDisposed(DisposeEvent e) {
                    textLayout.dispose();
                }
            });
        }
        textLayout.setFont(gc.getFont());
        textLayout.setText(item.getText(getColumn()));
        textLayout.setAlignment(getAlignment());
        textLayout.setWidth(width < 1 ? 1 : width);
        if (item.getParent().isAutoHeight()) {
            // Look through all columns (except this one) to get the max height needed for this item
            int columnCount = item.getParent().getColumnCount();
            int maxHeight = textLayout.getBounds().height + textTopMargin + textBottomMargin;
            for (int i = 0; i < columnCount; i++) {
                GridColumn column = item.getParent().getColumn(i);
                if (i != getColumn() && column.getWordWrap()) {
                    int height = column.getCellRenderer().computeSize(gc, column.getWidth(), SWT.DEFAULT, item).y;
                    maxHeight = Math.max(maxHeight, height);
                }
            }
            // Also look at the row header if necessary
            if (item.getParent().isWordWrapHeader()) {
                int height = item.getParent().getRowHeaderRenderer().computeSize(gc, SWT.DEFAULT, SWT.DEFAULT, item).y;
                maxHeight = Math.max(maxHeight, height);
            }
            if (maxHeight != item.getHeight()) {
                item.setHeight(maxHeight);
            }
        }
        textLayout.draw(gc, getBounds().x + x, getBounds().y + textTopMargin + topMargin);
    }
    if (item.getParent().getLinesVisible()) {
        if (isCellSelected()) {
            //XXX: should be user definable?
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
        } else {
            gc.setForeground(item.getParent().getLineColor());
        }
        gc.drawLine(getBounds().x, getBounds().y + getBounds().height, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height);
        gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height);
    }
    if (isCellFocus()) {
        Rectangle focusRect = new Rectangle(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height);
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
        gc.drawRectangle(focusRect);
        if (isFocus()) {
            focusRect.x++;
            focusRect.width -= 2;
            focusRect.y++;
            focusRect.height -= 2;
            gc.drawRectangle(focusRect);
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GridItem(org.eclipse.nebula.widgets.grid.GridItem) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Image(org.eclipse.swt.graphics.Image) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point) TextLayout(org.eclipse.swt.graphics.TextLayout)

Example 4 with GridColumn

use of org.eclipse.nebula.widgets.grid.GridColumn in project translationstudio8 by heartsome.

the class DefaultColumnFooterRenderer method getTextBounds.

/**
     * {@inheritDoc}
     */
public Rectangle getTextBounds(Object value, boolean preferred) {
    GridColumn column = (GridColumn) value;
    int x = leftMargin;
    if (column.getImage() != null) {
        x += column.getImage().getBounds().width + imageSpacing;
    }
    GC gc = new GC(column.getParent());
    gc.setFont(column.getFooterFont());
    int y = getBounds().height - bottomMargin - gc.getFontMetrics().getHeight();
    Rectangle bounds = new Rectangle(x, y, 0, 0);
    Point p = gc.stringExtent(column.getText());
    bounds.height = p.y;
    if (preferred) {
        bounds.width = p.x;
    } else {
        int width = getBounds().width - x;
        if (column.getSort() == SWT.NONE) {
            width -= rightMargin;
        }
        bounds.width = width;
    }
    gc.dispose();
    return bounds;
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point)

Example 5 with GridColumn

use of org.eclipse.nebula.widgets.grid.GridColumn in project translationstudio8 by heartsome.

the class DefaultColumnHeaderRenderer method paint.

/**
     * {@inheritDoc}
     */
public void paint(GC gc, Object value) {
    GridColumn column = (GridColumn) value;
    // set the font to be used to display the text.
    gc.setFont(column.getHeaderFont());
    boolean flat = (column.getParent().getCellSelectionEnabled() && !column.getMoveable());
    boolean drawSelected = ((isMouseDown() && isHover()));
    gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    if (flat && isSelected()) {
        gc.setBackground(column.getParent().getCellHeaderSelectionBackground());
    }
    gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width, getBounds().height);
    int pushedDrawingOffset = 0;
    if (drawSelected) {
        pushedDrawingOffset = 1;
    }
    int x = leftMargin;
    if (column.getImage() != null) {
        int y = bottomMargin;
        if (column.getHeaderControl() == null) {
            y = getBounds().y + pushedDrawingOffset + getBounds().height - bottomMargin - column.getImage().getBounds().height;
        }
        gc.drawImage(column.getImage(), getBounds().x + x + pushedDrawingOffset, y);
        x += column.getImage().getBounds().width + imageSpacing;
    }
    int width = getBounds().width - x;
    if (column.getSort() == SWT.NONE) {
        width -= rightMargin;
    } else {
        width -= arrowMargin + arrowRenderer.getSize().x + arrowMargin;
    }
    gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
    int y = bottomMargin;
    if (column.getHeaderControl() == null) {
        y = getBounds().y + getBounds().height - bottomMargin - gc.getFontMetrics().getHeight();
    } else {
        y = getBounds().y + getBounds().height - bottomMargin - gc.getFontMetrics().getHeight() - computeControlSize(column).y;
    }
    String text = column.getText();
    if (!isWordWrap()) {
        text = TextUtils.getShortString(gc, text, width);
    //y -= gc.getFontMetrics().getHeight();
    }
    if (column.getAlignment() == SWT.RIGHT) {
        int len = gc.stringExtent(text).x;
        if (len < width) {
            x += width - len;
        }
    } else if (column.getAlignment() == SWT.CENTER) {
        int len = gc.stringExtent(text).x;
        if (len < width) {
            x += (width - len) / 2;
        }
    }
    if (!isWordWrap()) {
        gc.drawString(text, getBounds().x + x + pushedDrawingOffset, y + pushedDrawingOffset, true);
    } else {
        getTextLayout(gc, column);
        textLayout.setWidth(width < 1 ? 1 : width);
        textLayout.setText(text);
        y -= textLayout.getBounds().height;
        if (column.getParent().isAutoHeight()) {
            column.getParent().recalculateHeader();
        }
        textLayout.draw(gc, getBounds().x + x + pushedDrawingOffset, y + pushedDrawingOffset);
    }
    if (column.getSort() != SWT.NONE) {
        if (column.getHeaderControl() == null) {
            y = getBounds().y + ((getBounds().height - arrowRenderer.getBounds().height) / 2) + 1;
        } else {
            y = getBounds().y + ((getBounds().height - computeControlSize(column).y - arrowRenderer.getBounds().height) / 2) + 1;
        }
        arrowRenderer.setSelected(column.getSort() == SWT.UP);
        if (drawSelected) {
            arrowRenderer.setLocation(getBounds().x + getBounds().width - arrowMargin - arrowRenderer.getBounds().width + 1, y);
        } else {
            if (column.getHeaderControl() == null) {
                y = getBounds().y + ((getBounds().height - arrowRenderer.getBounds().height) / 2);
            } else {
                y = getBounds().y + ((getBounds().height - computeControlSize(column).y - arrowRenderer.getBounds().height) / 2);
            }
            arrowRenderer.setLocation(getBounds().x + getBounds().width - arrowMargin - arrowRenderer.getBounds().width, y);
        }
        arrowRenderer.paint(gc, null);
    }
    if (!flat) {
        if (drawSelected) {
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        } else {
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
        }
        gc.drawLine(getBounds().x, getBounds().y, getBounds().x + getBounds().width - 1, getBounds().y);
        gc.drawLine(getBounds().x, getBounds().y, getBounds().x, getBounds().y + getBounds().height - 1);
        if (!drawSelected) {
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
            gc.drawLine(getBounds().x + 1, getBounds().y + 1, getBounds().x + getBounds().width - 2, getBounds().y + 1);
            gc.drawLine(getBounds().x + 1, getBounds().y + 1, getBounds().x + 1, getBounds().y + getBounds().height - 2);
        }
        if (drawSelected) {
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        } else {
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
        }
        gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height - 1);
        gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height - 1);
        if (!drawSelected) {
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
            gc.drawLine(getBounds().x + getBounds().width - 2, getBounds().y + 1, getBounds().x + getBounds().width - 2, getBounds().y + getBounds().height - 2);
            gc.drawLine(getBounds().x + 1, getBounds().y + getBounds().height - 2, getBounds().x + getBounds().width - 2, getBounds().y + getBounds().height - 2);
        }
    } else {
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
        gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height - 1);
        gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height - 1);
    }
}
Also used : GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point)

Aggregations

GridColumn (org.eclipse.nebula.widgets.grid.GridColumn)45 Point (org.eclipse.swt.graphics.Point)39 GridItem (org.eclipse.nebula.widgets.grid.GridItem)16 Rectangle (org.eclipse.swt.graphics.Rectangle)14 GC (org.eclipse.swt.graphics.GC)8 TalendGridColumn (org.eclipse.nebula.widgets.grid.TalendGridColumn)7 TalendGridItem (org.eclipse.nebula.widgets.grid.TalendGridItem)6 GridData (org.eclipse.swt.layout.GridData)6 Color (org.eclipse.swt.graphics.Color)5 Image (org.eclipse.swt.graphics.Image)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Grid (org.eclipse.nebula.widgets.grid.Grid)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 TextLayout (org.eclipse.swt.graphics.TextLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 GridCellRenderer (org.eclipse.nebula.widgets.grid.GridCellRenderer)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3