Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 157166 Details for
Bug 223475
[Webapp] Support filtering in TOC and index
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Early version of implementation
patch223475_v0.txt (text/plain), 73.18 KB, created by
Chris Goldthorpe
on 2010-01-25 15:55:08 EST
(
hide
)
Description:
Early version of implementation
Filename:
MIME Type:
Creator:
Chris Goldthorpe
Created:
2010-01-25 15:55:08 EST
Size:
73.18 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.help >Index: src/org/eclipse/help/internal/index/Index.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java,v >retrieving revision 1.10 >diff -u -r1.10 Index.java >--- src/org/eclipse/help/internal/index/Index.java 8 Oct 2009 20:31:24 -0000 1.10 >+++ src/org/eclipse/help/internal/index/Index.java 25 Jan 2010 20:51:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 Intel Corporation and others. >+ * Copyright (c) 2005, 2010 Intel 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 >@@ -9,6 +9,7 @@ > * Intel Corporation - initial API and implementation > * IBM Corporation - 122967 [Help] Remote help system > * IBM Corporation - add support for see / see also >+ * IBM Corporation - add support for filtering of the index view > *******************************************************************************/ > package org.eclipse.help.internal.index; > >@@ -42,18 +43,18 @@ > > /** > * @param see A see element >- * @return true if the keyword of the see matches an entry in the index >+ * @return the entry with matching keyword or null > */ >- public boolean containsSeeTarget(IndexSee see) { >+ public IndexEntry getSeeTarget(IndexSee see) { > if (children == null) getChildren(); > String keyword = see.getKeyword(); > for (Iterator iter = children.iterator(); iter.hasNext();) { > Object next = iter.next(); > if (next instanceof IndexEntry && keyword.equals(((IndexEntry)next).getKeyword())) { >- return true; >+ return (IndexEntry)next; > } > } >- return false; >+ return null; > } > > } >Index: src/org/eclipse/help/internal/index/IndexAssembler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java,v >retrieving revision 1.21 >diff -u -r1.21 IndexAssembler.java >--- src/org/eclipse/help/internal/index/IndexAssembler.java 14 Oct 2009 15:21:31 -0000 1.21 >+++ src/org/eclipse/help/internal/index/IndexAssembler.java 25 Jan 2010 20:51:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 IBM Corporation and others. >+ * Copyright (c) 2006, 2010 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * IBM Corporation - add support for filtering of the index view > *******************************************************************************/ > package org.eclipse.help.internal.index; > >@@ -195,7 +196,7 @@ > } > ancestor = ancestor.getParentElement(); > } >- return ((Index)ancestor).containsSeeTarget(see); >+ return ((Index)ancestor).getSeeTarget(see) != null; > } > > /* >#P org.eclipse.help.base >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.base/META-INF/MANIFEST.MF,v >retrieving revision 1.42 >diff -u -r1.42 MANIFEST.MF >--- META-INF/MANIFEST.MF 8 Jan 2010 19:57:14 -0000 1.42 >+++ META-INF/MANIFEST.MF 25 Jan 2010 20:51:37 -0000 >@@ -7,6 +7,7 @@ > Bundle-Vendor: %providerName > Bundle-Localization: plugin > Export-Package: org.apache.lucene.demo.html;x-internal:=true, >+ org.eclipse.help.base, > org.eclipse.help.browser, > org.eclipse.help.internal.base; > x-friends:="org.eclipse.help.ui, >@@ -15,6 +16,7 @@ > org.eclipse.ui.intro, > org.eclipse.ua.tests.doc", > org.eclipse.help.internal.base.remote;x-friends:="org.eclipse.ua.tests,org.eclipse.help.webapp,org.eclipse.help.ui", >+ org.eclipse.help.internal.base.scope;x-friends:="org.eclipse.help.webapp,org.eclipse.ua.tests", > org.eclipse.help.internal.base.util;x-friends:="org.eclipse.help.ui,org.eclipse.help.webapp,org.eclipse.ua.tests", > org.eclipse.help.internal.browser;x-friends:="org.eclipse.help.ui,org.eclipse.ua.tests", > org.eclipse.help.internal.browser.macosx;x-friends:="org.eclipse.ua.tests", >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.base/plugin.xml,v >retrieving revision 1.42 >diff -u -r1.42 plugin.xml >--- plugin.xml 8 Jan 2010 19:57:14 -0000 1.42 >+++ plugin.xml 25 Jan 2010 20:51:37 -0000 >@@ -19,6 +19,7 @@ > <extension-point id="luceneSearchParticipants" name="%search_participant_extension_point_name" schema="schema/luceneSearchParticipants.exsd"/> > <extension-point id="server" name="%server_extension_point_name" schema="schema/server.exsd"/> > <extension-point id="searchParticipant" name="Help Search Participant" schema="schema/searchParticipant.exsd"/> >+ <extension-point id="scope" name="Help Scope" schema="schema/scope.exsd"/> > > <!-- Stand-alone infocenter application --> > <extension >Index: schema/scope.exsd >=================================================================== >RCS file: schema/scope.exsd >diff -N schema/scope.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/scope.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.help.base" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.help.base" id="scope" name="Help Scope"/> >+ </appInfo> >+ <documentation> >+ Support for user defined scopes in the help table of contents, index and search results. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <sequence minOccurs="1" maxOccurs="unbounded"> >+ <element ref="scope"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="scope"> >+ <annotation> >+ <documentation> >+ Defines a scope class which contains methods to determine which UA elements are in scope. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ An id for this scope which must be unique among scope ids. >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ 3.5 >+ </documentation> >+ </annotation> >+ >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiinfo"/> >+ </appInfo> >+ <documentation> >+ A class which implements AbstractScope contains functions to determine which elemements should be displayed when the scope is active. The help UI allows the user to specify any of the predefiend scopes. >+ </documentation> >+ </annotation> >+ >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ Copyright (c) 2010 IBM Corporation and others.<br> >+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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/help/base/AbstractHelpScope.java >=================================================================== >RCS file: src/org/eclipse/help/base/AbstractHelpScope.java >diff -N src/org/eclipse/help/base/AbstractHelpScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/base/AbstractHelpScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.base; >+ >+import java.util.Locale; >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.IUAElement; >+import org.eclipse.help.internal.base.scope.ScopeUtils; >+ >+/** >+ * Represents a scope which can be used to specify which topics are shown in the >+ * table of contents and which entries will show in the index. The inScope() functions >+ * are used by the help system to determine which elements to show. Both the table of >+ * contents and index are trees and the help system reads these trees starting with the >+ * root and working down through the children. >+ * >+ * @since 3.5 >+ */ >+ >+public abstract class AbstractHelpScope { >+ >+ /** >+ * Determine whether a table of contents is in scope >+ */ >+ public abstract boolean inScope(IToc toc); >+ >+ /** >+ * Determine whether a topic is in scope >+ */ >+ public abstract boolean inScope(ITopic topic); >+ >+ /** >+ * Determine whether an index entry is in scope >+ */ >+ public abstract boolean inScope(IIndexEntry entry); >+ >+ /** >+ * a single information center instance can display content in multiple locales. >+ * This function exists to provide a name for a specific locale. >+ * @param locale a string representing the locale used for the UI >+ * @return a name for this scope appropriate for the locale which >+ * will be used in the scope selection dialog. It is recommended that >+ * the name be no more than 20 characters long. >+ */ >+ public abstract String getName(Locale locale); >+ >+ /** >+ * In the default implementation of this method an IndexSee element is in scope >+ * if it's target is in scope. May be overridden to exclude more IndexSee elements >+ * from the scope >+ * @param see >+ * @return >+ */ >+ public boolean inScope(IIndexSee see) { >+ return hasInScopeChildren(see); >+ } >+ >+ /** >+ * The help system can build the trees faster if it knows that an out of >+ * scope element cannot have child elements which are in scope. This >+ * is called a hierarchical scope. If an out of scope element can have >+ * in scope children this function should be overridden and the help >+ * system will perform a deeper search. >+ */ >+ public boolean isHierarchicalScope() { >+ return true; >+ } >+ >+ /** >+ * Convenience method to make it easier to write subclasses >+ * In the case of an IIndexSee element this method tests >+ * to see if the target is in scope. For all other elements >+ * it tests all children and if this is not a hierarchical scope >+ * all descendants are tested. >+ * @param element An element which may have children >+ * @return true if at least one child is in scope >+ */ >+ public final boolean hasInScopeChildren(IUAElement element) { >+ return ScopeUtils.hasInScopeChildren(element, this); >+ } >+ >+} >+ >Index: src/org/eclipse/help/internal/base/scope/EnablementScope.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/EnablementScope.java >diff -N src/org/eclipse/help/internal/base/scope/EnablementScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/EnablementScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.Locale; >+ >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; >+import org.eclipse.help.internal.base.HelpBasePlugin; >+ >+public class EnablementScope extends AbstractHelpScope { >+ >+ public boolean inScope(IToc toc) { >+ return HelpBasePlugin.getActivitySupport().isEnabled(toc.getHref()); >+ } >+ >+ public boolean inScope(ITopic topic) { >+ return true; >+ } >+ >+ public boolean inScope(IIndexEntry entry) { >+ return true; >+ } >+ >+ public boolean inScope(IIndexSee see) { >+ return true; >+ } >+ >+ public String getName(Locale locale) { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/FilterScope.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/FilterScope.java >diff -N src/org/eclipse/help/internal/base/scope/FilterScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/FilterScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.Locale; >+ >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; >+import org.eclipse.help.internal.base.HelpEvaluationContext; >+ >+/** >+ * A scope which tests for content filtering >+ */ >+ >+public class FilterScope extends AbstractHelpScope { >+ >+ public boolean inScope(IToc toc) { >+ if (!toc.isEnabled(HelpEvaluationContext.getContext())) { >+ return false; >+ } >+ return hasInScopeChildren(toc); >+ } >+ >+ public boolean inScope(ITopic topic) { >+ if (!topic.isEnabled(HelpEvaluationContext.getContext())) { >+ return false; >+ } >+ if (topic.getHref() != null) { >+ return true; >+ } >+ return ScopeUtils.hasInScopeDescendent(topic, this); >+ } >+ >+ public boolean inScope(IIndexEntry entry) { >+ return entry.isEnabled(HelpEvaluationContext.getContext()); >+ } >+ >+ public boolean inScope(IIndexSee see) { >+ return see.isEnabled(HelpEvaluationContext.getContext()); >+ } >+ >+ public String getName(Locale locale) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/IntersectionScope.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/IntersectionScope.java >diff -N src/org/eclipse/help/internal/base/scope/IntersectionScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/IntersectionScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.Locale; >+ >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; >+ >+/** >+ * A scope which represents the intersection of two or more other scopes >+ * An element is in scope only if it is included in every scope passed to the constructor >+ */ >+ >+public class IntersectionScope extends AbstractHelpScope { >+ >+ AbstractHelpScope[] scopes; >+ >+ public IntersectionScope(AbstractHelpScope[] scopes) { >+ this.scopes = scopes; >+ } >+ >+ public boolean inScope(IToc toc) { >+ for (int scope = 0; scope < scopes.length; scope ++) { >+ if (!scopes[scope].inScope(toc)) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ public boolean inScope(ITopic topic) { >+ for (int scope = 0; scope < scopes.length; scope ++) { >+ if (!scopes[scope].inScope(topic)) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ public boolean inScope(IIndexEntry entry) { >+ for (int scope = 0; scope < scopes.length; scope ++) { >+ if (!scopes[scope].inScope(entry)) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ public boolean inScope(IIndexSee see) { >+ for (int scope = 0; scope < scopes.length; scope ++) { >+ if (!scopes[scope].inScope(see)) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ public String getName(Locale locale) { >+ return null; >+ } >+ >+ public boolean isHierarchicalScope() { >+ for (int scope = 0; scope < scopes.length; scope ++) { >+ if (!scopes[scope].isHierarchicalScope()) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/ScopeHandle.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/ScopeHandle.java >diff -N src/org/eclipse/help/internal/base/scope/ScopeHandle.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/ScopeHandle.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import org.eclipse.help.base.AbstractHelpScope; >+ >+public class ScopeHandle { >+ >+ private AbstractHelpScope scope; >+ private String id; >+ >+ public ScopeHandle( String id, AbstractHelpScope scope) { >+ this.id = id; >+ this.scope = scope; >+ } >+ >+ public AbstractHelpScope getScope() { >+ return scope; >+ } >+ >+ public String getId() { >+ return id; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/ScopeRegistry.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/ScopeRegistry.java >diff -N src/org/eclipse/help/internal/base/scope/ScopeRegistry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/ScopeRegistry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.help.base.AbstractHelpScope; >+import org.eclipse.help.internal.base.HelpBasePlugin; >+ >+public class ScopeRegistry { >+ >+ public static final String SCOPE_XP_NAME = "org.eclipse.help.base.scope"; //$NON-NLS-1$ >+ >+ private static List scopes = null; >+ >+ private static ScopeRegistry instance; >+ >+ private boolean initialized = false; >+ >+ >+ private ScopeRegistry() { >+ } >+ >+ public static ScopeRegistry getInstance() { >+ if (instance == null) { >+ instance = new ScopeRegistry(); >+ } >+ return instance; >+ } >+ >+ public AbstractHelpScope getScope(String id) { >+ if (id == null) { >+ return new UniversalScope(); >+ } >+ readScopes(); >+ // Lookup in scope registry >+ for (Iterator iter = scopes.iterator(); iter.hasNext();) { >+ ScopeHandle handle = (ScopeHandle) iter.next(); >+ if (id.equals(handle.getId())) { >+ return handle.getScope(); >+ } >+ } >+ return null; >+ } >+ >+ synchronized private void readScopes() { >+ if (initialized ) { >+ return; >+ } >+ scopes = new ArrayList(); >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ IConfigurationElement[] elements = registry >+ .getConfigurationElementsFor(SCOPE_XP_NAME); >+ for (int i = 0; i < elements.length; i++) { >+ >+ Object obj = null; >+ try { >+ obj = elements[i].createExecutableExtension("class"); //$NON-NLS-1$ >+ } catch (CoreException e) { >+ HelpBasePlugin.logError("Create extension failed:[" //$NON-NLS-1$ >+ + SCOPE_XP_NAME + "].", e); //$NON-NLS-1$ >+ } >+ if (obj instanceof AbstractHelpScope) { >+ String id = elements[i].getAttribute("id"); //$NON-NLS-1$ >+ ScopeHandle filter = new ScopeHandle(id, (AbstractHelpScope) obj); >+ scopes.add(filter); >+ } >+ } >+ initialized = true; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/ScopeUtils.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/ScopeUtils.java >diff -N src/org/eclipse/help/internal/base/scope/ScopeUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/ScopeUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,188 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexEntry2; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.IUAElement; >+import org.eclipse.help.base.AbstractHelpScope; >+import org.eclipse.help.internal.UAElement; >+import org.eclipse.help.internal.index.Index; >+import org.eclipse.help.internal.index.IndexSee; >+ >+/** >+ * Utilities to test for enabled topics, index entries etc. >+ */ >+ >+public class ScopeUtils { >+ >+ >+ /* >+ * Function to determine whether a topic should be shown in the toc. >+ * For hierarchical scopes the element itself must be in scope. >+ * For non hierarchical scopes if any child is in scope the element should show. >+ */ >+ public static boolean showInTree(IToc toc, AbstractHelpScope scope) { >+ return scope.inScope(toc) || >+ (!scope.isHierarchicalScope() && hasInScopeDescendent(toc, scope)); >+ } >+ >+ /* >+ * Function to determine whether a topic should be shown in the toc. >+ * For hierarchical scopes the element itself must be in scope. >+ * For non hierarchical scopes if any child is in scope the element should show. >+ */ >+ public static boolean showInTree(ITopic topic, AbstractHelpScope scope) { >+ return scope.inScope(topic) || >+ (!scope.isHierarchicalScope() && hasInScopeDescendent(topic, scope)); >+ } >+ >+ /* >+ * Function to determine whether an entry should be shown in the index. >+ * For hierarchical scopes the element itself must be in scope. >+ * For non hierarchical scopes if any child is in scope the element should show. >+ */ >+ public static boolean showInTree(IIndexEntry entry, AbstractHelpScope scope) { >+ return scope.inScope(entry) || >+ (!scope.isHierarchicalScope() && hasInScopeDescendent(entry, scope)); >+ } >+ >+ public static boolean hasInScopeDescendent(ITopic topic, AbstractHelpScope scope) { >+ ITopic[] subtopics = topic.getSubtopics(); >+ for (int i = 0; i < subtopics.length; i++) { >+ if (showInTree(subtopics[i], scope)) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ public static boolean hasInScopeDescendent(IToc toc, AbstractHelpScope scope) { >+ ITopic[] topics = toc.getTopics(); >+ for (int i = 0; i < topics.length; i++) { >+ if (showInTree(topics[i], scope)) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ public static boolean hasInScopeDescendent(IIndexEntry entry, >+ AbstractHelpScope scope) { >+ ITopic[] topics = entry.getTopics(); >+ for (int t = 0; t < topics.length; t++) { >+ if (showInTree(topics[t], scope)) { >+ return true; >+ } >+ } >+ IIndexEntry[] entries = entry.getSubentries(); >+ for (int e = 0; e < entries.length; e++) { >+ if (showInTree(entries[e], scope)) { >+ return true; >+ } >+ } >+ if (entry instanceof IIndexEntry2) { >+ IIndexSee[] sees = ((IIndexEntry2)entry).getSees(); >+ for (int s = 0; s < sees.length; s++) { >+ if (scope.inScope(sees[s]) && hasInScopeTarget(sees[s], scope)) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ public static boolean hasInScopeTarget(IIndexSee see, AbstractHelpScope scope) { >+ if (see instanceof IndexSee) { >+ IndexSee indexSee = (IndexSee)see; >+ UAElement ancestor = indexSee.getParentElement(); >+ while (!(ancestor instanceof Index)) { >+ if (ancestor == null) { >+ return true; >+ } >+ ancestor = ancestor.getParentElement(); >+ } >+ IIndexEntry target = ((Index)ancestor).getSeeTarget(indexSee); >+ if (target == null) { >+ return false; >+ } >+ return scope.inScope(target) || hasInScopeDescendent(target, scope); >+ } >+ return false; >+ } >+ >+ /** >+ * Filter out any disabled entries from an array >+ * @param entries an array of entries >+ * @param scope >+ * @return an array containing only those entries which are enabled >+ */ >+ public static IIndexEntry[] inScopeEntries(IIndexEntry[] entries, AbstractHelpScope scope) { >+ for (int i=0;i<entries.length;++i) { >+ if (!scope.inScope(entries[i])) { >+ List list = new ArrayList(entries.length); >+ for (int j=0;j<entries.length;++j) { >+ if (j < i || scope.inScope(entries[j])) { >+ list.add(entries[j]); >+ } >+ } >+ return (IIndexEntry[])list.toArray(new IIndexEntry[list.size()]); >+ } >+ } >+ return entries; >+ } >+ >+ /** >+ * Filter out any disabled topics from an array >+ * @param topics an array of topics >+ * @param scope >+ * @return an array containing only those topics which are enabled >+ */ >+ public static ITopic[] inScopeTopics(ITopic[] topics, AbstractHelpScope scope) { >+ for (int i=0;i<topics.length;++i) { >+ if (!scope.inScope(topics[i])) { >+ List list = new ArrayList(topics.length); >+ for (int j=0;j<topics.length;++j) { >+ if (j < i || scope.inScope(topics[j])) { >+ list.add(topics[j]); >+ } >+ } >+ return (ITopic[])list.toArray(new ITopic[list.size()]); >+ } >+ } >+ return topics; >+ } >+ >+ public static boolean hasInScopeChildren(IUAElement element, >+ AbstractHelpScope scope) { >+ if (element instanceof IToc) { >+ return hasInScopeDescendent((IToc)element, scope); >+ } >+ if (element instanceof ITopic) { >+ return hasInScopeDescendent((ITopic)element, scope); >+ } >+ if (element instanceof IIndexEntry) { >+ return hasInScopeDescendent((IIndexEntry) element, scope); >+ } >+ if (element instanceof IIndexSee) { >+ return hasInScopeTarget((IIndexSee) element, scope); >+ } >+ return false; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/UniversalScope.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/UniversalScope.java >diff -N src/org/eclipse/help/internal/base/scope/UniversalScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/UniversalScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,45 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.Locale; >+ >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; >+ >+public class UniversalScope extends AbstractHelpScope { >+ >+ public boolean inScope(IToc toc) { >+ return true; >+ } >+ >+ public boolean inScope(ITopic topic) { >+ return true; >+ } >+ >+ public boolean inScope(IIndexEntry entry) { >+ return true; >+ } >+ >+ public boolean inScope(IIndexSee see) { >+ return true; >+ } >+ >+ public String getName(Locale locale) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+} >Index: src/org/eclipse/help/internal/base/scope/WorkingSetScope.java >=================================================================== >RCS file: src/org/eclipse/help/internal/base/scope/WorkingSetScope.java >diff -N src/org/eclipse/help/internal/base/scope/WorkingSetScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/base/scope/WorkingSetScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.scope; >+ >+import java.util.HashSet; >+import java.util.Locale; >+import java.util.Set; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.help.IIndexEntry; >+import org.eclipse.help.IIndexSee; >+import org.eclipse.help.IToc; >+import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; >+import org.eclipse.help.internal.UAElement; >+import org.eclipse.help.internal.workingset.AdaptableHelpResource; >+import org.eclipse.help.internal.workingset.IHelpWorkingSetManager; >+import org.eclipse.help.internal.workingset.WorkingSet; >+ >+public class WorkingSetScope extends AbstractHelpScope { >+ >+ IHelpWorkingSetManager wSetManager; >+ private WorkingSet workingSet; >+ AdaptableHelpResource[] elements; >+ >+ public WorkingSetScope(String scope, IHelpWorkingSetManager manager) { >+ wSetManager = manager; >+ workingSet = wSetManager.getWorkingSet(scope); >+ elements = workingSet.getElements(); >+ wSetManager = manager; >+ } >+ >+ public boolean inScope(IToc toc) { >+ for (int i = 0; i < elements.length; i++) { >+ for (AdaptableHelpResource adaptable = elements[i]; adaptable != null; ) { >+ Object itoc = adaptable.getAdapter(IToc.class); >+ if (toc == itoc) { >+ return true; >+ } >+ IAdaptable parent= adaptable.getParent(); >+ if (parent instanceof AdaptableHelpResource) { >+ adaptable = (AdaptableHelpResource) parent; >+ } else { >+ adaptable = null; >+ } >+ } >+ } >+ return false; >+ } >+ >+ public boolean inScope(ITopic topic) { >+ Set topics = new HashSet(); >+ IToc toc = null; >+ topics.add(topic); >+ if (topic instanceof UAElement) { >+ for (UAElement uae = (UAElement) topic; uae != null; ) { >+ if (uae instanceof IToc) { >+ toc = (IToc) uae; >+ uae = null; >+ } else if (uae instanceof IIndexEntry) { >+ for (int i = 0; i < elements.length; i++) { >+ AdaptableHelpResource adaptable = elements[i]; >+ if (adaptable.getTopic(topic.getHref()) != null) { >+ return true; >+ } >+ } >+ return false; >+ } else { >+ if (uae instanceof ITopic) { >+ topics.add(uae); >+ } >+ uae = uae.getParentElement(); >+ } >+ } >+ } >+ for (int i = 0; i < elements.length; i++) { >+ AdaptableHelpResource adaptable = elements[i]; >+ if (toc != null) { >+ Object itoc = adaptable.getAdapter(IToc.class); >+ if (toc == itoc) { >+ return true; >+ } >+ } >+ Object itopic = adaptable.getAdapter(ITopic.class); >+ if (topic != null && topics.contains(itopic)) { >+ return true; >+ } >+ IAdaptable parent = adaptable.getParent(); >+ if (parent instanceof AdaptableHelpResource) { >+ adaptable = (AdaptableHelpResource) parent; >+ } else { >+ adaptable = null; >+ } >+ } >+ return false; >+ } >+ >+ public boolean inScope(IIndexEntry entry) { >+ return hasInScopeChildren(entry); >+ } >+ >+ public boolean inScope(IIndexSee see) { >+ return hasInScopeChildren(see); >+ } >+ >+ public String getName(Locale locale) { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/help/internal/search/SearchResults.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java,v >retrieving revision 1.24 >diff -u -r1.24 SearchResults.java >--- src/org/eclipse/help/internal/search/SearchResults.java 30 Nov 2009 19:16:58 -0000 1.24 >+++ src/org/eclipse/help/internal/search/SearchResults.java 25 Jan 2010 20:51:38 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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 >@@ -16,6 +16,7 @@ > > import org.eclipse.help.IToc; > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.HelpPlugin; > import org.eclipse.help.internal.util.URLCoder; > import org.eclipse.help.internal.workingset.AdaptableHelpResource; >@@ -34,6 +35,7 @@ > private ArrayList scopes; > private int maxHits; > private String locale; >+ private AbstractHelpScope filter; > protected SearchHit[] searchHits = new SearchHit[0]; > /** > * Constructor >@@ -46,6 +48,10 @@ > this.locale = locale; > this.scopes = getScopes(workingSets); > } >+ >+ public void setFilter(AbstractHelpScope filter) { >+ this.filter = filter; >+ } > > /* (non-Javadoc) > * @see org.eclipse.help.internal.search.ISearchHitCollector#addHits(List, String) >@@ -65,6 +71,9 @@ > // the scope for the topic, if any > if (scopes == null) { > toc = getTocForTopic(href, locale); >+ if (toc == null) { >+ continue; >+ } > } else { > scope = getScopeForTopic(href); > if (scope == null) { >@@ -123,8 +132,11 @@ > private AdaptableHelpResource getScopeForTopic(String href) { > for (int i = 0; i < scopes.size(); i++) { > AdaptableHelpResource scope = (AdaptableHelpResource) scopes.get(i); >- if (scope.getTopic(href) != null) >- return scope; >+ ITopic inScopeTopic = scope.getTopic(href); >+ if (inScopeTopic != null) >+ if (filter == null || filter.inScope(inScopeTopic)) { >+ return scope; >+ } > > // add root toc's extradir topics to search scope > IToc tocRoot = getTocForScope(scope, locale); >@@ -133,6 +145,9 @@ > if (toc != null) { > String owningTocHref = toc.getHref(); > if (owningTocHref == tocRoot.getHref()) { >+ if (filter == null || filter.inScope(inScopeTopic)) { >+ return scope; >+ } > return scope; > } > } >@@ -176,10 +191,25 @@ > */ > private IToc getTocForTopic(String href, String locale) { > IToc[] tocs = HelpPlugin.getTocManager().getTocs(locale); >+ boolean foundInToc = false; > for (int i = 0; i < tocs.length; i++) { > ITopic topic = tocs[i].getTopic(href); >- if (topic != null) >- return tocs[i]; >+ if (topic != null) { >+ foundInToc = true; >+ if (filter == null || filter.inScope(topic)) { >+ return tocs[i]; >+ } >+ } >+ } >+ if (!foundInToc) { >+ // test to pick up files in extradirs >+ IToc toc = HelpPlugin.getTocManager().getOwningToc(href); >+ if (toc != null) { >+ foundInToc = true; >+ if (filter == null || filter.inScope(toc)) { >+ return toc; >+ } >+ } > } > return null; > } >#P org.eclipse.help.webapp >Index: advanced/index.jsp >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/advanced/index.jsp,v >retrieving revision 1.30 >diff -u -r1.30 index.jsp >--- advanced/index.jsp 18 Nov 2009 00:41:58 -0000 1.30 >+++ advanced/index.jsp 25 Jan 2010 20:51:39 -0000 >@@ -1,5 +1,5 @@ > <%-- >- Copyright (c) 2000, 2009 IBM Corporation and others. >+ Copyright (c) 2000, 2010 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 >@@ -18,6 +18,8 @@ > cookieTest.setMaxAge(365*24*60*60); > response.addCookie(cookieTest); > } >+ // Read the scope parameter >+ RequestScope.getScopeParameter(request, response, false); > %> > > <html> >Index: advanced/indexView.js >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/advanced/indexView.js,v >retrieving revision 1.12 >diff -u -r1.12 indexView.js >--- advanced/indexView.js 8 Oct 2009 20:31:22 -0000 1.12 >+++ advanced/indexView.js 25 Jan 2010 20:51:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 Intel Corporation and others. >+ * Copyright (c) 2005, 2010 Intel 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 >@@ -9,6 +9,7 @@ > * Intel Corporation - initial API and implementation > * IBM Corporation 2006, refactored index view into a single frame > * IBM Corporation 2007, allow partial loading of index >+ * IBM Corporation 2010, add filtering in toc and index view > *******************************************************************************/ > > var isMozilla = navigator.userAgent.indexOf("Mozilla") != -1 && parseInt(navigator.appVersion.substring(0,1)) >= 5; >@@ -204,7 +205,7 @@ > } > > function makeNodeRequest(parameters) { >- var href = "../indexfragment" + parameters; >+ var href = "indexfragment" + parameters; > var callback = function(xml) { updateIndexTree(xml);}; > var errorCallback = function() { > // alert("ajax error"); >Index: advanced/tocTree.js >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/advanced/tocTree.js,v >retrieving revision 1.22 >diff -u -r1.22 tocTree.js >--- advanced/tocTree.js 27 Feb 2009 20:54:54 -0000 1.22 >+++ advanced/tocTree.js 25 Jan 2010 20:51:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 IBM Corporation and others. >+ * Copyright (c) 2006, 2010 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 >@@ -12,14 +12,14 @@ > // Tree code specific to the help toc > > var showExpanders = true; >-var ajaxPrefix = "../tocfragment"; >+var ajaxPath = "tocfragment"; > var pendingSynchTopic = null; // Should the toc be synchronized when the view becomes visible > >-// The default value of ajaxPrefix works from jsp files but needs to be overridden to >+// The default value of ajaxPath works from jsp files but needs to be overridden to > // a non relative path to work from scripts launched from any page > > function setAjaxPrefix(prefix) { >- ajaxPrefix = prefix; >+ ajaxPath = prefix + "/tocfragment"; > } > > /* >@@ -174,11 +174,7 @@ > > function makeNodeRequest(parameters) { > var href; >- if (ajaxPrefix) { >- href = ajaxPrefix + "/tocfragment" +parameters; >- } else { >- href = "../tocfragment" + parameters; >- } >+ href = ajaxPath +parameters; > var callback = function(xml) { updateTocTree(xml);}; > var errorCallback = function() { > // alert("ajax error"); >@@ -188,11 +184,7 @@ > > function makeShowInTocRequest(parameters) { > var href; >- if (ajaxPrefix) { >- href = ajaxPrefix + "/tocfragment" +parameters; >- } else { >- href = "../tocfragment" + parameters; >- } >+ href = ajaxPath +parameters; > var callback = function(xml) { showInToc(xml);}; > var errorCallback = function() { > // alert("ajax error"); >Index: advanced/tocView.jsp >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/advanced/tocView.jsp,v >retrieving revision 1.57 >diff -u -r1.57 tocView.jsp >--- advanced/tocView.jsp 8 Dec 2009 19:14:09 -0000 1.57 >+++ advanced/tocView.jsp 25 Jan 2010 20:51:39 -0000 >@@ -1,5 +1,5 @@ > <%-- >- Copyright (c) 2000, 2009 IBM Corporation and others. >+ Copyright (c) 2000, 2010 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 >@@ -72,9 +72,9 @@ > setRootAccessibility(); > loadChildren(null); > >- // Set prefix for AJAX calls by removing advanced/tocView.jsp from location >+ // Set prefix for AJAX calls by removing tocView.jsp from location > var locationHref = window.location.href; >- var slashAdvanced = locationHref.lastIndexOf('/advanced'); >+ var slashAdvanced = locationHref.lastIndexOf('/tocView.jsp'); > if(slashAdvanced > 0) { > setAjaxPrefix(locationHref.substr(0, slashAdvanced)); > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/plugin.xml,v >retrieving revision 1.37 >diff -u -r1.37 plugin.xml >--- plugin.xml 20 Oct 2009 20:43:02 -0000 1.37 >+++ plugin.xml 25 Jan 2010 20:51:39 -0000 >@@ -83,7 +83,7 @@ > httpcontextId="help"> > </servlet> > <servlet >- alias="/tocfragment" >+ alias="/advanced/tocfragment" > class="org.eclipse.help.internal.webapp.servlet.TocFragmentServlet" > httpcontextId="help"> > </servlet> >@@ -93,7 +93,7 @@ > httpcontextId="help"> > </servlet> > <servlet >- alias="/indexfragment" >+ alias="/advanced/indexfragment" > class="org.eclipse.help.internal.webapp.servlet.IndexFragmentServlet" > httpcontextId="help"> > </servlet> >Index: src/org/eclipse/help/internal/webapp/data/PrintData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java,v >retrieving revision 1.10 >diff -u -r1.10 PrintData.java >--- src/org/eclipse/help/internal/webapp/data/PrintData.java 18 Nov 2009 19:16:49 -0000 1.10 >+++ src/org/eclipse/help/internal/webapp/data/PrintData.java 25 Jan 2010 20:51:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2009 IBM Corporation and others. >+ * Copyright (c) 2007, 2010 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 >@@ -33,8 +33,10 @@ > import org.eclipse.help.HelpSystem; > import org.eclipse.help.IToc; > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.HelpPlugin; > import org.eclipse.help.internal.base.BaseHelpSystem; >+import org.eclipse.help.internal.base.scope.ScopeUtils; > import org.eclipse.help.internal.search.HTMLDocParser; > import org.eclipse.help.internal.webapp.HelpWebappPlugin; > import org.eclipse.help.internal.xhtml.DynamicXHTMLProcessor; >@@ -70,6 +72,8 @@ > // flag right-to-left direction of text > private boolean isRTL; > >+ private AbstractHelpScope scope; >+ > /* > * Constructs the print data for the given request. > */ >@@ -81,6 +85,7 @@ > } > > isRTL = UrlUtil.isRTL(request, response); >+ scope = RequestScope.getScopeFromRequest(request, response); > > String confirmString = request.getParameter("confirmed"); //$NON-NLS-1$ > if ((confirmString != null) && ("true".equals(confirmString))) { //$NON-NLS-1$ >@@ -209,7 +214,7 @@ > topicsRequested++; > } > >- ITopic[] subtopics = EnabledTopicUtils.getEnabled(topic.getSubtopics()); >+ ITopic[] subtopics = ScopeUtils.inScopeTopics(topic.getSubtopics(), scope); > for (int i = 0; i < subtopics.length; ++i) { > topicsRequested += topicsRequested(subtopics[i]); > } >@@ -243,7 +248,7 @@ > if (href != null && href.length() > 0) { > tocGenerated++; > } >- ITopic[] subtopics = EnabledTopicUtils.getEnabled(topic.getSubtopics()); >+ ITopic[] subtopics = ScopeUtils.inScopeTopics(topic.getSubtopics(), scope); > for (int i = 0; i < subtopics.length; ++i) { > tocGenerated = generateToc(subtopics[i], String.valueOf(i + 1), tocGenerated, out); > } >@@ -267,7 +272,7 @@ > tocGenerated++; > } > >- ITopic[] subtopics = EnabledTopicUtils.getEnabled(topic.getSubtopics()); >+ ITopic[] subtopics = ScopeUtils.inScopeTopics(topic.getSubtopics(), scope); > for (int i = 0; i < subtopics.length; ++i) { > String subsectionId = sectionId + "." + (i + 1); //$NON-NLS-1$ > tocGenerated = generateToc(subtopics[i], subsectionId, tocGenerated, out); >@@ -311,7 +316,7 @@ > out.write(content); > } > } >- ITopic[] subtopics = EnabledTopicUtils.getEnabled(topic.getSubtopics()); >+ ITopic[] subtopics = ScopeUtils.inScopeTopics(topic.getSubtopics(), scope); > for (int i = 0; i < subtopics.length; ++i) { > String subsectionId = (sectionId != null ? sectionId + "." : "") + (i + 1); //$NON-NLS-1$ //$NON-NLS-2$ > topicsGenerated = generateContent(subtopics[i], subsectionId, topicsGenerated, generated, out); >Index: src/org/eclipse/help/internal/webapp/data/RequestScope.java >=================================================================== >RCS file: src/org/eclipse/help/internal/webapp/data/RequestScope.java >diff -N src/org/eclipse/help/internal/webapp/data/RequestScope.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/help/internal/webapp/data/RequestScope.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,122 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.data; >+ >+import java.util.ArrayList; >+import java.util.List; >+import java.util.StringTokenizer; >+ >+import javax.servlet.http.Cookie; >+import javax.servlet.http.HttpServletRequest; >+import javax.servlet.http.HttpServletResponse; >+ >+import org.eclipse.help.HelpSystem; >+import org.eclipse.help.base.AbstractHelpScope; >+import org.eclipse.help.internal.base.HelpBasePlugin; >+import org.eclipse.help.internal.base.scope.EnablementScope; >+import org.eclipse.help.internal.base.scope.FilterScope; >+import org.eclipse.help.internal.base.scope.IntersectionScope; >+import org.eclipse.help.internal.base.scope.ScopeRegistry; >+import org.eclipse.help.internal.base.scope.UniversalScope; >+import org.eclipse.help.internal.base.scope.WorkingSetScope; >+import org.eclipse.help.internal.webapp.servlet.WebappWorkingSetManager; >+ >+public class RequestScope { >+ >+ private static final String SCOPE_PARAMETER_NAME = "subset"; //$NON-NLS-1$ >+ private static final String SCOPE_COOKIE_NAME = "filter"; //$NON-NLS-1$ >+ >+ public static AbstractHelpScope getScopeFromRequest(HttpServletRequest req, HttpServletResponse resp ) { >+ if (!HelpSystem.isShared()) { >+ // Filtering by scope is currently only in information center mode >+ if (HelpBasePlugin.getActivitySupport().isFilteringEnabled()) { >+ AbstractHelpScope[] scopes = { new FilterScope(), new EnablementScope() }; >+ return new IntersectionScope(scopes); >+ } >+ return new FilterScope(); >+ } >+ >+ String scopesFromParameter= getScopeParameter(req, resp, true); >+ List scopes = new ArrayList(); >+ if (scopesFromParameter != null) { >+ StringTokenizer tokenizer = new StringTokenizer(scopesFromParameter, "/"); //$NON-NLS-1$ >+ while (tokenizer.hasMoreTokens()) { >+ String nextScope = tokenizer.nextToken().trim(); >+ if (!nextScope.equals("")) { //$NON-NLS-1$ >+ AbstractHelpScope scope = ScopeRegistry.getInstance().getScope(nextScope); >+ if (scope != null) { >+ scopes.add(scope); >+ } else { >+ // Try for a working set >+ try { >+ WorkingSetScope workingSetScope = new WorkingSetScope( >+ nextScope, new WebappWorkingSetManager(req, >+ resp, UrlUtil.getLocale(req, resp))); >+ scopes.add(workingSetScope); >+ } catch (Exception e) { >+ } >+ } >+ >+ } >+ } >+ } >+ switch (scopes.size()) { >+ case 0: >+ return new UniversalScope(); >+ case 1: >+ return (AbstractHelpScope) scopes.get(0); >+ default: >+ return new IntersectionScope( >+ (AbstractHelpScope[]) scopes.toArray(new AbstractHelpScope[scopes.size()])); >+ } >+ } >+ >+ public static String getScopeParameter(HttpServletRequest request, HttpServletResponse response, boolean readCookie ) { >+ // See if there is a scope parameter, if so save as cookie >+ String[] scope = request.getParameterValues(SCOPE_PARAMETER_NAME); >+ String scopeString = null; >+ if (scope != null) { >+ // save scope (in session cookie) for later use in a user session >+ // If there are multiple values separate them with an '&' >+ if (scope != null && scope.length > 0 && response != null) { >+ scopeString = scope[0]; >+ for (int s = 1; s < scope.length; s++) { >+ scopeString += '/'; >+ scopeString += scope[s]; >+ } >+ Cookie scopeCookie = new Cookie(SCOPE_COOKIE_NAME, scopeString); >+ response.addCookie(scopeCookie); >+ return scopeString; >+ } >+ } else { >+ if (readCookie) { >+ // check if scope was passed earlier in this session >+ Cookie[] cookies = request.getCookies(); >+ if (cookies != null) { >+ for (int c = 0; c < cookies.length; c++) { >+ if (SCOPE_COOKIE_NAME.equals(cookies[c].getName())) { >+ scopeString = cookies[c].getValue(); >+ break; >+ } >+ } >+ } >+ } else if (response != null) { >+ // No scope parameter and cookie is stale. Set the cookie to show all >+ scopeString = "all"; //$NON-NLS-1$ >+ Cookie scopeCookie = new Cookie(SCOPE_COOKIE_NAME, scopeString); >+ response.addCookie(scopeCookie); >+ } >+ } >+ return scopeString; >+ } >+ >+} >Index: src/org/eclipse/help/internal/webapp/data/SearchData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java,v >retrieving revision 1.6 >diff -u -r1.6 SearchData.java >--- src/org/eclipse/help/internal/webapp/data/SearchData.java 30 Nov 2009 19:16:56 -0000 1.6 >+++ src/org/eclipse/help/internal/webapp/data/SearchData.java 25 Jan 2010 20:51:41 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.help.IHelpResource; > import org.eclipse.help.IToc; > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.HelpPlugin; > import org.eclipse.help.internal.base.BaseHelpSystem; > import org.eclipse.help.internal.base.HelpBasePlugin; >@@ -348,7 +349,8 @@ > .getProgressMonitor(getLocale()); > if (pm.isDone()) { > this.indexCompletion = 100; >- SearchResults results = createHitCollector(); >+ AbstractHelpScope filter = RequestScope.getScopeFromRequest(request, response); >+ SearchResults results = createHitCollector(filter); > BaseHelpSystem.getSearchManager().search(createSearchQuery(), > results, pm); > hits = results.getSearchHits(); >@@ -386,7 +388,7 @@ > getLocale()); > } > >- private SearchResults createHitCollector() { >+ private SearchResults createHitCollector(AbstractHelpScope filter) { > WorkingSet[] workingSets; > if (request.getParameterValues("scopedSearch") != null) { //$NON-NLS-1$ > // scopes are books (advanced search) >@@ -414,7 +416,7 @@ > } catch (NumberFormatException nfe) { > } > } >- return new SearchResultFilter(workingSets, maxHits, getLocale()); >+ return new SearchResultFilter(workingSets, maxHits, getLocale(), filter); > } > > /** >@@ -533,8 +535,9 @@ > * that implement ISearchEngineResult2 and canOpen() returns true. > */ > private static class SearchResultFilter extends SearchResults { >- public SearchResultFilter(WorkingSet[] workingSets, int maxHits, String locale) { >+ public SearchResultFilter(WorkingSet[] workingSets, int maxHits, String locale, AbstractHelpScope filter) { > super(workingSets, maxHits, locale); >+ setFilter(filter); > } > public void addHits(List hits, String highlightTerms) { > List filtered = new ArrayList(); >Index: src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java,v >retrieving revision 1.1 >diff -u -r1.1 ChildLinkInserter.java >--- src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java 24 Aug 2009 16:46:08 -0000 1.1 >+++ src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java 25 Jan 2010 20:51:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 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 >@@ -19,9 +19,11 @@ > > import org.eclipse.core.runtime.Path; > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.HelpPlugin; >+import org.eclipse.help.internal.base.scope.ScopeUtils; > import org.eclipse.help.internal.toc.Toc; >-import org.eclipse.help.internal.webapp.data.EnabledTopicUtils; >+import org.eclipse.help.internal.webapp.data.RequestScope; > import org.eclipse.help.internal.webapp.data.UrlUtil; > > public class ChildLinkInserter { >@@ -31,10 +33,12 @@ > private OutputStream out; > private static final String NO_CHILDREN = "no_child_topics"; //$NON-NLS-1$ > private static final String HAS_CHILDREN = "has_child_topics"; //$NON-NLS-1$ >+ private AbstractHelpScope scope; > > public ChildLinkInserter(HttpServletRequest req, OutputStream out) { > this.req = req; > this.out = out; >+ scope = RequestScope.getScopeFromRequest(req, null); > } > > public void addContents(String encoding) throws IOException { >@@ -46,7 +50,7 @@ > } > StringBuffer links = new StringBuffer("\n<ul class=\"childlinks\">\n"); //$NON-NLS-1$ > for (int i=0;i<subtopics.length;++i) { >- if (EnabledTopicUtils.isEnabled(subtopics[i])) { >+ if (ScopeUtils.showInTree(subtopics[i], scope)) { > links.append("\n<li><a href=\""); //$NON-NLS-1$ > String href = subtopics[i].getHref(); > if (href == null) { >@@ -106,7 +110,7 @@ > if (topic != null && topic.getHref() != null) { > ITopic[] subtopics = topic.getSubtopics(); > for (int i = 0; i < subtopics.length; ++i) { >- if (EnabledTopicUtils.isEnabled(subtopics[i])) { >+ if (ScopeUtils.showInTree(subtopics[i], scope)) { > out.write(HAS_CHILDREN.getBytes(UTF_8)); > return; > } >Index: src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java,v >retrieving revision 1.2 >diff -u -r1.2 CookieUtil.java >--- src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java 16 Mar 2007 20:19:56 -0000 1.2 >+++ src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java 25 Jan 2010 20:51:41 -0000 >@@ -69,7 +69,7 @@ > * Saves string in multiple browser cookies. Cookies can store limited > * length string. This method will attemt to split string among multiple > * cookies. The following cookies will be set name1=length <substing1 >- * name2=substrging2 ... namen=substringn >+ * name2=substring2 ... namen=substringn > * > * @param data > * a string containing legal characters for cookie value >Index: src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java,v >retrieving revision 1.3 >diff -u -r1.3 IndexFragmentServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java 8 Oct 2009 20:31:22 -0000 1.3 >+++ src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java 25 Jan 2010 20:51:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2009 IBM Corporation and others. >+ * Copyright (c) 2007, 2010 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 >@@ -28,11 +28,13 @@ > import org.eclipse.help.IIndexSee; > import org.eclipse.help.IIndexSubpath; > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.HelpPlugin; > import org.eclipse.help.internal.base.BaseHelpSystem; >+import org.eclipse.help.internal.base.scope.ScopeUtils; > import org.eclipse.help.internal.webapp.WebappResources; > import org.eclipse.help.internal.webapp.data.ActivitiesData; >-import org.eclipse.help.internal.webapp.data.EnabledTopicUtils; >+import org.eclipse.help.internal.webapp.data.RequestScope; > import org.eclipse.help.internal.webapp.data.UrlUtil; > import org.eclipse.osgi.util.NLS; > >@@ -107,7 +109,8 @@ > resp.setHeader("Pragma","no-cache"); //$NON-NLS-1$ //$NON-NLS-2$ > resp.setDateHeader ("Expires", 0); //$NON-NLS-1$ > } >- Serializer serializer = new Serializer(locale); >+ AbstractHelpScope scope = RequestScope.getScopeFromRequest(req, resp); >+ Serializer serializer = new Serializer(locale, scope); > String response = serializer.generateIndexXml(); > locale2Response.put(locale, response); > resp.getWriter().write(response); >@@ -126,9 +129,11 @@ > private IIndexEntry[] entries; > private boolean enablePrevious = true; > private boolean enableNext = true; >+ private AbstractHelpScope scope; > >- public Serializer(String locale) { >+ public Serializer(String locale, AbstractHelpScope scope) { > this.locale = locale; >+ this.scope = scope; > index = HelpPlugin.getIndexManager().getIndex(locale); > buf = new StringBuffer(); > } >@@ -265,22 +270,45 @@ > } > > private int enabledEntryCount(IIndexEntry entry) { >- if (!EnabledTopicUtils.isEnabled(entry)) return 0; >+ if (!ScopeUtils.hasInScopeDescendent(entry, scope)) return 0; > if (entry.getKeyword() == null || entry.getKeyword().length() == 0) { > return 0; > } > int count = 1; >- ITopic[] topics = EnabledTopicUtils.getEnabled(entry.getTopics()); >- IIndexEntry[] subentries = EnabledTopicUtils.getEnabled(entry.getSubentries()); >+ int topicCount = enabledTopicCount(entry); >+ >+ IIndexEntry[] subentries = entry.getSubentries(); >+ int subentryCount = 0; >+ for (int i=0; i<subentries.length; ++i) { >+ count += enabledEntryCount(subentries[i]); >+ } >+ >+ int seeCount = 0; > IIndexSee[] sees = entry instanceof IIndexEntry2 ? ((IIndexEntry2)entry).getSees() : new IIndexSee[0]; >- if (topics.length + subentries.length + sees.length > 1) { >- count += topics.length; >+ for (int s = 0; s < sees.length; s++) { >+ if (scope.inScope(sees[s])) { >+ seeCount++; >+ } > } >- for (int i=0;i<subentries.length;++i) { >- count += enabledEntryCount(subentries[i]); >+ >+ if (topicCount + subentryCount + seeCount > 1) { >+ count += topicCount; > } >+ count += subentryCount; >+ count += seeCount; > return count; > } >+ >+ private int enabledTopicCount(IIndexEntry entry) { >+ int topicCount = 0; >+ ITopic[] topics = entry.getTopics(); >+ for (int i = 0; i < topics.length; i++) { >+ if (scope.inScope(topics[i])) { >+ topicCount++; >+ } >+ } >+ return topicCount; >+ } > > private void generateEmptyIndexMessage() { > buf.append("<node"); //$NON-NLS-1$ >@@ -293,10 +321,10 @@ > } > > private void generateEntry(IIndexEntry entry, int level, String id) { >- if (!EnabledTopicUtils.isEnabled(entry)) return; >+ if (!ScopeUtils.hasInScopeDescendent(entry, scope)) return; > if (entry.getKeyword() != null && entry.getKeyword().length() > 0) { >- ITopic[] topics = EnabledTopicUtils.getEnabled(entry.getTopics()); >- IIndexEntry[] subentries = EnabledTopicUtils.getEnabled(entry.getSubentries()); >+ ITopic[] topics = ScopeUtils.inScopeTopics(entry.getTopics(), scope); >+ IIndexEntry[] subentries = ScopeUtils.inScopeEntries(entry.getSubentries(), scope); > IIndexSee[] sees; > if (entry instanceof IIndexEntry2) { > sees = ((IIndexEntry2)entry).getSees(); >@@ -370,7 +398,7 @@ > private void generateSees(IIndexSee[] sees) { > for (int i = 0; i < sees.length; i++) { > IIndexSee see = sees[i]; >- if (EnabledTopicUtils.isEnabled(see)) { >+ if (scope.inScope(see)) { > // > String key = see.isSeeAlso() ? "SeeAlso" : "See"; //$NON-NLS-1$ //$NON-NLS-2$ > String seePrefix = WebappResources.getString(key, UrlUtil >Index: src/org/eclipse/help/internal/webapp/servlet/NavServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/NavServlet.java,v >retrieving revision 1.10 >diff -u -r1.10 NavServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/NavServlet.java 24 Feb 2009 18:24:09 -0000 1.10 >+++ src/org/eclipse/help/internal/webapp/servlet/NavServlet.java 25 Jan 2010 20:51:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2009 IBM Corporation and others. >+ * Copyright (c) 2007, 2010 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 >@@ -23,9 +23,10 @@ > import javax.servlet.http.HttpServletResponse; > > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.HelpPlugin; > import org.eclipse.help.internal.webapp.WebappResources; >-import org.eclipse.help.internal.webapp.data.EnabledTopicUtils; >+import org.eclipse.help.internal.webapp.data.RequestScope; > import org.eclipse.help.internal.webapp.data.UrlUtil; > import org.eclipse.help.webapp.IFilter; > >@@ -61,7 +62,8 @@ > } > > PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "UTF-8")); //$NON-NLS-1$ >- writeContent(topic, path, locale, writer, UrlUtil.isRTL(req, resp)); >+ AbstractHelpScope scope = RequestScope.getScopeFromRequest(req, resp); >+ writeContent(topic, path, locale, writer, UrlUtil.isRTL(req, resp), scope); > writer.close(); > } > >@@ -93,7 +95,7 @@ > return topic; > } > >- private void writeContent(ITopic topic, String path, Locale locale, PrintWriter writer, boolean isRTL) { >+ private void writeContent(ITopic topic, String path, Locale locale, PrintWriter writer, boolean isRTL, AbstractHelpScope scope) { > writer.write(XHTML_1); > writer.write(topic.getLabel()); > if (isRTL) { >@@ -106,7 +108,7 @@ > writer.write("<ul class=\"NavList\">\n"); //$NON-NLS-1$ > ITopic[] subtopics = topic.getSubtopics(); > for (int i=0;i<subtopics.length;++i) { >- if (EnabledTopicUtils.isEnabled(subtopics[i])) { >+ if (scope.inScope(subtopics[i])) { > writer.write("<li><a href=\""); //$NON-NLS-1$ > String href = subtopics[i].getHref(); > if (href == null) { >Index: src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java,v >retrieving revision 1.13 >diff -u -r1.13 TocFragmentServlet.java >--- src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java 20 Oct 2009 20:43:02 -0000 1.13 >+++ src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java 25 Jan 2010 20:51:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2009 IBM Corporation and others. >+ * Copyright (c) 2006, 2010 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,11 +22,13 @@ > > import org.eclipse.help.IToc; > import org.eclipse.help.ITopic; >+import org.eclipse.help.base.AbstractHelpScope; > import org.eclipse.help.internal.Topic; >+import org.eclipse.help.internal.base.scope.ScopeUtils; > import org.eclipse.help.internal.toc.Toc; > import org.eclipse.help.internal.webapp.WebappResources; >-import org.eclipse.help.internal.webapp.data.EnabledTopicUtils; > import org.eclipse.help.internal.webapp.data.IconFinder; >+import org.eclipse.help.internal.webapp.data.RequestScope; > import org.eclipse.help.internal.webapp.data.TocData; > import org.eclipse.help.internal.webapp.data.UrlUtil; > >@@ -54,7 +56,8 @@ > > readParameters(req); > >- Serializer serializer = new Serializer(data, req.getLocale()); >+ AbstractHelpScope scope = RequestScope.getScopeFromRequest(req, resp); >+ Serializer serializer = new Serializer(data, req.getLocale(), scope); > String response = serializer.generateTreeXml(); > locale2Response.put(locale, response); > resp.getWriter().write(response); >@@ -74,15 +77,17 @@ > private StringBuffer buf; > private int requestKind; > private Locale locale; >+ private AbstractHelpScope scope; > private static final int REQUEST_SHOW_IN_TOC = 1; // Get the path to an element an element based on its href > private static final int REQUEST_SHOW_TOCS = 2; // Show all the tocs but not their children > private static final int REQUEST_SHOW_CHILDREN = 3; // Show the children of a node > private static final int REQUEST_EXPAND_PATH = 4; // Get all the nodes requires to expand a path in the tree > >- public Serializer(TocData data, Locale locale) { >+ public Serializer(TocData data, Locale locale, AbstractHelpScope scope) { > tocData = data; > buf = new StringBuffer(); > this.locale = locale; >+ this.scope = scope; > if (tocData.isExpandPath()) { > requestKind = REQUEST_EXPAND_PATH; > } else if (tocData.getTopicHref() != null) { >@@ -119,7 +124,7 @@ > // Count the number of enabled tocs > int enabled = 0; > for (int i = 0; i <= selectedToc; i++) { >- if (EnabledTopicUtils.isEnabled(tocData.getTocs()[i])) { >+ if (ScopeUtils.showInTree(tocData.getTocs()[i], scope)) { > enabled++; > } > } >@@ -165,8 +170,8 @@ > > private void serializeToc(IToc toc, int tocIndex, ITopic[] topicPath, boolean isSelected) { > >- if (!EnabledTopicUtils.isEnabled(toc)) { >- // do not generate toc when there are no leaf topics >+ if (!ScopeUtils.showInTree(toc, scope)) { >+ // do not generate toc when there are no leaf topics or if it is filtered out > return; > } > ITopic[] topics = toc.getTopics(); >@@ -205,7 +210,7 @@ > > private void serializeTopic(ITopic topic, ITopic[] topicPath, boolean isSelected, String parentPath) { > ITopic[] subtopics = topic.getSubtopics(); >- boolean isLeaf = !EnabledTopicUtils.hasEnabledSubtopic(topic); >+ boolean isLeaf = !ScopeUtils.hasInScopeDescendent(topic, scope); > buf.append("<node"); //$NON-NLS-1$ > if (topic.getLabel() != null) { > buf.append('\n' + " title=\"" + XMLGenerator.xmlEscape(topic.getLabel()) + '"'); //$NON-NLS-1$ >@@ -293,14 +298,14 @@ > // Show the children of this node > for (int subtopic = 0; subtopic < childTopics.length; subtopic++) { > ITopic childTopic = childTopics[subtopic]; >- if (EnabledTopicUtils.isEnabled(childTopic)) { >+ if (ScopeUtils.showInTree(childTopic, scope)) { > serializeTopic(childTopic, null, false, addSuffix(parentPath, subtopic)); > } > } > } else if (topicPath != null) { > for (int subtopic = 0; subtopic < childTopics.length; subtopic++) { > ITopic childTopic = childTopics[subtopic]; >- if (EnabledTopicUtils.isEnabled(childTopic)) { >+ if (ScopeUtils.showInTree(childTopic, scope)) { > if (topicPath[0].getLabel().equals(childTopic.getLabel())) { > ITopic[] newPath = null; > if (topicPath.length > 1) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 223475
:
157166
|
157174
|
157465
|
159389