Search in sources :

Example 1 with DirectEditManager

use of org.eclipse.gef.tools.DirectEditManager in project yamcs-studio by yamcs.

the class PVWidgetSelectionHandle method createDragTracker.

@Override
protected DragTracker createDragTracker() {
    DragEditPartsTracker tracker = new DragEditPartsTracker(getOwner()) {

        @Override
        protected boolean handleButtonDown(int button) {
            if ((button == 1 || button == 3) && widgetModel instanceof IPVWidgetModel) {
                DirectEditManager directEditManager = new PVNameDirectEditManager(getOwner(), new CellEditorLocator() {

                    @Override
                    public void relocate(CellEditor celleditor) {
                        Rectangle rect;
                        int width = 120;
                        if (!pvName.isEmpty() && getTextExtent().width > 120)
                            width = getTextExtent().width + 4;
                        rect = new Rectangle(PVWidgetSelectionHandle.this.getLocation(), new Dimension(width, getTextExtent().height));
                        translateToAbsolute(rect);
                        Text control = (Text) celleditor.getControl();
                        org.eclipse.swt.graphics.Rectangle trim = control.computeTrim(0, 0, 0, 0);
                        rect.translate(trim.x, trim.y);
                        rect.width += trim.width;
                        rect.height += trim.height;
                        control.setBounds(rect.x, rect.y, rect.width, rect.height);
                    }
                });
                directEditManager.show();
            }
            return true;
        }
    };
    tracker.setDefaultCursor(getCursor());
    return tracker;
}
Also used : CellEditorLocator(org.eclipse.gef.tools.CellEditorLocator) IPVWidgetModel(org.csstudio.opibuilder.model.IPVWidgetModel) CellEditor(org.eclipse.jface.viewers.CellEditor) PVNameTextCellEditor(org.csstudio.opibuilder.visualparts.PVNameTextCellEditor) Rectangle(org.eclipse.draw2d.geometry.Rectangle) DirectEditManager(org.eclipse.gef.tools.DirectEditManager) Text(org.eclipse.swt.widgets.Text) Dimension(org.eclipse.draw2d.geometry.Dimension) DragEditPartsTracker(org.eclipse.gef.tools.DragEditPartsTracker)

Example 2 with DirectEditManager

use of org.eclipse.gef.tools.DirectEditManager 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 3 with DirectEditManager

use of org.eclipse.gef.tools.DirectEditManager 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)

Example 4 with DirectEditManager

use of org.eclipse.gef.tools.DirectEditManager in project dbeaver by serge-rider.

the class AttributePart method performDirectEdit.

protected void performDirectEdit() {
    ERDGraphicalViewer viewer = (ERDGraphicalViewer) getViewer();
    ValidationMessageHandler handler = viewer.getValidationHandler();
    Label l = getFigure().getLabel();
    ColumnNameTypeCellEditorValidator columnNameTypeCellEditorValidator = new ColumnNameTypeCellEditorValidator(handler);
    DirectEditManager manager = new ExtendedDirectEditManager(this, TextCellEditor.class, new LabelCellEditorLocator(l), l, columnNameTypeCellEditorValidator);
    manager.show();
}
Also used : ExtendedDirectEditManager(org.jkiss.dbeaver.erd.ui.directedit.ExtendedDirectEditManager) LabelCellEditorLocator(org.jkiss.dbeaver.erd.ui.directedit.LabelCellEditorLocator) ValidationMessageHandler(org.jkiss.dbeaver.erd.ui.directedit.ValidationMessageHandler) EditableLabel(org.jkiss.dbeaver.erd.ui.figures.EditableLabel) Label(org.eclipse.draw2d.Label) ExtendedDirectEditManager(org.jkiss.dbeaver.erd.ui.directedit.ExtendedDirectEditManager) DirectEditManager(org.eclipse.gef.tools.DirectEditManager) ERDGraphicalViewer(org.jkiss.dbeaver.erd.ui.editor.ERDGraphicalViewer) ColumnNameTypeCellEditorValidator(org.jkiss.dbeaver.erd.ui.directedit.ColumnNameTypeCellEditorValidator)

Aggregations

DirectEditManager (org.eclipse.gef.tools.DirectEditManager)4 Request (org.eclipse.gef.Request)2 TextDirectEditManager (org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager)2 XtextStyledTextCellEditor (org.yakindu.base.xtext.utils.jface.viewers.XtextStyledTextCellEditor)2 IPVWidgetModel (org.csstudio.opibuilder.model.IPVWidgetModel)1 PVNameTextCellEditor (org.csstudio.opibuilder.visualparts.PVNameTextCellEditor)1 Label (org.eclipse.draw2d.Label)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 SelectionRequest (org.eclipse.gef.requests.SelectionRequest)1 CellEditorLocator (org.eclipse.gef.tools.CellEditorLocator)1 DragEditPartsTracker (org.eclipse.gef.tools.DragEditPartsTracker)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 Text (org.eclipse.swt.widgets.Text)1 ColumnNameTypeCellEditorValidator (org.jkiss.dbeaver.erd.ui.directedit.ColumnNameTypeCellEditorValidator)1 ExtendedDirectEditManager (org.jkiss.dbeaver.erd.ui.directedit.ExtendedDirectEditManager)1 LabelCellEditorLocator (org.jkiss.dbeaver.erd.ui.directedit.LabelCellEditorLocator)1 ValidationMessageHandler (org.jkiss.dbeaver.erd.ui.directedit.ValidationMessageHandler)1 ERDGraphicalViewer (org.jkiss.dbeaver.erd.ui.editor.ERDGraphicalViewer)1 EditableLabel (org.jkiss.dbeaver.erd.ui.figures.EditableLabel)1