Search in sources :

Example 1 with IPVWidgetModel

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

the class GraphicalFeedbackChildEditPolicy method createSelectionHandles.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected List<?> createSelectionHandles() {
    // get default handles
    List<Handle> handleList = super.createSelectionHandles();
    // add contributed handles
    GraphicalEditPart hostEP = (GraphicalEditPart) getHost();
    List<Handle> contributedHandles = feedbackFactory.createCustomHandles(hostEP);
    if (contributedHandles != null) {
        handleList.addAll(contributedHandles);
    }
    if (hostEP.getModel() instanceof IPVWidgetModel && ((AbstractWidgetModel) (hostEP.getModel())).getProperty(IPVWidgetModel.PROP_PVNAME).isVisibleInPropSheet()) {
        handleList.add(new PVWidgetSelectionHandle((GraphicalEditPart) hostEP));
    }
    return handleList;
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) IPVWidgetModel(org.csstudio.opibuilder.model.IPVWidgetModel) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Handle(org.eclipse.gef.Handle)

Example 2 with IPVWidgetModel

use of org.csstudio.opibuilder.model.IPVWidgetModel 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 3 with IPVWidgetModel

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

the class WritePVAction method run.

@Override
public void run() {
    display = null;
    if (getWidgetModel() != null) {
        display = getWidgetModel().getRootDisplayModel().getViewer().getControl().getDisplay();
    } else {
        display = DisplayUtils.getDisplay();
    }
    if (!getConfirmMessage().isEmpty())
        if (!GUIUtil.openConfirmDialog("PV Name: " + getPVName() + "\nNew Value: " + getValue() + "\n\n" + getConfirmMessage()))
            return;
    // If it has the same nave as widget PV name, use it.
    if (getWidgetModel() instanceof IPVWidgetModel) {
        String mainPVName = ((IPVWidgetModel) getWidgetModel()).getPVName();
        if (getPVName().equals(mainPVName)) {
            Object o = getWidgetModel().getRootDisplayModel().getViewer().getEditPartRegistry().get(getWidgetModel());
            if (o instanceof IPVWidgetEditpart) {
                ((IPVWidgetEditpart) o).setPVValue(IPVWidgetModel.PROP_PVNAME, getValue().trim());
                return;
            }
        }
    }
    Job job = new Job(getDescription()) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            return writePVInSync();
        }
    };
    job.schedule();
}
Also used : IPVWidgetEditpart(org.csstudio.opibuilder.editparts.IPVWidgetEditpart) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPVWidgetModel(org.csstudio.opibuilder.model.IPVWidgetModel) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IPVWidgetModel (org.csstudio.opibuilder.model.IPVWidgetModel)3 IPVWidgetEditpart (org.csstudio.opibuilder.editparts.IPVWidgetEditpart)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 PVNameTextCellEditor (org.csstudio.opibuilder.visualparts.PVNameTextCellEditor)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 Handle (org.eclipse.gef.Handle)1 CellEditorLocator (org.eclipse.gef.tools.CellEditorLocator)1 DirectEditManager (org.eclipse.gef.tools.DirectEditManager)1 DragEditPartsTracker (org.eclipse.gef.tools.DragEditPartsTracker)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 Text (org.eclipse.swt.widgets.Text)1