Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemeNavigationPanel.java @ 805:f43d06d6a4a2
Refactored code of theme panel and added a MapThemePanel.
flys-client/trunk@2366 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 07:52:19 +0000 |
parents | |
children | f3325079dacc |
comparison
equal
deleted
inserted
replaced
804:374712890b94 | 805:f43d06d6a4a2 |
---|---|
1 package de.intevation.flys.client.client.ui; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import com.google.gwt.core.client.GWT; | |
7 | |
8 import com.smartgwt.client.widgets.Canvas; | |
9 import com.smartgwt.client.widgets.ImgButton; | |
10 import com.smartgwt.client.widgets.events.ClickEvent; | |
11 import com.smartgwt.client.widgets.events.ClickHandler; | |
12 import com.smartgwt.client.widgets.layout.HLayout; | |
13 | |
14 import de.intevation.flys.client.client.FLYSConstants; | |
15 import de.intevation.flys.client.client.event.OnMoveEvent; | |
16 import de.intevation.flys.client.client.event.OnMoveHandler; | |
17 | |
18 | |
19 /** | |
20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
21 */ | |
22 public class ThemeNavigationPanel extends Canvas { | |
23 | |
24 public static final int PANEL_MARGIN = 5; | |
25 public static final int BUTTON_HEIGHT = 25; | |
26 public static final int BUTTON_MARGIN = 5; | |
27 | |
28 | |
29 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
30 | |
31 | |
32 protected List<OnMoveHandler> handlers; | |
33 | |
34 | |
35 public ThemeNavigationPanel() { | |
36 this.handlers = new ArrayList<OnMoveHandler>(); | |
37 | |
38 setWidth100(); | |
39 setHeight(BUTTON_HEIGHT); | |
40 setMargin(PANEL_MARGIN); | |
41 | |
42 HLayout layout = new HLayout(); | |
43 layout.setWidth100(); | |
44 layout.setHeight(BUTTON_HEIGHT); | |
45 layout.setMembersMargin(BUTTON_MARGIN); | |
46 | |
47 Canvas cu = createButton(MSG.theme_top(), OnMoveEvent.TOP); | |
48 Canvas u = createButton(MSG.theme_up(), OnMoveEvent.UP); | |
49 Canvas d = createButton(MSG.theme_down(), OnMoveEvent.DOWN); | |
50 Canvas cd = createButton(MSG.theme_bottom(), OnMoveEvent.BOTTOM); | |
51 | |
52 layout.addMember(cu); | |
53 layout.addMember(u); | |
54 layout.addMember(d); | |
55 layout.addMember(cd); | |
56 | |
57 addChild(layout); | |
58 } | |
59 | |
60 | |
61 protected Canvas createButton(final String title, final int moveType) { | |
62 String url = GWT.getHostPageBaseURL() + title; | |
63 | |
64 ImgButton b = new ImgButton(); | |
65 b.setSrc(url); | |
66 b.setHeight(BUTTON_HEIGHT); | |
67 b.setWidth(40); | |
68 b.setIconHeight(BUTTON_HEIGHT-10); | |
69 b.setShowDown(false); | |
70 b.setShowRollOver(false); | |
71 b.setShowDisabled(false); | |
72 b.setShowDisabledIcon(true); | |
73 b.setShowDownIcon(false); | |
74 b.setShowFocusedIcon(false); | |
75 b.setBackgroundColor("f2f2f2"); | |
76 b.setBorder("1px solid #A6ABB4"); | |
77 | |
78 b.addClickHandler(new ClickHandler() { | |
79 public void onClick(ClickEvent event) { | |
80 fireOnMoveEvent(moveType); | |
81 } | |
82 }); | |
83 | |
84 return b; | |
85 } | |
86 | |
87 | |
88 protected void addOnMoveHandler(OnMoveHandler handler) { | |
89 if (handler != null) { | |
90 handlers.add(handler); | |
91 } | |
92 } | |
93 | |
94 | |
95 protected void fireOnMoveEvent(int type) { | |
96 OnMoveEvent event = new OnMoveEvent(type); | |
97 | |
98 for (OnMoveHandler handler: handlers) { | |
99 handler.onMove(event); | |
100 } | |
101 } | |
102 } | |
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |