Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2009-11-30 19:16:58 +0000
committerChris Goldthorpe2009-11-30 19:16:58 +0000
commitc39c32c8fe53ee81f0571c212ecb4882d6fb7e27 (patch)
tree40157e54320aa44e3b1da5e1035a24f94a38032f
parent83d8dca1e7e24d879fd4a56b966fab14b6bbdac3 (diff)
downloadeclipse.platform.ua-c39c32c8fe53ee81f0571c212ecb4882d6fb7e27.tar.gz
eclipse.platform.ua-c39c32c8fe53ee81f0571c212ecb4882d6fb7e27.tar.xz
eclipse.platform.ua-c39c32c8fe53ee81f0571c212ecb4882d6fb7e27.zip
Bug 293745 – [Help][Search]Provide enhancement for quick search function:
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java7
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedToc.java63
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedTopic.java60
-rw-r--r--org.eclipse.help.webapp/advanced/images/e_quick_search_multi.gifbin0 -> 561 bytes
-rw-r--r--org.eclipse.help.webapp/advanced/navActions.js15
-rw-r--r--org.eclipse.help.webapp/advanced/quickSearch.jsp7
-rw-r--r--org.eclipse.help.webapp/advanced/tocToolbar.jsp17
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.properties4
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java41
9 files changed, 198 insertions, 16 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java
index 91ad7d818..283200edf 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java
@@ -19,7 +19,10 @@ import org.eclipse.help.ITopic;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.util.URLCoder;
import org.eclipse.help.internal.workingset.AdaptableHelpResource;
+import org.eclipse.help.internal.workingset.AdaptableSelectedToc;
+import org.eclipse.help.internal.workingset.AdaptableSelectedTopic;
import org.eclipse.help.internal.workingset.AdaptableToc;
+import org.eclipse.help.internal.workingset.AdaptableTopic;
import org.eclipse.help.internal.workingset.WorkingSet;
/**
@@ -67,9 +70,9 @@ public class SearchResults implements ISearchHitCollector {
if (scope == null) {
// topic outside of scope
continue;
- } else if (scope instanceof AdaptableToc) {
+ } else if ((scope instanceof AdaptableToc) || (scope instanceof AdaptableSelectedToc)) {
toc = (IToc) scope.getAdapter(IToc.class);
- } else { // scope is AdaptableTopic
+ } else if((scope instanceof AdaptableTopic) || (scope instanceof AdaptableSelectedTopic)){ // scope is AdaptableTopic or AdaptableSelectedTopic
toc = (IToc) scope.getParent().getAdapter(IToc.class);
}
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedToc.java b/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedToc.java
new file mode 100644
index 000000000..e9ce8fbef
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedToc.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.workingset;
+
+import org.eclipse.help.IToc;
+import org.eclipse.help.ITopic;
+import org.w3c.dom.Element;
+
+/**
+ * Makes help resources adaptable and persistable
+ */
+public class AdaptableSelectedToc extends AdaptableHelpResource {
+
+ /**
+ * This constructor will be called when wrapping help resources.
+ */
+ public AdaptableSelectedToc(IToc element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IToc.class)
+ return element;
+ return super.getAdapter(adapter);
+ }
+
+ public AdaptableHelpResource[] getChildren() {
+ return new AdaptableHelpResource[0];
+ }
+
+
+ /**
+ * When href is exactly the href of the selected toc, then return the selected topic
+ * Otherwise, return null
+ *
+ * @param href
+ * The topic's href value.
+ */
+ public ITopic getTopic(String href) {
+ if(null == href){
+ return null;
+ }
+ if(href.equals(((IToc) element).getTopic(null).getHref())){
+ return ((IToc) element).getTopic(null);
+ }
+ return null;
+ }
+
+ public void saveState(Element element) {
+
+ }
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedTopic.java b/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedTopic.java
new file mode 100644
index 000000000..06112bc8c
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/AdaptableSelectedTopic.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.workingset;
+
+import org.eclipse.help.ITopic;
+import org.w3c.dom.Element;
+
+/**
+ * Makes help resources adaptable and persistable
+ */
+public class AdaptableSelectedTopic extends AdaptableHelpResource {
+
+ /**
+ * This constructor will be called when wrapping help resources.
+ */
+ public AdaptableSelectedTopic(ITopic element) {
+ super(element);
+ }
+
+ /**
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == ITopic.class)
+ return element;
+ return super.getAdapter(adapter);
+ }
+
+ public AdaptableHelpResource[] getChildren() {
+ return new AdaptableHelpResource[0];
+ }
+
+ /**
+ * When href is exactly the href of the selected topic, then return the selected topic
+ * Otherwise, return null
+ *
+ * @param href
+ * The topic's href value.
+ */
+ public ITopic getTopic(String href) {
+ if (href == null)
+ return null;
+ if (href.equals(getHref())) {
+ return (ITopic)element;
+ }
+ return null;
+ }
+
+ public void saveState(Element element) {
+
+ }
+}
diff --git a/org.eclipse.help.webapp/advanced/images/e_quick_search_multi.gif b/org.eclipse.help.webapp/advanced/images/e_quick_search_multi.gif
new file mode 100644
index 000000000..97184debc
--- /dev/null
+++ b/org.eclipse.help.webapp/advanced/images/e_quick_search_multi.gif
Binary files differ
diff --git a/org.eclipse.help.webapp/advanced/navActions.js b/org.eclipse.help.webapp/advanced/navActions.js
index 91e2f588e..a5f74b95e 100644
--- a/org.eclipse.help.webapp/advanced/navActions.js
+++ b/org.eclipse.help.webapp/advanced/navActions.js
@@ -141,13 +141,22 @@ function getSearchWord() {
return searchFrame.document.forms["searchForm"].searchWord.value;
}
-function quickSearch(button, errorMsg) { //search this topic and all subTopics
+function quickSearchTopic(errorMsg) {
+ quickSearch("QuickSearchTopic", errorMsg);
+}
+
+function quickSearchToc(errorMsg) {
+ quickSearch("QuickSearchToc", errorMsg);
+}
+
+function quickSearch(quickSearchType, errorMsg) { //search this topic and all subTopics
var topic = parent.tocViewFrame.getSelectedTopic();
if (topic) {
var node = parent.tocViewFrame.getActiveAnchor();
var treeItem = parent.tocViewFrame.getTreeItem(node);
if (!treeItem) { return; } // TODO need better error
var parameters = "?searchWord=" + getSearchWord();
+ parameters = parameters + "&quickSearchType=" + quickSearchType;
// Defect 593: resize search window 2/2
var w = 315;
@@ -172,14 +181,14 @@ function quickSearch(button, errorMsg) { //search this topic and all subTopics
}
}
-function searchFor(searchWord) {
+function searchFor(searchWord, quickSearchType) {
var node = parent.tocViewFrame.getActiveAnchor();
var treeItem = parent.tocViewFrame.getTreeItem(node);
var topAncestor = parent.tocViewFrame.getTopAncestor(treeItem);
if (!topAncestor) { return; }
var toc = topAncestor.nodeid;
var maxHits = 500;
- var query ="searchWord="+encodeURIComponent(searchWord)+"&maxHits="+maxHits + "&quickSearch=true&toc="+toc;
+ var query ="searchWord="+encodeURIComponent(searchWord)+"&maxHits="+maxHits + "&quickSearch=true&toc="+toc +"&quickSearchType=" + quickSearchType;
if (topAncestor !== treeItem) {
query += "&path=";
query += treeItem.nodeid;
diff --git a/org.eclipse.help.webapp/advanced/quickSearch.jsp b/org.eclipse.help.webapp/advanced/quickSearch.jsp
index 3cdcb425c..bcc106dd7 100644
--- a/org.eclipse.help.webapp/advanced/quickSearch.jsp
+++ b/org.eclipse.help.webapp/advanced/quickSearch.jsp
@@ -13,11 +13,12 @@
<%
SearchData data=new SearchData(application,request,response);
WebappPreferences prefs = data.getPrefs();
+ String quickSearchType = data.isSelectedTopicQuickSearchRequest()? "QuickSearchTopic":"QuickSearchToc";
%>
<html>
<head>
-<title><%=ServletResources.getString("QuickSearch", request)%></title>
+<title><%= ServletResources.getString(quickSearchType, request)%></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
@@ -92,6 +93,8 @@ if (data.isMozilla()) {
<script language="JavaScript" src="list.js"></script>
<script language="JavaScript">
+var quickSearchType = "<%=quickSearchType%>";
+
function onloadHandler() {
<%
if(!data.isMozilla() || "1.3".compareTo(data.getMozillaVersion()) <=0){
@@ -116,7 +119,7 @@ function sizeButtons() {
function doQuickSearch(){
var searchWord = document.getElementById("searchWord").value;
- window.opener.searchFor(searchWord);
+ window.opener.searchFor(searchWord, quickSearchType);
window.close();
}
diff --git a/org.eclipse.help.webapp/advanced/tocToolbar.jsp b/org.eclipse.help.webapp/advanced/tocToolbar.jsp
index 93803a87e..9591f3b47 100644
--- a/org.eclipse.help.webapp/advanced/tocToolbar.jsp
+++ b/org.eclipse.help.webapp/advanced/tocToolbar.jsp
@@ -15,8 +15,13 @@
String printTocLabel = UrlUtil.JavaScriptEncode(ServletResources.getString("PrintToc", request));
String printError = UrlUtil.JavaScriptEncode(ServletResources.getString("PrintError", request));
String menuData = printTopicLabel + "=printTopic(\\'" + printError + "\\')," + printTocLabel + "=printToc(\\'" + printError + "\\')";
- String quickSearchError = UrlUtil.JavaScriptEncode(ServletResources.getString("QuickSearchError", request));
- // See Bug 290064 for an explanation of why these constants are used
+
+ String quickSearchTopicLabel = UrlUtil.JavaScriptEncode(ServletResources.getString("QuickSearchTopic", request));
+ String quickSearchTocLabel = UrlUtil.JavaScriptEncode(ServletResources.getString("QuickSearchToc", request));
+ String quickSearchError = UrlUtil.JavaScriptEncode(ServletResources.getString("QuickSearchError", request));
+ String quickSearchMenuData = quickSearchTopicLabel + "=quickSearchTopic(\\'" + quickSearchError + "\\')," + quickSearchTocLabel+ "=quickSearchToc(\\'" + quickSearchError + "\\')";
+
+ // See Bug 290064 for an explanation of why these constants are used
final String ON = "on";
final String OFF = "off";
%>
@@ -47,10 +52,10 @@
<jsp:param name="state" value='off'/>
<jsp:param name="name" value="quick_search"/>
- <jsp:param name="tooltip" value='QuickSearch'/>
- <jsp:param name="image" value="quick_search.gif"/>
- <jsp:param name="action" value="quickSearch"/>
- <jsp:param name="param" value="<%=quickSearchError%>"/>
+ <jsp:param name="tooltip" value='QuickSearchMulti'/>
+ <jsp:param name="image" value="quick_search_multi.gif"/>
+ <jsp:param name="action" value="menu"/>
+ <jsp:param name="param" value="<%=quickSearchMenuData%>"/>
<jsp:param name="state" value='off'/>
<jsp:param name="name" value="collapseall"/>
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 3852b7c4c..d32a62fa3 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
@@ -27,7 +27,9 @@ PrintMulti=Print topics
PrintTopic=Print selected topic
PrintToc=Print selected topic and all subtopics
PrintError=You must select a valid topic to print
-QuickSearch=Search selected topic and all subtopics
+QuickSearchMulti=Search topics
+QuickSearchTopic=Search selected topic
+QuickSearchToc=Search selected topic and all subtopics
TocHeading=Contents
Close=Close
Nothing_found=Nothing found.
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java
index 46d4c6974..ffa7b4a32 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java
@@ -37,6 +37,8 @@ import org.eclipse.help.internal.search.SearchQuery;
import org.eclipse.help.internal.search.SearchResults;
import org.eclipse.help.internal.webapp.HelpWebappPlugin;
import org.eclipse.help.internal.webapp.servlet.WebappWorkingSetManager;
+import org.eclipse.help.internal.workingset.AdaptableSelectedToc;
+import org.eclipse.help.internal.workingset.AdaptableSelectedTopic;
import org.eclipse.help.internal.workingset.AdaptableToc;
import org.eclipse.help.internal.workingset.AdaptableTopic;
import org.eclipse.help.internal.workingset.WorkingSet;
@@ -123,6 +125,11 @@ public class SearchData extends ActivitiesData {
public boolean isScopeRequest() {
return (request.getParameter("workingSet") != null); //$NON-NLS-1$
}
+
+ public boolean isSelectedTopicQuickSearchRequest() {
+ String quickSearchType = request.getParameter("quickSearchType"); //$NON-NLS-1$
+ return (null != quickSearchType && "QuickSearchTopic".equalsIgnoreCase(quickSearchType)); //$NON-NLS-1$
+ }
public String getCategoryLabel(int i) {
IHelpResource cat = hits[i].getCategory();
@@ -385,8 +392,12 @@ public class SearchData extends ActivitiesData {
// scopes are books (advanced search)
workingSets = createTempWorkingSets();
} else if (request.getParameterValues("quickSearch") != null) { //$NON-NLS-1$
- // scopes is a toc or topic and its children
- workingSets = createQuickSearchWorkingSet();
+ // scopes is just the selected toc or topic
+ if(isSelectedTopicQuickSearchRequest()){
+ workingSets = createQuickSearchWorkingSetOnSelectedTopic();
+ } else{ // scopes is a toc or topic and its children
+ workingSets = createQuickSearchWorkingSet();
+ }
} else {
// scopes are working set names
workingSets = getWorkingSets();
@@ -483,6 +494,32 @@ public class SearchData extends ActivitiesData {
workingSets[0] = new WorkingSet("quickSearch", resources); //$NON-NLS-1$
return workingSets;
}
+
+ /**
+ * @return WorkingSet[] consisting of a single selected toc or topic or null
+ */
+ private WorkingSet[] createQuickSearchWorkingSetOnSelectedTopic() {
+ WorkingSet[] workingSets = new WorkingSet[1];
+ TocData tocData = new TocData(context, request, response);
+ int selectedToc = tocData.getSelectedToc();
+ if (selectedToc < 0) {
+ return new WorkingSet[0];
+ }
+ IToc toc = tocData.getTocs()[selectedToc];
+ ITopic[] topics = tocData.getTopicPathFromRootPath(toc);
+ List resources = new ArrayList();
+ AdaptableSelectedToc adaptableSelectedToc = new AdaptableSelectedToc(toc);
+ if (topics != null) {
+ ITopic selectedTopic = topics[topics.length - 1];
+ AdaptableSelectedTopic adaptableSelectedTopic = new AdaptableSelectedTopic(selectedTopic);
+ resources.add(adaptableSelectedTopic);
+ adaptableSelectedTopic.setParent(adaptableSelectedToc);
+ } else {
+ resources.add(adaptableSelectedToc);
+ }
+ workingSets[0] = new WorkingSet("quickSearch", resources); //$NON-NLS-1$
+ return workingSets;
+ }
public String getQueryExceptionMessage() {
if (queryException == null) {

Back to the top