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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/ui/search/BugzillaSearchPage.java (-2 / +459 lines)
Lines 149-154 Link Here
149
	private static final String[] emailRoleValues2 = { "emailassigned_to2", "emailreporter2", "emailcc2", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
149
	private static final String[] emailRoleValues2 = { "emailassigned_to2", "emailreporter2", "emailcc2", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
150
			"emaillongdesc2", "emailqa_contact2" }; //$NON-NLS-1$ //$NON-NLS-2$
150
			"emaillongdesc2", "emailqa_contact2" }; //$NON-NLS-1$ //$NON-NLS-2$
151
151
152
	private static final String[] chartFieldText = { "---", "Alias", "AssignedTo", "Attachment creator",
153
			"Attachment data", "Attachment description", "Attachment filename", "Attachment is a URL",
154
			"Attachment is obsolete", "Attachment is patch", "Attachment is private", "Attachment mime type", "Blocks",
155
			"Bug #", "CC", "CC Accessible", "Classification", "Comment", "Comment is private", "Commenter",
156
			"Component", "Content", "Creation date", "Days since bug changed", "Depends on", "drop down custom field",
157
			"Ever Confirmed", "Flag", "Flag Requestee", "Flag Setter", "free text custom field", "Group", "Keywords",
158
			"Last changed date", "OS/Version", "Platform", "Priority", "Product", "QAContact", "ReportedBy",
159
			"Reporter Accessible", "Resolution", "Severity", "Status", "Status Whiteboard", "Summary",
160
			"Target Milestone", "Time Since Assignee Touched", "URL", "Version", "Votes" };
161
162
	private static final String[] chartFieldValues = { "noop", "alias", "assigned_to", "attachments.submitter",
163
			"attach_data.thedata", "attachments.description", "attachments.filename", "attachments.isurl",
164
			"attachments.isobsolete", "attachments.ispatch", "attachments.isprivate", "attachments.mimetype",
165
			"blocked", "bug_id", "cc", "cclist_accessible", "classification", "longdesc", "longdescs.isprivate",
166
			"commenter", "component", "content", "creation_ts", "days_elapsed", "dependson", "cf_dropdown",
167
			"everconfirmed", "flagtypes.name", "requestees.login_name", "setters.login_name", "cf_freetext",
168
			"bug_group", "keywords", "delta_ts", "op_sys", "rep_platform", "priority", "product", "qa_contact",
169
			"reporter", "reporter_accessible", "resolution", "bug_severity", "bug_status", "status_whiteboard",
170
			"short_desc", "target_milestone", "owner_idle_time", "bug_file_loc", "version", "votes" };
171
172
	private static final String[] chartOperationText = { "---", "is equal to", "is not equal to",
173
			"is equal to any of the strings", "contains the string", "contains the string (exact case)",
174
			"does not contain the string", "contains any of the strings", "contains all of the strings",
175
			"contains none of the strings", "contains regexp", "does not contain regexp", "is less than",
176
			"is greater than", "contains any of the words", "contains all of the words", "contains none of the words",
177
			"changed before", "changed after", "changed from", "changed to", "changed by", "matches" };
178
179
	private static final String[] chartOperationValues = { "noop", "equals", "notequals", "anyexact", "substring",
180
			"casesubstring", "notsubstring", "anywordssubstr", "allwordssubstr", "nowordssubstr", "regexp",
181
			"notregexp", "lessthan", "greaterthan", "anywords", "allwords", "nowords", "changedbefore", "changedafter",
182
			"changedfrom", "changedto", "changedby", "matches" };
183
152
	// dialog store id constants
184
	// dialog store id constants
153
	private final static String DIALOG_BOUNDS_KEY = "ResizableDialogBounds"; //$NON-NLS-1$
185
	private final static String DIALOG_BOUNDS_KEY = "ResizableDialogBounds"; //$NON-NLS-1$
154
186
Lines 292-297 Link Here
292
324
293
	private ExpandableComposite moreOptionsExpandComposite;
325
	private ExpandableComposite moreOptionsExpandComposite;
294
326
327
	private ExpandableComposite chartExpandComposite;
328
329
	private Group chartGroup;
330
331
	protected class ChartExpression {
332
		private int fieldName;
333
334
		private int operation;
335
336
		private String value;
337
338
		public ChartExpression(int fieldName, int operation, String value) {
339
			super();
340
			this.fieldName = fieldName;
341
			this.operation = operation;
342
			this.value = value;
343
		}
344
345
		public int getFieldName() {
346
			return fieldName;
347
		}
348
349
		public void setFieldName(int fieldName) {
350
			this.fieldName = fieldName;
351
		}
352
353
		public int getOperation() {
354
			return operation;
355
		}
356
357
		public void setOperation(int operation) {
358
			this.operation = operation;
359
		}
360
361
		public String getValue() {
362
			return value;
363
		}
364
365
		public void setValue(String value) {
366
			this.value = value;
367
		}
368
	}
369
370
	protected class Chart {
371
		private final ArrayList<ArrayList<ChartExpression>> expressions;
372
373
		private boolean negate;
374
375
		private final int chartNumber;
376
377
		public Chart(int chartNumber) {
378
			super();
379
			ChartExpression expression = new ChartExpression(0, 0, ""); //$NON-NLS-1$
380
			ArrayList<ChartExpression> column = new ArrayList<ChartExpression>(1);
381
			column.add(expression);
382
			expressions = new ArrayList<ArrayList<ChartExpression>>(1);
383
			expressions.add(column);
384
			negate = false;
385
			this.chartNumber = chartNumber;
386
		}
387
388
		public boolean isNegate() {
389
			return negate;
390
		}
391
392
		public void setNegate(boolean negate) {
393
			this.negate = negate;
394
		}
395
396
		public void addExpression(int rowIndex, int columnIndex) {
397
			ChartExpression expression = new ChartExpression(0, 0, ""); //$NON-NLS-1$
398
			int size = expressions.size();
399
			if (rowIndex > size + 1) {
400
				rowIndex = size + 1;
401
			}
402
			if (rowIndex < 0) {
403
				rowIndex = 0;
404
			}
405
			ArrayList<ChartExpression> row;
406
			if (rowIndex == size) {
407
				row = new ArrayList<BugzillaSearchPage.ChartExpression>();
408
				expressions.add(rowIndex, row);
409
			} else {
410
				row = expressions.get(rowIndex);
411
			}
412
			if (row != null) {
413
				int size1 = expressions.size();
414
				if (columnIndex > size1 + 1) {
415
					columnIndex = size1 + 1;
416
				}
417
				if (columnIndex < 0) {
418
					columnIndex = 0;
419
				}
420
				row.add(columnIndex, expression);
421
			}
422
423
		}
424
425
		public void addRow(int index) {
426
			int size = expressions.size();
427
			if (index > size) {
428
				index = size;
429
			}
430
			if (index < 0) {
431
				index = 0;
432
			}
433
			addRow(index);
434
		}
435
436
		public int getRowSize() {
437
			return expressions.size();
438
		}
439
440
		public int getColumnSize(int row) {
441
			int size = expressions.size();
442
			if (row > size) {
443
				row = size;
444
			}
445
			if (row < 0) {
446
				row = 0;
447
			}
448
			return expressions.get(row).size();
449
		}
450
451
		public ChartExpression getChartExpression(int row, int column) {
452
			ChartExpression result = null;
453
			int rowSize = expressions.size();
454
			if (row > rowSize) {
455
				row = rowSize;
456
			}
457
			if (row < 0) {
458
				row = 0;
459
			}
460
461
			int columnSize = getColumnSize(row);
462
			if (column > columnSize) {
463
				column = columnSize;
464
			}
465
			if (column < 0) {
466
				column = 0;
467
			}
468
			return expressions.get(row).get(column);
469
		}
470
	}
471
472
	private final ArrayList<Chart> charts = new ArrayList<BugzillaSearchPage.Chart>(1);
473
474
	private class ChartControls {
475
		private final Combo field;
476
477
		private final Combo operation;
478
479
		private final Combo value;
480
481
		private final Button orButton;
482
483
		public ChartControls(Combo field, Combo operation, Combo value, Button orButton) {
484
			super();
485
			this.field = field;
486
			this.operation = operation;
487
			this.value = value;
488
			this.orButton = orButton;
489
		}
490
491
		public Combo getField() {
492
			return field;
493
		}
494
495
		public Combo getOperation() {
496
			return operation;
497
		}
498
499
		public Combo getValue() {
500
			return value;
501
		}
502
503
		public Button getOrButton() {
504
			return orButton;
505
		}
506
	}
507
508
	private final ArrayList<ArrayList<ArrayList<ChartControls>>> chartControls = new ArrayList<ArrayList<ArrayList<ChartControls>>>();
509
295
	private final SelectionAdapter updateActionSelectionAdapter = new SelectionAdapter() {
510
	private final SelectionAdapter updateActionSelectionAdapter = new SelectionAdapter() {
296
		@Override
511
		@Override
297
		public void widgetSelected(SelectionEvent e) {
512
		public void widgetSelected(SelectionEvent e) {
Lines 495-502 Link Here
495
		Dialog.applyDialogFont(moreOptionsComposite);
710
		Dialog.applyDialogFont(moreOptionsComposite);
496
		moreOptionsExpandComposite.setClient(moreOptionsComposite);
711
		moreOptionsExpandComposite.setClient(moreOptionsComposite);
497
712
713
//		####
714
		chartExpandComposite = toolkit.createExpandableComposite(control, ExpandableComposite.COMPACT
715
				| ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
716
		chartExpandComposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
717
		chartExpandComposite.setBackground(null);
718
		chartExpandComposite.setText("Boolean Charts");
719
		chartExpandComposite.setLayout(new GridLayout(1, false));
720
		g = new GridData(GridData.FILL, GridData.FILL, true, true);
721
		g.horizontalSpan = 4;
722
		g.horizontalIndent = INDENT;
723
		chartExpandComposite.setLayoutData(g);
724
		chartExpandComposite.addExpansionListener(new ExpansionAdapter() {
725
			@Override
726
			public void expansionStateChanged(ExpansionEvent e) {
727
				if ((Boolean) e.data == true) {
728
					Point minSize = getControl().getShell().getMinimumSize();
729
					minSize.y = 500;
730
					getControl().getShell().setMinimumSize(minSize);
731
				} else {
732
					Point minSize = getControl().getShell().getMinimumSize();
733
					minSize.y = 290;
734
					getControl().getShell().setMinimumSize(minSize);
735
				}
736
				Shell shell = getShell();
737
				shell.pack();
738
				Point shellSize = shell.getSize();
739
				shellSize.x++;
740
				shell.setSize(shellSize);
741
				shellSize.x--;
742
				shell.setSize(shellSize);
743
			}
744
		});
745
746
		Composite chartOptionsComposite = new Composite(chartExpandComposite, SWT.NULL);
747
		GridLayout chartLayout = new GridLayout(4, false);
748
		chartLayout.marginHeight = 0;
749
		chartLayout.marginWidth = 0;
750
		chartOptionsComposite.setLayout(chartLayout);
751
752
		Dialog.applyDialogFont(chartOptionsComposite);
753
		chartExpandComposite.setClient(chartOptionsComposite);
754
//####		
755
498
		createMoreOptionsComposite(moreOptionsComposite);
756
		createMoreOptionsComposite(moreOptionsComposite);
499
		createSearchGroup(moreOptionsComposite);
757
		createSearchGroup(moreOptionsComposite);
758
		createChartGroup(chartOptionsComposite);
500
		if (inSearchContainer()) {
759
		if (inSearchContainer()) {
501
			control.getShell().setMinimumSize(new Point(610, 450));
760
			control.getShell().setMinimumSize(new Point(610, 450));
502
		} else {
761
		} else {
Lines 974-980 Link Here
974
		gd_os.heightHint = HEIGHT_ATTRIBUTE_COMBO;
1233
		gd_os.heightHint = HEIGHT_ATTRIBUTE_COMBO;
975
		os.setLayoutData(gd_os);
1234
		os.setLayoutData(gd_os);
976
		os.addSelectionListener(updateActionSelectionAdapter);
1235
		os.addSelectionListener(updateActionSelectionAdapter);
977
978
	}
1236
	}
979
1237
980
	private void createSearchGroup(Composite control) {
1238
	private void createSearchGroup(Composite control) {
Lines 1466-1472 Link Here
1466
		sb.append("&status_whiteboard_type="); //$NON-NLS-1$
1724
		sb.append("&status_whiteboard_type="); //$NON-NLS-1$
1467
		sb.append(patternOperationValues[whiteboardOperation.getSelectionIndex()]);
1725
		sb.append(patternOperationValues[whiteboardOperation.getSelectionIndex()]);
1468
		appendToBuffer(sb, "&status_whiteboard=", whiteboardPattern.getText()); //$NON-NLS-1$
1726
		appendToBuffer(sb, "&status_whiteboard=", whiteboardPattern.getText()); //$NON-NLS-1$
1469
1727
		int indexMax = charts.size();
1728
		for (int index = 0; index < indexMax; index++) {
1729
			Chart chart = charts.get(index);
1730
			if (chart.isNegate()) {
1731
				sb.append("&negate" + index + "=1");
1732
			}
1733
			int rowMax = chart.getRowSize();
1734
			for (int row = 0; row < rowMax; row++) {
1735
				int columnMax = chart.getColumnSize(row);
1736
				for (int column = 0; column < columnMax; column++) {
1737
					ChartExpression chartExpression = chart.getChartExpression(row, column);
1738
					sb.append("&field" + index + "-" + row + "-" + column + "="
1739
							+ chartFieldValues[chartExpression.getFieldName()]);
1740
					sb.append("&type" + index + "-" + row + "-" + column + "="
1741
							+ chartOperationValues[chartExpression.getOperation()]);
1742
					sb.append("&value" + index + "-" + row + "-" + column + "=" + chartExpression.getValue());
1743
				}
1744
			}
1745
		}
1470
		return sb;
1746
		return sb;
1471
	}
1747
	}
1472
1748
Lines 2159-2162 Link Here
2159
		return currentSize.x < newSize.x || currentSize.y != newSize.y;
2435
		return currentSize.x < newSize.x || currentSize.y != newSize.y;
2160
	}
2436
	}
2161
2437
2438
	private void createChartGroup(final Composite parent) {
2439
		GridLayout layout;
2440
		GridData gd;
2441
2442
		chartGroup = new Group(parent, SWT.NONE);
2443
		layout = new GridLayout(1, false);
2444
		chartGroup.setLayout(layout);
2445
		gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
2446
		chartGroup.setLayoutData(gd);
2447
2448
		Group chartGroup0 = new Group(chartGroup, SWT.NONE);
2449
		layout = new GridLayout(2, false);
2450
		chartGroup0.setLayout(layout);
2451
		gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
2452
		chartGroup0.setLayoutData(gd);
2453
2454
		Group chartGroup1 = new Group(chartGroup0, SWT.NONE);
2455
		layout = new GridLayout(4, false);
2456
		chartGroup1.setLayout(layout);
2457
		gd = new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1);
2458
		chartGroup1.setLayoutData(gd);
2459
2460
		Chart chart = new Chart(0);
2461
		charts.add(chart);
2462
		createChartControls(chartGroup1, 0, 0, 0);
2463
2464
//		Button clearButton = new Button(chartGroup, SWT.PUSH);
2465
//		clearButton.setText("Charts");
2466
//		clearButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
2467
//		clearButton.addSelectionListener(new SelectionAdapter() {
2468
//			@Override
2469
//			public void widgetSelected(SelectionEvent e) {
2470
		// Comment pattern combo
2471
2472
		parent.layout(true);
2473
		parent.redraw();
2474
	}
2475
2476
	private void createChartControls(final Group chartGroup, final int chartNumber, final int row, final int column) {
2477
		final Combo comboField = new Combo(chartGroup, SWT.SINGLE | SWT.BORDER);
2478
		comboField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
2479
		comboField.addModifyListener(new ModifyListenerImplementation());
2480
		comboField.setItems(chartFieldText);
2481
		comboField.setText(chartFieldText[0]);
2482
		comboField.addSelectionListener(new SelectionAdapter() {
2483
			@Override
2484
			public void widgetSelected(SelectionEvent e) {
2485
				ChartExpression chartExpression = charts.get(chartNumber).getChartExpression(row, column);
2486
				chartExpression.setFieldName(comboField.getSelectionIndex());
2487
				chartGroup.getShell().layout(true);
2488
				chartGroup.getShell().redraw();
2489
			}
2490
		});
2491
2492
		final Combo comboOperation = new Combo(chartGroup, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
2493
		comboOperation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
2494
		comboOperation.setItems(chartOperationText);
2495
		comboOperation.setText(chartOperationText[0]);
2496
		comboOperation.select(0);
2497
		comboOperation.addSelectionListener(new SelectionAdapter() {
2498
			@Override
2499
			public void widgetSelected(SelectionEvent e) {
2500
				ChartExpression chartExpression = charts.get(chartNumber).getChartExpression(row, column);
2501
				chartExpression.setOperation(comboOperation.getSelectionIndex());
2502
			}
2503
		});
2504
2505
		final Combo comboValue = new Combo(chartGroup, SWT.SINGLE | SWT.BORDER);
2506
		GridData g = new GridData(GridData.FILL, GridData.CENTER, false, false);
2507
		g.widthHint = 150;
2508
		comboValue.setLayoutData(g);
2509
		comboValue.addModifyListener(new ModifyListener() {
2510
2511
			public void modifyText(ModifyEvent e) {
2512
				ChartExpression chartExpression = charts.get(chartNumber).getChartExpression(row, column);
2513
				chartExpression.setValue(comboValue.getText());
2514
				if (isControlCreated()) {
2515
					setPageComplete(isPageComplete());
2516
				}
2517
			}
2518
		});
2519
2520
		Button orButton = new Button(chartGroup, SWT.PUSH);
2521
		orButton.setText("OR");
2522
		g = new GridData(SWT.LEFT, SWT.CENTER, false, false);
2523
//		g.widthHint = 40;
2524
		orButton.setLayoutData(g);
2525
		orButton.addSelectionListener(new SelectionAdapter() {
2526
			@Override
2527
			public void widgetSelected(SelectionEvent e) {
2528
				int y = charts.get(chartNumber).getColumnSize(row);
2529
				charts.get(chartNumber).addExpression(row, column + 1);
2530
				createChartControls(chartGroup, chartNumber, row, y);
2531
			}
2532
		});
2533
		if (column == 0) {
2534
			final Button andButton = new Button(chartGroup.getParent(), SWT.PUSH);
2535
			andButton.setText("AND");
2536
			g = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
2537
//		g.widthHint = 60;
2538
			andButton.setLayoutData(g);
2539
			final Button newButton = new Button(chartGroup.getParent(), SWT.PUSH);
2540
			newButton.setText("New chart");
2541
			g = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
2542
			newButton.setLayoutData(g);
2543
			newButton.addSelectionListener(new SelectionAdapter() {
2544
				@Override
2545
				public void widgetSelected(SelectionEvent e) {
2546
					newButton.setVisible(false);
2547
					newButton.dispose();
2548
2549
					final Group chartGroup0 = new Group(chartGroup.getParent().getParent(), SWT.NONE);
2550
					GridLayout layout = new GridLayout(2, false);
2551
					chartGroup0.setLayout(layout);
2552
2553
					Group chartGroup1 = new Group(chartGroup0, SWT.NONE);
2554
					layout = new GridLayout(4, false);
2555
					chartGroup1.setLayout(layout);
2556
					GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1);
2557
					chartGroup1.setLayoutData(gd);
2558
2559
					charts.add(new Chart(chartNumber + 1));
2560
					createChartControls(chartGroup1, chartNumber + 1, 0, 0);
2561
				}
2562
			});
2563
			andButton.addSelectionListener(new SelectionAdapter() {
2564
				@Override
2565
				public void widgetSelected(SelectionEvent e) {
2566
					Label lable = new Label(chartGroup.getParent(), SWT.NONE);
2567
					andButton.setVisible(false);
2568
					andButton.dispose();
2569
					if (!newButton.isDisposed()) {
2570
						newButton.setVisible(false);
2571
						newButton.dispose();
2572
					}
2573
					lable.setText("AND");
2574
					GridData g = new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1);
2575
					lable.setLayoutData(g);
2576
2577
					Group chartGroup1 = new Group(chartGroup.getParent(), SWT.NONE);
2578
					GridLayout layout = new GridLayout(4, false);
2579
					chartGroup1.setLayout(layout);
2580
					chartGroup1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
2581
					GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1);
2582
					chartGroup1.setLayoutData(gd);
2583
2584
					charts.get(chartNumber).addExpression(row + 1, 0);
2585
					createChartControls(chartGroup1, chartNumber, row + 1, 0);
2586
				}
2587
			});
2588
		}
2589
		ChartControls chartControl = new ChartControls(comboField, comboOperation, comboValue, orButton);
2590
		int chart1 = chartControls.size();
2591
		if (chart1 < chartNumber + 1) {
2592
			chartControls.add(new ArrayList<ArrayList<ChartControls>>());
2593
		}
2594
		int chart2 = chartControls.get(chartNumber).size();
2595
		if (chart2 < row + 1) {
2596
			chartControls.get(chartNumber).add(new ArrayList<BugzillaSearchPage.ChartControls>());
2597
		}
2598
		chartControls.get(chartNumber).get(row).add(chartControl);
2599
		refreshChartControls();
2600
	}
2601
2602
	private void refreshChartControls() {
2603
		int chartNumMax = chartControls.size();
2604
		for (int chartNum = 0; chartNum < chartNumMax; chartNum++) {
2605
			int chartRowMax = chartControls.get(chartNum).size();
2606
			for (int chartRow = 0; chartRow < chartRowMax; chartRow++) {
2607
				int chartColumnMax = chartControls.get(chartNum).get(chartRow).size();
2608
				for (int chartColumn = 0; chartColumn < chartColumnMax; chartColumn++) {
2609
					ChartExpression expression = charts.get(chartNum).getChartExpression(chartRow, chartColumn);
2610
					ChartControls controls = chartControls.get(chartNum).get(chartRow).get(chartColumn);
2611
					controls.getField().setText(chartFieldText[expression.getFieldName()]);
2612
					controls.getOperation().setText(chartOperationText[expression.getOperation()]);
2613
					controls.getValue().setText(expression.getValue());
2614
				}
2615
			}
2616
		}
2617
		chartGroup.layout(true);
2618
	}
2162
}
2619
}

Return to bug 283200