Project

General

Profile

Download (2.35 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2011 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.taxeditor.editor.view.uses;
10

    
11
import org.eclipse.jface.viewers.TreeViewer;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.dnd.Transfer;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Tree;
16

    
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
19
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
20
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
21
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
22

    
23

    
24
/**
25
 * The Class create a specific Use View to keep the taxonomic view clean
26
 * @author a.theys
27
 * @created mar 13, 2012
28
 * @version 1.0
29
 */
30
public class UsesViewPart extends DescriptiveViewPart {
31

    
32
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.uses"</code> */
33
	public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses";
34
	/** {@inheritDoc} */
35
	@Override
36
	public void createViewer(Composite parent) {
37

    
38
		viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
39
				| SWT.V_SCROLL | SWT.FULL_SELECTION));
40
		viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));
41
		viewer.setLabelProvider(new UsesLabelProvider());
42
		viewer.setAutoExpandLevel(2);
43

    
44

    
45

    
46
		Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
47
		viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
48
				this));
49
		viewer.addDropSupport(dndOperations, transfers,
50
				new DescriptionElementDropAdapter(viewer));
51

    
52
		// Propagate selection from viewer
53
		getSite().setSelectionProvider(viewer);
54

    
55
		showAllElementsAction = new ToggleDescriptionAction(false);
56
		hideAllElementsAction = new ToggleDescriptionAction(true);
57

    
58
		// Add context menu to tree
59
		createMenu();
60

    
61
		createToolbar();
62

    
63
	}
64

    
65
	/** {@inheritDoc} */
66
	@Override
67
	public boolean postOperation(CdmBase objectAffectedByOperation) {
68
		viewer.refresh();
69
		return super.postOperation(objectAffectedByOperation);
70
	}
71

    
72

    
73

    
74
}
(3-3/3)