Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-08-17 14:34:56 -0400
committersminto2005-08-17 14:34:56 -0400
commit843c619067afd16ebeca40d9f66162c5b3f714e3 (patch)
tree6e346ce75307103f06b76b7e3d8c3af26e853150
parent5475a9bdc3c89ba94ec57c1e2fa6abd9f72c1bc8 (diff)
downloadorg.eclipse.mylyn.tasks-843c619067afd16ebeca40d9f66162c5b3f714e3.tar.gz
org.eclipse.mylyn.tasks-843c619067afd16ebeca40d9f66162c5b3f714e3.tar.xz
org.eclipse.mylyn.tasks-843c619067afd16ebeca40d9f66162c5b3f714e3.zip
fixed Bug #107085: Put a limit on a fetched query result size
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferences.java16
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java28
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java7
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java8
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java3
8 files changed, 63 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java
index a7b2aa589..affa090ed 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPlugin.java
@@ -339,4 +339,8 @@ public class BugzillaPlugin extends AbstractUIPlugin {
public boolean refreshOnStartUpEnabled() {
return getPreferenceStore().getBoolean(IBugzillaConstants.REFRESH_QUERY);
}
+
+ public int getMaxResults() {
+ return getPreferenceStore().getInt(IBugzillaConstants.MAX_RESULTS);
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferences.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferences.java
index 05771fd26..9f07294f6 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferences.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/BugzillaPreferences.java
@@ -31,6 +31,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.mylar.bugzilla.core.internal.ProductConfiguration;
import org.eclipse.mylar.bugzilla.core.internal.ProductConfigurationFactory;
@@ -71,12 +72,16 @@ public class BugzillaPreferences
private static final String bugzilla218Label = "Using Bugzilla 2.18 (default is 2.16)";
+ private static final String bugzillaMaxResultsLabel = "Maximum returned results: ";
+
private BooleanFieldEditor bugzilla218;
private StringFieldEditor bugzillaUser;
private MyStringFieldEditor bugzillaPassword;
+ private IntegerFieldEditor maxResults;
+
private BooleanFieldEditor refreshQueries;
/**
@@ -117,6 +122,8 @@ public class BugzillaPreferences
StringFieldEditor.UNLIMITED, getFieldEditorParent());
bugzillaPassword.getTextControl().setEchoChar('*');
+ maxResults = new IntegerFieldEditor(IBugzillaConstants.MAX_RESULTS, bugzillaMaxResultsLabel, getFieldEditorParent());
+
bugzilla218 = new BooleanFieldEditor(IBugzillaConstants.IS_218, bugzilla218Label, BooleanFieldEditor.DEFAULT, getFieldEditorParent());
refreshQueries = new BooleanFieldEditor(IBugzillaConstants.REFRESH_QUERY, "Automatically refresh Bugzilla reports and queries on startup",
@@ -126,13 +133,15 @@ public class BugzillaPreferences
addField(bugzillaServer);
addField(bugzillaUser);
addField(bugzillaPassword);
+ addField(maxResults);
addField(bugzilla218);
addField(refreshQueries);
+
// put the password and user name values into the field editors
getCachedData();
bugzillaUser.setStringValue(user);
- bugzillaPassword.setStringValue(password);
+ bugzillaPassword.setStringValue(password);
}
/**
@@ -149,6 +158,7 @@ public class BugzillaPreferences
store.setDefault(IBugzillaConstants.MOST_RECENT_QUERY, "");
store.setDefault(IBugzillaConstants.IS_218, true);
store.setDefault(IBugzillaConstants.REFRESH_QUERY, false);
+ store.setDefault(IBugzillaConstants.MAX_RESULTS, 100);
// set the default query options for the bugzilla search
setDefaultQueryOptions();
@@ -170,6 +180,8 @@ public class BugzillaPreferences
@Override
public boolean performOk() {
BugzillaPlugin.getDefault().getPreferenceStore().setValue(IBugzillaConstants.IS_218, bugzilla218.getBooleanValue());
+ BugzillaPlugin.getDefault().getPreferenceStore().setValue(IBugzillaConstants.REFRESH_QUERY, refreshQueries.getBooleanValue());
+ BugzillaPlugin.getDefault().getPreferenceStore().setValue(IBugzillaConstants.MAX_RESULTS, maxResults.getIntValue());
String oldBugzillaServer = BugzillaPlugin.getDefault().getServerName();
ProductConfiguration configuration = null;
@@ -236,8 +248,6 @@ public class BugzillaPreferences
else {
configFile.toFile().delete();
}
-
- BugzillaPlugin.getDefault().getPreferenceStore().setValue(IBugzillaConstants.REFRESH_QUERY, refreshQueries.getBooleanValue());
return true;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java
index b55886bd0..c2886525d 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/IBugzillaConstants.java
@@ -54,7 +54,7 @@ public interface IBugzillaConstants
static final String MOST_RECENT_QUERY = "MOST_RECENT_QUERY";
static final String IS_218 = "BUGZILLA_IS_218";
static final String REFRESH_QUERY = "REFRESH_QUERY";
-
+ static final String MAX_RESULTS = "MAX_BUGZILLA_RESULTS";
// names for the resources used to hold the different attributes of a bug
static final String STATUS_VALUES = "STATUS_VALUES";
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java
index 7fe1b1750..e90c2b444 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java
@@ -53,6 +53,8 @@ public class BugzillaSearchEngine {
protected static final RegularExpression reOld = new RegularExpression("<a href=\"show_bug.cgi\\?id=(\\d+)\">\\d+</a>\\s*<td class=severity><nobr>([^>]+)</nobr><td class=priority><nobr>([^>]+)</nobr><td class=platform><nobr>([^>]*)</nobr><td class=owner><nobr>([^>]*)</nobr><td class=status><nobr>([^>]*)</nobr><td class=resolution><nobr>([^>]*)</nobr><td class=summary>(.*)$", "i");
private String urlString;
+
+ private boolean maxReached = false;
public BugzillaSearchEngine(String url) {
this.urlString = url;
@@ -77,7 +79,17 @@ public class BugzillaSearchEngine {
*/
public IStatus search(IBugzillaSearchResultCollector collector) throws LoginException
{
- return this.search(collector, 0);
+ return this.search(collector, 0, -1);
+ }
+
+ /**
+ * Wrapper for search
+ * @param collector - The collector for the results to go into
+ * @param startMatches - The number of matches to start with for the progress monitor
+ */
+ public IStatus search(IBugzillaSearchResultCollector collector, int startMatches) throws LoginException
+ {
+ return this.search(collector, startMatches, BugzillaPlugin.getDefault().getMaxResults());
}
/**
@@ -116,8 +128,9 @@ public class BugzillaSearchEngine {
* </pre>
* @param collector - The collector for the search results
* @param startMatches - The number of matches to start with for the progress monitor
+ * @param maxMatches - the maximum number of matches to return or -1 for unlimited
*/
- public IStatus search(IBugzillaSearchResultCollector collector, int startMatches) throws LoginException {
+ private IStatus search(IBugzillaSearchResultCollector collector, int startMatches, int maxMatches) throws LoginException {
IProgressMonitor monitor = collector.getProgressMonitor();
IStatus status = null;
@@ -165,6 +178,13 @@ public class BugzillaSearchEngine {
Match match = new Match();
String line;
while ((line = in.readLine()) != null) {
+
+
+ if(numCollected != -1 && numCollected >= maxMatches){
+ maxReached = true;
+ break;
+ }
+
if (monitor.isCanceled()) {
throw new OperationCanceledException("Search cancelled");
}
@@ -307,4 +327,8 @@ public class BugzillaSearchEngine {
else
return status;
}
+
+ public boolean isMaxReached() {
+ return maxReached;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java
index a55009a6d..92dc40316 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java
@@ -768,6 +768,9 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
protected String getQueryURL(StringBuffer params) {
StringBuffer url = new StringBuffer(getQueryURLStart().toString());
url.append(params);
+
+ // HACK make sure that the searches come back sorted by priority. This should be a search opetion though
+ url.append("&order=Importance");
return url.toString();
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java
index ccc8ec9df..ad3e2d80d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaCategorySearchOperation.java
@@ -53,6 +53,8 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
private String url;
+ private boolean isMaxReached;
+
/**
* Constructor
*
@@ -102,6 +104,7 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
MylarPlugin.log(status);
return null;
}
+ isMaxReached = engine.isMaxReached();
return collector;
} catch (LoginException e) {
//save this exception to throw later
@@ -140,4 +143,8 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
public String getName() {
return null;
}
+
+ public boolean isMaxReached() {
+ return isMaxReached;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
index b46f8dc71..cd35e34d9 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryCategory.java
@@ -66,6 +66,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
}
private ICategorySearchListener listener = new BugzillaQueryCategorySearchListener();
+ private boolean isMaxReached = false;
public BugzillaQueryCategory(String label, String url) {
super(label);
@@ -74,7 +75,11 @@ public class BugzillaQueryCategory extends AbstractCategory {
public String getDescription(boolean label) {
if (hits.size() > 0 || !label) {
- return super.getDescription(label);
+ if(isMaxReached && label){
+ return super.getDescription(label) + " <first "+ BugzillaPlugin.getDefault().getMaxResults() +" hits>";
+ } else {
+ return super.getDescription(label);
+ }
} else if (!hasBeenRefreshed) {
return super.getDescription(label) + " <needs refresh>";
} else {
@@ -115,6 +120,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
try {
// execute the search operation
catSearch.execute(new NullProgressMonitor());
+ isMaxReached = catSearch.isMaxReached();
hasBeenRefreshed = true;
lastRefresh = new Date();
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java
index 6045e3d94..108d6f069 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugs/search/BugzillaMylarSearchOperation.java
@@ -52,7 +52,8 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
*/
public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation
implements IBugzillaSearchOperation {
- /** The IMember we are doing the search for */
+
+ /** The IMember we are doing the search for */
private IMember javaElement;
/** The bugzilla collector for the search */

Back to the top