Search in sources :

Example 1 with ITextFigure

use of org.csstudio.swt.widgets.figures.ITextFigure 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

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