Search in sources :

Example 1 with CellEditorActionHandler

use of org.eclipse.ui.part.CellEditorActionHandler in project statecharts by Yakindu.

the class XtextDirectEditManager method initCellEditor.

protected void initCellEditor() {
    committed = false;
    // Get the Text Compartments Edit Part
    setEditText(getEditPart().getEditText());
    IFigure label = getEditPart().getFigure();
    Assert.isNotNull(label);
    StyledText text = (StyledText) getCellEditor().getControl();
    // scale the font accordingly to the zoom level
    text.setFont(getScaledFont(label));
    // Hook the cell editor's copy/paste actions to the actionBars so that
    // they can
    // be invoked via keyboard shortcuts.
    actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
    saveCurrentActions(actionBars);
    actionHandler = new CellEditorActionHandler(actionBars);
    actionHandler.addCellEditor(getCellEditor());
    actionBars.updateActionBars();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with CellEditorActionHandler

use of org.eclipse.ui.part.CellEditorActionHandler in project webtools.sourceediting by eclipse.

the class LabelEditManager method initCellEditor.

protected void initCellEditor() {
    Text text = (Text) getCellEditor().getControl();
    Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure();
    if (label != null) {
        scaledFont = label.getFont();
        Color color = label.getBackgroundColor();
        text.setBackground(color);
        String initialLabelText = label.getText();
        getCellEditor().setValue(initialLabelText);
    } else {
        scaledFont = label.getParent().getFont();
        text.setBackground(label.getParent().getBackgroundColor());
    }
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, data.getHeight());
    label.getParent().translateToAbsolute(fontSize);
    data.setHeight(fontSize.height);
    scaledFont = new Font(null, data);
    text.setFont(scaledFont);
    // text.selectAll();
    // Hook the cell editor's copy/paste actions to the actionBars so that they can
    // be invoked via keyboard shortcuts.
    actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
    saveCurrentActions(actionBars);
    actionHandler = new CellEditorActionHandler(actionBars);
    actionHandler.addCellEditor(getCellEditor());
    actionBars.updateActionBars();
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.draw2d.Label) INamedEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler) Font(org.eclipse.swt.graphics.Font)

Example 3 with CellEditorActionHandler

use of org.eclipse.ui.part.CellEditorActionHandler in project webtools.sourceediting by eclipse.

the class TopLevelNameDirectEditManager method initCellEditor.

protected void initCellEditor() {
    Text text = (Text) getCellEditor().getControl();
    Label label = ((INamedEditPart) getEditPart()).getNameLabelFigure();
    if (label != null) {
        scaledFont = label.getFont();
        Color color = label.getBackgroundColor();
        text.setBackground(color);
        String initialLabelText = component.getName();
        getCellEditor().setValue(initialLabelText);
    } else {
        scaledFont = label.getParent().getFont();
        text.setBackground(label.getParent().getBackgroundColor());
    }
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, data.getHeight());
    label.getParent().translateToAbsolute(fontSize);
    data.setHeight(fontSize.height);
    scaledFont = new Font(null, data);
    text.setFont(scaledFont);
    // text.selectAll();
    // Hook the cell editor's copy/paste actions to the actionBars so that they
    // can
    // be invoked via keyboard shortcuts.
    actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
    saveCurrentActions(actionBars);
    actionHandler = new CellEditorActionHandler(actionBars);
    actionHandler.addCellEditor(getCellEditor());
    actionBars.updateActionBars();
}
Also used : Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.draw2d.Label) INamedEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler) Font(org.eclipse.swt.graphics.Font)

Example 4 with CellEditorActionHandler

use of org.eclipse.ui.part.CellEditorActionHandler in project yamcs-studio by yamcs.

the class TextEditManager method initCellEditor.

@Override
protected void initCellEditor() {
    // update text
    var textFigure = getEditPart().getAdapter(ITextFigure.class);
    // var 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
    var 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.
    var 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 : ZoomManager(org.eclipse.gef.editparts.ZoomManager) AbstractBackground(org.eclipse.draw2d.AbstractBackground) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler)

Example 5 with CellEditorActionHandler

use of org.eclipse.ui.part.CellEditorActionHandler in project eclipse.platform.text by eclipse.

the class SearchResultView method createPartControl.

/**
 * Creates the search list inner viewer.
 * @param parent the parent
 */
@Override
public void createPartControl(Composite parent) {
    Assert.isTrue(fViewer == null);
    fViewer = new SearchResultViewer(this, parent);
    if (fMemento != null)
        fViewer.restoreState(fMemento);
    fMemento = null;
    SearchManager.getDefault().addSearchChangeListener(fViewer);
    fViewer.init();
    // Add selectAll action handlers.
    fCellEditorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars());
    fSelectAllAction = new SelectAllAction();
    fSelectAllAction.setViewer(fViewer);
    fCellEditorActionHandler.setSelectAllAction(fSelectAllAction);
    fillActionBars(getViewSite().getActionBars());
    fPropertyChangeListener = event -> {
        if (SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR.equals(event.getProperty()) || SearchPreferencePage.EMPHASIZE_POTENTIAL_MATCHES.equals(event.getProperty()))
            if (fViewer != null)
                fViewer.updatedPotentialMatchFgColor();
    };
    SearchPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fViewer.getControl(), SearchPlugin.getDefault().getSearchViewHelpContextId());
}
Also used : CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler)

Aggregations

CellEditorActionHandler (org.eclipse.ui.part.CellEditorActionHandler)6 Font (org.eclipse.swt.graphics.Font)3 Label (org.eclipse.draw2d.Label)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Color (org.eclipse.swt.graphics.Color)2 FontData (org.eclipse.swt.graphics.FontData)2 Text (org.eclipse.swt.widgets.Text)2 INamedEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.INamedEditPart)2 AbstractBackground (org.eclipse.draw2d.AbstractBackground)1 IFigure (org.eclipse.draw2d.IFigure)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 StyledText (org.eclipse.swt.custom.StyledText)1 Annotation (org.knime.core.node.workflow.Annotation)1 AnnotationEditPart (org.knime.workbench.editor2.editparts.AnnotationEditPart)1 NodeAnnotationEditPart (org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)1