PageRenderTime 499ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/gwt/src/Timeline/doc/index.html

https://gitlab.com/Guy1394/chap-links-library
HTML | 398 lines | 330 code | 68 blank | 0 comment | 0 complexity | f3f663089f48aa1a968713672910fc99 MD5 | raw file
  1. <html>
  2. <head>
  3. <title>Timeline GWT documentation</title>
  4. <link rel='stylesheet' href='default.css' type='text/css'>
  5. <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <h1>Timeline GWT documentation</h1>
  10. <p>
  11. There is a GWT wrapper available to use the Timeline inside Google Web
  12. Toolkit (GWT).
  13. This documentation assumes you have Eclipse installed, and have GWT
  14. installed in Eclipse.
  15. </p>
  16. <h2>Short guide</h2>
  17. <p>
  18. To use the GWT version of the Timeline, create a GWT project. Put a copy of the
  19. modules <b><a href="http://almende.github.com/chap-links-library/downloads.html">gwt-links-timeline.jar</a></b> and
  20. <b><a href="http://code.google.com/p/gwt-google-apis/downloads/" target="_blank">gwt-visualization.jar</a></b>
  21. in a subfolder of your project (for example lib),
  22. and add both jar-modules to your project via "Build path", "Add external archives...".
  23. Then, add the following lines to the module file MyProject.gwt.xml:
  24. <pre class="prettyprint lang-html">&lt;!-- Other module inherits --&gt;
  25. &lt;inherits name='com.google.gwt.visualization.Visualization'/&gt;
  26. &lt;inherits name='com.chap.links.Timeline'/&gt;
  27. &lt;!-- External stylesheets --&gt;
  28. &lt;!-- Include at least one stylesheet, else the stylesheets in --&gt;
  29. &lt;!-- external modules like Timeline.jar are not loaded...(bug?) --&gt;
  30. &lt;stylesheet src=""&gt;&lt;/stylesheet&gt;
  31. </pre>
  32. Thats all, now you can use the Timeline.
  33. </p>
  34. <h2>Getting started</h2>
  35. <p>
  36. </p>
  37. <h3>Step 1: Strip the default Web Application Project</h3>
  38. <p>
  39. First, we start create a new, default Web Application Project, and strip
  40. off all unneeded code and files.
  41. </p>
  42. <ul>
  43. <li>Open Eclipse</li>
  44. <li>Go to menu File, New, Web Application Project.
  45. Give your project a name and package name (for example name "TimelineDemo1",
  46. and package "com.chap.links"), and click Finish.
  47. Now you have the default "Web Application Starter Project",
  48. which you can run directly.</li>
  49. <li>Go to the folder src and expand all subfolders in here.
  50. Remove the files <b>GreetingService.java</b>,
  51. <b>GreetingServiceAsync.java</b>, <b>GreetingServiceImpl.java</b>,
  52. and <b>FieldVerifier.java</b>.</li>
  53. <li>Now we have to remove the references to the just removed servlets.
  54. Go to the folder war/WEB-INF, and open the file <b>web.xml</b>.
  55. remove all code under
  56. <code>&lt;!-- Servlets --&gt;</code>
  57. such that you have
  58. the following contents remaining:
  59. <pre class="prettyprint lang-html">
  60. &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  61. &lt;!DOCTYPE web-app
  62. PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  63. "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
  64. &lt;web-app&gt;
  65. &lt;!-- Servlets --&gt;
  66. &lt;!-- Default page to serve --&gt;
  67. &lt;welcome-file-list&gt;
  68. &lt;welcome-file&gt;TimelineDemo1.html&lt;/welcome-file&gt;
  69. &lt;/welcome-file-list&gt;
  70. &lt;/web-app&gt;</pre>
  71. </li>
  72. <li>Open the file <b>TimelineDemo1.java</b>. Replace the contents with the following
  73. code:
  74. <pre class="prettyprint lang-java">
  75. package com.chap.links.client;
  76. import com.google.gwt.core.client.EntryPoint;
  77. import com.google.gwt.event.dom.client.ClickEvent;
  78. import com.google.gwt.event.dom.client.ClickHandler;
  79. import com.google.gwt.user.client.Window;
  80. import com.google.gwt.user.client.ui.Button;
  81. import com.google.gwt.user.client.ui.RootPanel;
  82. import com.google.gwt.user.client.ui.TextBox;
  83. /**
  84. * Entry point classes define onModuleLoad().
  85. */
  86. public class TimelineDemo1 implements EntryPoint {
  87. /**
  88. * This is the entry point method.
  89. */
  90. public void onModuleLoad() {
  91. final TextBox txtName = new TextBox();
  92. final Button btnHelloWorld = new Button("Click me");
  93. txtName.setText("user");
  94. // Add the button to the RootPanel
  95. RootPanel.get("txtName").add(txtName);
  96. RootPanel.get("btnHelloWorld").add(btnHelloWorld);
  97. txtName.setFocus(true);
  98. txtName.selectAll();
  99. // Add a handler to close the DialogBox
  100. btnHelloWorld.addClickHandler(new ClickHandler() {
  101. public void onClick(ClickEvent event) {
  102. Window.alert("Hello " + txtName.getText() + "!");
  103. }
  104. });
  105. }
  106. }</pre>
  107. </li>
  108. <li>Go to the folder web, and open the file <b>TimelineDemo1.html</b>.
  109. Replace the contents with the following code:
  110. <pre class="prettyprint lang-html">
  111. &lt;!doctype html&gt;
  112. &lt;html&gt;
  113. &lt;head&gt;
  114. &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;
  115. &lt;link type="text/css" rel="stylesheet" href="TimelineDemo1.css"&gt;
  116. &lt;title&gt;Timeline Demo 1&lt;/title&gt;
  117. &lt;script type="text/javascript" language="javascript"
  118. src="timelinedemo1/timelinedemo1.nocache.js"&gt;&lt;/script&gt;
  119. &lt;/head&gt;
  120. &lt;body&gt;
  121. &lt;!-- OPTIONAL: include this if you want history support --&gt;
  122. &lt;iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
  123. style="position:absolute;width:0;height:0;border:0"&gt;&lt;/iframe&gt;
  124. &lt;!-- RECOMMENDED if your web app will not function without JavaScript enabled --&gt;
  125. &lt;noscript&gt;
  126. &lt;div style="color: red;"&gt;
  127. Your web browser must have JavaScript enabled
  128. in order for this application to display correctly.
  129. &lt;/div&gt;
  130. &lt;/noscript&gt;
  131. &lt;h1&gt;Timeline Demo 1&lt;/h1&gt;
  132. Enter your name: &lt;span id="txtName"&gt;&lt;/span&gt; &lt;span id="btnHelloWorld"&gt;&lt;/span&gt;
  133. &lt;/body&gt;
  134. &lt;/html&gt; </pre>
  135. </li>
  136. <li>Open the file <b>TimelineDemo1.css</b>, and replace the contents with:
  137. <pre class="prettyprint lang-css">
  138. body {
  139. font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif;
  140. width: 800px;
  141. }
  142. h1 {
  143. font-size: 150%;
  144. font-weight: bold;
  145. padding: 0;
  146. margin: 1em 0 0 .3em;
  147. }
  148. h2 {
  149. font-size: 110%;
  150. } </pre>
  151. </li>
  152. </ul>
  153. <p>
  154. Run the application and check if it works. Enter your name, and press the button.
  155. See if you get a message window saying "Hello name!".
  156. If everything works correct, you are ready to implement a Timeline.
  157. </p>
  158. <h3>Step 2: Add GWT Visualization</h3>
  159. <p>
  160. Now we will add everything needed to use the Google Visualization Tools.
  161. </p>
  162. <ul>
  163. <li>
  164. Download the Chart Tools API Library
  165. <a href="http://code.google.com/p/gwt-google-apis/downloads/"
  166. target="_blank">here</a>.
  167. Extract the file <b>gwt-visualization.jar</b>, and put it somewhere on your computer,
  168. for example the folder src/lib/ of your project.
  169. Inside Eclipse, right-click on the project and choose "Build path",
  170. "Add external archives...".
  171. Then select the file gwt-visualization.jar you have just extracted.</li>
  172. <li>Open the file <b>TimelineDemo1.gwt.xml</b> inside the folder
  173. src/com.chap.links. Under the Comment line "Other module inherits",
  174. add the following line.
  175. <pre class="prettyprint lang-html">
  176. &lt;!-- Other module inherits --&gt;
  177. &lt;inherits name='com.google.gwt.visualization.Visualization'/&gt; </pre>
  178. </li>
  179. </ul>
  180. <p>
  181. Check if your program still compiles after you restart your application
  182. (nothing is yet changed in the interface though).
  183. </p>
  184. <h3>Step 3: Add the Timeline</h3>
  185. <p>
  186. </p>
  187. <ul>
  188. <li>Take a copy of the module <b>gwt-timeline.jar</b>,
  189. and put it somewhere on in your project,
  190. for example the folder src/lib/. Inside Eclipse, right-click on the project
  191. and choose "Build path", "Add external archives...".
  192. Then select the file gwt-timeline.jar you have just copied.</li>
  193. <li>Open the file <b>TimelineDemo1.gwt.xml</b> inside the folder
  194. src/com.chap.links. Under the Comment line "Other module inherits",
  195. add a line for the Timeline visualization, directly under the line
  196. for the Google visualization that we already added.
  197. <pre class="prettyprint lang-html">
  198. &lt;!-- Other module inherits --&gt;
  199. &lt;inherits name='com.google.gwt.visualization.Visualization'/&gt;
  200. &lt;inherits name='com.chap.links.Timeline'/&gt;
  201. &lt;!-- External stylesheets --&gt;
  202. &lt;!-- Include at least one stylesheet, else the stylesheets in --&gt;
  203. &lt;!-- external modules like Timeline.jar are not loaded...(bug?) --&gt;
  204. &lt;stylesheet src=""&gt;&lt;/stylesheet&gt;
  205. </pre>
  206. </li>
  207. <li>Open the file <b>TimelineDemo1.html</b> in the folder war,
  208. and replace the contents with the following code.
  209. <pre class="prettyprint lang-html">
  210. &lt;!doctype html&gt;
  211. &lt;html&gt;
  212. &lt;head&gt;
  213. &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;
  214. &lt;link type="text/css" rel="stylesheet" href="TimelineDemo1.css"&gt;
  215. &lt;title&gt;Timeline Demo 1&lt;/title&gt;
  216. &lt;script type="text/javascript" language="javascript"
  217. src="timelinedemo1/timelinedemo1.nocache.js"&gt;&lt;/script&gt;
  218. &lt;script type="text/javascript" language="javascript" src="timeline.js"&gt;&lt;/script&gt;
  219. &lt;/head&gt;
  220. &lt;body&gt;
  221. &lt;!-- OPTIONAL: include this if you want history support --&gt;
  222. &lt;iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
  223. style="position:absolute;width:0;height:0;border:0"&gt;&lt;/iframe&gt;
  224. &lt;!-- RECOMMENDED if your web app will not function without JavaScript enabled --&gt;
  225. &lt;noscript&gt;
  226. &lt;div style="color: red;"&gt;
  227. Your web browser must have JavaScript enabled
  228. in order for this application to display correctly.
  229. &lt;/div&gt;
  230. &lt;/noscript&gt;
  231. &lt;h1&gt;Timeline Demo 1&lt;/h1&gt;
  232. &lt;div id="mytimeline"&gt;&lt;/div&gt;
  233. &lt;/body&gt;
  234. &lt;/html&gt;
  235. </pre>
  236. </li>
  237. <li>Open the file <b>TimelineDemo1.java</b>, and replace the contents
  238. with the following code.
  239. <pre class="prettyprint lang-java">
  240. package com.chap.links.client;
  241. import com.chap.links.client.Timeline;
  242. import com.google.gwt.core.client.EntryPoint;
  243. import com.google.gwt.i18n.client.DateTimeFormat;
  244. import com.google.gwt.user.client.ui.RootPanel;
  245. import com.google.gwt.visualization.client.DataTable;
  246. import com.google.gwt.visualization.client.VisualizationUtils;
  247. /**
  248. * Entry point classes define <code>onModuleLoad()</code>.
  249. */
  250. public class TimelineDemo1 implements EntryPoint {
  251. Timeline timeline = null;
  252. /**
  253. * This is the entry point method.
  254. */
  255. public void onModuleLoad() {;
  256. // Create a callback to be called when the visualization API
  257. // has been loaded.
  258. Runnable onLoadCallback = new Runnable() {
  259. public void run() {
  260. // create a data table
  261. DataTable data = DataTable.create();
  262. data.addColumn(DataTable.ColumnType.DATETIME, "start");
  263. data.addColumn(DataTable.ColumnType.DATETIME, "end");
  264. data.addColumn(DataTable.ColumnType.STRING, "content");
  265. DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd");
  266. // fill the table with some data
  267. data.addRow();
  268. data.setValue(0, 0, dtf.parse("2010-08-23"));
  269. data.setValue(0, 1, dtf.parse("2010-08-30"));
  270. data.setValue(0, 2, "Project A");
  271. data.addRow();
  272. data.setValue(1, 0, dtf.parse("2010-08-28"));
  273. data.setValue(1, 2, "Meeting");
  274. data.addRow();
  275. data.setValue(2, 0, dtf.parse("2010-09-02"));
  276. data.setValue(2, 2, "Phone Call");
  277. data.addRow();
  278. data.setValue(3, 0, dtf.parse("2010-09-03"));
  279. data.setValue(3, 2, "Finished");
  280. // create options
  281. Timeline.Options options = Timeline.Options.create();
  282. options.setWidth("100%");
  283. options.setHeight("200px");
  284. options.setStyle(Timeline.Options.STYLE.BOX);
  285. options.setEditable(true);
  286. // create the timeline, with data and options
  287. timeline = new Timeline(data, options);
  288. RootPanel.get("mytimeline").add(timeline);
  289. }
  290. };
  291. // Load the visualization api, passing the onLoadCallback to be called
  292. // when loading is done.
  293. VisualizationUtils.loadVisualizationApi(onLoadCallback);
  294. }
  295. } </pre>
  296. </li>
  297. </ul>
  298. Start the application. You have your first Timeline working now.
  299. <h2>Custom stylesheet</h2>
  300. <p>
  301. The style of the Timeline can be changed by applying a customized stylesheet.
  302. This stylesheet cannot be referenced in the main HTML page of your project,
  303. because the stylesheet must be loaded <i>after</i> the timeline is loaded.
  304. Therefore, the stylesheet must be placed in a folder <code>public</code>, which must be
  305. located in the same folder as the module file MyProject.gwt.xml and the
  306. folders client, server, and shared.
  307. To let GWT load the stylesheet, add a reference to the stylesheet in
  308. the module file MyProject.gwt.xml:
  309. <pre class="prettyprint lang-html">
  310. &lt;!-- Other module inherits --&gt;
  311. &lt;inherits name='com.google.gwt.visualization.Visualization'/&gt;
  312. &lt;inherits name='com.chap.links.Timeline'/&gt;
  313. &lt;!-- Customized stylesheet for the Timeline --&gt;
  314. &lt;stylesheet src="myCustomStylesheet.css"&gt;&lt;/stylesheet&gt;
  315. </pre>
  316. </p>
  317. <h2>Documentation</h2>
  318. <p>
  319. At the moment there is no documentation available for the GWT version of the Timeline.
  320. Please use the javascript documentation, which describes the
  321. available methods, data format, options, events, and styles.
  322. </p>
  323. <p>
  324. <a href="http://almende.github.com/chap-links-library/timeline.html">Javascript documentation</a>
  325. </p>
  326. <h2>Reference sites</h2>
  327. <p><a href="http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted" target="_blank">http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted</a></p>
  328. <div style="height:50px;"></div>
  329. </body>
  330. </html>