Search in sources :

Example 1 with AbstractPVWidgetModel

use of org.csstudio.opibuilder.model.AbstractPVWidgetModel 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)

Example 2 with AbstractPVWidgetModel

use of org.csstudio.opibuilder.model.AbstractPVWidgetModel in project yamcs-studio by yamcs.

the class WidgetTreeEditpart method getText.

@Override
protected String getText() {
    StringBuilder sb = new StringBuilder();
    Object obj = getViewer().getProperty(ShowIndexInTreeViewAction.SHOW_INDEX_PROPERTY);
    if (obj != null && obj instanceof Boolean && (Boolean) obj) {
        sb.append(Integer.toString(getWidgetModel().getIndex()));
        // $NON-NLS-1$
        sb.append("_");
    }
    sb.append(getWidgetModel().getName());
    if (getWidgetModel() instanceof AbstractPVWidgetModel) {
        AbstractPVWidgetModel pvWidgetModel = (AbstractPVWidgetModel) getWidgetModel();
        String pvName = pvWidgetModel.getPVName();
        if (pvName != null && !pvName.trim().equals("")) {
            // $NON-NLS-1$
            sb.append("(");
            sb.append(pvName);
            // $NON-NLS-1$
            sb.append(")");
        }
    }
    return sb.toString();
}
Also used : AbstractPVWidgetModel(org.csstudio.opibuilder.model.AbstractPVWidgetModel)

Aggregations

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