01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.DragSourceEvent;
15:
16: import org.eclipse.jface.util.DelegatingDragAdapter;
17: import org.eclipse.jface.viewers.IStructuredSelection;
18: import org.eclipse.jface.viewers.StructuredViewer;
19:
20: public class JdtViewerDragAdapter extends DelegatingDragAdapter {
21:
22: private StructuredViewer fViewer;
23:
24: public JdtViewerDragAdapter(StructuredViewer viewer) {
25: super ();
26: Assert.isNotNull(viewer);
27: fViewer = viewer;
28: }
29:
30: public void dragStart(DragSourceEvent event) {
31: IStructuredSelection selection = (IStructuredSelection) fViewer
32: .getSelection();
33: if (selection.isEmpty()) {
34: event.doit = false;
35: return;
36: }
37: super.dragStart(event);
38: }
39: }
|