source: gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/TemporaryFrame.java@ 23934

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

Extensive improvements to the ATLAS code

File size: 1.9 KB
Line 
1package org.greenstone.atlas.client;
2
3import com.google.gwt.core.client.JsArray;
4import com.google.gwt.user.client.Element;
5import com.google.gwt.user.client.Timer;
6import com.google.gwt.user.client.ui.Frame;
7
8public class TemporaryFrame
9{
10 protected static int _totalIndex = 0;
11
12 protected Frame _frame = null;
13
14 protected String _url = null;
15 protected String _text = null;
16
17 protected boolean _doneLoading = false;
18
19 protected int _index = _totalIndex++;
20
21 public TemporaryFrame(String url)
22 {
23 _frame = new Frame();
24 _frame.setSize("0px", "0px");
25 _frame.getElement().getStyle().setProperty("border", "0px");
26
27 _url = url;
28 }
29
30 public void loadPage()
31 {
32 _frame.setUrl(_url);
33
34 Timer loadTimer = new Timer()
35 {
36 int timerCount = 0;
37
38 public void run()
39 {
40 if (timerCount++ > 10)
41 {
42 _doneLoading = true;
43 this.cancel();
44 return;
45 }
46
47 if (GS3MapLibrary.tempFrameGetElementById(_index, "banner") != null && GS3MapLibrary.tempFrameGetElementById(_index, "content") != null && GS3MapLibrary.tempFrameGetElementById(_index, "footer") != null)
48 {
49 this.cancel();
50
51 JsArray<Element> divs = GS3MapLibrary.tempFrameGetElementsByTagName(_index, "div");
52
53 Element documentTextDiv = null;
54 for (int i = 0; i < divs.length(); i++)
55 {
56 if (divs.get(i).getAttribute("class").equals("documenttext"))
57 {
58 documentTextDiv = divs.get(i);
59 break;
60 }
61 }
62
63 if (documentTextDiv != null)
64 {
65 _text = documentTextDiv.getInnerText();
66 }
67 _doneLoading = true;
68 }
69 }
70 };
71 loadTimer.scheduleRepeating(1000);
72 }
73
74 public boolean isFinishedLoading()
75 {
76 return _doneLoading;
77 }
78
79 public static void setCurrentFrameIndex(int index)
80 {
81 _totalIndex = index;
82 }
83
84 public void removeFromParent()
85 {
86 _frame.getElement().getParentElement().removeChild(_frame.getElement());
87 }
88
89 public Frame getFrame()
90 {
91 return _frame;
92 }
93
94 public String getText()
95 {
96 return _text;
97 }
98}
Note: See TracBrowser for help on using the repository browser.