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);
}
}
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();
}
}
Aggregations