Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ThemeNavigationPanel.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/client/ui/ThemeNavigationPanel.java@821a02bbfb4e |
children | 172338b1407f |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.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.types.Alignment; | |
9 import com.smartgwt.client.types.VerticalAlignment; | |
10 import com.smartgwt.client.widgets.Canvas; | |
11 import com.smartgwt.client.widgets.ImgButton; | |
12 import com.smartgwt.client.widgets.events.ClickEvent; | |
13 import com.smartgwt.client.widgets.events.ClickHandler; | |
14 import com.smartgwt.client.widgets.layout.HLayout; | |
15 | |
16 import org.dive4elements.river.client.client.FLYSConstants; | |
17 import org.dive4elements.river.client.client.event.OnMoveEvent; | |
18 import org.dive4elements.river.client.client.event.OnMoveHandler; | |
19 | |
20 | |
21 /** | |
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
23 */ | |
24 public class ThemeNavigationPanel extends Canvas { | |
25 | |
26 public static final int PANEL_MARGIN = 5; | |
27 public static final int BUTTON_HEIGHT = 20; | |
28 public static final int BUTTON_MARGIN = 5; | |
29 private static final int BOTTON_WIDTH = 20; | |
30 | |
31 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
32 | |
33 protected List<OnMoveHandler> handlers; | |
34 | |
35 | |
36 public ThemeNavigationPanel() { | |
37 this.handlers = new ArrayList<OnMoveHandler>(); | |
38 | |
39 setWidth100(); | |
40 setHeight(BUTTON_HEIGHT); | |
41 setMargin(PANEL_MARGIN); | |
42 | |
43 HLayout layout = new HLayout(); | |
44 layout.setWidth100(); | |
45 layout.setHeight(BUTTON_HEIGHT); | |
46 layout.setMembersMargin(BUTTON_MARGIN); | |
47 layout.setDefaultLayoutAlign(VerticalAlignment.CENTER); | |
48 layout.setDefaultLayoutAlign(Alignment.CENTER); | |
49 | |
50 Canvas cu = createButton(MSG.theme_top(), OnMoveEvent.TOP); | |
51 Canvas u = createButton(MSG.theme_up(), OnMoveEvent.UP); | |
52 Canvas d = createButton(MSG.theme_down(), OnMoveEvent.DOWN); | |
53 Canvas cd = createButton(MSG.theme_bottom(), OnMoveEvent.BOTTOM); | |
54 | |
55 HLayout left = new HLayout(); | |
56 left.setMembersMargin(BUTTON_MARGIN); | |
57 left.setLayoutAlign(Alignment.LEFT); | |
58 left.setDefaultLayoutAlign(Alignment.LEFT); | |
59 left.setAlign(Alignment.LEFT); | |
60 left.addMember(cu); | |
61 left.addMember(u); | |
62 | |
63 HLayout right = new HLayout(); | |
64 right.setMembersMargin(BUTTON_MARGIN); | |
65 right.setLayoutAlign(Alignment.RIGHT); | |
66 right.setDefaultLayoutAlign(Alignment.RIGHT); | |
67 right.setAlign(Alignment.RIGHT); | |
68 right.addMember(d); | |
69 right.addMember(cd); | |
70 | |
71 layout.addMember(left); | |
72 layout.addMember(right); | |
73 | |
74 addChild(layout); | |
75 } | |
76 | |
77 | |
78 protected Canvas createButton(final String title, final int moveType) { | |
79 String url = GWT.getHostPageBaseURL() + title; | |
80 | |
81 ImgButton b = new ImgButton(); | |
82 b.setSrc(url); | |
83 b.setWidth(BOTTON_WIDTH); | |
84 b.setHeight(BUTTON_HEIGHT); | |
85 b.setIconHeight(BUTTON_HEIGHT); | |
86 b.setIconWidth(BOTTON_WIDTH); | |
87 b.setShowDown(false); | |
88 b.setShowRollOver(false); | |
89 b.setShowDisabled(false); | |
90 b.setShowDisabledIcon(true); | |
91 b.setShowDownIcon(false); | |
92 b.setShowFocusedIcon(false); | |
93 b.setValign(VerticalAlignment.CENTER); | |
94 | |
95 b.addClickHandler(new ClickHandler() { | |
96 public void onClick(ClickEvent event) { | |
97 fireOnMoveEvent(moveType); | |
98 } | |
99 }); | |
100 | |
101 return b; | |
102 } | |
103 | |
104 | |
105 protected void addOnMoveHandler(OnMoveHandler handler) { | |
106 if (handler != null) { | |
107 handlers.add(handler); | |
108 } | |
109 } | |
110 | |
111 | |
112 protected void fireOnMoveEvent(int type) { | |
113 OnMoveEvent event = new OnMoveEvent(type); | |
114 | |
115 for (OnMoveHandler handler: handlers) { | |
116 handler.onMove(event); | |
117 } | |
118 } | |
119 } | |
120 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |