In this article, we'll learn a technique for customizing the drag-and-drop behavior of editors and view labels in Eclipse. We used an example to show this technique, which associates an editor with a transfer type Org.eclipse.ui.part.EditorInputTransfer. You can support the drag-and-drop behavior of the editor by implementing support for this type of transfer. We also provide a similar display for view labels. This article assumes that you are familiar with SWT's drag-and-drop technology.
What does customization mean?
The Editor and View tabs in the Eclipse Workbench can support the default drag-and-drop behavior, and the default drag release is supported:
Move and dock The view inside the Workbench the order in which the view or editor is rearranged within a tagged notepad create a quick view to view the source side-by-part, display several editors side-by-side in the editor area
Although this is a very exciting list of features, I still need more features in a project I worked on last year. Users need to be able to drag and drop the editor and View tabs and put them on a special view. When the user does so, what we do is intercept the Editor-id and input of the drag and drop editor, and the View-id of the dragged view, and then display the same content in a special view. Figure 1 and Figure 2 below will show this functionality.
Figure 1 shows an editor titled. Project, which is dragged and dropped into a special view titled Drop Window. Once you drop it in the position shown in Figure 2, this particular view displays the Editor-id and input of the drag and drop editor.
Figure 1. Editor label that is being dragged and dropped into a special view
Figure 2. Editor label dragged onto a special view