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

Collapse All | Expand All

(-)src/org/eclipse/mylar/internal/jira/ui/wizards/FilterSummaryPage.java (-96 / +746 lines)
Lines 12-20 Link Here
12
package org.eclipse.mylar.internal.jira.ui.wizards;
12
package org.eclipse.mylar.internal.jira.ui.wizards;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Calendar;
15
import java.util.Iterator;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
18
19
import org.eclipse.jface.viewers.ComboViewer;
18
import org.eclipse.jface.viewers.IColorProvider;
20
import org.eclipse.jface.viewers.IColorProvider;
19
import org.eclipse.jface.viewers.ILabelProvider;
21
import org.eclipse.jface.viewers.ILabelProvider;
20
import org.eclipse.jface.viewers.ILabelProviderListener;
22
import org.eclipse.jface.viewers.ILabelProviderListener;
Lines 26-35 Link Here
26
import org.eclipse.jface.viewers.SelectionChangedEvent;
28
import org.eclipse.jface.viewers.SelectionChangedEvent;
27
import org.eclipse.jface.viewers.StructuredSelection;
29
import org.eclipse.jface.viewers.StructuredSelection;
28
import org.eclipse.jface.viewers.Viewer;
30
import org.eclipse.jface.viewers.Viewer;
29
import org.eclipse.jface.wizard.IWizardPage;
30
import org.eclipse.jface.wizard.WizardPage;
31
import org.eclipse.jface.wizard.WizardPage;
31
import org.eclipse.mylar.internal.jira.JiraCustomQuery;
32
import org.eclipse.mylar.internal.jira.JiraCustomQuery;
32
import org.eclipse.mylar.internal.jira.JiraServerFacade;
33
import org.eclipse.mylar.internal.jira.JiraServerFacade;
34
import org.eclipse.mylar.internal.tasks.ui.views.DatePicker;
33
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
35
import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery;
34
import org.eclipse.mylar.tasks.core.TaskRepository;
36
import org.eclipse.mylar.tasks.core.TaskRepository;
35
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
37
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
Lines 43-48 Link Here
43
import org.eclipse.swt.events.SelectionEvent;
45
import org.eclipse.swt.events.SelectionEvent;
44
import org.eclipse.swt.graphics.Color;
46
import org.eclipse.swt.graphics.Color;
45
import org.eclipse.swt.graphics.Image;
47
import org.eclipse.swt.graphics.Image;
48
import org.eclipse.swt.layout.FillLayout;
46
import org.eclipse.swt.layout.GridData;
49
import org.eclipse.swt.layout.GridData;
47
import org.eclipse.swt.layout.GridLayout;
50
import org.eclipse.swt.layout.GridLayout;
48
import org.eclipse.swt.widgets.Button;
51
import org.eclipse.swt.widgets.Button;
Lines 51-62 Link Here
51
import org.eclipse.swt.widgets.Label;
54
import org.eclipse.swt.widgets.Label;
52
import org.eclipse.swt.widgets.Text;
55
import org.eclipse.swt.widgets.Text;
53
import org.tigris.jira.core.model.Component;
56
import org.tigris.jira.core.model.Component;
57
import org.tigris.jira.core.model.IssueType;
58
import org.tigris.jira.core.model.Priority;
54
import org.tigris.jira.core.model.Project;
59
import org.tigris.jira.core.model.Project;
60
import org.tigris.jira.core.model.Resolution;
61
import org.tigris.jira.core.model.Status;
55
import org.tigris.jira.core.model.Version;
62
import org.tigris.jira.core.model.Version;
56
import org.tigris.jira.core.model.filter.ComponentFilter;
63
import org.tigris.jira.core.model.filter.ComponentFilter;
57
import org.tigris.jira.core.model.filter.ContentFilter;
64
import org.tigris.jira.core.model.filter.ContentFilter;
65
import org.tigris.jira.core.model.filter.CurrentUserFilter;
66
import org.tigris.jira.core.model.filter.DateFilter;
67
import org.tigris.jira.core.model.filter.DateRangeFilter;
58
import org.tigris.jira.core.model.filter.FilterDefinition;
68
import org.tigris.jira.core.model.filter.FilterDefinition;
69
import org.tigris.jira.core.model.filter.IssueTypeFilter;
70
import org.tigris.jira.core.model.filter.NobodyFilter;
71
import org.tigris.jira.core.model.filter.PriorityFilter;
59
import org.tigris.jira.core.model.filter.ProjectFilter;
72
import org.tigris.jira.core.model.filter.ProjectFilter;
73
import org.tigris.jira.core.model.filter.ResolutionFilter;
74
import org.tigris.jira.core.model.filter.SpecificUserFilter;
75
import org.tigris.jira.core.model.filter.StatusFilter;
76
import org.tigris.jira.core.model.filter.UserFilter;
77
import org.tigris.jira.core.model.filter.UserInGroupFilter;
60
import org.tigris.jira.core.model.filter.VersionFilter;
78
import org.tigris.jira.core.model.filter.VersionFilter;
61
import org.tigris.jira.core.service.JiraServer;
79
import org.tigris.jira.core.service.JiraServer;
62
80
Lines 65-71 Link Here
65
 * @author Eugene Kuleshov (layout and other improvements)
83
 * @author Eugene Kuleshov (layout and other improvements)
66
 */
84
 */
67
public class FilterSummaryPage extends WizardPage {
85
public class FilterSummaryPage extends WizardPage {
68
86
	
69
	final Placeholder ANY_FIX_VERSION = new Placeholder("Any");
87
	final Placeholder ANY_FIX_VERSION = new Placeholder("Any");
70
88
71
	final Placeholder NO_FIX_VERSION = new Placeholder("No Fix Version");
89
	final Placeholder NO_FIX_VERSION = new Placeholder("No Fix Version");
Lines 82-89 Link Here
82
100
83
	final Placeholder NO_COMPONENT = new Placeholder("No Component");
101
	final Placeholder NO_COMPONENT = new Placeholder("No Component");
84
102
103
	// attributes
104
	
105
	final Placeholder ANY_ISSUE_TYPE = new Placeholder("Any");
106
107
	final Placeholder ANY_RESOLUTION = new Placeholder("Any");
108
109
	final Placeholder UNRESOLVED = new Placeholder("Unresolved");
110
111
	final Placeholder UNASSIGNED = new Placeholder("Unassigned");
112
113
	final Placeholder ANY_REPORTER = new Placeholder("Any");
114
115
	final Placeholder NO_REPORTER = new Placeholder("No Reporter");
116
117
	final Placeholder CURRENT_USER_REPORTER = new Placeholder("Current User");
118
119
	final Placeholder SPECIFIC_USER_REPORTER = new Placeholder("Specified User");
120
121
	final Placeholder SPECIFIC_GROUP_REPORTER = new Placeholder("Specified Group");
122
123
	final Placeholder ANY_ASSIGNEE = new Placeholder("Any");
124
125
	final Placeholder CURRENT_USER_ASSIGNEE = new Placeholder("Current User");
126
127
	final Placeholder SPECIFIC_USER_ASSIGNEE = new Placeholder("Specified User");
128
129
	final Placeholder SPECIFIC_GROUP_ASSIGNEE = new Placeholder("Specified Group");
130
131
	final Placeholder ANY_STATUS = new Placeholder("Any");
132
133
	final Placeholder ANY_PRIORITY = new Placeholder("Any");
134
135
	
85
	private final JiraServer server;
136
	private final JiraServer server;
86
137
138
	private Text name;
139
	
87
	private ListViewer project;
140
	private ListViewer project;
88
141
89
	private ListViewer reportedIn;
142
	private ListViewer reportedIn;
Lines 91-102 Link Here
91
	private ListViewer components;
144
	private ListViewer components;
92
145
93
	private ListViewer fixFor;
146
	private ListViewer fixFor;
147
	
148
	private ListViewer issueType;
149
	
150
	private ListViewer status;
151
	
152
	private ListViewer resolution;
153
	
154
	private ListViewer priority;
155
	
156
	private ComboViewer assigneeType;
94
157
95
	private final FilterDefinition workingCopy;
158
	private Text assignee;
96
159
97
	private Text name;
160
	private ComboViewer reporterType;
98
161
99
	private Text description;
162
	private Text reporter;
100
163
101
	private Text queryString;
164
	private Text queryString;
102
165
Lines 108-119 Link Here
108
171
109
	private Button searchEnvironment;
172
	private Button searchEnvironment;
110
173
111
	private final boolean isNew;
174
	private DatePicker dueStartDatePicker;
175
	
176
	private DatePicker dueEndDatePicker;
177
	
178
	private DatePicker updatedStartDatePicker;
179
	
180
	private DatePicker updatedEndDatePicker;
181
	
182
	private DatePicker createdStartDatePicker;
183
	
184
	private DatePicker createdEndDatePicker;
112
185
113
	private IssueAttributesPage issueAttributesPage;
186
	
187
	private final boolean isNew;
114
188
115
	private final TaskRepository repository;
189
	private final TaskRepository repository;
116
190
191
	private final FilterDefinition workingCopy;
192
193
194
	
117
	/**
195
	/**
118
	 * @param pageName
196
	 * @param pageName
119
	 * @param title
197
	 * @param title
Lines 132-138 Link Here
132
210
133
	public void createControl(Composite parent) {
211
	public void createControl(Composite parent) {
134
		Composite c = new Composite(parent, SWT.NONE);
212
		Composite c = new Composite(parent, SWT.NONE);
135
		c.setLayout(new GridLayout(5, false));
213
		c.setLayout(new GridLayout(3, false));
136
214
137
		Label lblName = new Label(c, SWT.NONE);
215
		Label lblName = new Label(c, SWT.NONE);
138
		final GridData gridData = new GridData();
216
		final GridData gridData = new GridData();
Lines 140-146 Link Here
140
		lblName.setText("Name:");
218
		lblName.setText("Name:");
141
219
142
		name = new Text(c, SWT.BORDER);
220
		name = new Text(c, SWT.BORDER);
143
		name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 4, 1));
221
		name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
144
		name.addModifyListener(new ModifyListener() {
222
		name.addModifyListener(new ModifyListener() {
145
223
146
			public void modifyText(ModifyEvent e) {
224
			public void modifyText(ModifyEvent e) {
Lines 149-185 Link Here
149
227
150
		});
228
		});
151
229
152
		if (!isNew) {
230
		SashForm sashForm = new SashForm(c, SWT.VERTICAL);
153
			name.setEnabled(false);
231
		sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1));
154
		}
155
156
		Label lblDescription = new Label(c, SWT.NONE);
157
		lblDescription.setText("Description:");
158
		lblDescription.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
159
160
		description = new Text(c, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
161
		GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false, 4, 1);
162
		gd.heightHint = 40;
163
		description.setLayoutData(gd);
164
		description.addFocusListener(new FocusAdapter() {
165
166
			public void focusLost(FocusEvent e) {
167
				validatePage();
168
			}
169
170
		});
171
232
172
		{
233
		{
173
			SashForm cc = new SashForm(c, SWT.HORIZONTAL);
234
			SashForm cc = new SashForm(sashForm, SWT.HORIZONTAL);
174
			cc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 5, 1));
175
235
176
			{
236
			{
177
				Composite comp = new Composite(cc, SWT.NONE);
237
				Composite comp = new Composite(cc, SWT.NONE);
178
				GridLayout gridLayout = new GridLayout(1, false);
238
				GridLayout gridLayout = new GridLayout(1, false);
179
				gridLayout.marginWidth = 0;
239
				gridLayout.marginWidth = 0;
180
				gridLayout.marginHeight = 0;
181
				comp.setLayout(gridLayout);
240
				comp.setLayout(gridLayout);
182
241
				
183
				Label label = new Label(comp, SWT.NONE);
242
				Label label = new Label(comp, SWT.NONE);
184
				label.setText("Project:");
243
				label.setText("Project:");
185
				createProjectsViewer(comp);
244
				createProjectsViewer(comp);
Lines 189-197 Link Here
189
				Composite comp = new Composite(cc, SWT.NONE);
248
				Composite comp = new Composite(cc, SWT.NONE);
190
				GridLayout gridLayout = new GridLayout(1, false);
249
				GridLayout gridLayout = new GridLayout(1, false);
191
				gridLayout.marginWidth = 0;
250
				gridLayout.marginWidth = 0;
192
				gridLayout.marginHeight = 0;
193
				comp.setLayout(gridLayout);
251
				comp.setLayout(gridLayout);
194
252
				
195
				new Label(comp, SWT.NONE).setText("Fix For:");
253
				new Label(comp, SWT.NONE).setText("Fix For:");
196
				createFixForViewer(comp);
254
				createFixForViewer(comp);
197
			}
255
			}
Lines 200-208 Link Here
200
				Composite comp = new Composite(cc, SWT.NONE);
258
				Composite comp = new Composite(cc, SWT.NONE);
201
				GridLayout gridLayout = new GridLayout(1, false);
259
				GridLayout gridLayout = new GridLayout(1, false);
202
				gridLayout.marginWidth = 0;
260
				gridLayout.marginWidth = 0;
203
				gridLayout.marginHeight = 0;
204
				comp.setLayout(gridLayout);
261
				comp.setLayout(gridLayout);
205
262
				
206
				new Label(comp, SWT.NONE).setText("In Components:");
263
				new Label(comp, SWT.NONE).setText("In Components:");
207
				createComponentsViewer(comp);
264
				createComponentsViewer(comp);
208
			}
265
			}
Lines 211-231 Link Here
211
				Composite comp = new Composite(cc, SWT.NONE);
268
				Composite comp = new Composite(cc, SWT.NONE);
212
				GridLayout gridLayout = new GridLayout(1, false);
269
				GridLayout gridLayout = new GridLayout(1, false);
213
				gridLayout.marginWidth = 0;
270
				gridLayout.marginWidth = 0;
214
				gridLayout.marginHeight = 0;
215
				comp.setLayout(gridLayout);
271
				comp.setLayout(gridLayout);
216
272
217
				Label label = new Label(comp, SWT.NONE);
273
				Label label = new Label(comp, SWT.NONE);
218
				label.setText("Reported In:");
274
				label.setText("Reported In:");
219
				createReportedInViewer(comp);
275
				createReportedInViewer(comp);
220
			}
276
			}
221
			// cc.setWeights(new int[] {1,1,1,1});
277
			cc.setWeights(new int[] {1,1,1,1});
278
		}
279
280
		{
281
			SashForm cc = new SashForm(sashForm, SWT.NONE);
282
283
			ISelectionChangedListener selectionChangeListener = new ISelectionChangedListener() {
284
				public void selectionChanged(SelectionChangedEvent event) {
285
					validatePage();
286
				}
287
			};
288
289
			{
290
				Composite comp = new Composite(cc, SWT.NONE);
291
				GridLayout gridLayout = new GridLayout();
292
				gridLayout.marginWidth = 0;
293
				comp.setLayout(gridLayout);
294
		
295
				Label typeLabel = new Label(comp, SWT.NONE);
296
				typeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
297
				typeLabel.setText("Type:");
298
		
299
				issueType = new ListViewer(comp, SWT.BORDER);
300
				issueType.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
301
				
302
				issueType.setContentProvider(new IStructuredContentProvider() {
303
304
					public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
305
					}
306
307
					public void dispose() {
308
					}
309
310
					public Object[] getElements(Object inputElement) {
311
						JiraServer server = (JiraServer) inputElement;
312
						Object[] elements = new Object[server.getIssueTypes().length + 1];
313
						elements[0] = ANY_ISSUE_TYPE;
314
						System.arraycopy(server.getIssueTypes(), 0, elements, 1, server.getIssueTypes().length);
315
316
						return elements;
317
					}
318
				});
319
320
				issueType.setLabelProvider(new LabelProvider() {
321
322
					public String getText(Object element) {
323
						if (element instanceof Placeholder) {
324
							return ((Placeholder) element).getText();
325
						}
326
327
						return ((IssueType) element).getName();
328
					}
329
330
				});
331
332
				issueType.addSelectionChangedListener(selectionChangeListener);
333
334
				issueType.setInput(server);
335
			}
336
	
337
			{
338
				Composite comp = new Composite(cc, SWT.NONE);
339
				GridLayout gridLayout = new GridLayout();
340
				gridLayout.marginWidth = 0;
341
				comp.setLayout(gridLayout);
342
		
343
				Label statusLabel = new Label(comp, SWT.NONE);
344
				statusLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
345
				statusLabel.setText("Status:");
346
		
347
				status = new ListViewer(comp, SWT.BORDER);
348
				status.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
349
				
350
				status.setContentProvider(new IStructuredContentProvider() {
351
352
					public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
353
					}
354
355
					public void dispose() {
356
					}
357
358
					public Object[] getElements(Object inputElement) {
359
						JiraServer server = (JiraServer) inputElement;
360
						Object[] elements = new Object[server.getStatuses().length + 1];
361
						elements[0] = ANY_STATUS;
362
						System.arraycopy(server.getStatuses(), 0, elements, 1, server.getStatuses().length);
363
364
						return elements;
365
					}
366
				});
367
368
				status.setLabelProvider(new LabelProvider() {
369
370
					public String getText(Object element) {
371
						if (element instanceof Placeholder) {
372
							return ((Placeholder) element).getText();
373
						}
374
375
						return ((Status) element).getName();
376
					}
377
378
				});
379
380
				status.addSelectionChangedListener(selectionChangeListener);
381
				status.setInput(server);
382
			}
383
	
384
			{
385
				Composite comp = new Composite(cc, SWT.NONE);
386
				GridLayout gridLayout = new GridLayout();
387
				gridLayout.marginWidth = 0;
388
				comp.setLayout(gridLayout);
389
		
390
				Label resolutionLabel = new Label(comp, SWT.NONE);
391
				resolutionLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
392
				resolutionLabel.setText("Resolution:");
393
		
394
				resolution = new ListViewer(comp, SWT.BORDER);
395
				resolution.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
396
397
				resolution.setContentProvider(new IStructuredContentProvider() {
398
399
					public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
400
					}
401
402
					public void dispose() {
403
					}
404
405
					public Object[] getElements(Object inputElement) {
406
						JiraServer server = (JiraServer) inputElement;
407
						Object[] elements = new Object[server.getResolutions().length + 2];
408
						elements[0] = ANY_RESOLUTION;
409
						elements[1] = UNRESOLVED;
410
						System.arraycopy(server.getResolutions(), 0, elements, 2, server.getResolutions().length);
411
412
						return elements;
413
					}
414
				});
415
416
				resolution.setLabelProvider(new LabelProvider() {
417
418
					public String getText(Object element) {
419
						if (element instanceof Placeholder) {
420
							return ((Placeholder) element).getText();
421
						}
422
423
						return ((Resolution) element).getName();
424
					}
425
426
				});
427
428
				resolution.addSelectionChangedListener(selectionChangeListener);
429
				resolution.setInput(server);
430
			}
431
	
432
			{
433
				Composite comp = new Composite(cc, SWT.NONE);
434
				GridLayout gridLayout = new GridLayout();
435
				gridLayout.marginWidth = 0;
436
				comp.setLayout(gridLayout);
437
		
438
				Label priorityLabel = new Label(comp, SWT.NONE);
439
				priorityLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
440
				priorityLabel.setText("Priority:");
441
		
442
				priority = new ListViewer(comp, SWT.BORDER);
443
				priority.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
444
445
				priority.setContentProvider(new IStructuredContentProvider() {
446
447
					public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
448
					}
449
450
					public void dispose() {
451
					}
452
453
					public Object[] getElements(Object inputElement) {
454
						JiraServer server = (JiraServer) inputElement;
455
						Object[] elements = new Object[server.getPriorities().length + 1];
456
						elements[0] = ANY_PRIORITY;
457
						System.arraycopy(server.getPriorities(), 0, elements, 1, server.getPriorities().length);
458
459
						return elements;
460
					}
461
				});
462
463
				priority.setLabelProvider(new LabelProvider() {
464
465
					public String getText(Object element) {
466
						if (element instanceof Placeholder) {
467
							return ((Placeholder) element).getText();
468
						}
469
470
						return ((Priority) element).getName();
471
					}
472
473
				});
474
				priority.addSelectionChangedListener(selectionChangeListener);
475
				priority.setInput(server);
476
			}
477
			
478
			cc.setWeights(new int[] {1, 1, 1, 1 });
222
		}
479
		}
480
		sashForm.setWeights(new int[] {1, 1 });
223
481
224
		Label lblQuery = new Label(c, SWT.NONE);
482
		Label lblQuery = new Label(c, SWT.NONE);
225
		lblQuery.setLayoutData(new GridData());
483
		lblQuery.setLayoutData(new GridData());
226
		lblQuery.setText("Query:");
484
		lblQuery.setText("Query:");
227
		queryString = new Text(c, SWT.BORDER);
485
		queryString = new Text(c, SWT.BORDER);
228
		queryString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 4, 1));
486
		queryString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
229
		// TODO put content assist here and a label describing what is available
487
		// TODO put content assist here and a label describing what is available
230
488
231
		queryString.addFocusListener(new FocusAdapter() {
489
		queryString.addFocusListener(new FocusAdapter() {
Lines 238-313 Link Here
238
496
239
		Label lblFields = new Label(c, SWT.NONE);
497
		Label lblFields = new Label(c, SWT.NONE);
240
		lblFields.setText("Fields:");
498
		lblFields.setText("Fields:");
241
		lblFields.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
499
		lblFields.setLayoutData(new GridData());
242
500
243
		searchSummary = new Button(c, SWT.CHECK);
501
		{
244
		searchSummary.setLayoutData(new GridData());
502
			SelectionAdapter selectionAdapter = new SelectionAdapter() {
245
		searchSummary.setText("Summary");
503
				public void widgetSelected(SelectionEvent e) {
246
		searchSummary.addSelectionListener(new SelectionAdapter() {
504
					validatePage();
505
				}
506
			};
247
507
248
			public void widgetSelected(SelectionEvent e) {
508
			Composite comp = new Composite(c, SWT.NONE);
249
				validatePage();
509
			comp.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
250
			}
510
			comp.setLayout(new FillLayout());
511
	
512
			searchSummary = new Button(comp, SWT.CHECK);
513
			searchSummary.setText("Summary");
514
			searchSummary.addSelectionListener(selectionAdapter);
515
	
516
			searchDescription = new Button(comp, SWT.CHECK);
517
			searchDescription.setText("Description");
518
			searchDescription.addSelectionListener(selectionAdapter);
519
	
520
			searchComments = new Button(comp, SWT.CHECK);
521
			searchComments.setText("Comments");
522
			searchComments.addSelectionListener(selectionAdapter);
523
	
524
			searchEnvironment = new Button(comp, SWT.CHECK);
525
			searchEnvironment.setText("Environment");
526
			searchEnvironment.addSelectionListener(selectionAdapter);
527
		}
528
		
529
		{
530
			Label reportedByLabel = new Label(c, SWT.NONE);
531
			reportedByLabel.setText("Reported By:");
251
532
252
		});
533
			reporterType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY);
534
			GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER, false, false);
535
			gridData_1.widthHint = 133;
536
			reporterType.getControl().setLayoutData(gridData_1);
537
	
538
			reporterType.setContentProvider(new IStructuredContentProvider() {
539
	
540
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
541
				}
542
	
543
				public void dispose() {
544
				}
545
	
546
				public Object[] getElements(Object inputElement) {
547
					return new Object[] { ANY_REPORTER, NO_REPORTER, CURRENT_USER_REPORTER, SPECIFIC_USER_REPORTER,
548
							SPECIFIC_GROUP_REPORTER };
549
				}
550
	
551
			});
552
	
553
			reporterType.setLabelProvider(new LabelProvider() {
554
				public String getText(Object element) {
555
					return ((Placeholder) element).getText();
556
				}
557
			});
558
	
559
			reporterType.setInput(server);
560
			
561
			reporter = new Text(c, SWT.BORDER);
562
			reporter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
563
			reporter.setEnabled(false);
564
			
565
			reporter.addModifyListener(new ModifyListener() {
253
566
254
		searchDescription = new Button(c, SWT.CHECK);
567
				public void modifyText(ModifyEvent e) {
255
		searchDescription.setLayoutData(new GridData());
568
					validatePage();
256
		searchDescription.setText("Description");
569
				}
257
		searchDescription.addSelectionListener(new SelectionAdapter() {
258
570
259
			public void widgetSelected(SelectionEvent e) {
571
			});
260
				validatePage();
572
		}
261
			}
262
573
263
		});
574
		{
575
			Label assignedToLabel = new Label(c, SWT.NONE);
576
			assignedToLabel.setText("Assigned To:");
577
	
578
			assigneeType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY);
579
			GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER, false, false);
580
			gridData_2.widthHint = 133;
581
			assigneeType.getCombo().setLayoutData(gridData_2);
582
	
583
			assigneeType.setContentProvider(new IStructuredContentProvider() {
264
584
265
		searchComments = new Button(c, SWT.CHECK);
585
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
266
		searchComments.setLayoutData(new GridData());
586
				}
267
		searchComments.setText("Comments");
268
		searchComments.addSelectionListener(new SelectionAdapter() {
269
587
270
			public void widgetSelected(SelectionEvent e) {
588
				public void dispose() {
271
				validatePage();
589
				}
272
			}
273
590
274
		});
591
				public Object[] getElements(Object inputElement) {
592
					return new Object[] { ANY_ASSIGNEE, UNASSIGNED, CURRENT_USER_ASSIGNEE, SPECIFIC_USER_ASSIGNEE,
593
							SPECIFIC_GROUP_ASSIGNEE };
594
				}
275
595
276
		searchEnvironment = new Button(c, SWT.CHECK);
596
			});
277
		searchEnvironment.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
278
		searchEnvironment.setText("Environment");
279
		searchEnvironment.addSelectionListener(new SelectionAdapter() {
280
597
281
			public void widgetSelected(SelectionEvent e) {
598
			assigneeType.setLabelProvider(new LabelProvider() {
282
				validatePage();
283
			}
284
599
285
		});
600
				public String getText(Object element) {
601
					return ((Placeholder) element).getText();
602
				}
603
604
			});
605
606
			assigneeType.addSelectionChangedListener(new ISelectionChangedListener() {
607
608
				public void selectionChanged(SelectionChangedEvent event) {
609
					Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
610
					if (SPECIFIC_USER_ASSIGNEE.equals(selection) || SPECIFIC_GROUP_ASSIGNEE.equals(selection)) {
611
						assignee.setEnabled(true);
612
					} else {
613
						assignee.setEnabled(false);
614
						assignee.setText(""); //$NON-NLS-1$
615
					}
616
					validatePage();
617
				}
618
619
			});
620
621
			assigneeType.setInput(server);
622
			
623
			assignee = new Text(c, SWT.BORDER);
624
			assignee.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
625
			assignee.setEnabled(false);
626
			assignee.addModifyListener(new ModifyListener() {
627
628
				public void modifyText(ModifyEvent e) {
629
					validatePage();
630
				}
631
632
			});
633
		}
634
		
635
		{
636
			Label createdLabel = new Label(c, SWT.NONE);
637
			createdLabel.setText("Created:");
638
639
			Composite composite = new Composite(c, SWT.NONE);
640
			FillLayout fillLayout = new FillLayout();
641
			fillLayout.spacing = 5;
642
			composite.setLayout(fillLayout);
643
			composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
644
645
			createdStartDatePicker = new DatePicker(composite, SWT.BORDER, "<start date>");
646
			createdEndDatePicker = new DatePicker(composite, SWT.BORDER, "<end date>");
647
		}
648
		
649
		{
650
			Label updatedLabel = new Label(c, SWT.NONE);
651
			updatedLabel.setText("Updated:");
652
653
			Composite composite = new Composite(c, SWT.NONE);
654
			FillLayout fillLayout = new FillLayout();
655
			fillLayout.spacing = 5;
656
			composite.setLayout(fillLayout);
657
			composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
658
	
659
			updatedStartDatePicker = new DatePicker(composite, SWT.BORDER, "<start date>");
660
			updatedEndDatePicker = new DatePicker(composite, SWT.BORDER, "<end date>");
661
		}
286
662
287
		// Need to turn off validation here
663
		{
664
			Label dueDateLabel = new Label(c, SWT.NONE);
665
			dueDateLabel.setText("Due Date:");
666
			
667
			Composite composite = new Composite(c, SWT.NONE);
668
			FillLayout fillLayout = new FillLayout();
669
			fillLayout.spacing = 5;
670
			composite.setLayout(fillLayout);
671
			composite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
672
673
			dueStartDatePicker = new DatePicker(composite, SWT.BORDER, "<start date>");
674
			dueEndDatePicker = new DatePicker(composite, SWT.BORDER, "<end date>");
675
		}
676
		
677
		//new FillLayout()f validation here
288
		if (isNew) {
678
		if (isNew) {
289
			loadFromDefaults();
679
			loadFromDefaults();
290
		} else {
680
		} else {
291
			loadFromWorkingCopy();
681
			loadFromWorkingCopy();
292
		}
682
		}
293
683
		
294
		setControl(c);
684
		setControl(c);
295
	}
685
	}
296
686
297
	public IWizardPage getNextPage() {
298
		if (issueAttributesPage == null) {
299
			issueAttributesPage = new IssueAttributesPage(repository, workingCopy, isNew);
300
			issueAttributesPage.setWizard(getWizard());
301
		}
302
303
		return issueAttributesPage;
304
	}
305
306
	private void createReportedInViewer(Composite c) {
687
	private void createReportedInViewer(Composite c) {
307
		reportedIn = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
688
		reportedIn = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
308
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
689
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
309
		gridData.heightHint = 200;
690
		gridData.heightHint = 55;
310
		gridData.widthHint = 80;
691
		gridData.widthHint = 90;
311
		reportedIn.getControl().setLayoutData(gridData);
692
		reportedIn.getControl().setLayoutData(gridData);
312
693
313
		reportedIn.setContentProvider(new IStructuredContentProvider() {
694
		reportedIn.setContentProvider(new IStructuredContentProvider() {
Lines 349-356 Link Here
349
	private void createComponentsViewer(Composite c) {
730
	private void createComponentsViewer(Composite c) {
350
		components = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
731
		components = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
351
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
732
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
352
		gridData.heightHint = 200;
733
		gridData.heightHint = 63;
353
		gridData.widthHint = 80;
734
		gridData.widthHint = 90;
354
		components.getControl().setLayoutData(gridData);
735
		components.getControl().setLayoutData(gridData);
355
736
356
		components.setContentProvider(new IStructuredContentProvider() {
737
		components.setContentProvider(new IStructuredContentProvider() {
Lines 384-391 Link Here
384
	private void createFixForViewer(Composite c) {
765
	private void createFixForViewer(Composite c) {
385
		fixFor = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
766
		fixFor = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
386
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
767
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
387
		gridData.heightHint = 200;
768
		gridData.heightHint = 57;
388
		gridData.widthHint = 80;
769
		gridData.widthHint = 90;
389
		fixFor.getControl().setLayoutData(gridData);
770
		fixFor.getControl().setLayoutData(gridData);
390
771
391
		fixFor.setContentProvider(new IStructuredContentProvider() {
772
		fixFor.setContentProvider(new IStructuredContentProvider() {
Lines 427-436 Link Here
427
	private void createProjectsViewer(Composite c) {
808
	private void createProjectsViewer(Composite c) {
428
		project = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
809
		project = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL);
429
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
810
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
430
		gridData.heightHint = 200;
811
		gridData.heightHint = 59;
431
		gridData.widthHint = 120;
812
		gridData.widthHint = 90;
432
		project.getControl().setLayoutData(gridData);
813
		project.getControl().setLayoutData(gridData);
433
814
		
434
		project.setContentProvider(new IStructuredContentProvider() {
815
		project.setContentProvider(new IStructuredContentProvider() {
435
816
436
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
817
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
Lines 501-506 Link Here
501
		project.setSelection(new StructuredSelection(new Placeholder("All Projects")));
882
		project.setSelection(new StructuredSelection(new Placeholder("All Projects")));
502
		searchSummary.setSelection(true);
883
		searchSummary.setSelection(true);
503
		searchDescription.setSelection(true);
884
		searchDescription.setSelection(true);
885
		
886
		issueType.setSelection(new StructuredSelection(ANY_ISSUE_TYPE));
887
		reporterType.setSelection(new StructuredSelection(ANY_REPORTER));
888
		assigneeType.setSelection(new StructuredSelection(ANY_ASSIGNEE));
889
		status.setSelection(new StructuredSelection(ANY_STATUS));
890
		resolution.setSelection(new StructuredSelection(ANY_RESOLUTION));
891
		priority.setSelection(new StructuredSelection(ANY_PRIORITY));
504
	}
892
	}
505
893
506
	private void loadFromWorkingCopy() {
894
	private void loadFromWorkingCopy() {
Lines 509-515 Link Here
509
		}
897
		}
510
898
511
		if (workingCopy.getDescription() != null) {
899
		if (workingCopy.getDescription() != null) {
512
			description.setText(workingCopy.getDescription());
513
		}
900
		}
514
901
515
		if (workingCopy.getProjectFilter() != null) {
902
		if (workingCopy.getProjectFilter() != null) {
Lines 570-580 Link Here
570
		} else {
957
		} else {
571
			components.setSelection(new StructuredSelection(ANY_COMPONENT));
958
			components.setSelection(new StructuredSelection(ANY_COMPONENT));
572
		}
959
		}
960
961
	    // attributes
962
		
963
		if (workingCopy.getIssueTypeFilter() != null) {
964
			issueType.setSelection(new StructuredSelection(workingCopy.getIssueTypeFilter().getIsueTypes()));
965
		} else {
966
			issueType.setSelection(new StructuredSelection(ANY_ISSUE_TYPE));
967
		}
968
969
		if (workingCopy.getReportedByFilter() != null) {
970
			UserFilter reportedByFilter = workingCopy.getReportedByFilter();
971
			if (reportedByFilter instanceof NobodyFilter) {
972
				reporterType.setSelection(new StructuredSelection(NO_REPORTER));
973
			} else if (reportedByFilter instanceof CurrentUserFilter) {
974
				reporterType.setSelection(new StructuredSelection(CURRENT_USER_REPORTER));
975
			} else if (reportedByFilter instanceof SpecificUserFilter) {
976
				reporterType.setSelection(new StructuredSelection(SPECIFIC_USER_REPORTER));
977
				reporter.setText(((SpecificUserFilter) reportedByFilter).getUser());
978
			} else if (reportedByFilter instanceof UserInGroupFilter) {
979
				reporterType.setSelection(new StructuredSelection(SPECIFIC_GROUP_REPORTER));
980
				reporter.setText(((UserInGroupFilter) reportedByFilter).getGroup());
981
			}
982
		} else {
983
			reporterType.setSelection(new StructuredSelection(ANY_REPORTER));
984
		}
985
986
		if (workingCopy.getAssignedToFilter() != null) {
987
			UserFilter assignedToFilter = workingCopy.getAssignedToFilter();
988
			if (assignedToFilter instanceof NobodyFilter) {
989
				assigneeType.setSelection(new StructuredSelection(UNASSIGNED));
990
			} else if (assignedToFilter instanceof CurrentUserFilter) {
991
				assigneeType.setSelection(new StructuredSelection(CURRENT_USER_ASSIGNEE));
992
			} else if (assignedToFilter instanceof SpecificUserFilter) {
993
				assigneeType.setSelection(new StructuredSelection(SPECIFIC_USER_ASSIGNEE));
994
				assignee.setText(((SpecificUserFilter) assignedToFilter).getUser());
995
			} else if (assignedToFilter instanceof UserInGroupFilter) {
996
				assigneeType.setSelection(new StructuredSelection(SPECIFIC_GROUP_ASSIGNEE));
997
				assignee.setText(((UserInGroupFilter) assignedToFilter).getGroup());
998
			}
999
		} else {
1000
			assigneeType.setSelection(new StructuredSelection(ANY_ASSIGNEE));
1001
		}
1002
1003
		if (workingCopy.getStatusFilter() != null) {
1004
			status.setSelection(new StructuredSelection(workingCopy.getStatusFilter().getStatuses()));
1005
		} else {
1006
			status.setSelection(new StructuredSelection(ANY_STATUS));
1007
		}
1008
1009
		if (workingCopy.getResolutionFilter() != null) {
1010
			Resolution[] resolutions = workingCopy.getResolutionFilter().getResolutions();
1011
			if(resolutions.length==0) {
1012
				resolution.setSelection(new StructuredSelection(UNRESOLVED));
1013
			} else {
1014
				resolution.setSelection(new StructuredSelection(resolutions));
1015
			}
1016
		} else {
1017
			resolution.setSelection(new StructuredSelection(ANY_RESOLUTION));
1018
		}
1019
1020
		if (workingCopy.getPriorityFilter() != null) {
1021
			priority.setSelection(new StructuredSelection(workingCopy.getPriorityFilter().getPriorities()));
1022
		} else {
1023
			priority.setSelection(new StructuredSelection(ANY_PRIORITY));
1024
		}
1025
		
1026
		setDateRange(workingCopy.getCreatedDateFilter(), createdStartDatePicker, createdEndDatePicker);
1027
		setDateRange(workingCopy.getUpdatedDateFilter(), updatedStartDatePicker, updatedEndDatePicker);
1028
		setDateRange(workingCopy.getDueDateFilter(), dueStartDatePicker, dueEndDatePicker);
1029
	}
1030
1031
	private void setDateRange(DateFilter dateFilter, DatePicker startDatePicker, DatePicker endDatePicker) {
1032
		if(dateFilter instanceof DateRangeFilter) {
1033
			DateRangeFilter rangeFilter = (DateRangeFilter) dateFilter;
1034
			Calendar c1 = Calendar.getInstance();
1035
			c1.setTime(rangeFilter.getFromDate());
1036
			startDatePicker.setDate(c1);
1037
			
1038
			Calendar c2 = Calendar.getInstance();
1039
			c2.setTime(rangeFilter.getToDate());
1040
			endDatePicker.setDate(c2);
1041
		}
573
	}
1042
	}
574
1043
575
	/* default */void applyChanges() {
1044
	/* default */void applyChanges() {
576
		workingCopy.setName(this.name.getText());
1045
		workingCopy.setName(this.name.getText());
577
		workingCopy.setDescription(this.description.getText());
578
		if (this.queryString.getText().length() > 0 || this.searchSummary.getSelection()
1046
		if (this.queryString.getText().length() > 0 || this.searchSummary.getSelection()
579
				|| this.searchDescription.getSelection() || this.searchEnvironment.getSelection()
1047
				|| this.searchDescription.getSelection() || this.searchEnvironment.getSelection()
580
				|| this.searchComments.getSelection()) {
1048
				|| this.searchComments.getSelection()) {
Lines 705-710 Link Here
705
				workingCopy.setComponentFilter(null);
1173
				workingCopy.setComponentFilter(null);
706
			}
1174
			}
707
		}
1175
		}
1176
		
1177
		// attributes
1178
		
1179
		// TODO support standard and subtask issue types
1180
		IStructuredSelection issueTypeSelection = (IStructuredSelection) issueType.getSelection();
1181
		if (issueTypeSelection.isEmpty()) {
1182
			workingCopy.setIssueTypeFilter(null);
1183
		} else {
1184
			boolean isAnyIssueTypeSelected = false;
1185
1186
			List<IssueType> selectedIssueTypes = new ArrayList<IssueType>();
1187
1188
			for (Iterator i = issueTypeSelection.iterator(); i.hasNext();) {
1189
				Object selection = i.next();
1190
				if (ANY_ISSUE_TYPE.equals(selection)) {
1191
					isAnyIssueTypeSelected = true;
1192
				} else if (selection instanceof IssueType) {
1193
					selectedIssueTypes.add((IssueType) selection);
1194
				}
1195
			}
1196
1197
			if (isAnyIssueTypeSelected) {
1198
				workingCopy.setIssueTypeFilter(null);
1199
			} else {
1200
				workingCopy.setIssueTypeFilter(
1201
					new IssueTypeFilter(selectedIssueTypes.toArray(new IssueType[selectedIssueTypes.size()])));
1202
			}
1203
		}
1204
1205
		IStructuredSelection reporterSelection = (IStructuredSelection) reporterType.getSelection();
1206
		if (reporterSelection.isEmpty()) {
1207
			workingCopy.setReportedByFilter(null);
1208
		} else {
1209
			if (ANY_REPORTER.equals(reporterSelection.getFirstElement())) {
1210
				workingCopy.setReportedByFilter(null);
1211
			} else if (NO_REPORTER.equals(reporterSelection.getFirstElement())) {
1212
				workingCopy.setReportedByFilter(new NobodyFilter());
1213
			} else if (CURRENT_USER_REPORTER.equals(reporterSelection.getFirstElement())) {
1214
				workingCopy.setReportedByFilter(new CurrentUserFilter());
1215
			} else if (SPECIFIC_GROUP_REPORTER.equals(reporterSelection.getFirstElement())) {
1216
				workingCopy.setReportedByFilter(new UserInGroupFilter(reporter.getText()));
1217
			} else if (SPECIFIC_USER_REPORTER.equals(reporterSelection.getFirstElement())) {
1218
				workingCopy.setReportedByFilter(new SpecificUserFilter(reporter.getText()));
1219
			} else {
1220
				workingCopy.setReportedByFilter(null);
1221
			}
1222
		}
1223
1224
		IStructuredSelection assigneeSelection = (IStructuredSelection) assigneeType.getSelection();
1225
		if (assigneeSelection.isEmpty()) {
1226
			workingCopy.setAssignedToFilter(null);
1227
		} else {
1228
			if (ANY_REPORTER.equals(assigneeSelection.getFirstElement())) {
1229
				workingCopy.setAssignedToFilter(null);
1230
			} else if (UNASSIGNED.equals(assigneeSelection.getFirstElement())) {
1231
				workingCopy.setAssignedToFilter(new NobodyFilter());
1232
			} else if (CURRENT_USER_REPORTER.equals(assigneeSelection.getFirstElement())) {
1233
				workingCopy.setAssignedToFilter(new CurrentUserFilter());
1234
			} else if (SPECIFIC_GROUP_REPORTER.equals(assigneeSelection.getFirstElement())) {
1235
				workingCopy.setAssignedToFilter(new UserInGroupFilter(assignee.getText()));
1236
			} else if (SPECIFIC_USER_REPORTER.equals(assigneeSelection.getFirstElement())) {
1237
				workingCopy.setAssignedToFilter(new SpecificUserFilter(assignee.getText()));
1238
			} else {
1239
				workingCopy.setAssignedToFilter(null);
1240
			}
1241
		}
1242
1243
		IStructuredSelection statusSelection = (IStructuredSelection) status.getSelection();
1244
		if (statusSelection.isEmpty()) {
1245
			workingCopy.setStatusFilter(null);
1246
		} else {
1247
			boolean isAnyStatusSelected = false;
1248
1249
			List<Status> selectedStatuses = new ArrayList<Status>();
1250
1251
			for (Iterator i = statusSelection.iterator(); i.hasNext();) {
1252
				Object selection = i.next();
1253
				if (ANY_STATUS.equals(selection)) {
1254
					isAnyStatusSelected = true;
1255
				} else if (selection instanceof Status) {
1256
					selectedStatuses.add((Status) selection);
1257
				}
1258
			}
1259
1260
			if (isAnyStatusSelected) {
1261
				workingCopy.setStatusFilter(null);
1262
			} else {
1263
				workingCopy.setStatusFilter(
1264
					new StatusFilter(selectedStatuses.toArray(new Status[selectedStatuses.size()])));
1265
			}
1266
		}
1267
1268
		IStructuredSelection resolutionSelection = (IStructuredSelection) resolution.getSelection();
1269
		if (resolutionSelection.isEmpty()) {
1270
			workingCopy.setResolutionFilter(null);
1271
		} else {
1272
			boolean isAnyResolutionSelected = false;
1273
1274
			List<Resolution> selectedResolutions = new ArrayList<Resolution>();
1275
1276
			for (Iterator i = resolutionSelection.iterator(); i.hasNext();) {
1277
				Object selection = i.next();
1278
				if (ANY_RESOLUTION.equals(selection)) {
1279
					isAnyResolutionSelected = true;
1280
				} else if (selection instanceof Resolution) {
1281
					selectedResolutions.add((Resolution) selection);
1282
				}
1283
			}
1284
1285
			if (isAnyResolutionSelected) {
1286
				workingCopy.setResolutionFilter(null);
1287
			} else {
1288
				workingCopy.setResolutionFilter(
1289
					new ResolutionFilter(selectedResolutions.toArray(new Resolution[selectedResolutions.size()])));
1290
			}
1291
		}
1292
1293
		IStructuredSelection prioritySelection = (IStructuredSelection) priority.getSelection();
1294
		if (prioritySelection.isEmpty()) {
1295
			workingCopy.setPriorityFilter(null);
1296
		} else {
1297
			boolean isAnyPrioritiesSelected = false;
1298
1299
			List<Priority> selectedPriorities = new ArrayList<Priority>();
1300
1301
			for (Iterator i = prioritySelection.iterator(); i.hasNext();) {
1302
				Object selection = i.next();
1303
				if (ANY_PRIORITY.equals(selection)) {
1304
					isAnyPrioritiesSelected = true;
1305
				} else if (selection instanceof Priority) {
1306
					selectedPriorities.add((Priority) selection);
1307
				}
1308
			}
1309
1310
			if (isAnyPrioritiesSelected) {
1311
				workingCopy.setPriorityFilter(null);
1312
			} else {
1313
				workingCopy.setPriorityFilter(
1314
					new PriorityFilter(selectedPriorities.toArray(new Priority[selectedPriorities.size()])));
1315
			}
1316
		}
1317
		
1318
		workingCopy.setDueDateFilter(getRangeFilter(dueStartDatePicker, dueEndDatePicker));
1319
		
1320
		workingCopy.setCreatedDateFilter(getRangeFilter(createdStartDatePicker, createdEndDatePicker));
1321
		
1322
		workingCopy.setUpdatedDateFilter(getRangeFilter(updatedStartDatePicker, updatedEndDatePicker));
1323
	}
1324
1325
	private DateRangeFilter getRangeFilter(DatePicker startDatePicker, DatePicker endDatePicker) {
1326
		Calendar startDate = startDatePicker.getDate();
1327
		Calendar endDate = endDatePicker.getDate();
1328
		if(startDate!=null && endDate!=null) {
1329
			return new DateRangeFilter(startDate.getTime(), endDate.getTime());
1330
		}
1331
		return null;
708
	}
1332
	}
709
1333
710
	final static class ComponentLabelProvider implements ILabelProvider {
1334
	final static class ComponentLabelProvider implements ILabelProvider {
Lines 740-746 Link Here
740
		public Image getImage(Object element) {
1364
		public Image getImage(Object element) {
741
			return null;
1365
			return null;
742
		}
1366
		}
743
	
1367
744
		public String getText(Object element) {
1368
		public String getText(Object element) {
745
			if (element instanceof Placeholder) {
1369
			if (element instanceof Placeholder) {
746
				return ((Placeholder) element).getText();
1370
				return ((Placeholder) element).getText();
Lines 775-783 Link Here
775
1399
776
	}
1400
	}
777
1401
1402
	private final class Placeholder {
1403
		private final String text;
1404
1405
		public Placeholder(String text) {
1406
			this.text = text;
1407
		}
1408
1409
		/*
1410
		 * (non-Javadoc)
1411
		 * 
1412
		 * @see java.lang.Object#equals(java.lang.Object)
1413
		 */
1414
		public boolean equals(Object obj) {
1415
			if (obj == null)
1416
				return false;
1417
			if (!(obj instanceof Placeholder))
1418
				return false;
1419
1420
			Placeholder that = (Placeholder) obj;
1421
			return this.text.equals(that.text);
1422
		}
1423
1424
		public String getText() {
1425
			return this.text;
1426
		}
1427
	}
1428
778
	public AbstractRepositoryQuery getQuery() {
1429
	public AbstractRepositoryQuery getQuery() {
779
		this.applyChanges();
1430
		this.applyChanges();
780
		issueAttributesPage.applyChanges();
781
		if (isNew) {
1431
		if (isNew) {
782
			server.addLocalFilter(workingCopy);
1432
			server.addLocalFilter(workingCopy);
783
		}
1433
		}
(-)src/org/eclipse/mylar/internal/jira/ui/wizards/Placeholder.java (-52 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 Mylar committers 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
9
package org.eclipse.mylar.internal.jira.ui.wizards;
10
11
12
/**
13
 * TODO: delete?
14
 * 
15
 * @author Mik Kersten
16
 */
17
class Placeholder {
18
	private final String text;
19
20
	public Placeholder(String text) {
21
		this.text = text;
22
	}
23
24
	@Override
25
	public int hashCode() {
26
		final int PRIME = 31;
27
		int result = 1;
28
		result = PRIME * result + ((text == null) ? 0 : text.hashCode());
29
		return result;
30
	}
31
32
	@Override
33
	public boolean equals(Object obj) {
34
		if (this == obj)
35
			return true;
36
		if (obj == null)
37
			return false;
38
		if (getClass() != obj.getClass())
39
			return false;
40
		final Placeholder other = (Placeholder) obj;
41
		if (text == null) {
42
			if (other.text != null)
43
				return false;
44
		} else if (!text.equals(other.text))
45
			return false;
46
		return true;
47
	}
48
49
	public String getText() {
50
		return this.text;
51
	}
52
}
(-)src/org/eclipse/mylar/internal/jira/ui/wizards/IssueAttributesPage.java (-689 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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
 *     Brock Janiczak - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.jira.ui.wizards;
13
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.List;
17
18
import org.eclipse.jface.viewers.ComboViewer;
19
import org.eclipse.jface.viewers.ISelectionChangedListener;
20
import org.eclipse.jface.viewers.IStructuredContentProvider;
21
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.jface.viewers.LabelProvider;
23
import org.eclipse.jface.viewers.ListViewer;
24
import org.eclipse.jface.viewers.SelectionChangedEvent;
25
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.jface.viewers.Viewer;
27
import org.eclipse.jface.wizard.WizardPage;
28
import org.eclipse.mylar.internal.jira.JiraServerFacade;
29
import org.eclipse.mylar.tasks.core.TaskRepository;
30
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.events.ModifyEvent;
32
import org.eclipse.swt.events.ModifyListener;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.swt.widgets.Text;
38
import org.tigris.jira.core.model.IssueType;
39
import org.tigris.jira.core.model.Priority;
40
import org.tigris.jira.core.model.Resolution;
41
import org.tigris.jira.core.model.Status;
42
import org.tigris.jira.core.model.filter.CurrentUserFilter;
43
import org.tigris.jira.core.model.filter.FilterDefinition;
44
import org.tigris.jira.core.model.filter.IssueTypeFilter;
45
import org.tigris.jira.core.model.filter.NobodyFilter;
46
import org.tigris.jira.core.model.filter.PriorityFilter;
47
import org.tigris.jira.core.model.filter.ResolutionFilter;
48
import org.tigris.jira.core.model.filter.SpecificUserFilter;
49
import org.tigris.jira.core.model.filter.StatusFilter;
50
import org.tigris.jira.core.model.filter.UserFilter;
51
import org.tigris.jira.core.model.filter.UserInGroupFilter;
52
import org.tigris.jira.core.service.JiraServer;
53
54
/**
55
 * @author Brock Janiczak
56
 * @author Eugene Kuleshov (layout and other improvements)
57
 */
58
public class IssueAttributesPage extends WizardPage {
59
	final Placeholder ANY_ISSUE_TYPE = new Placeholder("Any");
60
61
	final Placeholder ANY_RESOLUTION = new Placeholder("Any");
62
63
	final Placeholder UNRESOLVED = new Placeholder("Unresolved");
64
65
	final Placeholder UNASSIGNED = new Placeholder("Unassigned");
66
67
	final Placeholder ANY_REPORTER = new Placeholder("Any");
68
69
	final Placeholder NO_REPORTER = new Placeholder("No Reporter");
70
71
	final Placeholder CURRENT_USER_REPORTER = new Placeholder("Current User");
72
73
	final Placeholder SPECIFIC_USER_REPORTER = new Placeholder("Specified User");
74
75
	final Placeholder SPECIFIC_GROUP_REPORTER = new Placeholder("Specified Group");
76
77
	final Placeholder ANY_ASSIGNEE = new Placeholder("Any");
78
79
	final Placeholder CURRENT_USER_ASSIGNEE = new Placeholder("Current User");
80
81
	final Placeholder SPECIFIC_USER_ASSIGNEE = new Placeholder("Specified User");
82
83
	final Placeholder SPECIFIC_GROUP_ASSIGNEE = new Placeholder("Specified Group");
84
85
	final Placeholder ANY_STATUS = new Placeholder("Any");
86
87
	final Placeholder ANY_PRIORITY = new Placeholder("Any");
88
89
//	private final TaskRepository repository;
90
91
	private final JiraServer jiraServer;
92
93
	private final FilterDefinition workingCopy;
94
95
	private final boolean isNew;
96
97
	private ListViewer issueType;
98
99
	private ComboViewer reporterType;
100
101
	private ComboViewer assigneeType;
102
103
	private ListViewer status;
104
105
	private ListViewer resolution;
106
107
	private ListViewer priority;
108
109
	Text assignee;
110
111
	Text reporter;
112
113
	/**
114
	 * @param repository
115
	 * @param pageName
116
	 * @param title
117
	 * @param titleImage
118
	 * @param server
119
	 */
120
	protected IssueAttributesPage(TaskRepository repository, FilterDefinition workingCopy, boolean isNew) {
121
		super("issueAttributes", "Issue Attributes", null);
122
		this.jiraServer = JiraServerFacade.getDefault().getJiraServer(repository);
123
		this.workingCopy = workingCopy;
124
		this.isNew = isNew;
125
126
		setPageComplete(false);
127
	}
128
129
	/*
130
	 * (non-Javadoc)
131
	 * 
132
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
133
	 */
134
	public void createControl(Composite parent) {
135
		GridData gd;
136
137
		Composite cc = new Composite(parent, SWT.NONE);
138
		cc.setLayout(new GridLayout(1, false));
139
140
		{
141
			Composite c = new Composite(cc, SWT.NONE);
142
			final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
143
			gridData.widthHint = 515;
144
			c.setLayoutData(gridData);
145
			c.setLayout(new GridLayout(3, false));
146
147
			Label lblReportedBy = new Label(c, SWT.NONE);
148
			lblReportedBy.setText("Reported By:");
149
			lblReportedBy.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
150
151
			reporterType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY);
152
			final GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, false, false);
153
			gridData_1.widthHint = 133;
154
			reporterType.getControl().setLayoutData(gridData_1);
155
156
			reporterType.setContentProvider(new IStructuredContentProvider() {
157
158
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
159
				}
160
161
				public void dispose() {
162
				}
163
164
				public Object[] getElements(Object inputElement) {
165
					return new Object[] { ANY_REPORTER, NO_REPORTER, CURRENT_USER_REPORTER, SPECIFIC_USER_REPORTER,
166
							SPECIFIC_GROUP_REPORTER };
167
				}
168
169
			});
170
171
			reporterType.setLabelProvider(new LabelProvider() {
172
173
				public String getText(Object element) {
174
					return ((Placeholder) element).getText();
175
				}
176
177
			});
178
179
			reporterType.setInput(jiraServer);
180
181
			reporter = new Text(c, SWT.BORDER);
182
			reporter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
183
			reporter.setEnabled(false);
184
185
			reporter.addModifyListener(new ModifyListener() {
186
187
				public void modifyText(ModifyEvent e) {
188
					validatePage();
189
				}
190
191
			});
192
193
			Label lblAssignedTo = new Label(c, SWT.NONE);
194
			lblAssignedTo.setText("Assigned To:");
195
			lblAssignedTo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
196
197
			assigneeType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY);
198
			final GridData gridData_2 = new GridData(SWT.FILL, SWT.FILL, false, false);
199
			gridData_2.widthHint = 118;
200
			assigneeType.getControl().setLayoutData(gridData_2);
201
202
			assigneeType.setContentProvider(new IStructuredContentProvider() {
203
204
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
205
				}
206
207
				public void dispose() {
208
				}
209
210
				public Object[] getElements(Object inputElement) {
211
					return new Object[] { ANY_ASSIGNEE, UNASSIGNED, CURRENT_USER_ASSIGNEE, SPECIFIC_USER_ASSIGNEE,
212
							SPECIFIC_GROUP_ASSIGNEE };
213
				}
214
215
			});
216
217
			assigneeType.setLabelProvider(new LabelProvider() {
218
219
				public String getText(Object element) {
220
					return ((Placeholder) element).getText();
221
				}
222
223
			});
224
225
			assigneeType.setInput(jiraServer);
226
			assigneeType.addSelectionChangedListener(new ISelectionChangedListener() {
227
228
				public void selectionChanged(SelectionChangedEvent event) {
229
					Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
230
					if (SPECIFIC_USER_ASSIGNEE.equals(selection) || SPECIFIC_GROUP_ASSIGNEE.equals(selection)) {
231
						assignee.setEnabled(true);
232
					} else {
233
						assignee.setEnabled(false);
234
						assignee.setText(""); //$NON-NLS-1$
235
					}
236
					validatePage();
237
				}
238
239
			});
240
241
			reporterType.addSelectionChangedListener(new ISelectionChangedListener() {
242
243
				public void selectionChanged(SelectionChangedEvent event) {
244
					Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
245
					if (SPECIFIC_USER_REPORTER.equals(selection) || SPECIFIC_GROUP_REPORTER.equals(selection)) {
246
						reporter.setEnabled(true);
247
					} else {
248
						reporter.setEnabled(false);
249
					}
250
				}
251
252
			});
253
254
			assignee = new Text(c, SWT.BORDER);
255
			assignee.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
256
			assignee.setEnabled(false);
257
258
			assignee.addModifyListener(new ModifyListener() {
259
260
				public void modifyText(ModifyEvent e) {
261
					validatePage();
262
				}
263
264
			});
265
266
		}
267
268
		{
269
			Composite c = new Composite(cc, SWT.NONE);
270
			final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
271
			gridData.heightHint = 149;
272
			c.setLayoutData(gridData);
273
			c.setLayout(new GridLayout(4, false));
274
275
			Label lblIssueType = new Label(c, SWT.NONE);
276
			lblIssueType.setText("Type:");
277
278
			Label lblStatus = new Label(c, SWT.NONE);
279
			lblStatus.setText("Status:");
280
281
			Label lblResolution = new Label(c, SWT.NONE);
282
			lblResolution.setText("Resolution:");
283
284
			Label lblPriority = new Label(c, SWT.NONE);
285
			lblPriority.setText("Priority:");
286
			
287
			issueType = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
288
			gd = new GridData(SWT.FILL, SWT.FILL, true, true);
289
			gd.heightHint = 40;
290
			issueType.getControl().setLayoutData(gd);
291
292
			issueType.setContentProvider(new IStructuredContentProvider() {
293
294
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
295
				}
296
297
				public void dispose() {
298
				}
299
300
				public Object[] getElements(Object inputElement) {
301
					JiraServer server = (JiraServer) inputElement;
302
					Object[] elements = new Object[server.getIssueTypes().length + 1];
303
					elements[0] = ANY_ISSUE_TYPE;
304
					System.arraycopy(server.getIssueTypes(), 0, elements, 1, server.getIssueTypes().length);
305
306
					return elements;
307
				}
308
			});
309
310
			issueType.setLabelProvider(new LabelProvider() {
311
312
				public String getText(Object element) {
313
					if (element instanceof Placeholder) {
314
						return ((Placeholder) element).getText();
315
					}
316
317
					return ((IssueType) element).getName();
318
				}
319
320
			});
321
322
			issueType.addSelectionChangedListener(new ISelectionChangedListener() {
323
324
				public void selectionChanged(SelectionChangedEvent event) {
325
					validatePage();
326
				}
327
328
			});
329
			issueType.setInput(jiraServer);
330
331
			status = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
332
			gd = new GridData(SWT.FILL, SWT.FILL, true, true);
333
			gd.heightHint = 40;
334
			status.getControl().setLayoutData(gd);
335
336
			status.setContentProvider(new IStructuredContentProvider() {
337
338
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
339
				}
340
341
				public void dispose() {
342
				}
343
344
				public Object[] getElements(Object inputElement) {
345
					JiraServer server = (JiraServer) inputElement;
346
					Object[] elements = new Object[server.getStatuses().length + 1];
347
					elements[0] = ANY_STATUS;
348
					System.arraycopy(server.getStatuses(), 0, elements, 1, server.getStatuses().length);
349
350
					return elements;
351
				}
352
			});
353
354
			status.setLabelProvider(new LabelProvider() {
355
356
				public String getText(Object element) {
357
					if (element instanceof Placeholder) {
358
						return ((Placeholder) element).getText();
359
					}
360
361
					return ((Status) element).getName();
362
				}
363
364
			});
365
366
			status.addSelectionChangedListener(new ISelectionChangedListener() {
367
368
				public void selectionChanged(SelectionChangedEvent event) {
369
					validatePage();
370
				}
371
372
			});
373
			status.setInput(jiraServer);
374
375
			resolution = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
376
			gd = new GridData(SWT.FILL, SWT.FILL, true, true);
377
			gd.heightHint = 40;
378
			resolution.getControl().setLayoutData(gd);
379
			resolution.setContentProvider(new IStructuredContentProvider() {
380
381
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
382
				}
383
384
				public void dispose() {
385
				}
386
387
				public Object[] getElements(Object inputElement) {
388
					JiraServer server = (JiraServer) inputElement;
389
					Object[] elements = new Object[server.getResolutions().length + 2];
390
					elements[0] = ANY_RESOLUTION;
391
					elements[1] = UNRESOLVED;
392
					System.arraycopy(server.getResolutions(), 0, elements, 2, server.getResolutions().length);
393
394
					return elements;
395
				}
396
			});
397
398
			resolution.setLabelProvider(new LabelProvider() {
399
400
				public String getText(Object element) {
401
					if (element instanceof Placeholder) {
402
						return ((Placeholder) element).getText();
403
					}
404
405
					return ((Resolution) element).getName();
406
				}
407
408
			});
409
410
			resolution.addSelectionChangedListener(new ISelectionChangedListener() {
411
412
				public void selectionChanged(SelectionChangedEvent event) {
413
					validatePage();
414
				}
415
416
			});
417
			resolution.setInput(jiraServer);
418
419
			priority = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
420
			gd = new GridData(SWT.FILL, SWT.FILL, true, true);
421
			gd.heightHint = 40;
422
			priority.getControl().setLayoutData(gd);
423
424
			priority.setContentProvider(new IStructuredContentProvider() {
425
426
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
427
				}
428
429
				public void dispose() {
430
				}
431
432
				public Object[] getElements(Object inputElement) {
433
					JiraServer server = (JiraServer) inputElement;
434
					Object[] elements = new Object[server.getPriorities().length + 1];
435
					elements[0] = ANY_PRIORITY;
436
					System.arraycopy(server.getPriorities(), 0, elements, 1, server.getPriorities().length);
437
438
					return elements;
439
				}
440
			});
441
442
			priority.setLabelProvider(new LabelProvider() {
443
444
				public String getText(Object element) {
445
					if (element instanceof Placeholder) {
446
						return ((Placeholder) element).getText();
447
					}
448
449
					return ((Priority) element).getName();
450
				}
451
452
			});
453
			priority.addSelectionChangedListener(new ISelectionChangedListener() {
454
455
				public void selectionChanged(SelectionChangedEvent event) {
456
					validatePage();
457
				}
458
459
			});
460
			priority.setInput(jiraServer);
461
		}
462
463
		if (isNew) {
464
			loadFromDefaults();
465
		} else {
466
			loadFromWorkingCopy();
467
		}
468
469
		setControl(cc);
470
	}
471
472
	void validatePage() {
473
474
	}
475
476
	/* default */void applyChanges() {
477
		if(issueType==null) {
478
			return;
479
		}
480
		
481
		// TODO support standard and subtask issue types
482
		IStructuredSelection issueTypeSelection = (IStructuredSelection) issueType.getSelection();
483
		if (issueTypeSelection.isEmpty()) {
484
			workingCopy.setIssueTypeFilter(null);
485
		} else {
486
			boolean isAnyIssueTypeSelected = false;
487
488
			List<IssueType> selectedIssueTypes = new ArrayList<IssueType>();
489
490
			for (Iterator i = issueTypeSelection.iterator(); i.hasNext();) {
491
				Object selection = i.next();
492
				if (ANY_ISSUE_TYPE.equals(selection)) {
493
					isAnyIssueTypeSelected = true;
494
				} else if (selection instanceof IssueType) {
495
					selectedIssueTypes.add((IssueType) selection);
496
				}
497
			}
498
499
			if (isAnyIssueTypeSelected) {
500
				workingCopy.setIssueTypeFilter(null);
501
			} else {
502
				workingCopy.setIssueTypeFilter(
503
					new IssueTypeFilter(selectedIssueTypes.toArray(new IssueType[selectedIssueTypes.size()])));
504
			}
505
		}
506
507
		IStructuredSelection reporterSelection = (IStructuredSelection) reporterType.getSelection();
508
		if (reporterSelection.isEmpty()) {
509
			workingCopy.setReportedByFilter(null);
510
		} else {
511
			if (ANY_REPORTER.equals(reporterSelection.getFirstElement())) {
512
				workingCopy.setReportedByFilter(null);
513
			} else if (NO_REPORTER.equals(reporterSelection.getFirstElement())) {
514
				workingCopy.setReportedByFilter(new NobodyFilter());
515
			} else if (CURRENT_USER_REPORTER.equals(reporterSelection.getFirstElement())) {
516
				workingCopy.setReportedByFilter(new CurrentUserFilter());
517
			} else if (SPECIFIC_GROUP_REPORTER.equals(reporterSelection.getFirstElement())) {
518
				workingCopy.setReportedByFilter(new UserInGroupFilter(reporter.getText()));
519
			} else if (SPECIFIC_USER_REPORTER.equals(reporterSelection.getFirstElement())) {
520
				workingCopy.setReportedByFilter(new SpecificUserFilter(reporter.getText()));
521
			} else {
522
				workingCopy.setReportedByFilter(null);
523
			}
524
		}
525
526
		IStructuredSelection assigneeSelection = (IStructuredSelection) assigneeType.getSelection();
527
		if (assigneeSelection.isEmpty()) {
528
			workingCopy.setAssignedToFilter(null);
529
		} else {
530
			if (ANY_REPORTER.equals(assigneeSelection.getFirstElement())) {
531
				workingCopy.setAssignedToFilter(null);
532
			} else if (UNASSIGNED.equals(assigneeSelection.getFirstElement())) {
533
				workingCopy.setAssignedToFilter(new NobodyFilter());
534
			} else if (CURRENT_USER_REPORTER.equals(assigneeSelection.getFirstElement())) {
535
				workingCopy.setAssignedToFilter(new CurrentUserFilter());
536
			} else if (SPECIFIC_GROUP_REPORTER.equals(assigneeSelection.getFirstElement())) {
537
				workingCopy.setAssignedToFilter(new UserInGroupFilter(assignee.getText()));
538
			} else if (SPECIFIC_USER_REPORTER.equals(assigneeSelection.getFirstElement())) {
539
				workingCopy.setAssignedToFilter(new SpecificUserFilter(assignee.getText()));
540
			} else {
541
				workingCopy.setAssignedToFilter(null);
542
			}
543
		}
544
545
		IStructuredSelection statusSelection = (IStructuredSelection) status.getSelection();
546
		if (statusSelection.isEmpty()) {
547
			workingCopy.setStatusFilter(null);
548
		} else {
549
			boolean isAnyStatusSelected = false;
550
551
			List<Status> selectedStatuses = new ArrayList<Status>();
552
553
			for (Iterator i = statusSelection.iterator(); i.hasNext();) {
554
				Object selection = i.next();
555
				if (ANY_STATUS.equals(selection)) {
556
					isAnyStatusSelected = true;
557
				} else if (selection instanceof Status) {
558
					selectedStatuses.add((Status) selection);
559
				}
560
			}
561
562
			if (isAnyStatusSelected) {
563
				workingCopy.setStatusFilter(null);
564
			} else {
565
				workingCopy.setStatusFilter(
566
					new StatusFilter(selectedStatuses.toArray(new Status[selectedStatuses.size()])));
567
			}
568
		}
569
570
		IStructuredSelection resolutionSelection = (IStructuredSelection) resolution.getSelection();
571
		if (resolutionSelection.isEmpty()) {
572
			workingCopy.setResolutionFilter(null);
573
		} else {
574
			boolean isAnyResolutionSelected = false;
575
576
			List<Resolution> selectedResolutions = new ArrayList<Resolution>();
577
578
			for (Iterator i = resolutionSelection.iterator(); i.hasNext();) {
579
				Object selection = i.next();
580
				if (ANY_RESOLUTION.equals(selection)) {
581
					isAnyResolutionSelected = true;
582
				} else if (selection instanceof Resolution) {
583
					selectedResolutions.add((Resolution) selection);
584
				}
585
			}
586
587
			if (isAnyResolutionSelected) {
588
				workingCopy.setResolutionFilter(null);
589
			} else {
590
				workingCopy.setResolutionFilter(
591
					new ResolutionFilter(selectedResolutions.toArray(new Resolution[selectedResolutions.size()])));
592
			}
593
		}
594
595
		IStructuredSelection prioritySelection = (IStructuredSelection) priority.getSelection();
596
		if (prioritySelection.isEmpty()) {
597
			workingCopy.setPriorityFilter(null);
598
		} else {
599
			boolean isAnyPrioritiesSelected = false;
600
601
			List<Priority> selectedPriorities = new ArrayList<Priority>();
602
603
			for (Iterator i = prioritySelection.iterator(); i.hasNext();) {
604
				Object selection = i.next();
605
				if (ANY_PRIORITY.equals(selection)) {
606
					isAnyPrioritiesSelected = true;
607
				} else if (selection instanceof Priority) {
608
					selectedPriorities.add((Priority) selection);
609
				}
610
			}
611
612
			if (isAnyPrioritiesSelected) {
613
				workingCopy.setPriorityFilter(null);
614
			} else {
615
				workingCopy.setPriorityFilter(
616
					new PriorityFilter(selectedPriorities.toArray(new Priority[selectedPriorities.size()])));
617
			}
618
		}
619
	}
620
621
	private void loadFromDefaults() {
622
		issueType.setSelection(new StructuredSelection(ANY_ISSUE_TYPE));
623
		reporterType.setSelection(new StructuredSelection(ANY_REPORTER));
624
		assigneeType.setSelection(new StructuredSelection(ANY_ASSIGNEE));
625
		status.setSelection(new StructuredSelection(ANY_STATUS));
626
		resolution.setSelection(new StructuredSelection(ANY_RESOLUTION));
627
		priority.setSelection(new StructuredSelection(ANY_PRIORITY));
628
	}
629
630
	private void loadFromWorkingCopy() {
631
		if (workingCopy.getIssueTypeFilter() != null) {
632
			issueType.setSelection(new StructuredSelection(workingCopy.getIssueTypeFilter().getIsueTypes()));
633
		} else {
634
			issueType.setSelection(new StructuredSelection(ANY_ISSUE_TYPE));
635
		}
636
637
		if (workingCopy.getReportedByFilter() != null) {
638
			UserFilter reportedByFilter = workingCopy.getReportedByFilter();
639
			if (reportedByFilter instanceof NobodyFilter) {
640
				reporterType.setSelection(new StructuredSelection(NO_REPORTER));
641
			} else if (reportedByFilter instanceof CurrentUserFilter) {
642
				reporterType.setSelection(new StructuredSelection(CURRENT_USER_REPORTER));
643
			} else if (reportedByFilter instanceof SpecificUserFilter) {
644
				reporterType.setSelection(new StructuredSelection(SPECIFIC_USER_REPORTER));
645
				reporter.setText(((SpecificUserFilter) reportedByFilter).getUser());
646
			} else if (reportedByFilter instanceof UserInGroupFilter) {
647
				reporterType.setSelection(new StructuredSelection(SPECIFIC_GROUP_REPORTER));
648
				reporter.setText(((UserInGroupFilter) reportedByFilter).getGroup());
649
			}
650
		} else {
651
			reporterType.setSelection(new StructuredSelection(ANY_REPORTER));
652
		}
653
654
		if (workingCopy.getAssignedToFilter() != null) {
655
			UserFilter assignedToFilter = workingCopy.getAssignedToFilter();
656
			if (assignedToFilter instanceof NobodyFilter) {
657
				assigneeType.setSelection(new StructuredSelection(UNASSIGNED));
658
			} else if (assignedToFilter instanceof CurrentUserFilter) {
659
				assigneeType.setSelection(new StructuredSelection(CURRENT_USER_ASSIGNEE));
660
			} else if (assignedToFilter instanceof SpecificUserFilter) {
661
				assigneeType.setSelection(new StructuredSelection(SPECIFIC_USER_ASSIGNEE));
662
				assignee.setText(((SpecificUserFilter) assignedToFilter).getUser());
663
			} else if (assignedToFilter instanceof UserInGroupFilter) {
664
				assigneeType.setSelection(new StructuredSelection(SPECIFIC_GROUP_ASSIGNEE));
665
				assignee.setText(((UserInGroupFilter) assignedToFilter).getGroup());
666
			}
667
		} else {
668
			assigneeType.setSelection(new StructuredSelection(ANY_ASSIGNEE));
669
		}
670
671
		if (workingCopy.getStatusFilter() != null) {
672
			status.setSelection(new StructuredSelection(workingCopy.getStatusFilter().getStatuses()));
673
		} else {
674
			status.setSelection(new StructuredSelection(ANY_STATUS));
675
		}
676
677
		if (workingCopy.getResolutionFilter() != null) {
678
			resolution.setSelection(new StructuredSelection(workingCopy.getResolutionFilter().getResolutions()));
679
		} else {
680
			resolution.setSelection(new StructuredSelection(ANY_RESOLUTION));
681
		}
682
683
		if (workingCopy.getPriorityFilter() != null) {
684
			priority.setSelection(new StructuredSelection(workingCopy.getPriorityFilter().getPriorities()));
685
		} else {
686
			priority.setSelection(new StructuredSelection(ANY_PRIORITY));
687
		}
688
	}
689
}
(-)src/org/eclipse/mylar/internal/tasks/ui/planner/DateSelectionDialog.java (-3 / +19 lines)
Lines 16-21 Link Here
16
import java.util.GregorianCalendar;
16
import java.util.GregorianCalendar;
17
17
18
import org.eclipse.jface.dialogs.Dialog;
18
import org.eclipse.jface.dialogs.Dialog;
19
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.viewers.ISelectionChangedListener;
20
import org.eclipse.jface.viewers.ISelectionChangedListener;
20
import org.eclipse.jface.viewers.SelectionChangedEvent;
21
import org.eclipse.jface.viewers.SelectionChangedEvent;
21
import org.eclipse.mylar.internal.tasks.ui.views.DatePickerPanel;
22
import org.eclipse.mylar.internal.tasks.ui.views.DatePickerPanel;
Lines 35-41 Link Here
35
	private Date reminderDate = null;
36
	private Date reminderDate = null;
36
37
37
	private String title = "Date Selection";
38
	private String title = "Date Selection";
38
39
	
39
	private Calendar initialCalendar = GregorianCalendar.getInstance();
40
	private Calendar initialCalendar = GregorianCalendar.getInstance();
40
41
41
	public DateSelectionDialog(Shell parentShell, String title) {
42
	public DateSelectionDialog(Shell parentShell, String title) {
Lines 44-58 Link Here
44
45
45
	public DateSelectionDialog(Shell parentShell, Calendar initialDate, String title) {
46
	public DateSelectionDialog(Shell parentShell, Calendar initialDate, String title) {
46
		super(parentShell);
47
		super(parentShell);
47
		if (title != null) {
48
		if(title != null) {
48
			this.title = title;
49
			this.title = title;
49
		}
50
		}
50
		if (initialDate != null) {
51
		if(initialDate != null) {
51
			this.initialCalendar.setTime(initialDate.getTime());
52
			this.initialCalendar.setTime(initialDate.getTime());
52
		}
53
		}
53
		reminderDate = initialCalendar.getTime();
54
		reminderDate = initialCalendar.getTime();
54
	}
55
	}
55
56
57
	@Override
56
	protected Control createDialogArea(Composite parent) {
58
	protected Control createDialogArea(Composite parent) {
57
		getShell().setText(title);
59
		getShell().setText(title);
58
		DatePickerPanel datePanel = new DatePickerPanel(parent, SWT.NULL, initialCalendar);
60
		DatePickerPanel datePanel = new DatePickerPanel(parent, SWT.NULL, initialCalendar);
Lines 69-74 Link Here
69
71
70
		return datePanel;
72
		return datePanel;
71
	}
73
	}
74
	
75
	@Override
76
	protected void createButtonsForButtonBar(Composite parent) {
77
		createButton(parent, IDialogConstants.CLIENT_ID + 1, "Clear", false);
78
		super.createButtonsForButtonBar(parent);
79
	}
80
	
81
	protected void buttonPressed(int buttonId) {
82
		super.buttonPressed(buttonId);
83
		if(buttonId == IDialogConstants.CLIENT_ID + 1) {
84
			reminderDate = null;
85
			okPressed();
86
		}
87
	}
72
88
73
	public Date getDate() {
89
	public Date getDate() {
74
		return reminderDate;
90
		return reminderDate;
(-)src/org/eclipse/mylar/internal/tasks/ui/views/DatePicker.java (-5 / +7 lines)
Lines 140-146 Link Here
140
140
141
			public void widgetSelected(SelectionEvent arg0) {
141
			public void widgetSelected(SelectionEvent arg0) {
142
				Calendar newCalendar = GregorianCalendar.getInstance();
142
				Calendar newCalendar = GregorianCalendar.getInstance();
143
				if (date != null) {
143
				if(date != null) {
144
					newCalendar.setTime(date.getTime());
144
					newCalendar.setTime(date.getTime());
145
				}
145
				}
146
146
Lines 155-161 Link Here
155
				dateText.setEnabled(false);
155
				dateText.setEnabled(false);
156
156
157
				int dialogResponse = dialog.open();
157
				int dialogResponse = dialog.open();
158
				newCalendar.setTime(dialog.getDate());
158
				if(dialog.getDate()!=null) {
159
					newCalendar.setTime(dialog.getDate());
160
				} else {
161
					newCalendar = null;
162
				}
159
				dateSelected(dialogResponse == Window.CANCEL, newCalendar);
163
				dateSelected(dialogResponse == Window.CANCEL, newCalendar);
160
164
161
				// Display display = Display.getCurrent();
165
				// Display display = Display.getCurrent();
Lines 242-250 Link Here
242
	protected void dateSelected(boolean canceled, Calendar selectedDate) {
246
	protected void dateSelected(boolean canceled, Calendar selectedDate) {
243
247
244
		if (!canceled) {
248
		if (!canceled) {
245
			if (selectedDate != null) {
249
			this.date = selectedDate != null ? selectedDate : null;
246
				this.date = selectedDate;
247
			}
248
			updateDateText();
250
			updateDateText();
249
		}
251
		}

Return to bug 149605