Package org.csstudio.ui.util.dnd
Class ControlSystemDragSource
java.lang.Object
org.csstudio.ui.util.dnd.ControlSystemDragSource
General purpose utility to allowing Drag-and-Drop "Drag" of any adaptable or
Serializable
object.
As an example, assume a TableViewer or TreeViewer where the input contains Serializable objects like ProcessVariable. This would allow dragging the first of the currently selected elements:
...Viewer viewer = ... new ControlSystemDragSource(viewer.getControl()) { public Object getSelection() { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); return selection.getFirstElement(); } };
In principle this would allow dagging any number of selected PVs out of the viewer:
new ControlSystemDragSource(viewer.getControl()) { public Object getSelection() { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object[] objs = selection.toArray(); return objs; } };
.. but note that it will fail. The data needs to be serialized as the actual array type, not an Object array:
new ControlSystemDragSource(viewer.getControl()) { public Object getSelection() { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object[] objs = selection.toArray(); ProcessVariable[] pvs = Arrays.copyOf(objs, objs.length, ProcessVariable[].class); return pvs; } };
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Object
To be implemented by derived class: Provide the control system items that should be 'dragged' from this drag source
-
Constructor Details
-
ControlSystemDragSource
Initialize 'drag' source- Parameters:
control
- Control from which the selection may be dragged
-
-
Method Details
-
getSelection
To be implemented by derived class: Provide the control system items that should be 'dragged' from this drag source- Returns:
- the selection (can be single object or array)
-