Search in sources :

Example 1 with XtextStyledTextCellEditor

use of org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor in project statecharts by Yakindu.

the class ExternalXtextLabelEditPart method performDirectEditRequest.

@Override
protected void performDirectEditRequest(final Request request) {
    final DirectEditManager manager = createDirectEditManager();
    final Request theRequest = request;
    try {
        getEditingDomain().runExclusive(new Runnable() {

            public void run() {
                if (isActive()) {
                    if (theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
                        final Character initialChar = (Character) theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
                        if (manager instanceof XtextDirectEditManager) {
                            XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
                            xtextDirectEditManager.show(initialChar);
                        } else if (manager instanceof TextDirectEditManager) {
                            ((TextDirectEditManager) manager).show(initialChar);
                        }
                    } else {
                        manager.show();
                    }
                    if (manager instanceof XtextDirectEditManager) {
                        XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
                        XtextStyledTextCellEditor cellEditor = (XtextStyledTextCellEditor) xtextDirectEditManager.getCellEditor();
                        setContext(cellEditor.getXtextAdapter().getFakeResourceContext().getFakeResource());
                    }
                }
            }
        });
    } catch (final InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : XtextStyledTextCellEditor(org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor) Request(org.eclipse.gef.Request) TextDirectEditManager(org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) TextDirectEditManager(org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) DirectEditManager(org.eclipse.gef.tools.DirectEditManager)

Example 2 with XtextStyledTextCellEditor

use of org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor in project statecharts by Yakindu.

the class XtextLabelEditPart method performDirectEditRequest.

@Override
public void performDirectEditRequest(final Request request) {
    final DirectEditManager manager = createDirectEditManager();
    final Request theRequest = request;
    try {
        getEditingDomain().runExclusive(new Runnable() {

            public void run() {
                if (isActive()) {
                    if (theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
                        final Character initialChar = (Character) theRequest.getExtendedData().get(REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
                        if (manager instanceof XtextDirectEditManager) {
                            XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
                            xtextDirectEditManager.show(initialChar);
                        } else if (manager instanceof TextDirectEditManager) {
                            ((TextDirectEditManager) manager).show(initialChar);
                        }
                    } else {
                        manager.show();
                    }
                    if (manager instanceof XtextDirectEditManager) {
                        XtextDirectEditManager xtextDirectEditManager = (XtextDirectEditManager) manager;
                        XtextStyledTextCellEditor cellEditor = (XtextStyledTextCellEditor) xtextDirectEditManager.getCellEditor();
                        setContext(cellEditor.getXtextAdapter().getFakeResourceContext().getFakeResource());
                    }
                }
            }
        });
    } catch (final InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : XtextStyledTextCellEditor(org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor) Request(org.eclipse.gef.Request) SelectionRequest(org.eclipse.gef.requests.SelectionRequest) TextDirectEditManager(org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) TextDirectEditManager(org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) DirectEditManager(org.eclipse.gef.tools.DirectEditManager)

Aggregations

Request (org.eclipse.gef.Request)2 DirectEditManager (org.eclipse.gef.tools.DirectEditManager)2 TextDirectEditManager (org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager)2 XtextStyledTextCellEditor (org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor)2 SelectionRequest (org.eclipse.gef.requests.SelectionRequest)1