comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ThemeNavigationPanel.java @ 527:902609b5cc79

Added a navigation panel to the bottom of the theme control panel to move themes up/down (function not implemented yet). flys-client/trunk@2007 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 25 May 2011 16:23:16 +0000
parents
children 0ba7c43e7b62
comparison
equal deleted inserted replaced
526:96e60e0a4345 527:902609b5cc79
1 package de.intevation.flys.client.client.ui.chart;
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.widgets.Label;
10 import com.smartgwt.client.widgets.Canvas;
11 import com.smartgwt.client.widgets.events.ClickEvent;
12 import com.smartgwt.client.widgets.events.ClickHandler;
13 import com.smartgwt.client.widgets.layout.HLayout;
14
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 = 20;
26 public static final int BUTTON_MARGIN = 5;
27
28
29 protected List<OnMoveHandler> handlers;
30
31
32 public ThemeNavigationPanel() {
33 this.handlers = new ArrayList<OnMoveHandler>();
34
35 setWidth100();
36 setHeight(BUTTON_HEIGHT);
37 setMargin(PANEL_MARGIN);
38
39 HLayout layout = new HLayout();
40 layout.setWidth100();
41 layout.setHeight(BUTTON_HEIGHT);
42 layout.setMembersMargin(BUTTON_MARGIN);
43
44 Canvas cu = createButton("CU", OnMoveEvent.TOP);
45 Canvas u = createButton("U", OnMoveEvent.UP);
46 Canvas d = createButton("D", OnMoveEvent.DOWN);
47 Canvas cd = createButton("CD", OnMoveEvent.BOTTOM);
48
49 layout.addMember(cu);
50 layout.addMember(u);
51 layout.addMember(d);
52 layout.addMember(cd);
53
54 addChild(layout);
55 }
56
57
58 protected Canvas createButton(final String type, final int moveType) {
59 Label b = new Label(type);
60 b.setBackgroundColor("#BED730");
61 b.setBorder("1px solid black");
62 b.setWidth(40);
63 b.setHeight(BUTTON_HEIGHT);
64 b.setAlign(Alignment.CENTER);
65
66 b.addClickHandler(new ClickHandler() {
67 public void onClick(ClickEvent event) {
68 fireOnMoveEvent(moveType);
69 }
70 });
71
72 return b;
73 }
74
75
76 protected void addOnMoveHandler(OnMoveHandler handler) {
77 if (handler != null) {
78 handlers.add(handler);
79 }
80 }
81
82
83 protected void fireOnMoveEvent(int type) {
84 OnMoveEvent event = new OnMoveEvent(type);
85
86 for (OnMoveHandler handler: handlers) {
87 handler.onMove(event);
88 }
89 }
90 }
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org