Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-08-19 13:25:56 -0400
committersminto2005-08-19 13:25:56 -0400
commitc86b4b86e3124c91e13224b1b0cf8a7c53014ad6 (patch)
treebfc5624ca9147bcdd45c454afe8eda63bfd5655d
parent57e4f7e2dda36c7ff2872f54cb88ee34b12c97dd (diff)
downloadorg.eclipse.mylyn.tasks-c86b4b86e3124c91e13224b1b0cf8a7c53014ad6.tar.gz
org.eclipse.mylyn.tasks-c86b4b86e3124c91e13224b1b0cf8a7c53014ad6.tar.xz
org.eclipse.mylyn.tasks-c86b4b86e3124c91e13224b1b0cf8a7c53014ad6.zip
Bug #107085: Put a limit on a fetched query result size
added support for limiting per query
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchEngine.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java11
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaSearchPage.java65
-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.java24
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java15
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java3
9 files changed, 119 insertions, 17 deletions
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 e90c2b444..ef4ab7d33 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
@@ -130,7 +130,7 @@ public class BugzillaSearchEngine {
* @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
*/
- private IStatus search(IBugzillaSearchResultCollector collector, int startMatches, int maxMatches) throws LoginException {
+ public IStatus search(IBugzillaSearchResultCollector collector, int startMatches, int maxMatches) throws LoginException {
IProgressMonitor monitor = collector.getProgressMonitor();
IStatus status = null;
@@ -180,7 +180,7 @@ public class BugzillaSearchEngine {
while ((line = in.readLine()) != null) {
- if(numCollected != -1 && numCollected >= maxMatches){
+ if(maxMatches != -1 && numCollected >= maxMatches){
maxReached = true;
break;
}
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java
index aeb4a0ff6..36f900ef5 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/search/BugzillaSearchOperation.java
@@ -37,16 +37,23 @@ public class BugzillaSearchOperation extends WorkspaceModifyOperation implements
/** The LoginException that was thrown when trying to do the search */
private LoginException loginException = null;
+ private int maxHits;
+
/**
* Constructor
* @param url The url of the bugzilla server
* @param collector The bugzilla search collector to use for this search
*/
- public BugzillaSearchOperation(String url, IBugzillaSearchResultCollector collector)
+ public BugzillaSearchOperation(String url, IBugzillaSearchResultCollector collector, String maxHits)
{
this.url = url;
this.collector = collector;
collector.setOperation(this);
+ try{
+ this.maxHits = Integer.parseInt(maxHits);
+ } catch (Exception e){
+ this.maxHits = -1;
+ }
}
@Override
@@ -56,7 +63,7 @@ public class BugzillaSearchOperation extends WorkspaceModifyOperation implements
BugzillaSearchEngine engine = new BugzillaSearchEngine(url);
try
{
- status = engine.search(collector);
+ status = engine.search(collector, 0 , maxHits);
}
catch(LoginException e) {
//save this exception to throw later
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java
index fcfd60329..f6768645b 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java
@@ -51,7 +51,8 @@ public class CreateBugzillaQueryCategoryAction extends Action implements IViewAc
// MylarPlugin.getDefault().actionObserved(this);
BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell());
if(sqd.open() == Dialog.OK){
- final BugzillaQueryCategory queryCategory = new BugzillaQueryCategory(sqd.getName(), sqd.getUrl());
+ // TODO make this work properly
+ final BugzillaQueryCategory queryCategory = new BugzillaQueryCategory(sqd.getName(), sqd.getUrl(), sqd.getMaxHits());
MylarTasklistPlugin.getTaskListManager().addCategory(queryCategory);
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
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 92dc40316..9f96de811 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
@@ -130,6 +130,7 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
createLastDays(control);
createEmail(control);
createSaveQuery(control);
+ createMaxHits(control);
input = new SavedQueryFile(BugzillaPlugin.getDefault().getStateLocation().toString(), "/queries");
createUpdate(control);
@@ -398,6 +399,68 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
return group;
}
+ protected Text maxHitsText;
+
+ protected Control createMaxHits(Composite control)
+ {
+ GridLayout layout;
+ GridData gd;
+
+ Group group = new Group(control, SWT.NONE);
+ layout = new GridLayout(3, false);
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group.setLayoutData(gd);
+
+ Label label = new Label(group, SWT.LEFT);
+ label.setText("Show a maximum of ");
+
+ // operation combo
+ maxHitsText = new Text(group, SWT.BORDER);
+ maxHitsText.setTextLimit(5);
+ maxHitsText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ String maxHitss = maxHitsText.getText();
+ if (maxHitss.length() == 0)
+ return;
+ for (int i = maxHitss.length() - 1; i >= 0; i--) {
+ try {
+ if (maxHitss.equals("") || Integer.parseInt(maxHitss) > -1) {
+ if (i == maxHitss.length() - 1){
+ maxHits = maxHitss;
+ return;
+ } else {
+ break;
+ }
+ }
+ } catch (NumberFormatException ex) {
+ maxHitss = maxHitss.substring(0, i);
+ }
+ }
+ maxHitsText.setText(maxHitss);
+ BugzillaSearchPage.this.maxHits = maxHitss;
+ }
+ });
+ gd = new GridData();
+ gd.widthHint = 20;
+ maxHitsText.setLayoutData(gd);
+ label = new Label(group, SWT.LEFT);
+ label.setText(" Hits.");
+
+ maxHits = "100";
+ maxHitsText.setText(maxHits);
+
+ return group;
+ }
+
+ protected String maxHits;
+
+ public String getMaxHits(){
+ return maxHits;
+ }
+
private static final String [] emailText = {"bug owner", "reporter", "CC list", "commenter"};
protected Control createEmail(Composite control) {
GridLayout layout;
@@ -661,7 +724,7 @@ public class BugzillaSearchPage extends DialogPage implements ISearchPage {
IBugzillaSearchResultCollector collector= new BugzillaSearchResultCollector();
IBugzillaSearchOperation op= new BugzillaSearchOperation(
- url, collector);
+ url, collector, maxHits);
BugzillaSearchQuery searchQuery = new BugzillaSearchQuery(op);
NewSearchUI.runQueryInBackground(searchQuery);
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 ad3e2d80d..8177cf91b 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
@@ -52,7 +52,7 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
private LoginException loginException = null;
private String url;
-
+ private int maxHits;
private boolean isMaxReached;
/**
@@ -61,8 +61,9 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
* @param m
* The member that we are doing the search for
*/
- public BugzillaCategorySearchOperation(String url) {
+ public BugzillaCategorySearchOperation(String url, int maxHits) {
this.url = url;
+ this.maxHits = maxHits;
}
@Override
@@ -92,7 +93,7 @@ public class BugzillaCategorySearchOperation extends WorkspaceModifyOperation
try {
// perform the search
- status = engine.search(collector, matches);
+ status = engine.search(collector, matches, maxHits);
// check the status so that we don't keep searching if there
// is a problem
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 cd35e34d9..965b34443 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
@@ -46,6 +46,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
private static final long serialVersionUID = 5517146402031743253L;
private String url;
+ private int maxHits;
private List<BugzillaHit> hits = new ArrayList<BugzillaHit>();
private boolean hasBeenRefreshed = false;
@@ -68,15 +69,20 @@ public class BugzillaQueryCategory extends AbstractCategory {
private ICategorySearchListener listener = new BugzillaQueryCategorySearchListener();
private boolean isMaxReached = false;
- public BugzillaQueryCategory(String label, String url) {
+ public BugzillaQueryCategory(String label, String url, String maxHits) {
super(label);
this.url = url;
+ try{
+ this.maxHits = Integer.parseInt(maxHits);
+ } catch (Exception e){
+ this.maxHits = -1;
+ }
}
public String getDescription(boolean label) {
if (hits.size() > 0 || !label) {
if(isMaxReached && label){
- return super.getDescription(label) + " <first "+ BugzillaPlugin.getDefault().getMaxResults() +" hits>";
+ return super.getDescription(label) + " <first "+ maxHits +" hits>";
} else {
return super.getDescription(label);
}
@@ -113,7 +119,7 @@ public class BugzillaQueryCategory extends AbstractCategory {
public void refreshBugs() {
hits.clear();
final BugzillaCategorySearchOperation catSearch = new BugzillaCategorySearchOperation(
- getUrl());
+ getUrl(), maxHits);
catSearch.addResultsListener(listener);
final IStatus[] status = new IStatus[1];
@@ -231,4 +237,16 @@ public class BugzillaQueryCategory extends AbstractCategory {
tooltip += BugzillaTask.getLastRefreshTime(lastRefresh);
return tooltip;
}
+
+ public int getMaxHits() {
+ return maxHits;
+ }
+
+ public void setMaxHits(String maxHits) {
+ try{
+ this.maxHits = Integer.parseInt(maxHits);
+ } catch (Exception e){
+ this.maxHits = -1;
+ }
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java
index 58583b466..e2cbe782d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaQueryDialog.java
@@ -48,6 +48,7 @@ public class BugzillaQueryDialog extends Dialog {
private String name = "";
private BugzillaSearchOptionPage searchOptionPage;
private String startingUrl = null;
+ private String maxHits;
public BugzillaQueryDialog(Shell parentShell) {
super(parentShell);
@@ -55,10 +56,11 @@ public class BugzillaQueryDialog extends Dialog {
}
- public BugzillaQueryDialog(Shell parentShell, String startingUrl, String name) {
+ public BugzillaQueryDialog(Shell parentShell, String startingUrl, String name, String maxHits) {
super(parentShell);
searchOptionPage = new BugzillaSearchOptionPage();
this.startingUrl = startingUrl;
+ this.maxHits = maxHits;
this.name = name;
}
@@ -70,6 +72,10 @@ public class BugzillaQueryDialog extends Dialog {
return url;
}
+ public String getMaxHits(){
+ return maxHits;
+ }
+
@Override
protected Control createContents(Composite parent) {
searchOptionPage.createControl(parent);
@@ -78,7 +84,7 @@ public class BugzillaQueryDialog extends Dialog {
Control c = super.createContents(parent);
if(startingUrl != null){
try{
- searchOptionPage.updateDefaults(startingUrl);
+ searchOptionPage.updateDefaults(startingUrl, maxHits);
} catch (UnsupportedEncodingException e){
// ignore, should never get this
}
@@ -96,6 +102,7 @@ public class BugzillaQueryDialog extends Dialog {
*/
return;
}
+ maxHits = searchOptionPage.getMaxHits();
InputDialog getNameDialog = new InputDialog(Display.getCurrent().getActiveShell(), "Bugzilla Query Category Name", "Please enter a name for the bugzilla query category",name, new IInputValidator(){
public String isValid(String newText) {
@@ -159,7 +166,7 @@ public class BugzillaQueryDialog extends Dialog {
};
}
- public void updateDefaults(String startingUrl) throws UnsupportedEncodingException{
+ public void updateDefaults(String startingUrl, String maxHits) throws UnsupportedEncodingException{
// String serverName = startingUrl.substring(0, startingUrl.indexOf("?"));
startingUrl = startingUrl.substring(startingUrl.indexOf("?") + 1);
String[] options = startingUrl.split("&");
@@ -314,6 +321,8 @@ public class BugzillaQueryDialog extends Dialog {
daysText.setText(value);
}
}
+ this.maxHits = maxHits;
+ maxHitsText.setText(maxHits);
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
index 0d2ac6476..d0c2b5c17 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskExternalizer.java
@@ -41,6 +41,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
private static final String DIRTY = "Dirty";
private static final String URL = "URL";
private static final String DESCRIPTION = "Description";
+ private static final String MAX_HITS = "MaxHits";
private static final String BUGZILLA_TASK_REGISTRY = "BugzillaTaskRegistry" + TAG_CATEGORY;
private static final String TAG_BUGZILLA_CATEGORY = "BugzillaQuery" + TAG_CATEGORY;
@@ -72,7 +73,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
if (e.getNodeName().equals(BUGZILLA_TASK_REGISTRY)) {
readRegistry(node, taskList);
} else {
- BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL));
+ BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL), e.getAttribute(MAX_HITS));
taskList.addCategory(cat);
}
}
@@ -104,6 +105,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
Element node = doc.createElement(getCategoryTagName());
node.setAttribute(DESCRIPTION, queryCategory.getDescription(false));
node.setAttribute(URL, queryCategory.getUrl());
+ node.setAttribute(MAX_HITS, ""+queryCategory.getMaxHits());
parent.appendChild(node);
return node;
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
index ad6da1180..728a972c1 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTaskHandler.java
@@ -105,10 +105,11 @@ public class BugzillaTaskHandler implements ITaskHandler {
}
else if (element instanceof BugzillaQueryCategory){
BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)element;
- BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell(), queryCategory.getUrl(), queryCategory.getDescription(false));
+ BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell(), queryCategory.getUrl(), queryCategory.getDescription(false), queryCategory.getMaxHits()+"");
if(sqd.open() == Dialog.OK){
queryCategory.setDescription(sqd.getName());
queryCategory.setUrl(sqd.getUrl());
+ queryCategory.setMaxHits(sqd.getMaxHits());
new RefreshBugzillaAction(queryCategory).run();
}

Back to the top