|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.csstudio.ui.util.dnd.ControlSystemDragSource
public abstract class 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()
{
final 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()
{
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final 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()
{
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final Object[] objs = selection.toArray();
final ProcessVariable[] pvs = Arrays.copyOf(objs, objs.length, ProcessVariable[].class);
return pvs;
}
};
| Constructor Summary | |
|---|---|
ControlSystemDragSource(Control control)
Initialize 'drag' source |
|
| Method Summary | |
|---|---|
abstract java.lang.Object |
getSelection()
To be implemented by derived class: Provide the control system items that should be 'dragged' from this drag source |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ControlSystemDragSource(Control control)
control - Control from which the selection may be dragged| Method Detail |
|---|
public abstract java.lang.Object getSelection()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||