Search in sources :

Example 1 with AbstractBackground

use of org.eclipse.draw2d.AbstractBackground in project tdi-studio-se by Talend.

the class ToolBarButtonImageFigure method paintFigure.

/**
     * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
     */
@Override
protected void paintFigure(Graphics graphics) {
    if (isOpaque()) {
        graphics.fillRectangle(getBounds());
    }
    if (getBorder() instanceof AbstractBackground) {
        ((AbstractBackground) getBorder()).paintBackground(this, graphics, NO_INSETS);
    }
    int x, y;
    Rectangle area = getClientArea();
    y = area.y;
    x = area.x;
    // }
    if (getImage() != null) {
        graphics.drawImage(getImage(), x, y);
        x = x + size.width + iconTextGap;
    }
    if (getText() != null) {
        graphics.drawText(getText(), x, y);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractBackground(org.eclipse.draw2d.AbstractBackground)

Example 2 with AbstractBackground

use of org.eclipse.draw2d.AbstractBackground in project yamcs-studio by yamcs.

the class TextEditManager method initCellEditor.

@Override
protected void initCellEditor() {
    // update text
    ITextFigure textFigure = getEditPart().getAdapter(ITextFigure.class);
    // AbstractWidgetModel labelModel = (AbstractWidgetModel) getEditPart().getModel();
    getCellEditor().setValue(textFigure.getText());
    if (textFigure.isOpaque() || textFigure.getBorder() instanceof AbstractBackground) {
        getCellEditor().getControl().setBackground(textFigure.getBackgroundColor());
    } else {
        getCellEditor().getControl().setBackground(textFigure.getParent().getBackgroundColor());
    }
    getCellEditor().getControl().setForeground(textFigure.getForegroundColor());
    // update font
    ZoomManager zoomMgr = (ZoomManager) getEditPart().getViewer().getProperty(ZoomManager.class.toString());
    if (zoomMgr != null) {
        // this will force the font to be set
        cachedZoom = -1.0;
        updateScaledFont(zoomMgr.getZoom());
        zoomMgr.addZoomListener(zoomListener);
    } else
        getCellEditor().getControl().setFont(textFigure.getFont());
    // Hook the cell editor's copy/paste actions to the actionBars so that they can
    // be invoked via keyboard shortcuts.
    IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor != null) {
        actionBars = activeEditor.getEditorSite().getActionBars();
        saveCurrentActions(actionBars);
        actionHandler = new CellEditorActionHandler(actionBars);
        actionHandler.addCellEditor(getCellEditor());
        actionBars.updateActionBars();
    }
}
Also used : ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) ZoomManager(org.eclipse.gef.editparts.ZoomManager) AbstractBackground(org.eclipse.draw2d.AbstractBackground) IEditorPart(org.eclipse.ui.IEditorPart) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler)

Aggregations

AbstractBackground (org.eclipse.draw2d.AbstractBackground)2 ITextFigure (org.csstudio.swt.widgets.figures.ITextFigure)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 IEditorPart (org.eclipse.ui.IEditorPart)1 CellEditorActionHandler (org.eclipse.ui.part.CellEditorActionHandler)1