comparison src/econnect/wp3_3/client/widgets/map/MapControl.java @ 3:cf06b77a8bbd

Committed branch of the e4D repos sti-gwt branch 16384. git-svn-id: http://dev.dariah.eu/svn/repos/eu.dariah.de/ap1/sti-gwt-dariah-geobrowser@36 f2b5be40-def6-11e0-8a09-b3c1cc336c6b
author StefanFunk <StefanFunk@f2b5be40-def6-11e0-8a09-b3c1cc336c6b>
date Tue, 17 Jul 2012 13:34:40 +0000
parents
children
comparison
equal deleted inserted replaced
2:2897af43ccc6 3:cf06b77a8bbd
1 package econnect.wp3_3.client.widgets.map;
2
3 import com.google.gwt.user.client.ui.Image;
4 import com.google.gwt.core.client.GWT;
5 import com.google.gwt.event.dom.client.ClickEvent;
6 import com.google.gwt.event.dom.client.ClickHandler;
7
8 import econnect.wp3_3.client.core.StiConstants;
9
10 /**
11 * Implementation of the MapControl element
12 */
13 public class MapControl {
14
15 /**
16 * The corresponding map object
17 */
18 private Map map;
19
20 /**
21 * The url of the corresponding image of this control, if it is activated
22 */
23 private String activeImageURL;
24
25 /**
26 * The url of the corresponding image of this control, if it is deactivated
27 */
28 private String deactiveImageURL;
29
30 /**
31 * The id of this control
32 */
33 private String id;
34
35 /**
36 * The button object of a control
37 */
38 private Image button;
39
40 /**
41 * Constructor for the map control element
42 *
43 * @param map object The corresponding map object
44 * @param activeImageURL The url of the corresponding image of this control, if it is activated
45 * @param deactiveImageURL The url of the corresponding image of this control, if it is activated
46 * @param id The id of this control
47 * @param title The title text for the button element
48 */
49 public MapControl( final Map map, String activeImageURL, String deactiveImageURL, final String id, String title ){
50
51 this.map = map;
52 this.activeImageURL = activeImageURL;
53 this.deactiveImageURL = deactiveImageURL;
54 this.id = id;
55
56 final StiConstants textConstants = (StiConstants) GWT.create(StiConstants.class);
57 final MapControl control = this;
58 this.button = new Image( this.deactiveImageURL );
59 this.button.setTitle(title);
60 this.button.addClickHandler(new ClickHandler() {
61 public void onClick(ClickEvent event) {
62 if( map.getActiveControl() != control ){
63 if( id == "add" ){
64 if( map.core.isMaximumReached() && !map.core.individualSet() ){
65 map.core.alert(textConstants.maxDatasources());
66 return;
67 }
68 }
69 map.getActiveControl().deactivate();
70 activate();
71 }
72 }
73 });
74
75 }
76
77 /**
78 * deactivates this map control
79 */
80 public void deactivate(){
81 this.button.setUrl(this.deactiveImageURL);
82 this.map.getJsMap().deactivate(this.id);
83 }
84
85 /**
86 * activates this map control
87 */
88 public void activate(){
89 this.button.setUrl(this.activeImageURL);
90 this.map.getJsMap().activate(this.id);
91 this.map.setActiveControl(this);
92 }
93
94 /**
95 * Getter for the button-image of this control
96 *
97 * @return the actual image element
98 */
99 public Image getButton(){
100 return this.button;
101 }
102
103 }