Project

General

Profile

Download (2.47 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
	public UsesViewPart() {
33
		super();
34
	}
35

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

    
42
		viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
43
				| SWT.V_SCROLL | SWT.FULL_SELECTION));
44
		viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));
45
		viewer.setLabelProvider(new UsesLabelProvider());
46
		viewer.setAutoExpandLevel(2);
47

    
48

    
49

    
50
		Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
51
		viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
52
				this));
53
		viewer.addDropSupport(dndOperations, transfers,
54
				new DescriptionElementDropAdapter(viewer));
55

    
56
		// Propagate selection from viewer
57
		getSite().setSelectionProvider(viewer);
58

    
59
		showAllElementsAction = new ToggleDescriptionAction(false);
60
		hideAllElementsAction = new ToggleDescriptionAction(true);
61

    
62
		// Add context menu to tree
63
		createMenu();
64

    
65
		createToolbar();
66

    
67
	}
68

    
69
	@Override
70
    protected String getViewName(){
71
	    return "Uses";
72
	}
73

    
74
	/** {@inheritDoc} */
75
	@Override
76
	public boolean postOperation(CdmBase objectAffectedByOperation) {
77
		viewer.refresh();
78
		return super.postOperation(objectAffectedByOperation);
79
	}
80

    
81

    
82

    
83
}
(3-3/3)