Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2009-10-20 20:43:05 +0000
committerChris Goldthorpe2009-10-20 20:43:05 +0000
commit25d75487496e7ceac0d3ae2a7979209bbc78416f (patch)
tree93122a7c68f456cfa755f50fa19fb9e1b57179a5
parent576d9c1d8f796950a7ed119f3103a1b7f0b1df6e (diff)
downloadeclipse.platform.ua-25d75487496e7ceac0d3ae2a7979209bbc78416f.tar.gz
eclipse.platform.ua-25d75487496e7ceac0d3ae2a7979209bbc78416f.tar.xz
eclipse.platform.ua-25d75487496e7ceac0d3ae2a7979209bbc78416f.zip
Bug 280459 – [Help] Error codes for failed remote assist network transactions:
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java114
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java1
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties1
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java14
-rw-r--r--org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java58
-rw-r--r--org.eclipse.help.webapp/plugin.xml8
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java265
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties17
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java7
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java15
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java6
11 files changed, 492 insertions, 14 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java
new file mode 100644
index 000000000..5be163553
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.base.remote;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.IHelpBaseConstants;
+
+public class RemoteStatusData {
+
+
+ private static final String INDEXJSP = "/index.jsp"; //$NON-NLS-1$
+
+ /*
+ * Convience method to see if any remote help
+ * is down
+ */
+ public static boolean isAnyRemoteHelpUnavailable()
+ {
+ ArrayList sites = getRemoteSites();
+ if (sites.isEmpty())
+ return false;
+
+ ArrayList badSites = checkSitesConnectivity(sites);
+ if (badSites.isEmpty())
+ return false;
+
+ return true;
+ }
+
+ /*
+ * Checks each URL in the ArrayList site to see if
+ * a network connection can be opened to
+ * url+/index.jsp
+ *
+ * Returns a subset of sites that cannot be connected.
+ * May be empty, or may be the same as sites
+ */
+ public static ArrayList checkSitesConnectivity(ArrayList sites)
+ {
+ ArrayList badSites = new ArrayList();
+
+ for (int i=0;i<sites.size();i++)
+ {
+ URL baseURL = (URL)sites.get(i);
+ try{
+ URL indexURL = new URL(baseURL.toExternalForm()+INDEXJSP);
+
+ InputStream in = indexURL.openStream();
+ in.close();
+
+ }catch(Exception ex)
+ {
+ badSites.add(baseURL);
+ }
+ }
+ return badSites;
+ }
+
+ /*
+ * Loads the remote sites stored in preferences,
+ * and places them as URLs in an ArrayList.
+ *
+ * Returns the ArrayList with sites in URL form
+ */
+ public static ArrayList getRemoteSites()
+ {
+ ArrayList sites = new ArrayList();
+
+ boolean remoteHelpEnabled =
+ Platform.getPreferencesService().getBoolean(
+ HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_ON, false,null);
+
+ if (!remoteHelpEnabled)
+ return sites;
+
+ String hosts[] = Platform.getPreferencesService().getString(
+ HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_HOST, "", null).split(","); //$NON-NLS-1$ //$NON-NLS-2$
+ String paths[] = Platform.getPreferencesService().getString(
+ HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_PATH, "", null).split(","); //$NON-NLS-1$ //$NON-NLS-2$
+ String ports[] = Platform.getPreferencesService().getString(
+ HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_PORT, "", null).split(","); //$NON-NLS-1$ //$NON-NLS-2$
+ String enableds[] = Platform.getPreferencesService().getString(
+ HelpBasePlugin.PLUGIN_ID, IHelpBaseConstants.P_KEY_REMOTE_HELP_ICEnabled, "", null).split(","); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ for (int i=0;i<hosts.length;i++)
+ {
+ try{
+ if (enableds[i].equalsIgnoreCase("true")) //$NON-NLS-1$
+ {
+ URL url = new URL(
+ "http://"+hosts[i]+':'+ports[i]+paths[i]); //$NON-NLS-1$
+ sites.add(url);
+ }
+ }
+ catch(Exception ex){
+ }
+ }
+ return sites;
+ }
+}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java
index 00502789b..434c00e9a 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java
@@ -253,6 +253,7 @@ public final class Messages extends NLS {
public static String ViewICPropsDialog_8;
public static String ViewICPropsDialog_URL;
+ public static String remoteHelpUnavailable;
public static String See;
public static String SeeAlso;
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties
index e6f870804..595fa3039 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties
@@ -52,6 +52,7 @@ HelpView_defaultText=Click on any workbench part to show related help topics.
expression = Search expression:
expression_label = * = any string, ? = any character, "" = phrase, AND, OR, NOT = boolean operators
limit_to = Search scope
+remoteHelpUnavailable=Some network help is unavailable.
SeeAlsoPart_search=Search
SeeAlsoPart_allTopics=Contents
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java
index 19f4c56c4..8e7e148b6 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -382,6 +382,17 @@ public class ReusableHelpPart implements IHelpUIConstants,
public PartRec[] getParts() {
return (PartRec[]) partRecs.toArray(new PartRec[partRecs.size()]);
}
+
+ public void refreshPage()
+ {
+ PartRec parts[] = getParts();
+ if (parts==null)
+ return;
+
+ for (int p=0;p<parts.length;p++)
+ if (parts[p]!=null && parts[p].part!=null && parts[p].part.isStale())
+ parts[p].part.refresh();
+ }
public int getNumberOfFlexibleParts() {
return nflexible;
@@ -955,6 +966,7 @@ public class ReusableHelpPart implements IHelpUIConstants,
HelpPartPage page = findPage(id);
if (page != null) {
+ page.refreshPage();
boolean success = flipPages(currentPage, page);
return success ? page : null;
}
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java
index cc4dca417..37fe7dc48 100644
--- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java
+++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.help.HelpSystem;
import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.eclipse.help.internal.base.remote.RemoteStatusData;
import org.eclipse.help.internal.search.federated.FederatedSearchEntry;
import org.eclipse.help.internal.search.federated.FederatedSearchJob;
import org.eclipse.help.search.ISearchEngineResult;
@@ -32,8 +33,10 @@ import org.eclipse.help.ui.internal.IHelpUIConstants;
import org.eclipse.help.ui.internal.Messages;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
@@ -42,6 +45,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -58,6 +62,7 @@ import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormText;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
@@ -71,6 +76,10 @@ public class SearchPart extends AbstractFormPart implements IHelpPart, IHelpUICo
private static final String HREF_SEARCH_HELP = "/org.eclipse.platform.doc.user/tasks/help_search.htm"; //$NON-NLS-1$
private static boolean SEARCH_HELP_AVAILABLE = false;
+
+
+ private ImageHyperlink remoteStatusLink;
+ private boolean wasHelpUnavailable = false;
static {
InputStream is = HelpSystem.getHelpContent(HREF_SEARCH_HELP);
@@ -232,10 +241,23 @@ public class SearchPart extends AbstractFormPart implements IHelpPart, IHelpUICo
});
createScopeSection(toolkit);
+
+ createRemoteStatusLink(toolkit);
toolkit.paintBordersFor(container);
jobListener = new JobListener();
Job.getJobManager().addJobChangeListener(jobListener);
}
+
+ public boolean isStale()
+ {
+ if (wasHelpUnavailable!=RemoteStatusData.isAnyRemoteHelpUnavailable())
+ {
+ wasHelpUnavailable=RemoteStatusData.isAnyRemoteHelpUnavailable();
+ return true;
+ }
+
+ return false;
+ }
private void createScopeSection(FormToolkit toolkit) {
TableWrapData td;
@@ -281,7 +303,35 @@ public class SearchPart extends AbstractFormPart implements IHelpPart, IHelpUICo
updateSearchWordText();
toolkit.paintBordersFor(detailGroup);
}
+
+ private void createRemoteStatusLink(FormToolkit toolkit){
+ TableWrapData td;
+
+
+ Image warningImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
+
+ remoteStatusLink = toolkit.createImageHyperlink(container, SWT.NULL);
+ remoteStatusLink.setText(Messages.remoteHelpUnavailable);
+ remoteStatusLink.setImage(warningImage);
+ remoteStatusLink.addHyperlinkListener(new HyperlinkAdapter() {
+
+ public void linkActivated(HyperlinkEvent e) {
+ doRemoteStatus();
+ }
+ });
+
+ if (wasHelpUnavailable = RemoteStatusData.isAnyRemoteHelpUnavailable())
+ remoteStatusLink.setVisible(true);
+ else
+ remoteStatusLink.setVisible(false);
+
+ td = new TableWrapData();
+ td.colspan = 2;
+ td.align = TableWrapData.FILL;
+ remoteStatusLink.setLayoutData(td);
+ }
+
private void createAdvancedLink(Composite parent, FormToolkit toolkit) {
advancedLink = toolkit.createHyperlink(parent, Messages.FederatedSearchPart_advanced, SWT.NULL);
advancedLink.addHyperlinkListener(new HyperlinkAdapter() {
@@ -569,6 +619,10 @@ public class SearchPart extends AbstractFormPart implements IHelpPart, IHelpUICo
updateMasters(set);
}
+ private void doRemoteStatus() {
+ SearchPart.this.parent.showURL("org.eclipse.help.webapp/SearchNetworkHelpStatus.html",true); //$NON-NLS-1$
+ }
+
private void doChangeScopeSet() {
ScopeSetDialog dialog = new ScopeSetDialog(container.getShell(), scopeSetManager, parent
.getEngineManager());
@@ -640,6 +694,8 @@ public class SearchPart extends AbstractFormPart implements IHelpPart, IHelpUICo
searchPending = false;
doSearch(searchWordCombo.getText());
}
+
+ remoteStatusLink.setVisible(RemoteStatusData.isAnyRemoteHelpUnavailable());
}
public String getId() {
diff --git a/org.eclipse.help.webapp/plugin.xml b/org.eclipse.help.webapp/plugin.xml
index dcf78db3b..4678a8fbe 100644
--- a/org.eclipse.help.webapp/plugin.xml
+++ b/org.eclipse.help.webapp/plugin.xml
@@ -126,4 +126,12 @@
filter="(other.info=org.eclipse.help)">
</serviceSelector>
</extension>
+ <extension
+ id="org.eclipse.help.webapp.remoteStatusProducer"
+ name="Remote Status Producer"
+ point="org.eclipse.help.contentProducer">
+ <contentProducer
+ producer="org.eclipse.help.internal.webapp.StatusProducer">
+ </contentProducer>
+ </extension>
</plugin>
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java
new file mode 100644
index 000000000..5624f33a7
--- /dev/null
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/StatusProducer.java
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.help.internal.webapp;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Locale;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.IHelpContentProducer;
+import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.remote.RemoteStatusData;
+import org.eclipse.help.internal.protocols.HelpURLStreamHandler;
+import org.eclipse.help.internal.webapp.data.WebappPreferences;
+
+
+public class StatusProducer implements IHelpContentProducer {
+
+ // Remote Status 'page' href
+ public static final String REMOTE_STATUS_HREF = "NetworkHelpStatus.html"; //$NON-NLS-1$
+ // Remote Status from bad topic 'page' href
+ public static final String MISSING_TOPIC_HREF = "MissingTopicStatus.html"; //$NON-NLS-1$
+ // Remote Status from bad topic 'page' href
+ public static final String SEARCH_REMOTE_STATUS_HREF = "SearchNetworkHelpStatus.html"; //$NON-NLS-1$
+ // Default TAB size
+ private static final String TAB = " "; //$NON-NLS-1$
+ // index.jsp
+ private static final String INDEX = "/index.jsp"; //$NON-NLS-1$
+
+ // HTML constants
+ private static final String BEGIN_HEAD_HTML = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" //$NON-NLS-1$
+ + "<html>\n" //$NON-NLS-1$
+ + tab(1)+"<head>\n" //$NON-NLS-1$
+ + tab(2)+"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n"; //$NON-NLS-1$
+
+ private static final String END_HEAD_HTML = tab(1)+"</head>\n"; //$NON-NLS-1$
+
+ private static final String BEGIN_BODY_HTML = tab(1)+"<body>\n"; //$NON-NLS-1$
+
+ private static final String END_BODY_HTML = tab(2)+"</div>\n"+tab(1)+"</body>\n</html>"; //$NON-NLS-1$ //$NON-NLS-2$
+
+
+
+ public InputStream getInputStream(String pluginID, String href, Locale locale) {
+
+ // Only accept requests for our pages. Otherwise
+ // return null so Eclipse tries to find the right help
+ if (!href.equalsIgnoreCase(REMOTE_STATUS_HREF) &&
+ !href.equalsIgnoreCase(MISSING_TOPIC_HREF) &&
+ !href.equalsIgnoreCase(SEARCH_REMOTE_STATUS_HREF))
+ return null;
+
+ StringBuffer pageBuffer = new StringBuffer();
+
+
+ // Get all remote sites, and subset of non-working sites
+ ArrayList remoteSites = RemoteStatusData.getRemoteSites();
+ ArrayList badSites = RemoteStatusData.checkSitesConnectivity(remoteSites);
+
+ // Check to see if there are any enabled remote sites.
+ // If not, return null - default topic not found will display
+ if (remoteSites.isEmpty())
+ {
+ return null;
+ }
+
+ // If this is a call from an invalid topic,
+ // check to see if a predefined error page exists
+ // in the preferences
+ if (href.equalsIgnoreCase(MISSING_TOPIC_HREF)){
+ String errorPage = Platform.getPreferencesService().getString(
+ HelpBasePlugin.PLUGIN_ID,
+ "page_not_found", //$NON-NLS-1$
+ null,
+ null);
+ if (errorPage != null && errorPage.length() > 0) {
+
+ URL helpURL;
+ try {
+ helpURL = new URL("help", //$NON-NLS-1$
+ null, -1, errorPage,
+ HelpURLStreamHandler.getDefault());
+ return helpURL.openStream();
+ } catch (MalformedURLException e) {
+ HelpWebappPlugin.logError("Unable to locate error page: "+errorPage, e); //$NON-NLS-1$
+ } catch (IOException e) {
+ HelpWebappPlugin.logError("Unable to open error page: "+errorPage, e); //$NON-NLS-1$
+ }
+
+ }
+ }
+
+
+ // Write HTML header and body beginning.
+ pageBuffer.append(getHtmlHead(locale));
+ pageBuffer.append(getBeginHtmlBody());
+
+
+
+ // Check to see if all remote sites failed,
+ // or just a subset
+ boolean allFailed;
+ if (remoteSites.size()==badSites.size())
+ {
+ allFailed = true;
+ pageBuffer.append(tab(3)+"<h1>"+WebappResources.getString("allRemoteHelpUnavailable", locale)+"</h1>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ else
+ {
+ allFailed = false;
+ pageBuffer.append(tab(3)+"<h1>"+WebappResources.getString("someRemoteHelpUnavailable", locale)+"</h1>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+
+ // Add a close link to top
+ if (href.equalsIgnoreCase(REMOTE_STATUS_HREF))
+ {
+ WebappPreferences prefs = new WebappPreferences();
+ String homepage = "/help/topic"+prefs.getHelpHome(); //$NON-NLS-1$
+
+ pageBuffer.append(tab(3)+"<div style=\"position:absolute;right:4px;top:4px;\">\n"); //$NON-NLS-1$
+ pageBuffer.append(tab(4)+"<table>\n"+tab(5)+"<tr>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ pageBuffer.append(tab(6)+"<td style=\"background-color:white;border-width:1px;border-style:solid;border-color:grey;\">"+makeAnchor(homepage,WebappResources.getString("Close", locale),"style=\"font-size:.8em;\"",false)+"</td>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ pageBuffer.append(tab(5)+"</tr>\n"+tab(4)+"</table>\n"+tab(3)+"</div>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+
+ if (href.equalsIgnoreCase(MISSING_TOPIC_HREF))
+ pageBuffer.append(tab(3)+"<p>"+WebappResources.getString("topicUnavailable",locale)+"</p>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // Write potential causes, based on some or
+ // all sites failing.
+ pageBuffer.append(tab(3)+"<p>"+WebappResources.getString("potentialCauses",locale)+"</p>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ pageBuffer.append(tab(3)+"<ul>\n"); //$NON-NLS-1$
+ pageBuffer.append(tab(4)+"<li>"+WebappResources.getString("serversCouldBeDown",locale)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ pageBuffer.append(tab(4)+"<li>"+WebappResources.getString("mayNeedProxy",locale)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (allFailed)
+ pageBuffer.append(tab(4)+"<li>"+WebappResources.getString("networkCouldBeDown",locale)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ pageBuffer.append(tab(3)+"</ul>\n"); //$NON-NLS-1$
+
+
+ // Check for bad sites, and write them
+
+ if (remoteSites.size()>badSites.size())
+ {
+ pageBuffer.append(tab(3)+"<h2>"+WebappResources.getString("sitesWithConnectivity", locale)+"</h2>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ pageBuffer.append(tab(3)+"<ul>\n"); //$NON-NLS-1$
+ for (int r=0;r<remoteSites.size();r++)
+ {
+ if (!badSites.contains(remoteSites.get(r)))
+ pageBuffer.append(tab(4)+"<li>"+makeAnchor(remoteSites.get(r)+INDEX,remoteSites.get(r)+INDEX,"",true)+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ pageBuffer.append(tab(3)+"</ul>\n"); //$NON-NLS-1$
+ }
+ else
+ pageBuffer.append(tab(3)+WebappResources.getString("noRemoteSitesAvailable", locale)+"</br>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (!badSites.isEmpty())
+ {
+ pageBuffer.append(tab(3)+"<h2>"+WebappResources.getString("sitesWithoutConnectivity", locale)+"</h2>\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ pageBuffer.append(tab(3)+"<ul>\n"); //$NON-NLS-1$
+
+ for (int b=0;b<badSites.size();b++)
+ pageBuffer.append(tab(4)+ "<li>"+badSites.get(b)+INDEX+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pageBuffer.append(tab(3)+ "</ul>\n"); //$NON-NLS-1$
+ }
+
+ String activeLink =
+ MessageFormat.format(
+ WebappResources.getString("remotePreferences", locale), //$NON-NLS-1$
+ new String[]{getActiveLink(locale)});
+
+ pageBuffer.append(tab(3)+activeLink);
+
+ pageBuffer.append(END_BODY_HTML);
+
+
+// String tmp = pluginID+" , "+href; //$NON-NLS-1$
+// System.out.println(tmp);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(pageBuffer.toString().getBytes());
+
+ return bais;
+ }
+
+
+
+ /*
+ * Build the HTML header
+ */
+ private String getHtmlHead(Locale locale)
+ {
+ return BEGIN_HEAD_HTML + '\n'
+ + tab(2) + "<meta name=\"copyright\" content=\"Copyright (c) IBM Corporation and others 2000, 2009. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.\" >\n" //$NON-NLS-1$
+ + tab(2) + "<title>"+WebappResources.getString("remoteStatusTitle", locale)+"</title>\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + tab(2) + "<link rel=\"stylesheet\" href=\"PLUGINS_ROOT/org.eclipse.help.base/doc/book.css\" charset=\"utf-8\" type=\"text/css\">\n" //$NON-NLS-1$
+ + tab(2) + "<script language=\"JavaScript\" src=\"PLUGINS_ROOT/org.eclipse.help/livehelp.js\"> </script>\n" //$NON-NLS-1$
+ + tab(2) + "<script type=\"text/javascript\" src=\"../../../content/org.eclipse.help/livehelp.js\"></script>\n" //$NON-NLS-1$
+ + END_HEAD_HTML;
+ }
+
+ /*
+ * Build the beginning of the HTML body
+ */
+ private String getBeginHtmlBody()
+ {
+ return BEGIN_BODY_HTML + '\n'
+ + tab(2) + "<div id=\"banner\"><img src=\"PLUGINS_ROOT/org.eclipse.help.base/doc/help_banner.jpg\" alt=\"Help banner\" width=\"1600\" height=\"36\"></div>\n" //$NON-NLS-1$
+ + tab(2) + "<div id=\"content\">\n"; //$NON-NLS-1$
+ }
+
+ /*
+ * Build the active help link that opens the
+ * remote infocenter content preferences
+ */
+ private String getActiveLink(Locale locale)
+ {
+ return "<img src=\"PLUGINS_ROOT/org.eclipse.help/command_link.png\"/>" //$NON-NLS-1$
+ + "<a class=\"command-link\"" //$NON-NLS-1$
+ + " href='javascript:executeCommand(\"org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.help.ui.contentPreferencePage)\")'>" //$NON-NLS-1$
+ + WebappResources.getString("remotePreferencesMenuSelect", locale)+"</a>"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /*
+ * Generate an HTML anchor. Anchors
+ * will open in a new window / tab based on
+ * newWindow arg.
+ */
+ private String makeAnchor(String url,String title,String style,boolean newWindow)
+ {
+ String target=""; //$NON-NLS-1$
+ if (newWindow)
+ target = "target=\"_blank\" "; //$NON-NLS-1$
+
+ return "<a "+style+" "+target+"href=\""+url+"\">"+title+"</a>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+ /*
+ * Generate tabbed spacing for HTML elements
+ */
+ private static String tab(int count)
+ {
+ String tabs = ""; //$NON-NLS-1$
+ for (int i=0;i<count;i++)
+ tabs+=TAB;
+ return tabs;
+ }
+
+}
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties
index b028ab0d0..e6fbf8607 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties
@@ -109,8 +109,21 @@ yes=Yes
no=No
dontask=Do &not warn me again
-# Remote help error dialog
-remoteHelpErrorMessage=There was a problem communicating with the remote help server. Some topics\nmay not be available.\n\nPlease check your network connection and remote help server preferences.
+# Remote help status page
+remoteStatusTitle=Network Help Status - Eclipse SDK
+noRemoteSitesToQuery=There are no remote sites to query for status.
+sitesWithConnectivity=Available Sites
+sitesWithoutConnectivity=Unavailable Sites
+noRemoteSitesAvailable=<em>Note: </em>Eclipse can not connect to any of your enabled remote sites.
+allRemoteHelpUnavailable=Network Help Unavailable
+someRemoteHelpUnavailable=Some Network Help Unavailable
+topicUnavailable=The topic that you have requested is not available.
+potentialCauses=This condition may be caused by one of the following:
+serversCouldBeDown=The remote server(s) could be down.
+networkCouldBeDown=Your machine may have lost network connectivity.
+mayNeedProxy=You may need to configure proxy settings to access a remote server.
+remotePreferences=To view, edit, and test Network Infocenter settings, open {0}.
+remotePreferencesMenuSelect=Window &gt Preferences &gt Help &gt Content
# Frame Titles
ignore=Layout frame: {0}
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java
index 12d18df75..2fbfd007e 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java
@@ -22,7 +22,9 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.base.BaseHelpSystem;
+import org.eclipse.help.internal.base.remote.RemoteStatusData;
import org.eclipse.help.internal.webapp.HelpWebappPlugin;
+import org.eclipse.help.internal.webapp.StatusProducer;
import org.eclipse.help.webapp.AbstractView;
import org.eclipse.osgi.service.localization.BundleLocalization;
import org.osgi.framework.Bundle;
@@ -109,7 +111,10 @@ public class LayoutData extends RequestData {
}
String topicHref = request.getParameter("topic"); //$NON-NLS-1$
if (topicHref == null || topicHref.length() == 0) {
- return UrlUtil.getHelpURL(preferences.getHelpHome());
+ if (BaseHelpSystem.getMode()!=BaseHelpSystem.MODE_INFOCENTER && RemoteStatusData.isAnyRemoteHelpUnavailable())
+ return "../topic/"+HelpWebappPlugin.PLUGIN_ID+'/'+StatusProducer.REMOTE_STATUS_HREF; //$NON-NLS-1$
+ else
+ return UrlUtil.getHelpURL(preferences.getHelpHome());
}
else {
TocData tocData = new TocData(context, request, response);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
index 41c7626ef..1c7e05d96 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java
@@ -32,9 +32,11 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.base.remote.RemoteStatusData;
import org.eclipse.help.internal.protocols.HelpURLConnection;
import org.eclipse.help.internal.protocols.HelpURLStreamHandler;
import org.eclipse.help.internal.webapp.HelpWebappPlugin;
+import org.eclipse.help.internal.webapp.StatusProducer;
import org.eclipse.help.internal.webapp.data.ServletResources;
import org.eclipse.help.internal.webapp.data.UrlUtil;
import org.eclipse.help.webapp.IFilter;
@@ -119,10 +121,15 @@ public class EclipseConnector {
pageNotFound = true;
if (notFoundCallout != null) {
notFoundCallout.notFound(url);
- }
- if (requiresErrorPage(lowerCaseuRL)) {
- // Try to load the error page if defined
- String errorPage = Platform.getPreferencesService().getString(HelpBasePlugin.PLUGIN_ID, "page_not_found", null, null); //$NON-NLS-1$
+ } if (requiresErrorPage(lowerCaseuRL)) {
+
+ String errorPage;
+
+ if (RemoteStatusData.isAnyRemoteHelpUnavailable())
+ errorPage = '/'+HelpWebappPlugin.PLUGIN_ID+'/'+StatusProducer.MISSING_TOPIC_HREF;
+ else // Try to load the error page if defined
+ errorPage = Platform.getPreferencesService().getString(HelpBasePlugin.PLUGIN_ID, "page_not_found", null, null); //$NON-NLS-1$
+
if (errorPage != null && errorPage.length() > 0) {
con = createConnection(req, resp, "help:" + errorPage); //$NON-NLS-1$
resp.setContentType("text/html"); //$NON-NLS-1$
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java
index cce2436ac..b4da7b71a 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java
@@ -97,11 +97,7 @@ public class TocFragmentServlet extends HttpServlet {
public String generateTreeXml() {
buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$
buf.append("<tree_data>\n"); //$NON-NLS-1$
-
- if (tocData.isRemoteHelpError()) {
- addError(WebappResources.getString("remoteHelpErrorMessage", locale)); //$NON-NLS-1$
- }
-
+
// Return an error for show in toc if topic was not found in toc
if ((requestKind == REQUEST_SHOW_IN_TOC || requestKind == REQUEST_EXPAND_PATH) && tocData.getTopicPath() == null) {
addError(WebappResources.getString("CannotSync", locale)); //$NON-NLS-1$

Back to the top