Moving editor sources back into trunk
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / description / DistributionFeatureGroupComposite.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.editor.description;
12
13 import java.util.HashSet;
14 import java.util.Set;
15
16 import org.apache.log4j.Logger;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.events.MouseAdapter;
19 import org.eclipse.swt.events.MouseEvent;
20 import org.eclipse.swt.events.MouseListener;
21 import org.eclipse.swt.widgets.Button;
22 import org.eclipse.swt.widgets.Composite;
23 import org.eclipse.swt.widgets.Event;
24
25 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
26 import eu.etaxonomy.cdm.model.description.Distribution;
27 import eu.etaxonomy.cdm.model.description.Feature;
28 import eu.etaxonomy.cdm.model.description.TaxonDescription;
29
30 /**
31 * @author n.hoffmann
32 * @created 26.05.2009
33 * @version 1.0
34 */
35 public class DistributionFeatureGroupComposite extends DescriptionFeatureGroupComposite implements MouseListener{
36 private static final Logger logger = Logger
37 .getLogger(DistributionFeatureGroupComposite.class);
38
39 private Set<Distribution> distributions;
40
41 private Button showMapButton;
42
43 public DistributionFeatureGroupComposite(TaxonDescriptionEditor editor, Composite parent,
44 TaxonDescription description, Feature feature) {
45 super(editor, parent, description, feature);
46
47 distributions = new HashSet<Distribution>();
48
49 for(DescriptionElementBase descriptionElement : description.getElements()){
50 if(descriptionElement.getFeature().equals(Feature.DISTRIBUTION())){
51 distributions.add((Distribution) descriptionElement);
52 }
53 }
54
55 showMapButton = new Button(parent, SWT.PUSH);
56 showMapButton.setText("Show Map");
57 showMapButton.addMouseListener(this);
58 }
59
60 /* (non-Javadoc)
61 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
62 */
63 public void mouseUp(MouseEvent event) {
64 if(event.widget == showMapButton){
65
66 DistributionMapDialog dialog = new DistributionMapDialog(editor, this.getShell(), distributions);
67
68 dialog.open();
69 }
70 }
71
72 public void mouseDoubleClick(MouseEvent e) {}
73
74 public void mouseDown(MouseEvent e) {}
75 }