Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis D'Entremont2006-03-01 19:10:25 -0500
committerCurtis D'Entremont2006-03-01 19:10:25 -0500
commit94ff6f30fee5393bf8c5563bbd4040068f357e3c (patch)
treeb3e990764296852127f7ce37e2d4b6aecc5858e3 /org.eclipse.help
parent488c04382d19f95121b443ec6d7972789c6082d3 (diff)
downloadeclipse.platform.ua-94ff6f30fee5393bf8c5563bbd4040068f357e3c.tar.gz
eclipse.platform.ua-94ff6f30fee5393bf8c5563bbd4040068f357e3c.tar.xz
eclipse.platform.ua-94ff6f30fee5393bf8c5563bbd4040068f357e3c.zip
130051 [Help] Search dynamic content properlyv20060301
Diffstat (limited to 'org.eclipse.help')
-rw-r--r--org.eclipse.help/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/DynamicContentProducer.java27
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java41
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java19
4 files changed, 79 insertions, 10 deletions
diff --git a/org.eclipse.help/META-INF/MANIFEST.MF b/org.eclipse.help/META-INF/MANIFEST.MF
index b8201ee9a..746e451b0 100644
--- a/org.eclipse.help/META-INF/MANIFEST.MF
+++ b/org.eclipse.help/META-INF/MANIFEST.MF
@@ -14,6 +14,6 @@ Export-Package: org.eclipse.help,
org.eclipse.help.internal.protocols;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp,org.eclipse.ua.tests",
org.eclipse.help.internal.toc;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp,org.eclipse.ua.tests",
org.eclipse.help.internal.util;x-friends:="org.eclipse.help.base,org.eclipse.help.ui,org.eclipse.help.webapp,org.eclipse.ua.tests",
- org.eclipse.help.internal.xhtml;x-friends:="org.eclipse.help.ui,org.eclipse.ui.intro,org.eclipse.ua.tests"
+ org.eclipse.help.internal.xhtml;x-friends:="org.eclipse.help.ui,org.eclipse.ui.intro,org.eclipse.ua.tests,org.eclipse.help.base"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)"
Eclipse-LazyStart: true
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/DynamicContentProducer.java b/org.eclipse.help/src/org/eclipse/help/internal/DynamicContentProducer.java
index 4238da55a..ef8f55a70 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/DynamicContentProducer.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/DynamicContentProducer.java
@@ -33,14 +33,25 @@ import org.w3c.dom.Document;
public class DynamicContentProducer implements IHelpContentProducer {
public InputStream getInputStream(String pluginID, String href, Locale locale) {
+ String file = href;
int qloc = href.indexOf('?');
if (qloc != -1)
- href = href.substring(0, qloc);
- int loc = href.lastIndexOf('.');
+ file = href.substring(0, qloc);
+ int loc = file.lastIndexOf('.');
if (loc != -1) {
- String extension = href.substring(loc + 1).toLowerCase();
- if ("xhtml".equals(extension)) //$NON-NLS-1$
- return openXHTMLFromPlugin(pluginID, href, locale.toString());
+ String extension = file.substring(loc + 1).toLowerCase();
+ if ("xhtml".equals(extension)) {//$NON-NLS-1$
+ /*
+ * Filtering can be turned off when, for example,
+ * indexing documents.
+ */
+ boolean filter = true;
+ if (qloc != -1 && qloc < href.length() - 1) {
+ String query = href.substring(qloc + 1);
+ filter = (query.indexOf("filter=false") == -1); //$NON-NLS-1$
+ }
+ return openXHTMLFromPlugin(pluginID, file, locale.toString(), filter);
+ }
// place support for other formats here
}
return null;
@@ -56,16 +67,18 @@ public class DynamicContentProducer implements IHelpContentProducer {
* the relative path of the file to find
* @param locale
* the locale used as an override or <code>null</code> to use the default locale
+ * @param filter
+ * whether or not the content should be filtered
*
* @return an InputStream to the file or <code>null</code> if the file wasn't found
*/
- private InputStream openXHTMLFromPlugin(String pluginID, String file, String locale) {
+ private InputStream openXHTMLFromPlugin(String pluginID, String file, String locale, boolean filter) {
InputStream inputStream = openStreamFromPlugin(pluginID, file, locale);
if (inputStream != null) {
UAContentParser parser = new UAContentParser(inputStream);
Document dom = parser.getDocument();
XHTMLSupport support = new XHTMLSupport(pluginID, file, dom, locale);
- dom = support.processDOM();
+ dom = support.processDOM(filter);
try {
inputStream.close();
} catch (IOException e) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java
index 1caa9d124..3b54378fd 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java
@@ -63,6 +63,32 @@ public class UAContentFilterProcessor {
}
}
+ /**
+ * Returns the current value for the given single-value filterable property
+ * by the given name (e.g. "os"). For multi-value properties, returns null.
+ *
+ * @param filterName the filter name (e.g. "os")
+ * @return the current value (e.g. "win32") or null
+ */
+ public String getCurrentValue(String filterName) {
+ if (filterName.equals("ws")) { //$NON-NLS-1$
+ return Platform.getWS();
+ }
+ else if (filterName.equals("os")) { //$NON-NLS-1$
+ return Platform.getOS();
+ }
+ else if (filterName.equals("arch")) { //$NON-NLS-1$
+ return Platform.getOSArch();
+ }
+ else if (filterName.equals("product")) { //$NON-NLS-1$
+ IProduct product = Platform.getProduct();
+ if (product != null) {
+ return product.getId();
+ }
+ }
+ return null;
+ }
+
private static boolean hasFilterAttribute(Element element) {
if (element.getAttribute(DOMUtil.ATT_FILTER).equals("")) //$NON-NLS-1$
return false;
@@ -162,6 +188,21 @@ public class UAContentFilterProcessor {
}
/**
+ * Returns whether or not the given filter property allows multiple instances
+ * to be specified. For example, for os there can only ever be one os running,
+ * but for plugins there can be many.
+ *
+ * @param filterName the name of the filter (without value)
+ * @return whether or not the filter allows multiple values
+ */
+ public boolean isMultiValue(String filterName) {
+ return !(filterName.equals("os") //$NON-NLS-1$
+ || filterName.equals("ws") //$NON-NLS-1$
+ || filterName.equals("arch") //$NON-NLS-1$
+ || filterName.equals("product")); //$NON-NLS-1$
+ }
+
+ /**
* evaluates WS filter.
*/
private static boolean filterByWS(String ws) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java
index 46574b999..1aca37ab8 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/XHTMLSupport.java
@@ -35,11 +35,26 @@ public class XHTMLSupport {
}
-
+ /**
+ * Processes the DOM, with filtering turned on.
+ *
+ * @return the resulting DOM
+ */
public Document processDOM() {
+ return processDOM(true);
+ }
+
+ /**
+ * Processes the DOM. Filtering will only be done if requested. Filtering
+ * may be skipped, for example, for indexing.
+ *
+ * @param filter whether or not to filter
+ * @return the resulting DOM
+ */
+ public Document processDOM(boolean filter) {
// filters do not apply to shared help systems
- if (!HelpSystem.isShared()) {
+ if (filter && !HelpSystem.isShared()) {
// resolve filters.
filterProcessor.applyFilters(document);
}

Back to the top