Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSWorkspace.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java@e70ff0a600a3 |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.client.client.ui; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 | |
5 import com.smartgwt.client.types.Alignment; | |
6 import com.smartgwt.client.types.VerticalAlignment; | |
7 import com.smartgwt.client.widgets.Button; | |
8 import com.smartgwt.client.widgets.Canvas; | |
9 import com.smartgwt.client.widgets.Img; | |
10 import com.smartgwt.client.widgets.Label; | |
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 import com.smartgwt.client.widgets.layout.VLayout; | |
15 | |
16 import de.intevation.flys.client.client.FLYS; | |
17 import de.intevation.flys.client.client.FLYSConstants; | |
18 | |
19 import java.util.HashMap; | |
20 import java.util.Map; | |
21 | |
22 | |
23 /** | |
24 * "Workspace" canvas showing the CollectionViews (subwindows). | |
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
26 */ | |
27 public class FLYSWorkspace extends Canvas { | |
28 | |
29 /** The maximal number of windows that fit into the browser view when an | |
30 * offset is used to move windows initially.*/ | |
31 public static int MAX_WINDOWS = 10; | |
32 | |
33 /** The number of pixels used to move windows.*/ | |
34 public static int WINDOW_OFFSET = 20; | |
35 | |
36 /** A map that contains the open CollectionViews. */ | |
37 protected Map<String, CollectionView> views; | |
38 | |
39 /** The interface that provides the message resources. */ | |
40 private FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); | |
41 | |
42 /** Application instance. */ | |
43 private FLYS flys; | |
44 | |
45 | |
46 /** | |
47 * The default constructor creates an empty FLYSWorkspace with no | |
48 * CollectionViews opened. | |
49 */ | |
50 public FLYSWorkspace(FLYS flys) { | |
51 this.flys = flys; | |
52 views = new HashMap<String, CollectionView>(); | |
53 | |
54 setWidth("100%"); | |
55 setHeight("100%"); | |
56 | |
57 addBackgroundWorkspace(); | |
58 } | |
59 | |
60 | |
61 /** | |
62 * This method adds a new CollectionView to this workspace and stores a | |
63 * reference in {@link views}. | |
64 * | |
65 * @param collectionView A new CollectionView. | |
66 */ | |
67 public void addView(String uuid, CollectionView collectionView) { | |
68 collectionView.moveTo(0, 0); | |
69 collectionView.setMaximized(true); | |
70 | |
71 views.put(uuid, collectionView); | |
72 addChild(collectionView); | |
73 } | |
74 | |
75 | |
76 public void removeProject(String uuid) { | |
77 views.remove(uuid); | |
78 } | |
79 | |
80 | |
81 public void bringUp(String uuid) { | |
82 CollectionView view = views.get(uuid); | |
83 | |
84 if (view != null) { | |
85 view.show(); | |
86 view.restore(); | |
87 } | |
88 else { | |
89 GWT.log("FLYSWorkspace.bringUp() failed!"); | |
90 } | |
91 } | |
92 | |
93 | |
94 /** | |
95 * Removes a project from workspace (view) and clears its reference from | |
96 * hash map. | |
97 * | |
98 * @param uuid The project's uuid. | |
99 */ | |
100 public void destroyProject(String uuid) { | |
101 CollectionView project = views.get(uuid); | |
102 | |
103 if (project != null) { | |
104 removeProject(uuid); | |
105 project.destroy(); | |
106 } | |
107 } | |
108 | |
109 | |
110 public void updateTitle(String uuid, String title) { | |
111 CollectionView view = views.get(uuid); | |
112 view.setTitle(title); | |
113 } | |
114 | |
115 | |
116 public boolean hasView(String uuid) { | |
117 if(views.get(uuid) != null) { | |
118 return true; | |
119 } | |
120 return false; | |
121 } | |
122 | |
123 private void addBackgroundWorkspace() { | |
124 String baseUrl = GWT.getHostPageBaseURL(); | |
125 Img bfg = new Img( | |
126 baseUrl + MESSAGES.bfgLogo()); | |
127 bfg.setWidth(150); | |
128 bfg.setHeight(100); | |
129 bfg.setLayoutAlign(Alignment.RIGHT); | |
130 | |
131 HLayout backgroundlayout = new HLayout(); | |
132 backgroundlayout.setHeight100(); | |
133 backgroundlayout.setWidth100(); | |
134 backgroundlayout.setDefaultLayoutAlign(Alignment.CENTER); | |
135 backgroundlayout.setDefaultLayoutAlign(VerticalAlignment.CENTER); | |
136 | |
137 Canvas spacer = new Canvas(); | |
138 spacer.setWidth("33%"); | |
139 | |
140 VLayout infobox = new VLayout(); | |
141 infobox.setHeight("*"); | |
142 infobox.setWidth("*"); | |
143 infobox.setDefaultLayoutAlign(Alignment.CENTER); | |
144 | |
145 Label welcome = new Label(MESSAGES.welcome()); | |
146 welcome.setAlign(Alignment.CENTER); | |
147 welcome.setStyleName("fontNormalBig"); | |
148 | |
149 Label lcreate = new Label(MESSAGES.welcome_open_or_create()); | |
150 lcreate.setStyleName("welcomeCreateText"); | |
151 lcreate.setWidth100(); | |
152 lcreate.setAlign(Alignment.CENTER); | |
153 | |
154 Button addbutton = new Button(MESSAGES.new_project()); | |
155 addbutton.setStyleName("projectsAddButton"); | |
156 addbutton.setAlign(Alignment.CENTER); | |
157 addbutton.setTitle(MESSAGES.new_project()); | |
158 addbutton.setAutoFit(true); | |
159 addbutton.addClickHandler(new ClickHandler() { | |
160 | |
161 @Override | |
162 public void onClick(ClickEvent event) { | |
163 flys.newProject(); | |
164 } | |
165 }); | |
166 | |
167 | |
168 infobox.addMember(welcome); | |
169 infobox.addMember(lcreate); | |
170 infobox.addMember(addbutton); | |
171 | |
172 backgroundlayout.addMember(spacer); | |
173 backgroundlayout.addMember(infobox); | |
174 backgroundlayout.addMember(spacer); | |
175 | |
176 addChild(backgroundlayout); | |
177 } | |
178 } | |
179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |