core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java
changeset 1849 40d70835dc4f
parent 1832 aaf2f7bc0609
child 1856 e3ec6febb587
equal deleted inserted replaced
1848:2a6d912d3065 1849:40d70835dc4f
    87 					NavigationActionBar.this.updater.updateAll();
    87 					NavigationActionBar.this.updater.updateAll();
    88 				}
    88 				}
    89 				@Override
    89 				@Override
    90 				public void completed(ProgressEvent event) {
    90 				public void completed(ProgressEvent event) {
    91 					getStatusLineManager().setMessage(null);
    91 					getStatusLineManager().setMessage(null);
    92 					if (!failedConnect && !browserHasURL()) {
    92 					if (!failedConnect && !isValidPage()) {
    93 						displayCannotFindServerPage();
    93 						displayCannotFindServerPage();
    94 						Activator.logError("Could not display URL in browser: " + getURL().toExternalForm(), null);
    94 						Activator.logError("Could not display URL in browser: " + getURL().toExternalForm(), null);
    95 						failedConnect = true;
    95 						failedConnect = true;
    96 					}
    96 					}
    97 					setLoading(false);
    97 					setLoading(false);
   186 			Activator.runInUIThreadWhenProxyDataSet(browser, new Runnable() {
   186 			Activator.runInUIThreadWhenProxyDataSet(browser, new Runnable() {
   187 				@Override
   187 				@Override
   188 				public void run() {
   188 				public void run() {
   189 					URL url = getURL();
   189 					URL url = getURL();
   190 					if (url != null) {
   190 					if (url != null) {
   191 						browser.setUrl(url.toString());
   191 						setUrl(url.toString());
   192 					}
   192 					}
   193 					actionBar.hookBrowser();
   193 					actionBar.hookBrowser();
   194 					actionBar.update();
   194 					actionBar.update();
   195 					browser.setFocus();
   195 					browser.setFocus();
   196 				}
   196 				}
   244 		
   244 		
   245 		a = new BrowserAction(Messages.AbstractBrowserPortalPage_RefreshLabel) {
   245 		a = new BrowserAction(Messages.AbstractBrowserPortalPage_RefreshLabel) {
   246 			@Override
   246 			@Override
   247 			public void run() {
   247 			public void run() {
   248 				if (browser != null) {
   248 				if (browser != null) {
   249 					if (failedConnect) {
   249 					if (browserHasURL())
       
   250 						browser.refresh();
       
   251 					else {
   250 						URL url = getURL();
   252 						URL url = getURL();
   251 						if (url != null) {
   253 						if (url != null) {
   252 							browser.setUrl(url.toString());
   254 							setUrl(url.toString());
   253 							failedConnect = false;
       
   254 						}
   255 						}
   255 					}
   256 					}
   256 					else
       
   257 						browser.refresh();
       
   258 					actionBar.update();
   257 					actionBar.update();
   259 				}
   258 				}
   260 			}
   259 			}
   261 		};
   260 		};
   262 		actions.add(a);
   261 		actions.add(a);
   302 						return null;
   301 						return null;
   303 					}
   302 					}
   304 				});
   303 				});
   305 				int result = dlg.open();
   304 				int result = dlg.open();
   306 				if (result == Dialog.OK) {
   305 				if (result == Dialog.OK) {
   307 					browser.setUrl(dlg.getValue());
   306 					setUrl(dlg.getValue());
   308 					actionBar.update();
   307 					actionBar.update();
   309 				}
   308 				}
   310 			};
   309 			};
   311 			
   310 			
   312 			public boolean isEnabled() {
   311 			public boolean isEnabled() {
   319 	}
   318 	}
   320 
   319 
   321 	protected boolean browserHasURL() {
   320 	protected boolean browserHasURL() {
   322 		String url = browser.getUrl();
   321 		String url = browser.getUrl();
   323 		return url.matches("^.*://.*"); //$NON-NLS-1$
   322 		return url.matches("^.*://.*"); //$NON-NLS-1$
       
   323 	}
       
   324 
       
   325 	protected boolean isValidPage() {
       
   326 		return browserHasURL();
       
   327 	}
       
   328 	
       
   329 	protected void setUrl(String url) {
       
   330 		browser.setUrl(url);
       
   331 		failedConnect = false;
   324 	}
   332 	}
   325 
   333 
   326 	protected void displayCannotFindServerPage() {
   334 	protected void displayCannotFindServerPage() {
   327 		StringBuilder sb = new StringBuilder(HTML_BODY_HEADER);
   335 		StringBuilder sb = new StringBuilder(HTML_BODY_HEADER);
   328 		// if we want, we can add html here for failed connect case
   336 		// if we want, we can add html here for failed connect case