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

Last change on this file since 23906 was 23906, checked in by sjm84, 13 years ago

Committing most recent version of ATLAS

File size: 1.9 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 private GS3MapLibrary _atlasInstance = null;
15
16 public StatusBar(GS3MapLibrary atlasInstance)
17 {
18 _statusBarDiv.setStyleName("statusBar");
19 _atlasInstance = atlasInstance;
20 }
21
22 public void addUpdate(String update, String id)
23 {
24 GS3MapLibrary.logToConsole("Got update -> " + update + " - " + id);
25
26 if(_ids.get(id) != null)
27 {
28 return;
29 }
30
31 for(int j = 0; j < _statusUpdates.size(); j++)
32 {
33 if(_statusUpdates.get(j) == null)
34 {
35
36 _statusUpdates.add(j, update);
37 _ids.put(id, j);
38 updateStatusBar();
39 return;
40 }
41 }
42
43 _ids.put(id, _statusUpdates.size());
44 _statusUpdates.add(update);
45 updateStatusBar();
46 _atlasInstance.resizeElements();
47 }
48
49 public boolean removeUpdate(String updateId)
50 {
51 Integer index = _ids.get(updateId);
52 if(index == null)
53 {
54 return false;
55 }
56
57 _ids.remove(updateId);
58 _statusUpdates.set(index, null);
59 updateStatusBar();
60 _atlasInstance.resizeElements();
61 return true;
62 }
63
64 private void updateStatusBar()
65 {
66 String status = "";
67 boolean noStatusUpdate = true;
68
69 for(int j = 0; j < _statusUpdates.size(); j++)
70 {
71 if(_statusUpdates.get(j) != null)
72 {
73 if(noStatusUpdate)
74 {
75 noStatusUpdate = false;
76 }
77 else
78 {
79 status += " <br/> ";
80 }
81
82 status += _statusUpdates.get(j);
83 }
84 }
85
86 if(!status.equals(""))
87 {
88 GS3MapLibrary.logToConsole("Adding progress image");
89 status += "<br/><img src=\"http://localhost:8080/ATLAS/images/progress.gif\"></img>";
90 }
91 _statusBarDiv.setHTML(status);
92 }
93
94 public HTML getStatusBarDiv()
95 {
96 return _statusBarDiv;
97 }
98}
Note: See TracBrowser for help on using the repository browser.