1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************************************
 * Copyright (c) 2000, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.internal.ui.typehierarchy;

import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ISelection;

import org.eclipse.jdt.core.IJavaElement;

import org.eclipse.jdt.internal.ui.dnd.ViewerInputDropAdapter;
import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
import org.eclipse.jdt.internal.ui.util.SelectionUtil;

public class TypeHierarchyTransferDropAdapter extends ViewerInputDropAdapter {

    private TypeHierarchyViewPart fTypeHierarchyViewPart;

    public TypeHierarchyTransferDropAdapter(TypeHierarchyViewPart viewPart, AbstractTreeViewer viewer) {
        super(viewer);
        fTypeHierarchyViewPart= viewPart;
    }

    /**
     * {@inheritDoc}
     */
    protected void doInputView(Object inputElement) {
        fTypeHierarchyViewPart.setInputElement((IJavaElement) inputElement);
    }

    /**
     * {@inheritDoc}
     */
    protected Object getInputElement(ISelection selection) {
        Object single= SelectionUtil.getSingleElement(selection);
        if (single == null)
            return null;

        IJavaElement[] candidates= OpenTypeHierarchyUtil.getCandidates(single);
        if (candidates != null && candidates.length > 0)
            return candidates[0];

        return null;
    }

}
			
			

Browsed Source: [clear]