|
3 | 3 | import com.google.gwt.core.client.EntryPoint; |
4 | 4 | import com.google.gwt.core.client.JavaScriptException; |
5 | 5 | import com.google.gwt.core.client.Scheduler; |
| 6 | +import com.google.gwt.dom.client.Style; |
6 | 7 | import com.google.gwt.user.client.DOM; |
7 | 8 | import com.google.gwt.user.client.Window; |
8 | 9 | import com.google.gwt.user.client.ui.RootLayoutPanel; |
9 | 10 | import org.reactome.web.pwp.client.common.utils.Console; |
10 | 11 | import org.reactome.web.pwp.client.manager.state.token.Token; |
11 | 12 | import org.reactome.web.pwp.client.manager.title.event.TitleChangedEvent; |
| 13 | +import org.reactome.web.pwp.model.client.classes.DBInfo; |
| 14 | +import org.reactome.web.pwp.model.client.common.ContentClientHandler; |
| 15 | +import org.reactome.web.pwp.model.client.content.ContentClient; |
| 16 | +import org.reactome.web.pwp.model.client.content.ContentClientError; |
12 | 17 |
|
13 | 18 |
|
14 | 19 | /** |
15 | 20 | * Entry point classes define <code>onModuleLoad()</code>. |
16 | 21 | */ |
17 | | -public class Browser implements EntryPoint { |
| 22 | +public class Browser implements EntryPoint, ContentClientHandler.DatabaseInfo { |
18 | 23 |
|
19 | 24 | public static final String VERSION = "3.6"; |
20 | 25 | public static final Boolean BETA = false; |
21 | 26 |
|
22 | 27 | public static boolean VERBOSE = true; |
| 28 | + private AppController appViewer; |
23 | 29 |
|
24 | 30 | /** |
25 | 31 | * This is the entry point method. |
26 | 32 | */ |
27 | 33 | public void onModuleLoad() { |
28 | 34 | initConfig(); |
| 35 | + ContentClient.getDatabaseInformation(this); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public void onDatabaseInfoLoaded(DBInfo dbInfo) { |
29 | 40 | Scheduler.get().scheduleDeferred(() -> { |
30 | | - AppController appViewer = new AppController(); |
| 41 | + appViewer = new AppController(dbInfo); |
31 | 42 | appViewer.go(RootLayoutPanel.get()); |
32 | 43 | removeLoadingMessage(); |
33 | 44 | }); |
34 | 45 | } |
35 | 46 |
|
36 | | - private void initConfig(){ |
| 47 | + @Override |
| 48 | + public void onContentClientException(Type type, String message) { |
| 49 | + showErrorMessage(); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public void onContentClientError(ContentClientError error) { |
| 54 | + showErrorMessage(); |
| 55 | + } |
| 56 | + |
| 57 | + private void initConfig() { |
37 | 58 | String hostName = Window.Location.getHostName(); |
38 | 59 | Browser.VERBOSE = (hostName.equals("localhost") || hostName.equals("127.0.0.1")); |
39 | 60 | TitleChangedEvent.REPORT = false; |
40 | 61 | Token.DEFAULT_SPECIES_ID = 48887L; //Homo sapiens |
41 | 62 | Token.DELIMITER = "&"; |
42 | 63 | } |
43 | 64 |
|
44 | | - private void removeLoadingMessage(){ |
| 65 | + private void removeLoadingMessage() { |
45 | 66 | try { |
46 | | - if(DOM.getElementById("appLoadMessage")!=null) { |
| 67 | + if (DOM.getElementById("appLoadMessage") != null) { |
47 | 68 | DOM.getElementById("appLoadMessage").removeFromParent(); |
48 | 69 | } |
49 | | - }catch (JavaScriptException exception){ |
| 70 | + } catch (JavaScriptException exception) { |
| 71 | + Console.error(exception.getMessage(), this); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + private void showErrorMessage() { |
| 76 | + removeLoadingMessage(); |
| 77 | + try { |
| 78 | + if (DOM.getElementById("appErrorMessage") != null) { |
| 79 | + DOM.getElementById("appErrorMessage").getStyle().setDisplay(Style.Display.BLOCK); |
| 80 | + } |
| 81 | + } catch (JavaScriptException exception) { |
50 | 82 | Console.error(exception.getMessage(), this); |
51 | 83 | } |
52 | 84 | } |
|
0 commit comments