initial quantum version
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / packageview / SelectionTransferDragAdapter.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.packageview;
12
13 import java.util.Iterator;
14
15 import net.sourceforge.phpdt.core.IJavaElement;
16 import net.sourceforge.phpdt.core.IPackageFragmentRoot;
17
18 import net.sourceforge.phpdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
19 import org.eclipse.jface.viewers.ISelection;
20 import org.eclipse.jface.viewers.ISelectionProvider;
21 import org.eclipse.jface.viewers.IStructuredSelection;
22
23 public class SelectionTransferDragAdapter extends BasicSelectionTransferDragAdapter {
24                 
25         public SelectionTransferDragAdapter(ISelectionProvider provider) {
26                 super(provider);
27         }
28
29         protected boolean isDragable(ISelection selection) {
30                 if (selection instanceof IStructuredSelection) {
31                         for (Iterator iter= ((IStructuredSelection)selection).iterator(); iter.hasNext();) {
32                                 Object element= iter.next();
33                                 if (element instanceof IJavaElement) {
34                                         IPackageFragmentRoot root= (IPackageFragmentRoot)((IJavaElement)element).getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
35                                         if (root != null && root.isArchive())
36                                                 return false;
37                                 }
38                         }
39                         return true;
40                 }
41                 return false;
42         }
43 }