01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.typehierarchy;
11:
12: import org.eclipse.jface.viewers.AbstractTreeViewer;
13: import org.eclipse.jface.viewers.ISelection;
14:
15: import org.eclipse.jdt.core.IJavaElement;
16:
17: import org.eclipse.jdt.internal.ui.dnd.ViewerInputDropAdapter;
18: import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
19: import org.eclipse.jdt.internal.ui.util.SelectionUtil;
20:
21: public class TypeHierarchyTransferDropAdapter extends
22: ViewerInputDropAdapter {
23:
24: private TypeHierarchyViewPart fTypeHierarchyViewPart;
25:
26: public TypeHierarchyTransferDropAdapter(
27: TypeHierarchyViewPart viewPart, AbstractTreeViewer viewer) {
28: super (viewer);
29: fTypeHierarchyViewPart = viewPart;
30: }
31:
32: /**
33: * {@inheritDoc}
34: */
35: protected void doInputView(Object inputElement) {
36: fTypeHierarchyViewPart
37: .setInputElement((IJavaElement) inputElement);
38: }
39:
40: /**
41: * {@inheritDoc}
42: */
43: protected Object getInputElement(ISelection selection) {
44: Object single = SelectionUtil.getSingleElement(selection);
45: if (single == null)
46: return null;
47:
48: IJavaElement[] candidates = OpenTypeHierarchyUtil
49: .getCandidates(single);
50: if (candidates != null && candidates.length > 0)
51: return candidates[0];
52:
53: return null;
54: }
55:
56: }
|