Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4d39036a4be0fd61084113f95b6e31e1e7108e75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*******************************************************************************
 * Copyright (c) 2003 - 2005 University Of British Columbia 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:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
package org.eclipse.mylar.bugzilla.search;

import javax.security.auth.login.LoginException;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

/**
 * An operation to perform Bugzilla search query.
 */
public class BugzillaSearchOperation extends WorkspaceModifyOperation implements IBugzillaSearchOperation 
{
	/** The url of the bugzilla server */
	private String url;
	
	/** The bugzilla collector for the search */
	private IBugzillaSearchResultCollector collector;
	
	/** The bugzilla search query */
	private BugzillaSearchQuery query;
	
	/** The status of the search operation */
	private IStatus status;
	
	/** The LoginException that was thrown when trying to do the search */
	private LoginException loginException = null;
	
	/**
	 * 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) 
	{
		this.url = url;
		this.collector = collector;
		collector.setOperation(this);
	}

	@Override
	public void execute(IProgressMonitor monitor) {
		// set the progress monitor for the search collector and start the search
		collector.setProgressMonitor(monitor);
		BugzillaSearchEngine engine = new BugzillaSearchEngine(url);
		try
		{
			status = engine.search(collector);
		}
		catch(LoginException e) {
			//save this exception to throw later
			this.loginException = e;
		}
	}
	
	/**
	 * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getImageDescriptor()
	 */
    public ImageDescriptor getImageDescriptor() {
		return null;
	}
	
	/**
	 * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getStatus()
	 */
    public IStatus getStatus() throws LoginException {
		// if a LoginException was thrown while trying to search, throw this
		if (loginException == null)
			return status;
		else
			throw loginException;
	}
	
	/**
	 * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#getQuery()
	 */
	public BugzillaSearchQuery getQuery() {
		return query;
	}

	/**
	 * @see org.eclipse.mylar.bugzilla.search.IBugzillaSearchOperation#setQuery(org.eclipse.mylar.bugzilla.search.BugzillaSearchQuery)
	 */
	public void setQuery(BugzillaSearchQuery newQuery) {
		this.query = newQuery;
	}

}

Back to the top