Search in sources :

Example 1 with AncestorListener

use of org.eclipse.draw2d.AncestorListener in project statecharts by Yakindu.

the class DirectEditManagerEx method hookListeners.

protected void hookListeners() {
    ancestorListener = new AncestorListener.Stub() {

        public void ancestorMoved(IFigure ancestor) {
            placeCellEditor();
        }
    };
    getEditPart().getFigure().addAncestorListener(ancestorListener);
    Control control = getControl();
    controlListener = new ControlAdapter() {

        public void controlMoved(ControlEvent e) {
            // This must be handled async because during scrolling, the
            // CellEditor moves
            // first, but then afterwards the viewport Scrolls, which would
            // cause the
            // shadow to move twice
            Display.getCurrent().asyncExec(new Runnable() {

                public void run() {
                    placeBorder();
                }
            });
        }

        public void controlResized(ControlEvent e) {
            placeBorder();
        }
    };
    control.addControlListener(controlListener);
    cellEditorListener = new ICellEditorListener() {

        public void applyEditorValue() {
            commit();
        }

        public void cancelEditor() {
            bringDown();
        }

        public void editorValueChanged(boolean old, boolean newState) {
            handleValueChanged();
        }
    };
    getCellEditor().addListener(cellEditorListener);
    editPartListener = new EditPartListener.Stub() {

        public void partDeactivated(EditPart editpart) {
            bringDown();
        }
    };
    getEditPart().addEditPartListener(editPartListener);
}
Also used : Control(org.eclipse.swt.widgets.Control) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) EditPartListener(org.eclipse.gef.EditPartListener) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AncestorListener(org.eclipse.draw2d.AncestorListener) ControlEvent(org.eclipse.swt.events.ControlEvent) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with AncestorListener

use of org.eclipse.draw2d.AncestorListener in project archi by archimatetool.

the class DirectEditManager method hookListeners.

protected void hookListeners() {
    ancestorListener = new AncestorListener.Stub() {

        @Override
        public void ancestorMoved(IFigure ancestor) {
            placeCellEditor();
        }
    };
    getEditPart().getFigure().addAncestorListener(ancestorListener);
    Control control = getControl();
    controlListener = new ControlAdapter() {

        @Override
        public void controlMoved(ControlEvent e) {
            // This must be handled async because during scrolling, the
            // CellEditor moves
            // first, but then afterwards the viewport Scrolls, which would
            // cause the
            // shadow to move twice
            Display.getCurrent().asyncExec(new Runnable() {

                @Override
                public void run() {
                    placeCellEditorFrame();
                }
            });
        }

        @Override
        public void controlResized(ControlEvent e) {
            placeCellEditorFrame();
        }
    };
    control.addControlListener(controlListener);
    cellEditorListener = new ICellEditorListener() {

        @Override
        public void applyEditorValue() {
            commit();
        }

        @Override
        public void cancelEditor() {
            bringDown();
        }

        @Override
        public void editorValueChanged(boolean old, boolean newState) {
            handleValueChanged();
        }
    };
    getCellEditor().addListener(cellEditorListener);
    editPartListener = new EditPartListener.Stub() {

        @Override
        public void partDeactivated(EditPart editpart) {
            bringDown();
        }
    };
    getEditPart().addEditPartListener(editPartListener);
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) EditPartListener(org.eclipse.gef.EditPartListener) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) Control(org.eclipse.swt.widgets.Control) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) AncestorListener(org.eclipse.draw2d.AncestorListener) ControlEvent(org.eclipse.swt.events.ControlEvent) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

AncestorListener (org.eclipse.draw2d.AncestorListener)2 IFigure (org.eclipse.draw2d.IFigure)2 EditPart (org.eclipse.gef.EditPart)2 EditPartListener (org.eclipse.gef.EditPartListener)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 ICellEditorListener (org.eclipse.jface.viewers.ICellEditorListener)2 ControlAdapter (org.eclipse.swt.events.ControlAdapter)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 Control (org.eclipse.swt.widgets.Control)2