a1b0a05618849c648253472fbe8b605a0db9d731
[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.eclipse.swt.SWT;
17 import org.eclipse.swt.events.MouseEvent;
18 import org.eclipse.swt.events.MouseListener;
19 import org.eclipse.swt.widgets.Button;
20 import org.eclipse.swt.widgets.Composite;
21
22 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
23 import eu.etaxonomy.cdm.model.description.Distribution;
24 import eu.etaxonomy.cdm.model.description.Feature;
25 import eu.etaxonomy.cdm.model.description.TaxonDescription;
26
27 /**
28 * @author n.hoffmann
29 * @created 26.05.2009
30 * @version 1.0
31 */
32 public class DistributionFeatureGroupComposite extends DescriptionFeatureGroupComposite implements MouseListener{
33
34 private Set<Distribution> distributions;
35
36 private Button showMapButton;
37
38 public DistributionFeatureGroupComposite(TaxonDescriptionEditor editor, Composite parent,
39 TaxonDescription description, Feature feature) {
40 super(editor, parent, description, feature);
41
42 distributions = new HashSet<Distribution>();
43
44 for(DescriptionElementBase descriptionElement : description.getElements()){
45 if(descriptionElement.getFeature().equals(Feature.DISTRIBUTION())){
46 distributions.add((Distribution) descriptionElement);
47 }
48 }
49
50 showMapButton = new Button(parent, SWT.PUSH);
51 showMapButton.setText("Show Map");
52 showMapButton.addMouseListener(this);
53 }
54
55 /* (non-Javadoc)
56 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
57 */
58 public void mouseUp(MouseEvent event) {
59 if(event.widget == showMapButton){
60
61 DistributionMapDialog dialog = new DistributionMapDialog(editor, this.getShell(), distributions);
62
63 dialog.open();
64 }
65 }
66
67 public void mouseDoubleClick(MouseEvent e) {}
68
69 public void mouseDown(MouseEvent e) {}
70 }