01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.dnd;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: import org.eclipse.swt.dnd.DND;
15: import org.eclipse.swt.dnd.FileTransfer;
16: import org.eclipse.swt.dnd.Transfer;
17:
18: import org.eclipse.jface.viewers.StructuredViewer;
19:
20: import org.eclipse.ui.part.ResourceTransfer;
21:
22: import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
23:
24: import org.eclipse.jdt.internal.ui.packageview.FileTransferDragAdapter;
25: import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter;
26:
27: public class JdtViewerDragSupport {
28:
29: private final StructuredViewer fViewer;
30: private JdtViewerDragAdapter fDragAdapter;
31: private boolean fStarted;
32:
33: public JdtViewerDragSupport(StructuredViewer viewer) {
34: fViewer = viewer;
35:
36: fDragAdapter = new JdtViewerDragAdapter(fViewer);
37: fDragAdapter
38: .addDragSourceListener(new SelectionTransferDragAdapter(
39: fViewer));
40: fDragAdapter
41: .addDragSourceListener(new ResourceTransferDragAdapter(
42: fViewer));
43: fDragAdapter.addDragSourceListener(new FileTransferDragAdapter(
44: fViewer));
45:
46: fStarted = false;
47: }
48:
49: public void start() {
50: Assert.isLegal(!fStarted);
51:
52: int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
53:
54: Transfer[] transfers = new Transfer[] {
55: LocalSelectionTransfer.getInstance(),
56: ResourceTransfer.getInstance(),
57: FileTransfer.getInstance() };
58:
59: fViewer.addDragSupport(ops, transfers, fDragAdapter);
60:
61: fStarted = true;
62: }
63:
64: }
|