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 139312 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/internal/tasks/ui/search/AbstractRepositoryQueryPage.java (-27 / +25 lines)
Lines 24-36 Link Here
24
import org.eclipse.search.ui.ISearchPageContainer;
24
import org.eclipse.search.ui.ISearchPageContainer;
25
import org.eclipse.search.ui.NewSearchUI;
25
import org.eclipse.search.ui.NewSearchUI;
26
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.KeyEvent;
27
import org.eclipse.swt.events.ModifyEvent;
28
import org.eclipse.swt.events.KeyListener;
28
import org.eclipse.swt.events.ModifyListener;
29
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridLayout;
30
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Display;
32
import org.eclipse.swt.widgets.Display;
33
import org.eclipse.swt.widgets.Group;
33
import org.eclipse.swt.widgets.Label;
34
import org.eclipse.swt.widgets.Text;
34
import org.eclipse.swt.widgets.Text;
35
35
36
/**
36
/**
Lines 38-44 Link Here
38
 */
38
 */
39
public abstract class AbstractRepositoryQueryPage extends WizardPage implements ISearchPage {
39
public abstract class AbstractRepositoryQueryPage extends WizardPage implements ISearchPage {
40
40
41
	private static final String TITLE_QUERY_TITLE = "Query Title";
41
	private static final String TITLE_QUERY_TITLE = "Query &Title:";
42
42
43
	private static final String TITLE = "Enter query parameters";
43
	private static final String TITLE = "Enter query parameters";
44
44
Lines 62-68 Link Here
62
62
63
	public AbstractRepositoryQueryPage(String wizardTitle, String queryTitle) {
63
	public AbstractRepositoryQueryPage(String wizardTitle, String queryTitle) {
64
		super(wizardTitle);
64
		super(wizardTitle);
65
		titleString = queryTitle;
65
		titleString = queryTitle==null ? "" : queryTitle;
66
	}
66
	}
67
67
68
	public void createControl(Composite parent) {
68
	public void createControl(Composite parent) {
Lines 72-117 Link Here
72
		}
72
		}
73
	}
73
	}
74
74
75
	private void createTitleGroup(Composite composite) {
75
	private void createTitleGroup(Composite parent) {
76
		if(scontainer != null) return;
76
		Composite group = new Composite(parent, SWT.NONE);
77
		Group group = new Group(composite, SWT.NONE);
77
		
78
		group.setText(TITLE_QUERY_TITLE);
78
		GridLayout layout = new GridLayout(2, false);
79
		GridLayout layout = new GridLayout();
80
		layout.numColumns = 1;
81
		group.setLayout(layout);
79
		group.setLayout(layout);
80
82
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
81
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
83
		gd.horizontalSpan = 1;
82
		gd.horizontalSpan = 1;
84
		group.setLayoutData(gd);
83
		group.setLayoutData(gd);
85
84
85
		Label label = new Label(group, SWT.NONE);
86
		label.setText(TITLE_QUERY_TITLE);
87
86
		title = new Text(group, SWT.BORDER);
88
		title = new Text(group, SWT.BORDER);
87
		gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
89
		title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
88
		title.setLayoutData(gd);
89
		title.setText(titleString);
90
		title.setText(titleString);
90
91
91
		title.addKeyListener(new KeyListener() {
92
		title.addModifyListener(new ModifyListener() {
92
93
			public void modifyText(ModifyEvent e) {
93
			public void keyPressed(KeyEvent e) {
94
				setPageComplete(isPageComplete());
94
				// ignore
95
			}
96
97
			public void keyReleased(KeyEvent e) {
98
				setPageComplete(canFlipToNextPage());
99
			}
95
			}
100
		});
96
		});
101
	}
97
	}
102
98
103
	public boolean canFlipToNextPage() {
99
//	public boolean canFlipToNextPage() {
104
		if (getErrorMessage() != null || !isPageComplete())
100
//		if (getErrorMessage() != null || !isPageComplete()) {
105
			return false;
101
//			return false;
106
102
//		}
107
		return true;
103
//		return true;
108
	}
104
//	}
109
105
110
	@Override
106
	@Override
111
	public boolean isPageComplete() {
107
	public boolean isPageComplete() {
112
		if (title != null && !title.getText().equals("")) {
108
		if (title != null && !title.getText().equals("")) {
109
			setErrorMessage(null);
113
			return true;
110
			return true;
114
		}
111
		}
112
		setErrorMessage("Name is mandatory");
115
		return false;
113
		return false;
116
	}
114
	}
117
115
(-)src/org/eclipse/mylar/internal/jira/JiraRepositoryUi.java (-3 / +2 lines)
Lines 29-35 Link Here
29
29
30
	@Override
30
	@Override
31
	public WizardPage getSearchPage(TaskRepository repository, IStructuredSelection selection) {
31
	public WizardPage getSearchPage(TaskRepository repository, IStructuredSelection selection) {
32
		return new JiraQueryPage(repository, new FilterDefinition(), true);
32
		return new JiraQueryPage(repository, new FilterDefinition(), true, false);
33
	} 
33
	} 
34
34
35
	public AbstractRepositorySettingsPage getSettingsPage() {
35
	public AbstractRepositorySettingsPage getSettingsPage() {
Lines 39-47 Link Here
39
	public IWizard getQueryWizard(TaskRepository repository, AbstractRepositoryQuery query) {
39
	public IWizard getQueryWizard(TaskRepository repository, AbstractRepositoryQuery query) {
40
		if (query instanceof JiraRepositoryQuery || query instanceof JiraCustomQuery) {
40
		if (query instanceof JiraRepositoryQuery || query instanceof JiraCustomQuery) {
41
			return new EditJiraQueryWizard(repository, query);
41
			return new EditJiraQueryWizard(repository, query);
42
		} else {
43
			return new NewJiraQueryWizard(repository);
44
		}
42
		}
43
		return new NewJiraQueryWizard(repository);
45
	}
44
	}
46
	
45
	
47
	@Override
46
	@Override
(-)src/org/eclipse/mylar/internal/jira/JiraCustomQuery.java (-6 / +394 lines)
Lines 11-37 Link Here
11
11
12
package org.eclipse.mylar.internal.jira;
12
package org.eclipse.mylar.internal.jira;
13
13
14
import java.io.UnsupportedEncodingException;
15
import java.net.URLDecoder;
16
import java.net.URLEncoder;
17
import java.text.SimpleDateFormat;
18
import java.util.ArrayList;
19
import java.util.Collections;
20
import java.util.Date;
21
import java.util.HashMap;
22
import java.util.List;
23
import java.util.Map;
24
14
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
25
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
15
import org.eclipse.mylar.tasks.core.TaskList;
26
import org.eclipse.mylar.tasks.core.TaskList;
27
import org.eclipse.mylar.tasks.core.TaskRepository;
28
import org.tigris.jira.core.model.Component;
29
import org.tigris.jira.core.model.IssueType;
30
import org.tigris.jira.core.model.Priority;
31
import org.tigris.jira.core.model.Project;
32
import org.tigris.jira.core.model.Resolution;
33
import org.tigris.jira.core.model.Status;
34
import org.tigris.jira.core.model.Version;
35
import org.tigris.jira.core.model.filter.ComponentFilter;
36
import org.tigris.jira.core.model.filter.ContentFilter;
37
import org.tigris.jira.core.model.filter.CurrentUserFilter;
38
import org.tigris.jira.core.model.filter.DateFilter;
39
import org.tigris.jira.core.model.filter.DateRangeFilter;
16
import org.tigris.jira.core.model.filter.FilterDefinition;
40
import org.tigris.jira.core.model.filter.FilterDefinition;
41
import org.tigris.jira.core.model.filter.IssueTypeFilter;
42
import org.tigris.jira.core.model.filter.NobodyFilter;
43
import org.tigris.jira.core.model.filter.PriorityFilter;
44
import org.tigris.jira.core.model.filter.ProjectFilter;
45
import org.tigris.jira.core.model.filter.ResolutionFilter;
46
import org.tigris.jira.core.model.filter.SpecificUserFilter;
47
import org.tigris.jira.core.model.filter.StatusFilter;
48
import org.tigris.jira.core.model.filter.UserFilter;
49
import org.tigris.jira.core.model.filter.UserInGroupFilter;
50
import org.tigris.jira.core.model.filter.VersionFilter;
51
import org.tigris.jira.core.service.JiraServer;
17
52
18
/**
53
/**
19
 * A JiraFilter represents a query for issues from a Jira repository.
54
 * A JiraCustomQuery represents a custom query for issues from a Jira repository.
20
 * 
55
 * 
21
 * @author Mik Kersten
56
 * @author Mik Kersten
57
 * @author Eugene Kuleshov
22
 */
58
 */
23
public class JiraCustomQuery extends AbstractRepositoryQuery {
59
public class JiraCustomQuery extends AbstractRepositoryQuery {
24
60
61
	private static final String PROJECT_KEY = "pid";
62
	private static final String COMPONENT_KEY = "component";
63
	private static final String TYPE_KEY = "type";
64
	private static final String PRIORITY_KEY = "priority";
65
	private static final String STATUS_KEY = "status";
66
	private static final String RESOLUTION_KEY = "resolution";
67
	
68
	private static final String FIXFOR_KEY = "fixfor";
69
	private static final String VERSION_KEY = "version";
70
	
71
	private static final String QUERY_KEY = "query";
72
	private static final String ENVIRONMENT_KEY = "environment";
73
	private static final String BODY_KEY = "body";
74
	private static final String DESCRIPTION_KEY = "description";
75
	private static final String SUMMARY_KEY = "summary";
76
	
77
	private static final String ASSIGNEE_KEY = "assignee";
78
	private static final String REPORTER_KEY = "reporter";
79
	
80
	private static final String CREATED_KEY = "created";
81
	private static final String UPDATED_KEY = "updated";
82
	private static final String DUEDATE_KEY = "duedate";
83
	
84
	private static final String ISSUE_SPECIFIC_GROUP = "specificgroup";
85
	private static final String ISSUE_SPECIFIC_USER = "specificuser";
86
	private static final String ISSUE_CURRENT_USER = "issue_current_user";
87
	private static final String ISSUE_NO_REPORTER = "issue_no_reporter";
88
	
25
	private static final int MAX_HITS = 200;
89
	private static final int MAX_HITS = 200;
90
	
91
	
92
	private final FilterDefinition filter;
93
	private String encoding;
26
94
27
	protected FilterDefinition filter = null;
28
95
29
	public JiraCustomQuery(String repositoryUrl, FilterDefinition filter, TaskList taskList) {
96
	public JiraCustomQuery(String repositoryUrl, FilterDefinition filter, TaskList taskList, TaskRepository taskRepository) {
30
		super(filter.getName(), taskList);
97
		super(filter.getName(), taskList);
31
		setMaxHits(MAX_HITS);
32
		this.filter = filter;
98
		this.filter = filter;
33
		super.repositoryUrl = repositoryUrl;
99
		this.repositoryUrl = repositoryUrl;
34
		setUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + filter.getName());
100
		this.encoding = taskRepository.getCharacterEncoding();
101
		this.url = repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + "&reset=true&mode=hide" + getQueryParams(filter);
102
		this.maxHits = MAX_HITS;
103
	}
104
105
	public JiraCustomQuery(String name, String queryUrl, String repositoryUrl, 
106
			JiraServer jiraServer, TaskList taskList, TaskRepository taskRepository) {
107
		super(name, taskList);
108
		this.repositoryUrl = repositoryUrl;
109
		this.url = queryUrl;
110
		this.encoding = taskRepository.getCharacterEncoding();
111
		this.filter = createFilter(jiraServer, queryUrl);
112
		this.filter.setName(name);
113
		this.maxHits = MAX_HITS;
35
	}
114
	}
36
115
37
	public String getRepositoryKind() {
116
	public String getRepositoryKind() {
Lines 41-46 Link Here
41
	public FilterDefinition getFilterDefinition() {
120
	public FilterDefinition getFilterDefinition() {
42
		return filter;
121
		return filter;
43
	}
122
	}
123
124
	
125
	private FilterDefinition createFilter(JiraServer jiraServer, String url) {
126
		FilterDefinition filter = new FilterDefinition();
127
		
128
		HashMap<String, List<String>> params = new HashMap<String, List<String>>();
129
		
130
		for (String pair : url.split("&\\?")) {
131
			String[] tokens = pair.split("=");
132
			if (tokens.length > 1) {
133
				try {
134
					String key = tokens[0];
135
					String value = tokens.length>1 ? null : URLDecoder.decode(tokens[1], encoding);
136
					List<String> values = params.get(key);
137
					if(values==null) {
138
						values = new ArrayList<String>();
139
						params.put(key, values);
140
					}
141
					values.add(value);
142
				} catch (UnsupportedEncodingException ex) {
143
					// ignore
144
				}
145
			}
146
		}
147
148
		List<String> projectIds = getIds(params, PROJECT_KEY);
149
		for (String projectId : projectIds) {
150
			Project project = jiraServer.getProjectById(projectId);
151
			filter.setProjectFilter(new ProjectFilter(project));
152
			
153
			List<String> componentIds = getIds(params, COMPONENT_KEY);
154
			List<Component> components = new ArrayList<Component>();
155
			for (String componentId : componentIds) {
156
				Component[] projectComponents = project.getComponents();
157
				for(Component component : projectComponents) {
158
					if(component.getId().equals(componentId)) {
159
						components.add(component);
160
					}
161
				}
162
			}
163
			if(!components.isEmpty()) {
164
				filter.setComponentFilter(new ComponentFilter(components.toArray(new Component[components.size()])));
165
			}
166
167
			Version[] projectVersions = project.getVersions();
168
			
169
			List<String> fixForIds = getIds(params, FIXFOR_KEY);
170
			List<Version> fixForversions = new ArrayList<Version>();
171
			for (String fixForId : fixForIds) {
172
				for (Version projectVersion : projectVersions) {
173
					if(projectVersion.getId().equals(fixForId)) {
174
						fixForversions.add(projectVersion);
175
					}
176
				}
177
			}
178
			if(!fixForversions.isEmpty()) {
179
				filter.setFixForVersionFilter(new VersionFilter(fixForversions.toArray(new Version[fixForversions.size()])));
180
			}
181
			
182
			List<String> versionIds = getIds(params, VERSION_KEY);
183
			List<Version> versions = new ArrayList<Version>();
184
			for (String versionId : versionIds) {
185
				for (Version projectVersion : projectVersions) {
186
					if(projectVersion.getId().equals(versionId)) {
187
						versions.add(projectVersion);
188
					}
189
				}
190
			}
191
			if(!versions.isEmpty()) {
192
				filter.setReportedInVersionFilter(new VersionFilter(versions.toArray(new Version[versions.size()])));
193
			}
194
		}
195
		
196
		List<String> typeIds = getIds(params, TYPE_KEY);
197
		List<IssueType> issueTypes = new ArrayList<IssueType>();  
198
		for (String typeId : typeIds) {
199
			IssueType issueType = jiraServer.getIssueTypeById(typeId);
200
			if(!IssueType.MISSING_ISSUE_TYPE.equals(issueType)) {
201
				issueTypes.add(issueType);
202
			}
203
		}
204
		if(!issueTypes.isEmpty()) {
205
			filter.setIssueTypeFilter(new IssueTypeFilter(issueTypes.toArray(new IssueType[issueTypes.size()])));
206
		}
207
208
		List<String> statusIds = getIds(params, STATUS_KEY);
209
		List<Status> statuses = new ArrayList<Status>();  
210
		for (String statusId : statusIds) {
211
			Status status = jiraServer.getStatusById(statusId);
212
			if(!Status.MISSING_STATUS.equals(status)) {
213
				statuses.add(status);
214
			}
215
		}
216
		if(!statuses.isEmpty()) {
217
			filter.setStatusFilter(new StatusFilter(statuses.toArray(new Status[statuses.size()])));
218
		}
219
		
220
		List<String> resolutionIds = getIds(params, RESOLUTION_KEY);
221
		List<Resolution> resolutions = new ArrayList<Resolution>();
222
		for (String resolutionId : resolutionIds) {
223
			Resolution resolution = jiraServer.getResolutionById(resolutionId);
224
			if(!Resolution.UNKNOWN_RESOLUTION.equals(resolution)) {
225
				resolutions.add(resolution);
226
			}
227
		}
228
		if(!resolutions.isEmpty()) {
229
			filter.setResolutionFilter(new ResolutionFilter(resolutions.toArray(new Resolution[resolutions.size()])));
230
		}
231
232
		List<String> queries = getIds(params, QUERY_KEY);
233
		for (String query : queries) {
234
			boolean searchSummary = !getIds(params, SUMMARY_KEY).contains("true");
235
			boolean searchDescription = !getIds(params, DESCRIPTION_KEY).contains("true");
236
			boolean searchEnvironment = !getIds(params, ENVIRONMENT_KEY).contains("true");
237
			boolean searchComments = !getIds(params, BODY_KEY).contains("true");
238
			filter.setContentFilter(new ContentFilter(query, searchSummary, searchDescription, searchEnvironment, searchComments));
239
		}
240
241
		filter.setReportedByFilter(createUserFilter(params, REPORTER_KEY));
242
		filter.setAssignedToFilter(createUserFilter(params, ASSIGNEE_KEY));
243
244
		filter.setCreatedDateFilter(createDateFilter(params, CREATED_KEY));
245
		filter.setUpdatedDateFilter(createDateFilter(params, UPDATED_KEY));
246
		filter.setDueDateFilter(createDateFilter(params, DUEDATE_KEY));
247
		
248
		return filter;
249
	}
250
251
	private DateFilter createDateFilter(Map<String, List<String>> params, String key) {
252
		String after = getId(params, key + ":after");
253
		String before = getId(params, key + ":before");
254
		
255
		SimpleDateFormat df = new SimpleDateFormat("d/MMM/yy");
256
		Date fromDate;
257
		try {
258
			fromDate = df.parse(after);
259
		} catch (Exception ex) {
260
			fromDate = null;
261
		}
262
		Date toDate;
263
		try {
264
			toDate = df.parse(before);
265
		} catch (Exception ex) {
266
			toDate = null;
267
		}		
268
		
269
		return fromDate==null && toDate==null ? null : new DateRangeFilter(fromDate, toDate);
270
	}
271
272
	private UserFilter createUserFilter(Map<String, List<String>> params, String key) {
273
		String type = getId(params, key + "Select");
274
		if(ISSUE_NO_REPORTER.equals(type)) {
275
			return new NobodyFilter();
276
		} else if(ISSUE_CURRENT_USER.equals(type)) {
277
			return new CurrentUserFilter();
278
		} else {
279
			String reporter = getId(params, key);
280
			if(reporter!=null) {
281
				if(ISSUE_SPECIFIC_USER.equals(type)) {
282
					return new SpecificUserFilter(reporter);
283
				} else if(ISSUE_SPECIFIC_GROUP.equals(type)) {
284
					return new UserInGroupFilter(reporter);
285
				}
286
			}
287
		}
288
		return null;
289
	}
290
	
291
	private String getId(Map<String, List<String>> params, String key) {
292
		List<String> ids = getIds(params, key);
293
		return ids.isEmpty() ? null : ids.get(0);
294
	}
295
296
	private List<String> getIds(Map<String, List<String>> params, String key) {
297
		List<String> ids = params.get(key);
298
		if (ids==null) {
299
			return Collections.emptyList();
300
		}
301
		return ids; 
302
	}
303
	
304
	
305
	private String getQueryParams(FilterDefinition filter) {
306
		StringBuffer sb = new StringBuffer();
307
		
308
		ProjectFilter projectFilter = filter.getProjectFilter();
309
		if(projectFilter!=null) {
310
			Project project = projectFilter.getProject();
311
			// TODO all projects
312
			addParameter(sb, PROJECT_KEY, project.getId());
313
		}
314
		
315
		ComponentFilter componentFilter = filter.getComponentFilter();
316
		// TODO all components
317
		if(componentFilter==null || componentFilter.hasNoComponent()) {
318
			addParameter(sb, COMPONENT_KEY, "-1");
319
		} else {
320
			for (Component component : componentFilter.getComponents()) {
321
				addParameter(sb, COMPONENT_KEY, component.getId());
322
			}
323
		}
324
		
325
		// TODO
326
		VersionFilter fixForVersionFilter = filter.getFixForVersionFilter();
327
		if (fixForVersionFilter != null) {
328
			for ( Version fixVersion : fixForVersionFilter.getVersions()) {
329
				addParameter(sb, FIXFOR_KEY, fixVersion.getId());
330
			}
331
		}
332
		
333
		// TODO
334
		VersionFilter reportedInVersionFilter = filter.getReportedInVersionFilter();
335
		if (reportedInVersionFilter != null) {
336
			for (Version reportedVersion : reportedInVersionFilter.getVersions()) {
337
				addParameter(sb, VERSION_KEY, reportedVersion.getId());
338
			}
339
		}
340
		
341
		// TODO
342
		IssueTypeFilter issueTypeFilter = filter.getIssueTypeFilter();
343
		if (issueTypeFilter != null) {
344
			for (IssueType issueType : issueTypeFilter.getIsueTypes()) {
345
				addParameter(sb, TYPE_KEY, issueType.getId());
346
			}
347
		}
348
		
349
		// TODO
350
		StatusFilter statusFilter = filter.getStatusFilter();
351
		if(statusFilter!=null) {
352
			for ( Status status : statusFilter.getStatuses()) {
353
				addParameter(sb, STATUS_KEY, status.getId());
354
			}
355
		}
356
		
357
		ResolutionFilter resolutionFilter = filter.getResolutionFilter();
358
		if(resolutionFilter!=null) {
359
			for (Resolution resolution : resolutionFilter.getResolutions()) {
360
				addParameter(sb, RESOLUTION_KEY, resolution.getId());
361
			}
362
		}
363
		
364
		PriorityFilter priorityFilter = filter.getPriorityFilter();
365
		if(priorityFilter!=null) {
366
			for ( Priority priority : priorityFilter.getPriorities()) {
367
				addParameter(sb, PRIORITY_KEY, priority.getId());
368
			}
369
		}
370
		
371
		ContentFilter contentFilter = filter.getContentFilter();
372
		if(contentFilter!=null) {
373
			String queryString = contentFilter.getQueryString();
374
			if(queryString!=null) {
375
				addParameter(sb, QUERY_KEY, queryString);
376
			}
377
			if(contentFilter.isSearchingSummary()) {
378
				addParameter(sb, SUMMARY_KEY, "true");
379
			}
380
			if(contentFilter.isSearchingDescription()) {
381
				addParameter(sb, DESCRIPTION_KEY, "true");
382
			}
383
			if(contentFilter.isSearchingComments()) {
384
				addParameter(sb, BODY_KEY, "true");
385
			}
386
			if(contentFilter.isSearchingEnvironment()) {
387
				addParameter(sb, ENVIRONMENT_KEY, "true");
388
			}
389
		}
390
		
391
		addUserFilter(sb, filter.getReportedByFilter(), REPORTER_KEY); 
392
		addUserFilter(sb, filter.getAssignedToFilter(), ASSIGNEE_KEY); 
393
		
394
		addDateFilter(sb, filter.getCreatedDateFilter(), CREATED_KEY);
395
		addDateFilter(sb, filter.getUpdatedDateFilter(), UPDATED_KEY);
396
		addDateFilter(sb, filter.getDueDateFilter(), DUEDATE_KEY);
397
		
398
		return sb.toString();
399
	}
400
401
	private void addDateFilter(StringBuffer sb, DateFilter filter, String type) {
402
		if(filter instanceof DateRangeFilter) {
403
			SimpleDateFormat df = new SimpleDateFormat("d/MMM/yy");
404
			DateRangeFilter rangeFilter = (DateRangeFilter) filter;
405
			addParameter(sb, type + ":after", df.format(rangeFilter.getFromDate()));
406
			addParameter(sb, type + ":before", df.format(rangeFilter.getToDate()));
407
		}
408
	}
409
410
	private void addUserFilter(StringBuffer sb, UserFilter filter, String type) {
411
		if(filter instanceof NobodyFilter) {
412
			addParameter(sb, type + "Select", ISSUE_NO_REPORTER);
413
		} else if(filter instanceof CurrentUserFilter) {
414
			addParameter(sb, type + "Select", ISSUE_CURRENT_USER);
415
		} else if(filter instanceof SpecificUserFilter) {
416
			addParameter(sb, type + "Select", ISSUE_SPECIFIC_USER);
417
			addParameter(sb, type, ((SpecificUserFilter) filter).getUser());
418
		} else if(filter instanceof UserInGroupFilter) {
419
			addParameter(sb, type + "Select", ISSUE_SPECIFIC_GROUP);
420
			addParameter(sb, type, ((UserInGroupFilter) filter).getGroup());
421
		}
422
	}	
423
	
424
	private void addParameter(StringBuffer sb, String name, String value) {
425
		try {
426
			sb.append('&').append(name).append('=').append(URLEncoder.encode(value, encoding));
427
		} catch (UnsupportedEncodingException ex) {
428
			// ignore
429
		}
430
	}
431
	
44
}
432
}
45
433
46
//public void refreshHits() {
434
//public void refreshHits() {
(-)src/org/eclipse/mylar/internal/jira/JiraRepositoryQuery.java (-2 / +2 lines)
Lines 16-22 Link Here
16
import org.tigris.jira.core.model.NamedFilter;
16
import org.tigris.jira.core.model.NamedFilter;
17
17
18
/**
18
/**
19
 * A JiraFilter represents a query for issues from a Jira repository.
19
 * A JiraRepositoryQuery represents a server-side query for Jira repository.
20
 * 
20
 * 
21
 * @author Mik Kersten
21
 * @author Mik Kersten
22
 */
22
 */
Lines 31-37 Link Here
31
		setMaxHits(MAX_HITS);
31
		setMaxHits(MAX_HITS);
32
		this.filter = filter;
32
		this.filter = filter;
33
		super.repositoryUrl = repositoryUrl;
33
		super.repositoryUrl = repositoryUrl;
34
		setUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + filter.getId());
34
		setUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + "&requestId=" + filter.getId());
35
//		super.setDescription(filter.getName());
35
//		super.setDescription(filter.getName());
36
	}
36
	}
37
37
(-)src/org/eclipse/mylar/internal/jira/MylarJiraPlugin.java (-1 / +1 lines)
Lines 34-40 Link Here
34
	public final static String ISSUE_URL_PREFIX = "/browse/";
34
	public final static String ISSUE_URL_PREFIX = "/browse/";
35
35
36
	/** Repository address + Filter Prefix + Issue key = the filter's web address */
36
	/** Repository address + Filter Prefix + Issue key = the filter's web address */
37
	public final static String FILTER_URL_PREFIX = "/secure/IssueNavigator.jspa?mode=hide&requestId=";
37
	public final static String FILTER_URL_PREFIX = "/secure/IssueNavigator.jspa?mode=hide";
38
38
39
	public MylarJiraPlugin() {
39
	public MylarJiraPlugin() {
40
		INSTANCE = this;
40
		INSTANCE = this;
(-)src/org/eclipse/mylar/internal/jira/ui/wizards/JiraQueryPage.java (-98 / +93 lines)
Lines 30-35 Link Here
30
import org.eclipse.jface.viewers.Viewer;
30
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.mylar.internal.jira.JiraCustomQuery;
31
import org.eclipse.mylar.internal.jira.JiraCustomQuery;
32
import org.eclipse.mylar.internal.jira.JiraServerFacade;
32
import org.eclipse.mylar.internal.jira.JiraServerFacade;
33
import org.eclipse.mylar.internal.jira.MylarJiraPlugin;
33
import org.eclipse.mylar.internal.tasks.ui.search.AbstractRepositoryQueryPage;
34
import org.eclipse.mylar.internal.tasks.ui.search.AbstractRepositoryQueryPage;
34
import org.eclipse.mylar.internal.tasks.ui.views.DatePicker;
35
import org.eclipse.mylar.internal.tasks.ui.views.DatePicker;
35
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
36
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
Lines 37-48 Link Here
37
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
38
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
38
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.custom.SashForm;
40
import org.eclipse.swt.custom.SashForm;
40
import org.eclipse.swt.events.FocusAdapter;
41
import org.eclipse.swt.events.FocusEvent;
42
import org.eclipse.swt.events.ModifyEvent;
43
import org.eclipse.swt.events.ModifyListener;
44
import org.eclipse.swt.events.SelectionAdapter;
45
import org.eclipse.swt.events.SelectionEvent;
46
import org.eclipse.swt.graphics.Color;
41
import org.eclipse.swt.graphics.Color;
47
import org.eclipse.swt.graphics.Image;
42
import org.eclipse.swt.graphics.Image;
48
import org.eclipse.swt.layout.FillLayout;
43
import org.eclipse.swt.layout.FillLayout;
Lines 138-144 Link Here
138
133
139
	private final JiraServer server;
134
	private final JiraServer server;
140
135
141
	private Text name;
136
//	private Text name;
142
137
143
	private ListViewer project;
138
	private ListViewer project;
144
139
Lines 188-203 Link Here
188
183
189
	private final boolean isNew;
184
	private final boolean isNew;
190
185
186
	private final boolean namedQuery;
187
	
191
	private final FilterDefinition workingCopy;
188
	private final FilterDefinition workingCopy;
192
189
193
	private boolean namedQuery;
190
	public JiraQueryPage(TaskRepository repository, FilterDefinition workingCopy, boolean isNew, boolean namedQuery) {
194
191
		super(TITLE_PAGE, workingCopy==null ? "" : workingCopy.getName());
195
	public JiraQueryPage(TaskRepository repository, FilterDefinition workingCopy, boolean isNew) {
196
		super(TITLE_PAGE);
197
		this.repository = repository;
192
		this.repository = repository;
198
		this.server = JiraServerFacade.getDefault().getJiraServer(repository);
193
		this.server = JiraServerFacade.getDefault().getJiraServer(repository);
199
		this.workingCopy = workingCopy;
194
		this.workingCopy = workingCopy;
200
		this.isNew = isNew;
195
		this.isNew = isNew;
196
		this.namedQuery = namedQuery;
201
197
202
		setDescription("Add search filters to define query.");
198
		setDescription("Add search filters to define query.");
203
		setPageComplete(false);
199
		setPageComplete(false);
Lines 208-227 Link Here
208
		c.setLayout(new GridLayout(3, false));
204
		c.setLayout(new GridLayout(3, false));
209
205
210
		if (namedQuery) {
206
		if (namedQuery) {
211
			Label lblName = new Label(c, SWT.NONE);
207
			
212
			final GridData gridData = new GridData();
208
			super.createControl(c);
213
			lblName.setLayoutData(gridData);
209
			
214
			lblName.setText("Name:");
210
//			Label lblName = new Label(c, SWT.NONE);
215
	
211
//			final GridData gridData = new GridData();
216
			name = new Text(c, SWT.BORDER);
212
//			lblName.setLayoutData(gridData);
217
			name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
213
//			lblName.setText("Name:");
218
			name.addModifyListener(new ModifyListener() {
214
//	
219
	
215
//			name = new Text(c, SWT.BORDER);
220
				public void modifyText(ModifyEvent e) {
216
//			name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
221
					validatePage();
217
//			name.addModifyListener(new ModifyListener() {
222
				}
218
//	
223
	
219
//				public void modifyText(ModifyEvent e) {
224
			});
220
//					validatePage();
221
//				}
222
//	
223
//			});
225
		}
224
		}
226
225
227
		SashForm sashForm = new SashForm(c, SWT.VERTICAL);
226
		SashForm sashForm = new SashForm(c, SWT.VERTICAL);
Lines 277-287 Link Here
277
		{
276
		{
278
			SashForm cc = new SashForm(sashForm, SWT.NONE);
277
			SashForm cc = new SashForm(sashForm, SWT.NONE);
279
278
280
			ISelectionChangedListener selectionChangeListener = new ISelectionChangedListener() {
279
//			ISelectionChangedListener selectionChangeListener = new ISelectionChangedListener() {
281
				public void selectionChanged(SelectionChangedEvent event) {
280
//				public void selectionChanged(SelectionChangedEvent event) {
282
					validatePage();
281
//					validatePage();
283
				}
282
//				}
284
			};
283
//			};
285
284
286
			{
285
			{
287
				Composite comp = new Composite(cc, SWT.NONE);
286
				Composite comp = new Composite(cc, SWT.NONE);
Lines 326-333 Link Here
326
325
327
				});
326
				});
328
327
329
				issueType.addSelectionChangedListener(selectionChangeListener);
328
//				issueType.addSelectionChangedListener(selectionChangeListener);
330
331
				issueType.setInput(server);
329
				issueType.setInput(server);
332
			}
330
			}
333
331
Lines 374-380 Link Here
374
372
375
				});
373
				});
376
374
377
				status.addSelectionChangedListener(selectionChangeListener);
375
//				status.addSelectionChangedListener(selectionChangeListener);
378
				status.setInput(server);
376
				status.setInput(server);
379
			}
377
			}
380
378
Lines 422-428 Link Here
422
420
423
				});
421
				});
424
422
425
				resolution.addSelectionChangedListener(selectionChangeListener);
423
//				resolution.addSelectionChangedListener(selectionChangeListener);
426
				resolution.setInput(server);
424
				resolution.setInput(server);
427
			}
425
			}
428
426
Lines 468-474 Link Here
468
					}
466
					}
469
467
470
				});
468
				});
471
				priority.addSelectionChangedListener(selectionChangeListener);
469
//				priority.addSelectionChangedListener(selectionChangeListener);
472
				priority.setInput(server);
470
				priority.setInput(server);
473
			}
471
			}
474
472
Lines 483-506 Link Here
483
		queryString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
481
		queryString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
484
		// TODO put content assist here and a label describing what is available
482
		// TODO put content assist here and a label describing what is available
485
483
486
		queryString.addFocusListener(new FocusAdapter() {
484
//		queryString.addFocusListener(new FocusAdapter() {
487
485
//
488
			public void focusLost(FocusEvent e) {
486
//			public void focusLost(FocusEvent e) {
489
				validatePage();
487
//				validatePage();
490
			}
488
//			}
491
489
//
492
		});
490
//		});
493
491
494
		Label lblFields = new Label(c, SWT.NONE);
492
		Label lblFields = new Label(c, SWT.NONE);
495
		lblFields.setText("Fields:");
493
		lblFields.setText("Fields:");
496
		lblFields.setLayoutData(new GridData());
494
		lblFields.setLayoutData(new GridData());
497
495
498
		{
496
		{
499
			SelectionAdapter selectionAdapter = new SelectionAdapter() {
497
//			SelectionAdapter selectionAdapter = new SelectionAdapter() {
500
				public void widgetSelected(SelectionEvent e) {
498
//				public void widgetSelected(SelectionEvent e) {
501
					validatePage();
499
//					validatePage();
502
				}
500
//				}
503
			};
501
//			};
504
502
505
			Composite comp = new Composite(c, SWT.NONE);
503
			Composite comp = new Composite(c, SWT.NONE);
506
			comp.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
504
			comp.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
Lines 508-526 Link Here
508
506
509
			searchSummary = new Button(comp, SWT.CHECK);
507
			searchSummary = new Button(comp, SWT.CHECK);
510
			searchSummary.setText("Summary");
508
			searchSummary.setText("Summary");
511
			searchSummary.addSelectionListener(selectionAdapter);
509
//			searchSummary.addSelectionListener(selectionAdapter);
512
510
513
			searchDescription = new Button(comp, SWT.CHECK);
511
			searchDescription = new Button(comp, SWT.CHECK);
514
			searchDescription.setText("Description");
512
			searchDescription.setText("Description");
515
			searchDescription.addSelectionListener(selectionAdapter);
513
//			searchDescription.addSelectionListener(selectionAdapter);
516
514
517
			searchComments = new Button(comp, SWT.CHECK);
515
			searchComments = new Button(comp, SWT.CHECK);
518
			searchComments.setText("Comments");
516
			searchComments.setText("Comments");
519
			searchComments.addSelectionListener(selectionAdapter);
517
//			searchComments.addSelectionListener(selectionAdapter);
520
518
521
			searchEnvironment = new Button(comp, SWT.CHECK);
519
			searchEnvironment = new Button(comp, SWT.CHECK);
522
			searchEnvironment.setText("Environment");
520
			searchEnvironment.setText("Environment");
523
			searchEnvironment.addSelectionListener(selectionAdapter);
521
//			searchEnvironment.addSelectionListener(selectionAdapter);
524
		}
522
		}
525
523
526
		{
524
		{
Lines 559-571 Link Here
559
			reporter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
557
			reporter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
560
			reporter.setEnabled(false);
558
			reporter.setEnabled(false);
561
559
562
			reporter.addModifyListener(new ModifyListener() {
560
//			reporter.addModifyListener(new ModifyListener() {
563
561
//
564
				public void modifyText(ModifyEvent e) {
562
//				public void modifyText(ModifyEvent e) {
565
					validatePage();
563
//					validatePage();
566
				}
564
//				}
567
565
//
568
			});
566
//			});
569
		}
567
		}
570
568
571
		{
569
		{
Lines 600-632 Link Here
600
598
601
			});
599
			});
602
600
603
			assigneeType.addSelectionChangedListener(new ISelectionChangedListener() {
601
//			assigneeType.addSelectionChangedListener(new ISelectionChangedListener() {
604
602
//
605
				public void selectionChanged(SelectionChangedEvent event) {
603
//				public void selectionChanged(SelectionChangedEvent event) {
606
					Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
604
//					Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
607
					if (SPECIFIC_USER_ASSIGNEE.equals(selection) || SPECIFIC_GROUP_ASSIGNEE.equals(selection)) {
605
//					if (SPECIFIC_USER_ASSIGNEE.equals(selection) || SPECIFIC_GROUP_ASSIGNEE.equals(selection)) {
608
						assignee.setEnabled(true);
606
//						assignee.setEnabled(true);
609
					} else {
607
//					} else {
610
						assignee.setEnabled(false);
608
//						assignee.setEnabled(false);
611
						assignee.setText(""); //$NON-NLS-1$
609
//						assignee.setText(""); //$NON-NLS-1$
612
					}
610
//					}
613
					validatePage();
611
//					validatePage();
614
				}
612
//				}
615
613
//
616
			});
614
//			});
617
615
618
			assigneeType.setInput(server);
616
			assigneeType.setInput(server);
619
617
620
			assignee = new Text(c, SWT.BORDER);
618
			assignee = new Text(c, SWT.BORDER);
621
			assignee.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
619
			assignee.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
622
			assignee.setEnabled(false);
620
			assignee.setEnabled(false);
623
			assignee.addModifyListener(new ModifyListener() {
621
//			assignee.addModifyListener(new ModifyListener() {
624
622
//
625
				public void modifyText(ModifyEvent e) {
623
//				public void modifyText(ModifyEvent e) {
626
					validatePage();
624
//					validatePage();
627
				}
625
//				}
628
626
//
629
			});
627
//			});
630
		}
628
		}
631
629
632
		{
630
		{
Lines 851-857 Link Here
851
				}
849
				}
852
850
853
				updateCurrentProject(selectedProject);
851
				updateCurrentProject(selectedProject);
854
				validatePage();
852
//				validatePage();
855
			}
853
			}
856
854
857
		});
855
		});
Lines 864-879 Link Here
864
862
865
	}
863
	}
866
864
867
	void validatePage() {
865
//	void validatePage() {
868
		if (namedQuery && name.getText().length() == 0) {
866
//		if (namedQuery && !isPageComplete()) {
869
			setErrorMessage("Name is mandatory");
867
//			setPageComplete(false);
870
			setPageComplete(false);
868
//			return;
871
			return;
869
//		}
872
		}
870
//
873
871
//		setPageComplete(true);
874
		setErrorMessage(null);
872
//	}
875
		setPageComplete(true);
876
	}
877
873
878
	private void loadFromDefaults() {
874
	private void loadFromDefaults() {
879
		project.setSelection(new StructuredSelection(new Placeholder("All Projects")));
875
		project.setSelection(new StructuredSelection(new Placeholder("All Projects")));
Lines 889-900 Link Here
889
	}
885
	}
890
886
891
	private void loadFromWorkingCopy() {
887
	private void loadFromWorkingCopy() {
892
		if (namedQuery && workingCopy.getName() != null) {
888
//		if (namedQuery && workingCopy.getName() != null) {
893
			name.setText(workingCopy.getName());
889
//			name.setText(workingCopy.getName());
894
		}
890
//		}
895
896
		if (workingCopy.getDescription() != null) {
897
		}
898
891
899
		if (workingCopy.getProjectFilter() != null) {
892
		if (workingCopy.getProjectFilter() != null) {
900
			project.setSelection(new StructuredSelection(workingCopy.getProjectFilter().getProject()));
893
			project.setSelection(new StructuredSelection(workingCopy.getProjectFilter().getProject()));
Lines 1040-1046 Link Here
1040
1033
1041
	void applyChanges() {
1034
	void applyChanges() {
1042
		if (namedQuery) {
1035
		if (namedQuery) {
1043
			workingCopy.setName(this.name.getText());
1036
			workingCopy.setName(getQueryTitle());
1044
		}
1037
		}
1045
		if (this.queryString.getText().length() > 0 || this.searchSummary.getSelection()
1038
		if (this.queryString.getText().length() > 0 || this.searchSummary.getSelection()
1046
				|| this.searchDescription.getSelection() || this.searchEnvironment.getSelection()
1039
				|| this.searchDescription.getSelection() || this.searchEnvironment.getSelection()
Lines 1431-1436 Link Here
1431
			server.addLocalFilter(workingCopy);
1424
			server.addLocalFilter(workingCopy);
1432
		}
1425
		}
1433
1426
1434
		return new JiraCustomQuery(repository.getUrl(), workingCopy, TasksUiPlugin.getTaskListManager().getTaskList());
1427
		String url = repository.getUrl();
1428
		return new JiraCustomQuery(url, workingCopy, TasksUiPlugin.getTaskListManager().getTaskList(), 
1429
				TasksUiPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.REPOSITORY_KIND, url));
1435
	}
1430
	}
1436
}
1431
}
(-)src/org/eclipse/mylar/internal/jira/ui/wizards/JiraQueryWizardPage.java (-1 / +1 lines)
Lines 161-167 Link Here
161
				isNew = true;
161
				isNew = true;
162
			}
162
			}
163
163
164
			filterSummaryPage = new JiraQueryPage(repository, workingCopy, isNew);
164
			filterSummaryPage = new JiraQueryPage(repository, workingCopy, isNew, true);
165
			filterSummaryPage.setWizard(getWizard());
165
			filterSummaryPage.setWizard(getWizard());
166
		}
166
		}
167
		return filterSummaryPage;
167
		return filterSummaryPage;

Return to bug 139312