Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 145123 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java (-6 / +108 lines)
Lines 11-23 Link Here
11
11
12
package org.eclipse.mylar.internal.sandbox.web;
12
package org.eclipse.mylar.internal.sandbox.web;
13
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.InputStream;
17
import java.io.InputStreamReader;
18
import java.net.URL;
19
import java.util.ArrayList;
14
import java.util.Collections;
20
import java.util.Collections;
15
import java.util.List;
21
import java.util.List;
16
import java.util.Set;
22
import java.util.Set;
23
import java.util.regex.Matcher;
24
import java.util.regex.Pattern;
17
25
18
import org.eclipse.core.runtime.IProgressMonitor;
26
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.MultiStatus;
28
import org.eclipse.core.runtime.MultiStatus;
29
import org.eclipse.core.runtime.Status;
30
import org.eclipse.jface.window.Window;
20
import org.eclipse.jface.wizard.IWizard;
31
import org.eclipse.jface.wizard.IWizard;
32
import org.eclipse.jface.wizard.WizardDialog;
33
import org.eclipse.mylar.internal.core.util.MylarStatusHandler;
21
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractAddExistingTaskWizard;
34
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractAddExistingTaskWizard;
22
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage;
35
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage;
23
import org.eclipse.mylar.internal.tasklist.ui.wizards.ExistingTaskWizardPage;
36
import org.eclipse.mylar.internal.tasklist.ui.wizards.ExistingTaskWizardPage;
Lines 30-35 Link Here
30
import org.eclipse.mylar.provisional.tasklist.ITask;
43
import org.eclipse.mylar.provisional.tasklist.ITask;
31
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
44
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
32
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
45
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
46
import org.eclipse.swt.widgets.Shell;
47
import org.eclipse.ui.PlatformUI;
33
48
34
/**
49
/**
35
 * Generic connector for web based issue tracking systems
50
 * Generic connector for web based issue tracking systems
Lines 98-109 Link Here
98
			}
113
			}
99
		}
114
		}
100
		
115
		
116
		for (AbstractRepositoryQuery query : MylarTaskListPlugin.getTaskListManager().getTaskList().getQueries()) {
117
			if(query instanceof WebQuery) {
118
				WebQuery webQuery = (WebQuery) query;
119
				if(url.startsWith(webQuery.getTaskPrefix())) {
120
					return webQuery.getRepositoryUrl();
121
				}
122
			}			
123
		}
124
		
101
		return null;
125
		return null;
102
	}
126
	}
103
	
127
	
104
	public List<AbstractQueryHit> performQuery(AbstractRepositoryQuery query, IProgressMonitor monitor, MultiStatus queryStatus) {
128
	public List<AbstractQueryHit> performQuery(AbstractRepositoryQuery query, IProgressMonitor monitor, MultiStatus queryStatus) {
105
		// TODO
129
		List<AbstractQueryHit> hits = new ArrayList<AbstractQueryHit>();
106
		return null;
130
		
131
		if(query instanceof WebQuery) {
132
			StringBuffer resource = null;
133
			try {
134
				resource = fetchResource(query.getQueryUrl());
135
			} catch (IOException ex) {
136
				queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK,
137
						"Could not fetch resource: " + query.getQueryUrl(), ex));
138
			}
139
			
140
			String regexp = ((WebQuery) query).getRegexp();
141
			
142
		    Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE | Pattern.CANON_EQ);
143
		    Matcher matcher = p.matcher(resource);
144
145
		    if(matcher.find()) {
146
		    	if(matcher.groupCount()<2) {
147
		    		queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK,
148
		    				"Unable to parse fetched resource. Check query regexp", null));
149
		    	} else {
150
			    	do {
151
			    		String id = matcher.group(1);
152
			    		String description = matcher.group(2);
153
			    		hits.add(new WebQueryHit(id, description, query.getRepositoryUrl()));
154
			    	} while(matcher.find());
155
			    	queryStatus.add(Status.OK_STATUS);
156
			    }
157
		    } else {
158
				queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK,
159
						"Unable to parse fetched resource. Check query regexp", null));
160
		    }
161
			
162
		}
163
		return hits;
107
	}
164
	}
108
165
109
	protected void updateTaskState(AbstractRepositoryTask repositoryTask) {
166
	protected void updateTaskState(AbstractRepositoryTask repositoryTask) {
Lines 140-152 Link Here
140
	}
197
	}
141
198
142
	
199
	
143
	public IWizard getNewQueryWizard(TaskRepository repository) {
200
	public IWizard getNewQueryWizard(TaskRepository taskRepository) {
144
		// TODO
201
		return new WebQueryWizard(taskRepository);
145
		return null;
146
	}
202
	}
147
	
203
	
148
	public void openEditQueryDialog(AbstractRepositoryQuery query) {
204
	public void openEditQueryDialog(AbstractRepositoryQuery query) {
149
		// TODO
205
		try {
206
			TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(
207
					query.getRepositoryKind(), query.getRepositoryUrl());
208
			if (repository == null)
209
				return;
210
211
			IWizard wizard = null;
212
			if (query instanceof WebQuery) {
213
				wizard = new WebQueryEditWizard(repository, query);
214
			}
215
216
			Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
217
			if (wizard != null && shell != null && !shell.isDisposed()) {
218
				WizardDialog dialog = new WizardDialog(shell, wizard);
219
				dialog.create();
220
				dialog.setTitle("Edit Web Query");
221
				dialog.setBlockOnOpen(true);
222
				if (dialog.open() == Window.CANCEL) {
223
					dialog.close();
224
					return;
225
				}
226
			}
227
		} catch (Exception e) {
228
			MylarStatusHandler.fail(e, e.getMessage(), true);
229
		}
150
	}
230
	}
151
	
231
	
152
	
232
	
Lines 165-169 Link Here
165
		return null;
245
		return null;
166
	}
246
	}
167
	
247
	
248
	
249
	public static StringBuffer fetchResource(String url) throws IOException {
250
		URL u = new URL(url);
251
		InputStream is = null;
252
		try {
253
			is = u.openStream();
254
		    BufferedReader r = new BufferedReader(new InputStreamReader(is));
255
256
		    StringBuffer resource = new StringBuffer();
257
		    String line;
258
		    while((line = r.readLine())!=null) {
259
		    	resource.append(line).append("\n");
260
		    }
261
		    return resource;
262
		    
263
		} finally {
264
			if(is!=null) {
265
				is.close();
266
			}
267
		}
268
		
269
	}
168
}
270
}
169
271
(-)src/org/eclipse/mylar/internal/sandbox/web/WebQueryHit.java (+61 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.sandbox.web;
13
14
import org.eclipse.mylar.provisional.tasklist.AbstractQueryHit;
15
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryTask;
16
17
/**
18
 * Represents issue returned by <code>WebQuery</code> 
19
 * 
20
 * @author Eugene Kuleshov
21
 */
22
public class WebQueryHit extends AbstractQueryHit {
23
24
	private AbstractRepositoryTask task;
25
26
27
	public WebQueryHit(String id, String description, String repositoryUrl) {
28
		super(repositoryUrl, description, Integer.parseInt(id));
29
	}
30
31
	public String getDescription() {
32
		return id + ": "+ description;
33
	}
34
	
35
	public String getPriority() {
36
		return "?";
37
	}
38
39
	public boolean isCompleted() {
40
		return false;
41
	}
42
43
	public AbstractRepositoryTask getCorrespondingTask() {
44
		return task;
45
	}
46
47
	public void setCorrespondingTask(AbstractRepositoryTask task) {
48
		this.task = task;
49
	}
50
51
	public AbstractRepositoryTask getOrCreateCorrespondingTask() {
52
		// TODO
53
		return null;
54
	}
55
	
56
	public void setHandleIdentifier(String id) {
57
		// TODO
58
	}
59
60
}
61
(-)src/org/eclipse/mylar/internal/sandbox/web/WebQueryEditWizard.java (+70 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.sandbox.web;
13
14
import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractEditQueryWizard;
15
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector;
16
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery;
17
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
18
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
19
20
public class WebQueryEditWizard extends AbstractEditQueryWizard {
21
22
	private WebQueryWizardPage queryPage;
23
24
	public WebQueryEditWizard(TaskRepository repository, AbstractRepositoryQuery query) {
25
		super(repository, query);
26
		setForcePreviousAndNextButtons(true);
27
	}
28
29
	@Override
30
	public void addPages() {
31
		queryPage = new WebQueryWizardPage(repository, (WebQuery) query);
32
		queryPage.setWizard(this);
33
		addPage(queryPage);
34
	}
35
36
	@Override
37
	public boolean performFinish() {
38
39
		AbstractRepositoryQuery q = queryPage.getQuery();
40
		if (q != null) {
41
			
42
//			String name;
43
//			if (q instanceof JiraRepositoryQuery) {
44
//				name = ((JiraRepositoryQuery) q).getNamedFilter().getName();
45
//			} else {
46
//				name = ((JiraCustomQuery) query).getFilterDefinition().getName();
47
//			}
48
			
49
			MylarTaskListPlugin.getTaskListManager().getTaskList().deleteQuery(query);
50
			MylarTaskListPlugin.getTaskListManager().getTaskList().addQuery(q);
51
			
52
			AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
53
			if (connector != null) {
54
				connector.synchronize(q, null);
55
			}
56
//			filter.refreshHits();
57
		} 
58
59
		return true;
60
	}
61
62
	@Override
63
	public boolean canFinish() {
64
		if(queryPage.getNextPage() == null) {
65
			return queryPage.isPageComplete();
66
		}
67
		return queryPage.getNextPage().isPageComplete();
68
	}
69
}
70
(-)src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java (+213 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.sandbox.web;
13
14
import java.util.regex.Matcher;
15
import java.util.regex.Pattern;
16
17
import org.eclipse.jface.wizard.WizardPage;
18
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery;
19
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
20
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.custom.SashForm;
23
import org.eclipse.swt.events.ModifyEvent;
24
import org.eclipse.swt.events.ModifyListener;
25
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.swt.widgets.Table;
33
import org.eclipse.swt.widgets.TableColumn;
34
import org.eclipse.swt.widgets.TableItem;
35
import org.eclipse.swt.widgets.Text;
36
37
/**
38
 * 
39
 * Subclipse (IssueZilla)
40
 *   url: http://subclipse.tigris.org/issues/buglist.cgi?issue_status=NEW;issue_status=STARTED;issue_status=REOPENED&order=issues.issue_id
41
 *   regexp: <a href="show_bug.cgi\?id\=(.+?)">.+?<span class="summary">(.+?)</span>
42
 *   task prefix: http://subclipse.tigris.org/issues/show_bug.cgi?id=
43
 * 
44
 * ASM (GForge)
45
 *   url: http://forge.objectweb.org/tracker/?group_id=23&atid=350023
46
 *   regexp: <a class="tracker" href="/tracker/index.php\?func=detail&aid=(.+?)&group_id=23&atid=350023">(.+?)</a></td>
47
 *   task prefix: http://forge.objectweb.org/tracker/index.php?func=detail&group_id=23&atid=350023&aid=
48
 * 
49
 * @author Eugene Kuleshov
50
 */
51
public class WebQueryWizardPage extends WizardPage {
52
	private Text taskPrefixText;
53
	private Text descriptionText;
54
	private Text queryUrlText;
55
	private Text regexpText;
56
	private Table previewTable;
57
	
58
	private StringBuffer webPage;
59
	
60
	private TaskRepository repository;
61
	private WebQuery query;
62
63
	public WebQueryWizardPage(TaskRepository repository) {
64
		this(repository, null);
65
	}
66
67
	public WebQueryWizardPage(TaskRepository repository, WebQuery query) {
68
		super("New web query");
69
		this.repository = repository;
70
		this.query = query;
71
72
		setTitle("Create web query");
73
		setDescription("http://subclipse.tigris.org/issues/buglist.cgi?issue_status=NEW;issue_status=STARTED;issue_status=REOPENED&order=issues.issue_id\n" +
74
			"<a href=\"show_bug.cgi\\?id\\=(.+?)\">.+?<span class=\"summary\">(.+?)</span>");
75
	}
76
77
	public void createControl(Composite parent) {
78
		SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
79
80
		Composite composite = new Composite(sashForm, SWT.NONE);
81
		GridLayout gridLayout = new GridLayout();
82
		gridLayout.numColumns = 3;
83
		composite.setLayout(gridLayout);
84
85
		Label descriptionLabel = new Label(composite, SWT.NONE);
86
		descriptionLabel.setLayoutData(new GridData());
87
		descriptionLabel.setText("Description:");
88
89
		descriptionText = new Text(composite, SWT.BORDER);
90
		descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
91
		new Label(composite, SWT.NONE);
92
93
		Label queryUrlLabel = new Label(composite, SWT.NONE);
94
		queryUrlLabel.setText("URL:");
95
96
		queryUrlText = new Text(composite, SWT.BORDER);
97
		queryUrlText.addModifyListener(new ModifyListener() {
98
			public void modifyText(final ModifyEvent e) {
99
				webPage = null;
100
			}
101
		});
102
		queryUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
103
104
		Button preview = new Button(composite, SWT.NONE);
105
		preview.setText("Preview");
106
		preview.addSelectionListener(new SelectionAdapter() {
107
			public void widgetSelected(final SelectionEvent e) {
108
				updatePreview();
109
			}
110
		});
111
112
		Label taskPrefixLabel = new Label(composite, SWT.NONE);
113
		taskPrefixLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
114
		taskPrefixLabel.setText("Task prefix:");
115
116
		taskPrefixText = new Text(composite, SWT.BORDER);
117
		taskPrefixText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
118
		new Label(composite, SWT.NONE);
119
120
		Label regexpLabel = new Label(composite, SWT.NONE);
121
		regexpLabel.setText("Regexp:");
122
		regexpLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true));
123
124
		regexpText = new Text(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
125
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
126
		gridData.heightHint = 39;
127
		regexpText.setLayoutData(gridData);
128
		regexpText.addModifyListener(new ModifyListener() {
129
			public void modifyText(final ModifyEvent e) {
130
				if(webPage!=null) {
131
					updatePreview();
132
				}
133
			}
134
		});
135
136
		previewTable = new Table(sashForm, SWT.BORDER);
137
		previewTable.setLinesVisible(true);
138
		previewTable.setHeaderVisible(true);
139
140
		TableColumn colId = new TableColumn(previewTable, SWT.NONE);
141
		colId.setWidth(100);
142
		colId.setText("Id");
143
144
		TableColumn colDescription = new TableColumn(previewTable, SWT.NONE);
145
		colDescription.setWidth(328);
146
		colDescription.setText("Description");
147
148
		setControl(sashForm);
149
		
150
		if(query!=null) {
151
			descriptionText.setText(query.getDescription());
152
			queryUrlText.setText(query.getQueryUrl());
153
			taskPrefixText.setText(query.getTaskPrefix());
154
			regexpText.setText(query.getRegexp());
155
		}
156
		new Label(composite, SWT.NONE);
157
		sashForm.setWeights(new int[] {123, 166 });
158
	}
159
160
	public AbstractRepositoryQuery getQuery() {
161
		String description = descriptionText.getText();
162
		String queryUrl = queryUrlText.getText();
163
		String taskPrefix = taskPrefixText.getText();
164
		String regexp = regexpText.getText();
165
		return new WebQuery(description, queryUrl, taskPrefix, regexp, 
166
				MylarTaskListPlugin.getTaskListManager().getTaskList(), repository.getUrl());
167
	}
168
169
	// TODO run asynchronously
170
	synchronized void updatePreview() {
171
		String regexp = regexpText.getText();
172
		try {
173
		    Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE | Pattern.CANON_EQ);
174
		    Matcher matcher = p.matcher(getWebPage());
175
		    
176
		    previewTable.removeAll();
177
178
		    while(matcher.find()) {
179
		    	if(matcher.groupCount()>0) {
180
		    		TableItem item = new TableItem(previewTable, SWT.NONE);
181
		    		for (int i = 0; i < matcher.groupCount(); i++) {
182
		    			item.setText(i, matcher.group(i+1));
183
					}
184
		    	}
185
		    	
186
		    	if(matcher.groupCount()<2) {
187
		    		setErrorMessage("Require two matching groups (id and description)");
188
					setPageComplete(false);
189
		    	} else {
190
		    		setErrorMessage(null);
191
		    		setPageComplete(true);
192
		    	}
193
		    }
194
			
195
		} catch(Exception ex) {
196
			setErrorMessage("Parsing error: "+ex.getMessage());
197
			setPageComplete(false);
198
		}
199
	}
200
	
201
	private StringBuffer getWebPage() {
202
		if(webPage==null) {
203
			try {
204
				webPage = WebRepositoryConnector.fetchResource(queryUrlText.getText());
205
			} catch(Exception ex) {
206
				setErrorMessage("Unable to fetch resource: "+ex.getMessage());
207
				setPageComplete(false);
208
			}
209
		}
210
		return webPage;
211
	}
212
	
213
}
(-)src/org/eclipse/mylar/internal/sandbox/web/WebQuery.java (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.sandbox.web;
13
14
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery;
15
import org.eclipse.mylar.provisional.tasklist.TaskList;
16
17
/**
18
 * Represents regexp-based query on repository web page  
19
 * 
20
 * @author Eugene Kuleshov
21
 */
22
public class WebQuery extends AbstractRepositoryQuery {
23
24
	private final String regexp;
25
	private final String taskPrefix;
26
27
	public WebQuery(String description, String queryUrl, String taskPrefix, String regexp, 
28
			TaskList taskList, String repositoryUrl) {
29
		super(description, taskList);
30
		this.taskPrefix = taskPrefix;
31
32
		this.regexp = regexp;
33
		
34
		setQueryUrl(queryUrl);
35
		setRepositoryUrl(repositoryUrl);
36
	}
37
38
	public String getRepositoryKind() {
39
		return WebRepositoryConnector.REPOSITORY_TYPE;
40
	}
41
	
42
	public String getRegexp() {
43
		return this.regexp;
44
	}
45
46
	public String getTaskPrefix() {
47
		return this.taskPrefix;
48
	}
49
50
}
(-)src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizard.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.sandbox.web;
13
14
import org.eclipse.jface.wizard.Wizard;
15
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector;
16
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery;
17
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
18
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
19
20
/**
21
 * Wizard used to create query for web based connector
22
 * 
23
 * @author Eugene Kuleshov
24
 */
25
public class WebQueryWizard extends Wizard {
26
27
	private static final String TITLE = "New Web Query";
28
	
29
	private final TaskRepository repository;
30
31
	private WebQueryWizardPage queryPage;
32
33
	public WebQueryWizard(TaskRepository repository) {
34
		this.repository = repository;
35
		setNeedsProgressMonitor(true);
36
		setWindowTitle(TITLE); 
37
	}
38
39
	@Override
40
	public void addPages() {
41
		queryPage = new WebQueryWizardPage(repository);
42
		queryPage.setWizard(this);
43
		addPage(queryPage);
44
	}
45
46
	@Override
47
	public boolean performFinish() {
48
49
		AbstractRepositoryQuery query = queryPage.getQuery();
50
		if (query != null) {
51
			MylarTaskListPlugin.getTaskListManager().getTaskList().addQuery(query);
52
			AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind());
53
			if (connector != null) {
54
				connector.synchronize(query, null);
55
			}
56
//			filter.refreshHits();
57
		} 
58
59
		return true;
60
	}
61
62
	
63
	
64
	public boolean canFinish() {
65
		if(queryPage.getNextPage() == null) {
66
			return queryPage.isPageComplete();
67
		}
68
		return queryPage.getNextPage().isPageComplete();
69
	}
70
	
71
	
72
}

Return to bug 145123