Search in sources :

Example 1 with AbstractPVWidgetEditPart

use of org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart in project yamcs-studio by yamcs.

the class RuntimePatchedSelectionTool method handleButtonUp.

/**
 * Intercept middle clicks and restore original cursor if it has changed.
 */
@Override
protected boolean handleButtonUp(int button) {
    if (button == 2) {
        EditPart editPart = getTargetEditPart();
        if (editPart instanceof AbstractPVWidgetEditPart) {
            AbstractPVWidgetEditPart apvwep = (AbstractPVWidgetEditPart) editPart;
            IFigure figure = apvwep.getFigure();
            if (cursorChanged) {
                figure.setCursor(oldCursor);
                oldCursor = null;
                cursorChanged = false;
            }
        }
        return true;
    } else {
        return super.handleButtonUp(button);
    }
}
Also used : AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) EditPart(org.eclipse.gef.EditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with AbstractPVWidgetEditPart

use of org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart in project yamcs-studio by yamcs.

the class RuntimePatchedSelectionTool method handleButtonDown.

/**
 * Intercept middle clicks and copy PV name to pastebuffer if available.
 * Change cursor to copy symbol.
 */
@Override
protected boolean handleButtonDown(int button) {
    if (button == 2) {
        EditPart editPart = getTargetEditPart();
        if (editPart instanceof AbstractPVWidgetEditPart) {
            AbstractPVWidgetEditPart apvwep = (AbstractPVWidgetEditPart) editPart;
            String pvName = ((AbstractPVWidgetModel) editPart.getModel()).getPVName();
            if (pvName != "" && pvName != null) {
                Display display = Display.getCurrent();
                Clipboard clipboard = new Clipboard(display);
                // Copies to middle button paste buffer,
                // to be pasted via another middle-button click
                clipboard.setContents(new Object[] { pvName }, new Transfer[] { TextTransfer.getInstance() }, DND.SELECTION_CLIPBOARD);
                // Copies to normal clipboard,
                // to be pasted via Ctrl-V or Edit/Paste
                clipboard.setContents(new String[] { pvName }, new Transfer[] { TextTransfer.getInstance() });
                clipboard.dispose();
                IFigure figure = apvwep.getFigure();
                oldCursor = figure.getCursor();
                figure.setCursor(ResourceUtil.getCopyPvCursor());
                cursorChanged = true;
            }
        }
        return true;
    } else {
        return super.handleButtonDown(button);
    }
}
Also used : AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) EditPart(org.eclipse.gef.EditPart) AbstractPVWidgetModel(org.csstudio.opibuilder.model.AbstractPVWidgetModel) Clipboard(org.eclipse.swt.dnd.Clipboard) Display(org.eclipse.swt.widgets.Display) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

AbstractPVWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart)2 IFigure (org.eclipse.draw2d.IFigure)2 EditPart (org.eclipse.gef.EditPart)2 AbstractPVWidgetModel (org.csstudio.opibuilder.model.AbstractPVWidgetModel)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 Display (org.eclipse.swt.widgets.Display)1