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;
}
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;
}
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();
}
Aggregations