Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » differences between browser.setText and browser.setUrl behavior
differences between browser.setText and browser.setUrl behavior [message #488237] Sat, 26 September 2009 14:53 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Hi,
I'm trying to use the browser widget to do non-standard work, so I'm in a mess Smile

I'm basically trying to use the browser to display a Timeline and thus I am interested in building the pages dynamically in memory and then feed them to the browser.

Problem is the "page" uses heavily javascript to display the Timeline.

I did a lot of trials using a "local" timeline provided in the site and modifying it.

My current stumbling block is the browser.setText() and browser.setUrl() methods seem to behave in a somewhat different way.

My current test code includes this method:
	private void reload() {
		if (true) {
			String s = "local_example.html";
			File f = new File(s);
			try {
				URL u = f.toURI().toURL();
				s = u.toString();
				try {
					br.setUrl(s);
				} catch (Exception e) {
					e.printStackTrace();
				}
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
		} else if (true) {
			String s = "local_example.html";
			File f = new File(s);
			StringBuilder sb = new StringBuilder();
			BufferedReader r;
			try {
				r = new BufferedReader(new FileReader(f));
				while (true) {
					String l;
					try {
						l = r.readLine();
						if (l == null) break;
						sb.append(l);
						sb.append('\n');
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				try {
					r.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
			String page = sb.toString();
			br.setText(page);
		} else {
			String page =
				 "<html>\n"
				+"<head>\n"
				+"   <script>\n"
				+"      Timeline_ajax_url=\"timeline_2.3.0/timeline_ajax/simile-ajax-api.js\";\n"
				+"      Timeline_urlPrefix='timeline_2.3.0/timeline_js/';\n"
				+"      Timeline_parameters='bundle=true';\n"
				+"   </script>\n"
				+"   <script src=\"timeline_2.3.0/timeline_js/timeline-api.js?bundle=true\" type=\"text/javascript\"></script>\n"
				+"\n"
				+"   <!-- Since we don't have our own server, we do something tricky and load our data here as if it were a library file -->\n"
				+"   <!--\n"
				+"   <script src=\"local_data.js\" type=\"text/javascript\"></script>\n"
				+"   -->\n"
				+"   <script>\n"
				+"        var tl;\n"
				+"\n"
				+"var timeline_data = {  // save as a global variable\n"
				+"'dateTimeFormat': 'iso8601',\n"
				+"'wikiURL': \"http://simile.mit.edu/shelf/\",\n"
				+"'wikiSection': \"Simile Cubism Timeline\",\n"
				+"\n"
				+"'events' : [\n"
				+"        {'start': '1924',\n"
				+"        'title': 'Barfusserkirche',\n"
				+"        'description': 'by Lyonel Feininger, American/German Painter, 1871-1956',\n"
				+"        'image': 'http://images.allposters.com/images/AWI/NR096_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Barfusserkirche-1924-Posters_i1116895_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2013',\n"
				+"        'end': '2029',\n"
				+"        'title': 'Three Figures',\n"
				+"        'description': 'by Kasimir Malevich, Ukrainian Painter, 1878-1935',\n"
				+"        'image': 'http://images.allposters.com/images/BRGPOD/75857_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Three-Figures-1913-28-Posters_i1349989_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2081',\n"
				+"        'end': '2153',\n"
				+"        'title': 'Landschaft bei Montreuil',\n"
				+"        'description': 'by Albert Gleizes, French Painter, 1881-1953',\n"
				+"        'image': 'http://images.allposters.com/images/mer/1336_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Landschaft-bei-Montreuil-Posters_i339007_.htm',\n"
				+"        'isDuration' : true,\n"
				+"        'icon' : \"dark-red-circle.png\",        \n"
				+"        'color' : 'red',\n"
				+"        'textColor' : 'green'},\n"
				+"\n"
				+"\n"
				+"        {'start': '2020',\n"
				+"        'title': 'Femme au Miroir',\n"
				+"        'description': 'by Fernand Leger, French Painter, 1881-1955',\n"
				+"        'image': 'http://images.allposters.com/images/AWI/GMR117_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Femme-au-Miroir-1920-Posters_i141266_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2003',\n"
				+"        'title': 'The Old Guitarist',\n"
				+"        'description': 'by Pablo Picasso, Spanish Painter/Sculptor, 1881-1973',\n"
				+"        'image': 'http://images.allposters.com/images/ESC/AP599_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/The-Old-Guitarist-c-1903-Posters_i328746_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2082',\n"
				+"        'end': '2164',\n"
				+"        'title': 'Jour',\n"
				+"        'description': 'by Georges Braque, French Painter, 1882-1963',\n"
				+"        'image': 'http://images.allposters.com/images/SHD/S1041_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Jour-Posters_i126663_.htm',\n"
				+"        'color': 'green'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '1916',\n"
				+"        'title': 'Still Life with a White Dish',\n"
				+"        'description': 'by Gino Severini, Italian Painter, 1883-1966',\n"
				+"        'image': 'http://images.allposters.com/images/MCG/FS1254_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Still-Life-with-a-White-Dish-1916-Posters_i366823_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2085',\n"
				+"        'end': '2141',\n"
				+"        'title': 'Rhythm, Joie de Vivre',\n"
				+"        'description': 'by Robert Delaunay, French Painter, 1885-1941',\n"
				+"        'image': 'http://imagecache2.allposters.com/images/pic/adc/10053983a_b~Rhythm-Joie-de-Vivre-Posters.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Rhythm-Joie-de-Vivre-Posters_i1250641_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2085',\n"
				+"        'end': '2125',\n"
				+"        'title': 'Castor Et Pollux',\n"
				+"        'description': 'by Roger de la Fresnaye, French Painter, 1885-1925',\n"
				+"        'image': 'http://images.allposters.com/images/CORPOD/IX001463_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Castor-Et-Pollux-Posters_i831718_.htm',\n"
				+"        'tapeImage': 'blue_stripes.png',\n"
				+"        'tapeRepeat': 'repeat-x',\n"
				+"        'caption': \"This is the event's caption attribute.\",\n"
				+"        'classname': 'hot_event' \n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '1912',\n"
				+"        'title': 'Portrait of Pablo Picasso',\n"
				+"        'description': 'by Juan Gris, Spanish Painter/Sculptor, 1887-1927',\n"
				+"        'image': 'http://images.allposters.com/images/BRGPOD/156514_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Portrait-of-Pablo-Picasso-1881-1973-1912-Posters_i1344154_.htm'\n"
				+"        },\n"
				+"\n"
				+"\n"
				+"        {'start': '2091',\n"
				+"        'end': '2115',\n"
				+"        'title': 'Portrait of Horace Brodsky',\n"
				+"        'description': 'by Henri Gaudier-Brzeska, French Sculptor, 1891-1915',\n"
				+"        'image': 'http://imagecache2.allposters.com/images/BRGPOD/102770_b.jpg',\n"
				+"        'link': 'http://www.allposters.com/-sp/Portrait-of-Horace-Brodsky-Posters_i1584413_.htm'\n"
				+"        }\n"
				+"]\n"
				+"}\n"
				+" \n"
				+"        function onLoad() {\n"
				+"            var tl_el = document.getElementById(\"tl\");\n"
				+"            var eventSource1 = new Timeline.DefaultEventSource();\n"
				+"\n"
				+"            var theme1 = Timeline.ClassicTheme.create();\n"
				+"            theme1.autoWidth = true; // Set the Timeline's \"width\" automatically.\n"
				+"                                     // Set autoWidth on the Timeline's first band's theme,\n"
				+"                                     // will affect all bands.\n"
				+"            theme1.timeline_start = new Date(Date.UTC(1890, 0, 1));\n"
				+"            theme1.timeline_stop  = new Date(Date.UTC(2160, 0, 1));\n"
				+"\n"
				+"            var d = Timeline.DateTime.parseGregorianDateTime(\"1900\")\n"
				+"            var bandInfos = [\n"
				+"                Timeline.createBandInfo({\n"
				+"                    width:          45, // set to a minimum, autoWidth will then adjust\n"
				+"                    intervalUnit:   Timeline.DateTime.DECADE, \n"
				+"                    intervalPixels: 200,\n"
				+"                    eventSource:    eventSource1,\n"
				+"                    date:           d,\n"
				+"                    theme:          theme1,\n"
				+"                    layout:         'original'  // original, overview, detailed\n"
				+"                })\n"
				+"            ];\n"
				+"\n"
				+"            // create the Timeline\n"
				+"            tl = Timeline.create(tl_el, bandInfos, Timeline.HORIZONTAL);\n"
				+"\n"
				+"            var url = '.'; // The base url for image, icon and background image\n"
				+"                           // references in the data\n"
				+"            eventSource1.loadJSON(timeline_data, url); // The data was stored into the \n"
				+"                                                       // timeline_data variable.\n"
				+"            tl.layout(); // display the Timeline\n"
				+"        }\n"
				+"\n"
				+"        var resizeTimerID = null;\n"
				+"        function onResize() {\n"
				+"            if (resizeTimerID == null) {\n"
				+"                resizeTimerID = window.setTimeout(function() {\n"
				+"                    resizeTimerID = null;\n"
				+"                    tl.layout();\n"
				+"                }, 500);\n"
				+"            }\n"
				+"        }\n"
				+"   </script>\n"
				+"\n"
				+"</head>\n"
				+"<body onload=\"onLoad();\" onresize=\"onResize();\">\n"
				+"   <div id='tl'/>\n"
				+"</body>\n"
				+"</html>\n"
				;
			br.setText(page);
		}
	}

Obviously only one of the three methods to load a page can be used.
Only the first (the currently enabled one, using setUrl()) works ok; the other two (using setText()) display an empty page.
A bit of further investigation shows the browser is unable to find the javascript libraries (if I add something else, in pure HTML, to the page it is shown!).

Can someone shed light on what's going on here?

Two side issues:

  1. is it possible to have a javascript console showing the errors somehow?
  2. is there a better way to chose alternate "compile time" code variants than using plain "if(true)"; eclipse complains about dead code (rightly!).


Many Thanks in advance
Mauro
Re: differences between browser.setText and browser.setUrl behavior [message #488664 is a reply to message #488237] Tue, 29 September 2009 16:33 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Mauro,

I don't read javascript too often, but it looks like your library paths are
not absolute. A first experiment to try is to hard-code their absolute
values, and if this works then see if relative paths can be made to work by
specifying a "base" value like in
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet137.java?view=co .

> is it possible to have a javascript console showing the errors somehow?

In theory yes, but I don't know of any real-world cases to suggest. A
plug-in like Firebug depends on Firefox xpcom components that are not part
of the core embeddable browser, so it would not work in our case. I think
"try{...}catch(e){alert(e);}" is still your friend here ;-).

> is there a better way to chose alternate "compile time" code variants
than using plain "if(true)"; eclipse complains about dead code (rightly!).

I don't think so, the compiler's getting smarter. The old stand-bys like
"if (1 == 2-1)" don't fool it either.

HTH,
Grant


"Mauro Condarelli" <mc5686@mclink.it> wrote in message
news:h9l9u1$90c$1@build.eclipse.org...
> Hi,
> I'm trying to use the browser widget to do non-standard work, so I'm in a
mess :)
>
> I'm basically trying to use the browser to display a
http://www.simile-widgets.org/timeline/ and thus I am interested in building
the pages dynamically in memory and then feed them to the browser.
>
> Problem is the "page" uses heavily javascript to display the Timeline.
>
> I did a lot of trials using a "local" timeline provided in the site and
modifying it.
>
> My current stumbling block is the browser.setText() and browser.setUrl()
methods seem to behave in a somewhat different way.
>
> My current test code includes this method:
> private void reload() {
> if (true) {
> String s = "local_example.html";
> File f = new File(s);
> try {
> URL u = f.toURI().toURL();
> s = u.toString();
> try {
> br.setUrl(s);
> } catch (Exception e) {
> e.printStackTrace();
> }
> } catch (MalformedURLException e) {
> e.printStackTrace();
> }
> } else if (true) {
> String s = "local_example.html";
> File f = new File(s);
> StringBuilder sb = new StringBuilder();
> BufferedReader r;
> try {
> r = new BufferedReader(new FileReader(f));
> while (true) {
> String l;
> try {
> l = r.readLine();
> if (l == null) break;
> sb.append(l);
> sb.append('\n');
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> try {
> r.close();
> } catch (IOException e) {
> e.printStackTrace();
> }
> } catch (FileNotFoundException e) {
> e.printStackTrace();
> }
> String page = sb.toString();
> br.setText(page);
> } else {
> String page =
> "<html>\n"
> +"<head>\n"
> +" <script>\n"
> +"
Timeline_ajax_url=\"timeline_2.3.0/timeline_ajax/simile-ajax-api.js\ ";\n"
> +" Timeline_urlPrefix='timeline_2.3.0/timeline_js/';\n"
> +" Timeline_parameters='bundle=true';\n"
> +" </script>\n"
> +" <script
src=\"timeline_2.3.0/timeline_js/timeline-api.js?bundle=true\ "
type=\"text/javascript\"></script>\n"
> +"\n"
> +" <!-- Since we don't have our own server, we do something tricky and
load our data here as if it were a library file -->\n"
> +" <!--\n"
> +" <script src=\"local_data.js\" type=\"text/javascript\"></script>\n"
> +" -->\n"
> +" <script>\n"
> +" var tl;\n"
> +"\n"
> +"var timeline_data = { // save as a global variable\n"
> +"'dateTimeFormat': 'iso8601',\n"
> +"'wikiURL': \"http://simile.mit.edu/shelf/\",\n"
> +"'wikiSection': \"Simile Cubism Timeline\",\n"
> +"\n"
> +"'events' : [\n"
> +" {'start': '1924',\n"
> +" 'title': 'Barfusserkirche',\n"
> +" 'description': 'by Lyonel Feininger, American/German Painter,
1871-1956',\n"
> +" 'image':
'http://images.allposters.com/images/AWI/NR096_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Barfusserkirche-1924-Posters_i 1116895_.htm'\n
"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2013',\n"
> +" 'end': '2029',\n"
> +" 'title': 'Three Figures',\n"
> +" 'description': 'by Kasimir Malevich, Ukrainian Painter,
1878-1935',\n"
> +" 'image':
'http://images.allposters.com/images/BRGPOD/75857_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Three-Figures-1913-28-Posters_ i1349989_.htm'\
n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2081',\n"
> +" 'end': '2153',\n"
> +" 'title': 'Landschaft bei Montreuil',\n"
> +" 'description': 'by Albert Gleizes, French Painter,
1881-1953',\n"
> +" 'image':
'http://images.allposters.com/images/mer/1336_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Landschaft-bei-Montreuil-Poste rs_i339007_.htm
',\n"
> +" 'isDuration' : true,\n"
> +" 'icon' : \"dark-red-circle.png\", \n"
> +" 'color' : 'red',\n"
> +" 'textColor' : 'green'},\n"
> +"\n"
> +"\n"
> +" {'start': '2020',\n"
> +" 'title': 'Femme au Miroir',\n"
> +" 'description': 'by Fernand Leger, French Painter, 1881-1955',\n"
> +" 'image':
'http://images.allposters.com/images/AWI/GMR117_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Femme-au-Miroir-1920-Posters_i 141266_.htm'\n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2003',\n"
> +" 'title': 'The Old Guitarist',\n"
> +" 'description': 'by Pablo Picasso, Spanish Painter/Sculptor,
1881-1973',\n"
> +" 'image':
'http://images.allposters.com/images/ESC/AP599_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/The-Old-Guitarist-c-1903-Poste rs_i328746_.htm
'\n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2082',\n"
> +" 'end': '2164',\n"
> +" 'title': 'Jour',\n"
> +" 'description': 'by Georges Braque, French Painter,
1882-1963',\n"
> +" 'image':
'http://images.allposters.com/images/SHD/S1041_b.jpg',\n"
> +" 'link':
'http://www.allposters.com/-sp/Jour-Posters_i126663_.htm',\n"
> +" 'color': 'green'\n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '1916',\n"
> +" 'title': 'Still Life with a White Dish',\n"
> +" 'description': 'by Gino Severini, Italian Painter,
1883-1966',\n"
> +" 'image':
'http://images.allposters.com/images/MCG/FS1254_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Still-Life-with-a-White-Dish-1 916-Posters_i36
6823_.htm'\n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2085',\n"
> +" 'end': '2141',\n"
> +" 'title': 'Rhythm, Joie de Vivre',\n"
> +" 'description': 'by Robert Delaunay, French Painter,
1885-1941',\n"
> +" 'image':
' http://imagecache2.allposters.com/images/pic/adc/10053983a_b ~Rhythm-Joie-de
-Vivre-Posters.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Rhythm-Joie-de-Vivre-Posters_i 1250641_.htm'\n
"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2085',\n"
> +" 'end': '2125',\n"
> +" 'title': 'Castor Et Pollux',\n"
> +" 'description': 'by Roger de la Fresnaye, French Painter,
1885-1925',\n"
> +" 'image':
'http://images.allposters.com/images/CORPOD/IX001463_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Castor-Et-Pollux-Posters_i8317 18_.htm',\n"
> +" 'tapeImage': 'blue_stripes.png',\n"
> +" 'tapeRepeat': 'repeat-x',\n"
> +" 'caption': \"This is the event's caption attribute.\",\n"
> +" 'classname': 'hot_event' \n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '1912',\n"
> +" 'title': 'Portrait of Pablo Picasso',\n"
> +" 'description': 'by Juan Gris, Spanish Painter/Sculptor,
1887-1927',\n"
> +" 'image':
'http://images.allposters.com/images/BRGPOD/156514_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Portrait-of-Pablo-Picasso-1881 -1973-1912-Post
ers_i1344154_.htm'\n"
> +" },\n"
> +"\n"
> +"\n"
> +" {'start': '2091',\n"
> +" 'end': '2115',\n"
> +" 'title': 'Portrait of Horace Brodsky',\n"
> +" 'description': 'by Henri Gaudier-Brzeska, French Sculptor,
1891-1915',\n"
> +" 'image':
' http://imagecache2.allposters.com/images/BRGPOD/102770_b.jpg',\n"
> +" 'link':
' http://www.allposters.com/-sp/Portrait-of-Horace-Brodsky-Pos ters_i1584413_.
htm'\n"
> +" }\n"
> +"]\n"
> +"}\n"
> +" \n"
> +" function onLoad() {\n"
> +" var tl_el = document.getElementById(\"tl\");\n"
> +" var eventSource1 = new Timeline.DefaultEventSource();\n"
> +"\n"
> +" var theme1 = Timeline.ClassicTheme.create();\n"
> +" theme1.autoWidth = true; // Set the Timeline's \"width\"
automatically.\n"
> +" // Set autoWidth on the Timeline's
first band's theme,\n"
> +" // will affect all bands.\n"
> +" theme1.timeline_start = new Date(Date.UTC(1890, 0, 1));\n"
> +" theme1.timeline_stop = new Date(Date.UTC(2160, 0, 1));\n"
> +"\n"
> +" var d =
Timeline.DateTime.parseGregorianDateTime(\"1900\")\n"
> +" var bandInfos = [\n"
> +" Timeline.createBandInfo({\n"
> +" width: 45, // set to a minimum, autoWidth
will then adjust\n"
> +" intervalUnit: Timeline.DateTime.DECADE, \n"
> +" intervalPixels: 200,\n"
> +" eventSource: eventSource1,\n"
> +" date: d,\n"
> +" theme: theme1,\n"
> +" layout: 'original' // original, overview,
detailed\n"
> +" })\n"
> +" ];\n"
> +"\n"
> +" // create the Timeline\n"
> +" tl = Timeline.create(tl_el, bandInfos,
Timeline.HORIZONTAL);\n"
> +"\n"
> +" var url = '.'; // The base url for image, icon and
background image\n"
> +" // references in the data\n"
> +" eventSource1.loadJSON(timeline_data, url); // The data was
stored into the \n"
> +" // timeline_data
variable.\n"
> +" tl.layout(); // display the Timeline\n"
> +" }\n"
> +"\n"
> +" var resizeTimerID = null;\n"
> +" function onResize() {\n"
> +" if (resizeTimerID == null) {\n"
> +" resizeTimerID = window.setTimeout(function() {\n"
> +" resizeTimerID = null;\n"
> +" tl.layout();\n"
> +" }, 500);\n"
> +" }\n"
> +" }\n"
> +" </script>\n"
> +"\n"
> +"</head>\n"
> +"<body onload=\"onLoad();\" onresize=\"onResize();\">\n"
> +" <div id='tl'/>\n"
> +"</body>\n"
> +"</html>\n"
> ;
> br.setText(page);
> }
> }
>
> Obviously only one of the three methods to load a page can be used.
> Only the first (the currently enabled one, using setUrl()) works ok; the
other two (using setText()) display an empty page.
> A bit of further investigation shows the browser is unable to find the
javascript libraries (if I add something else, in pure HTML, to the page it
is shown!).
>
> Can someone shed light on what's going on here?
>
> Two side issues:
> is it possible to have a javascript console showing the errors somehow?
> is there a better way to chose alternate "compile time" code variants
than using plain "if(true)"; eclipse complains about dead code (rightly!).
>
>
> Many Thanks in advance
> Mauro
>
Re: differences between browser.setText and browser.setUrl behavior [message #488682 is a reply to message #488664] Tue, 29 September 2009 17:45 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Quote:
Hi Mauro,

I don't read javascript too often, but it looks like your library paths are
not absolute. A first experiment to try is to hard-code their absolute
values, and if this works then see if relative paths can be made to work by
specifying a "base" value like in
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet137.java?view=co .



Thanks Grant.

First test was *not* successful.
IE is now complaining about "out of memory in line xxxx".
I will dig further, probably I did some stupid mistake.

Question is: I would like, if at all possible, to pack the whole bunch of javascript in the same jarfile with the product (RCP app),
Is there any chance to convince the browser to search for resources in the jar?
If so, can You give me some pointer to docs?

I do not have a real web server, all pages should be rendered from the local filesystem (file:///...)

Thanks again
Mauro
Re: differences between browser.setText and browser.setUrl behavior [message #488853 is a reply to message #488682] Wed, 30 September 2009 13:49 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
The Browser will not look for resources in a jar. However if they are in
your plug-in jar then I think the eclipse RCP platform will auto-extract
them somewhere, and you can then point at them there. For an example of
something like this (just solving a different problem) see the code snippet
that's part of http://www.eclipse.org/swt/faq.php#specifyxulrunner .

Grant


"Mauro Condarelli" <mc5686@mclink.it> wrote in message
news:h9th39$1m2$1@build.eclipse.org...
> Quote:
> > Hi Mauro,
> >
> > I don't read javascript too often, but it looks like your library paths
are
> > not absolute. A first experiment to try is to hard-code their absolute
> > values, and if this works then see if relative paths can be made to work
by
> > specifying a "base" value like in
> > http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni
ppets/src/org/eclipse/swt/snippets/Snippet137.java?view=co .
>
>
> Thanks Grant.
>
> First test was *not* successful.
> IE is now complaining about "out of memory in line xxxx".
> I will dig further, probably I did some stupid mistake.
>
> Question is: I would like, if at all possible, to pack the whole bunch of
javascript in the same jarfile with the product (RCP app),
> Is there any chance to convince the browser to search for resources in the
jar?
> If so, can You give me some pointer to docs?
>
> I do not have a real web server, all pages should be rendered from the
local filesystem (file:///...)
>
> Thanks again
> Mauro
Re: differences between browser.setText and browser.setUrl behavior [message #494713 is a reply to message #488237] Mon, 02 November 2009 10:12 Go to previous message
No real name is currently offline No real nameFriend
Messages: 1
Registered: November 2009
Junior Member
In reply and ignorant whether of nor you've discovered the solution since ~month ago but worth offering insights for yourself and the rest stumbling across this thread.

For displaying errors and even verbose level trace debugs, we've discovered Aptana's Suite is capable of parsing Timeline's fairly unique brand of JSON data files while most others failed to recognize it or would choke at the first "isduration" command. Whether you're already familiar with Aptana it comes in stand alone and eclipse packages and completely free from the Aptana web site. Eclipse may already be accomplishing this to some degree and we aren't experienced Eclipse users but one testament for Aptana is native modules opened up a Timeline site via the URL and local file path and immediately marked a unicode comma that was pasted into the JSON data source and borked up the whole widget. The "developer" who searched for a while but never found anything better than FrontPage 2003 to edit their JSON wasted nearly a week of frustration practically rebuilding it step by step w/o solving the error until Aptana zinged it and offered a single right click quick fix back to usable.
For the other parts of our group, Aptana's JSON parser saves them time from the old method of saving and refreshing the JSON for browser reload since you likely know a single misplaced comma is enough to bork it all and force a person to scream at the moon if debugging the last 10 events since the last refresh.

Regarding your particular code example and the mysteries of why it works when you jam pure HTML and the errors in IE the reasons are annoying but fixed in a few secs:

--Don't fret about using a real web server for Timeline since its ultra compatibility and industry compliant design makes it useful for loading massive amounts of events and venerable on nearly any dinosaur PC even if using dial up. Aptana includes a web server but timeline's browser behavior is the same whether the URL is HTTP or a local file.

-- IE chokes when commas precede a brace while Firefox and other browsers accommodate it w/o performance hits. The IE issue is like most others whenever a recalcitrant Microsoft product is confronted with an industry / open standard data format. The preceding comma error typically results in the popup script error box and sometimes displays a minimal chrono time strip but w/o events or can just fail to display anything except the HTML the same way a malformed JSON file does.

-- I've noticed several backslashes in your example script and if those are just translated by this forum server and your actual code doesn't have backslashes you can disregard this warning but the timeline widgets are rigid in their conventions regardless of any accommodating features of AJAX and JSON or Eclipse for parsing "\". Even on Win32, using forward slashes will be properly interpreted using relative paths starting with the location of your HTML file as the root of the tree but can still parse "../" and the variants if you need to crawl up your filesystem and out of your source directory. Crawling up and out isn't a best practice for most web scripts and we'd discourage it and copy any resource from your webserver into your timelines starting path for good measure. Even NTFS symbolic directory links with Timeline have resulted in sporadic errors that occur w/o consistency.

Also catching your question about compiling the widgets and data *.js into a single JAR file is intriguing but un-necessary if your goal is to use the Simile widgets offline, the base examples connect to MIT's web site to load painter and core API's but fail to display on systems w/o live connections until corrections of variables are twirked and the painters loaded. Aptana also uses Firebug but seems to trap the output and loads back into the Aptana suite and reveals a slew of labellers and painter scripts from MIT's site to make those timelines work and blitzingly fast despite the script downloads. I'll be happy to paste or upload attachments if possible the modified timeline api's and the additional painters to make it all run locally w/o live connections. The Simile MIT website packages it with a readme but it assumes you'll always have a locally controlled web or intranet server to emulate their own HTML paths and even decent enough to include a jetty daemon and ready to run XML config. It seems every time we see the Timeline loaded into any wrapper and its contrasting conventions like backslashes causes Timeline to malfunction, their code base site seems to imply a fierce independence and unforgiving for any code between it and the end users browser. Like putting snow tires on a Ferrari since it may work but so irksome you'll lose faith in your reasons and just reinstall the original feet and strap a snowplow to the front bumper !

A web server isn't really necessary as long as the local versions paths are laid out and is a necessity for us because we use Timeline as a litigation tool when presenting evidence packages to opposing counsel on a CD / DVD. Law firms are mostly techno illiterate and fairly nervous when loading media from a plantiff and lose their fuddamucking minds from the XP / Vista popup warnings that a process is attempting to start a web server,listening port, etc, etc fearful of trojans and prefer to read the evidence on their island laptop w/o access to MIT's api directory.

The Simile timeline widgets are nothing less than high performance equivalent Ferrari's for displaying events in a temporal fashion but also just as quirky as a handmade automobile while the docs are choppy and seem to commingle old conventions into non accepting current API's and isn't unique to Timeline or most other student created projects where the authors earned their A+ for execution but nary a grade for docs and have moved on . Even worse is the local versions inabilities to incorporate all of the full versions including some of the multi bands until specific local <--> twerks are coded and incompatible in different versions.

The timeline software offerings remain anemic or inadequate whether commercial and freeware and the original simile timeline authors or anyone else skilled enough could earn a fortune and garner infinite kudos for reconciling the docs and managing the code trees.

I must advise I HAVE NO AFFILIATION NOR RELATIONSHIP WITH APTANA AND THIS HAS TO BE MENTIONED SINCE MY RECOMMENDATIONS SEEM NEARLY OBSEQUIOUS BUT I'M JUST A CONFIRMED USER WHO FOUND A SOLUTION SEEMINGLY TAILORED FOR OUR UNIQUE REQUIREMENTS.
The APTANA sutie is FULLY FUNCTIONAL AND FREE OF CHARGE AND NO ONE RECEIVES ANY REWARDS FOR RECOMMENDING THEIR SUITE. TRULY OPEN SOURCE IN THE ORIGINAL SENSE.
Previous Topic:Background mode and SWT.NO_REDRAW_RESIZE
Next Topic:Concurrently modifying position in an IDocument
Goto Forum:
  


Current Time: Fri Mar 29 09:31:57 GMT 2024

Powered by FUDForum. Page generated in 0.02411 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top