source: gs3-extensions/atlas-src/trunk/src/org/greenstone/client/StatusBar.java@ 22272

Last change on this file since 22272 was 22272, checked in by sjm84, 14 years ago

Initial version of ATLAS as an extension

File size: 1.7 KB
Line 
1package org.greenstone.client;
2
3import java.util.ArrayList;
4import java.util.HashMap;
5
6import com.google.gwt.user.client.ui.HTML;
7
8public class StatusBar
9{
10 private HashMap<String, Integer> _ids = new HashMap<String, Integer>();
11 private HTML _statusBarDiv = new HTML();
12 private ArrayList<String> _statusUpdates = new ArrayList<String>();
13
14 public StatusBar()
15 {
16 _statusBarDiv.setStyleName("statusBar");
17 }
18
19 public void addUpdate(String update, String id)
20 {
21 GS3MapLibrary.logToConsole("Got update -> " + update + " - " + id);
22
23 if(_ids.get(id) != null)
24 {
25 return;
26 }
27
28 for(int j = 0; j < _statusUpdates.size(); j++)
29 {
30 if(_statusUpdates.get(j) == null)
31 {
32
33 _statusUpdates.add(j, update);
34 _ids.put(id, j);
35 updateStatusBar();
36 return;
37 }
38 }
39
40 _ids.put(id, _statusUpdates.size());
41 _statusUpdates.add(update);
42 updateStatusBar();
43 }
44
45 public boolean removeUpdate(String updateId)
46 {
47 Integer index = _ids.get(updateId);
48 if(index == null)
49 {
50 return false;
51 }
52
53 _ids.remove(updateId);
54 _statusUpdates.set(index, null);
55 updateStatusBar();
56 return true;
57 }
58
59 private void updateStatusBar()
60 {
61 String status = "";
62 boolean noStatusUpdate = true;
63
64 for(int j = 0; j < _statusUpdates.size(); j++)
65 {
66 if(_statusUpdates.get(j) != null)
67 {
68 if(noStatusUpdate)
69 {
70 noStatusUpdate = false;
71 }
72 else
73 {
74 status += " <br/> ";
75 }
76
77 status += _statusUpdates.get(j);
78 }
79 }
80
81 if(!status.equals(""))
82 {
83 GS3MapLibrary.logToConsole("Adding progress image");
84 status += "<br/><img src=\"http://localhost:8080/GS3MapLibrary/images/progress.gif\"></img>";
85 }
86 _statusBarDiv.setHTML(status);
87 }
88
89 public HTML getStatusBarDiv()
90 {
91 return _statusBarDiv;
92 }
93}
Note: See TracBrowser for help on using the repository browser.