# HG changeset patch
# User dadubrow
# Date 1281971898 18000
# Node ID aaf2f7bc060941c8c318e1bbdc2880d2ab52998c
# Parent 3319dd95321275432a3bdf14108732404cb4b3be
better handling of failed connect
diff -r 3319dd953212 -r aaf2f7bc0609 core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java Mon Aug 16 09:03:23 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractBrowserPortalPageLayer.java Mon Aug 16 10:18:18 2010 -0500
@@ -24,6 +24,7 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -34,6 +35,8 @@
import org.eclipse.swt.browser.OpenWindowListener;
import org.eclipse.swt.browser.ProgressAdapter;
import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.StatusTextEvent;
+import org.eclipse.swt.browser.StatusTextListener;
import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
@@ -85,6 +88,12 @@
}
@Override
public void completed(ProgressEvent event) {
+ getStatusLineManager().setMessage(null);
+ if (!failedConnect && !browserHasURL()) {
+ displayCannotFindServerPage();
+ Activator.logError("Could not display URL in browser: " + getURL().toExternalForm(), null);
+ failedConnect = true;
+ }
setLoading(false);
NavigationActionBar.this.updater.updateAll();
}
@@ -95,6 +104,12 @@
event.browser = browser;
}
});
+ browser.addStatusTextListener(new StatusTextListener() {
+ @Override
+ public void changed(StatusTextEvent event) {
+ getStatusLineManager().setMessage(event.text);
+ }
+ });
}
@Override
@@ -126,11 +141,17 @@
}
}
+ protected static final String HTML_BODY_HEADER = "
"; //$NON-NLS-1$
+ protected static final String HTML_BODY_FOOTER = ""; //$NON-NLS-1$
+
protected Browser browser;
protected NavigationActionBar actionBar;
+ private IEditorPart part;
+ private boolean failedConnect;
@Override
public Control createControl(Composite parent, IEditorPart part) {
+ this.part = part;
Composite composite = new Composite(parent, SWT.NONE);
composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
composite.setLayout(new FillLayout());
@@ -167,9 +188,7 @@
public void run() {
URL url = getURL();
if (url != null) {
- if (!browser.setUrl(url.toString())) {
- browser.redraw();
- }
+ browser.setUrl(url.toString());
}
actionBar.hookBrowser();
actionBar.update();
@@ -227,7 +246,15 @@
@Override
public void run() {
if (browser != null) {
- browser.refresh();
+ if (failedConnect) {
+ URL url = getURL();
+ if (url != null) {
+ browser.setUrl(url.toString());
+ failedConnect = false;
+ }
+ }
+ else
+ browser.refresh();
actionBar.update();
}
}
@@ -295,4 +322,16 @@
String url = browser.getUrl();
return url.matches("^.*://.*"); //$NON-NLS-1$
}
+
+ protected void displayCannotFindServerPage() {
+ StringBuilder sb = new StringBuilder(HTML_BODY_HEADER);
+ // if we want, we can add html here for failed connect case
+ sb.append(HTML_BODY_FOOTER);
+ browser.setText(sb.toString());
+ browser.redraw();
+ }
+
+ private IStatusLineManager getStatusLineManager() {
+ return part.getEditorSite().getActionBars().getStatusLineManager();
+ }
}
diff -r 3319dd953212 -r aaf2f7bc0609 core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Mon Aug 16 09:03:23 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/extension/AbstractRSSPortalPageLayer.java Mon Aug 16 10:18:18 2010 -0500
@@ -94,8 +94,6 @@
}
}
- private static final String HTML_BODY_HEADER = ""; //$NON-NLS-1$
- private static final String HTML_BODY_FOOTER = ""; //$NON-NLS-1$
private static final int MAX_ELEM_LEN = 256;
private Rss rss;