Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis D'Entremont2006-03-27 11:16:36 -0500
committerCurtis D'Entremont2006-03-27 11:16:36 -0500
commit55de88a67d6363f71c5921eab1bf96d3cb47c620 (patch)
tree4739adbe39cebe4b3e1331c4c3a838130189336d /org.eclipse.help
parentd24427a4e0ccfc5477838a129407129b763f45fc (diff)
downloadeclipse.platform.ua-55de88a67d6363f71c5921eab1bf96d3cb47c620.tar.gz
eclipse.platform.ua-55de88a67d6363f71c5921eab1bf96d3cb47c620.tar.xz
eclipse.platform.ua-55de88a67d6363f71c5921eab1bf96d3cb47c620.zip
10087 [Help] Missing Help Index Solution
Diffstat (limited to 'org.eclipse.help')
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/Index.java25
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java5
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java12
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java21
4 files changed, 43 insertions, 20 deletions
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java b/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java
index 4ad7e23c3..8b4c19199 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java
@@ -27,21 +27,18 @@ import org.eclipse.help.IIndexEntry;
*/
public class Index implements IIndex {
- protected Map entries;
+ protected TreeMap entries;
- public static final class IgnoreCaseComparator implements Comparator {
-
- public int compare(Object left, Object right) {
- return ((String)left).compareToIgnoreCase((String) right);
- }
- }
-
public Index() {
- entries = new TreeMap(new IgnoreCaseComparator());
+ entries = new TreeMap();
}
- public Index(List entries) {
- this();
+ public Index(Comparator comparator) {
+ entries = new TreeMap(comparator);
+ }
+
+ public Index(Comparator comparator, List entries) {
+ this(comparator);
for (Iterator i = entries.iterator(); i.hasNext();) {
IndexEntry entry = (IndexEntry)i.next();
this.entries.put(entry.getKeyword(), entry);
@@ -54,7 +51,7 @@ public class Index implements IIndex {
protected IndexEntry addEntry(String keyword) {
IndexEntry oldEntry = (IndexEntry) entries.get(keyword);
if (oldEntry == null) {
- oldEntry = new IndexEntry(keyword);
+ oldEntry = new IndexEntry(entries.comparator(), keyword);
entries.put(keyword, oldEntry);
}
return oldEntry;
@@ -73,4 +70,8 @@ public class Index implements IIndex {
entryCollection.toArray(entryArray);
return entryArray;
}
+
+ public Comparator getComparator() {
+ return entries.comparator();
+ }
}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java
index 17a6d214d..e6bc9b36f 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexBuilder.java
@@ -12,6 +12,7 @@ package org.eclipse.help.internal.index;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Comparator;
import java.util.Stack;
import org.eclipse.core.runtime.Platform;
@@ -39,9 +40,9 @@ public class IndexBuilder {
/**
* Constructs the index builder
*/
- public IndexBuilder() {
+ public IndexBuilder(Comparator comparator) {
unprocessedIndexFiles = new ArrayList();
- index = new Index();
+ index = new Index(comparator);
entries = new Stack();
tocs = HelpPlugin.getTocManager().getTocs(Platform.getNL());
}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java
index 19d0e40d6..15b2ac58b 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java
@@ -11,6 +11,7 @@
package org.eclipse.help.internal.index;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.help.IHelpResource;
@@ -25,17 +26,18 @@ public class IndexEntry extends Index implements IIndexEntry {
String keyword;
List topics;
- public IndexEntry(String keyword) {
- this(keyword, new ArrayList());
+ public IndexEntry(Comparator comparator, String keyword) {
+ this(comparator, keyword, new ArrayList());
}
- public IndexEntry(String keyword, List topics) {
+ public IndexEntry(Comparator comparator, String keyword, List topics) {
+ super(comparator);
this.keyword = keyword;
this.topics = topics;
}
- public IndexEntry(String keyword, List topics, List subentries) {
- super(subentries);
+ public IndexEntry(Comparator comparator, String keyword, List topics, List subentries) {
+ super(comparator, subentries);
this.keyword = keyword;
this.topics = topics;
}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java
index 7e34fc1c0..652b032ff 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java
@@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.help.internal.index;
+import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
@@ -51,7 +53,7 @@ public class IndexManager {
*/
private void build(String locale) {
Collection contributedIndexFiles = getContributedIndexFiles(locale);
- IndexBuilder builder = new IndexBuilder();
+ IndexBuilder builder = new IndexBuilder(Collator.getInstance(getLocale(locale)));
builder.build(contributedIndexFiles);
IIndex index = builder.getBuiltIndex();
indexesByLang.put(locale, index);
@@ -139,4 +141,21 @@ public class IndexManager {
return false;
return !getContributedIndexFiles(locale).isEmpty();
}
+
+ /**
+ * Returns the locale object from the provided string.
+ * @param localeStr the encoded locale string
+ * @return the Locale object
+ */
+ private static Locale getLocale(String localeStr) {
+ if (localeStr.length() >= 5) {
+ return new Locale(localeStr.substring(0, 2), localeStr.substring(3,
+ 5));
+ } else if (localeStr.length() >= 2) {
+ return new Locale(localeStr.substring(0, 2), ""); //$NON-NLS-1$
+ } else {
+ return Locale.getDefault();
+ }
+ }
+
}

Back to the top