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

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/views/markers/FiltersConfigurationDialog.java (-46 / +75 lines)
Lines 82-87 Link Here
82
82
83
	private Button removeButton;
83
	private Button removeButton;
84
84
85
	private Button cloneButton;
86
85
	/**
87
	/**
86
	 * Create a new instance of the receiver on builder.
88
	 * Create a new instance of the receiver on builder.
87
	 * 
89
	 * 
Lines 326-367 Link Here
326
		addNew.setText(MarkerMessages.MarkerFilter_addFilterName);
328
		addNew.setText(MarkerMessages.MarkerFilter_addFilterName);
327
		addNew.addSelectionListener(new SelectionAdapter() {
329
		addNew.addSelectionListener(new SelectionAdapter() {
328
			public void widgetSelected(SelectionEvent e) {
330
			public void widgetSelected(SelectionEvent e) {
329
				InputDialog newDialog = new InputDialog(getShell(),
331
				addNewFilter(false);
330
						MarkerMessages.MarkerFilterDialog_title,
332
			}			
331
						MarkerMessages.MarkerFilterDialog_message,
332
						MarkerMessages.MarkerFilter_newFilterName,
333
						new IInputValidator() {
334
							/*
335
							 * (non-Javadoc)
336
							 * 
337
							 * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String)
338
							 */
339
							public String isValid(String newText) {
340
								if (newText.length() == 0)
341
									return MarkerMessages.MarkerFilterDialog_emptyMessage;
342
								Iterator filterIterator = filterGroups
343
										.iterator();
344
								while (filterIterator.hasNext()) {
345
									if (((MarkerFieldFilterGroup) filterIterator
346
											.next()).getName().equals(newText))
347
										return NLS
348
												.bind(
349
														MarkerMessages.filtersDialog_conflictingName,
350
														newText);
351
								}
352
353
								return null;
354
							}
355
						});
356
				if (Window.OK == newDialog.open()) {
357
					String newName = newDialog.getValue();
358
					if (newName != null) {
359
						createNewFilter(newName);
360
					}
361
				}
362
			}
363
		});
333
		});
364
		setButtonLayoutData(addNew);
334
		setButtonLayoutData(addNew);
335
		
336
		cloneButton= new Button(buttons, SWT.PUSH);
337
		cloneButton.setText(MarkerMessages.MarkerFilter_cloneFilterName);
338
		cloneButton.addSelectionListener(new SelectionAdapter() {
339
			public void widgetSelected(SelectionEvent e) {
340
				addNewFilter(true);
341
			}
342
		});
343
		setButtonLayoutData(cloneButton);
365
344
366
		removeButton = new Button(buttons, SWT.PUSH);
345
		removeButton = new Button(buttons, SWT.PUSH);
367
		removeButton.setText(MarkerMessages.MarkerFilter_deleteSelectedName);
346
		removeButton.setText(MarkerMessages.MarkerFilter_deleteSelectedName);
Lines 411-422 Link Here
411
	}
390
	}
412
391
413
	/**
392
	/**
414
	 * Create a new filter called newName
393
	 * Opens Input Dialog for name,creates a 
415
	 * 
394
	 * new filterGroup, and adds it to the filterGroups 
416
	 * @param newName
395
	 * @param cloneSelected true clones the selected filterGroup
396
	 * 				
397
	 */
398
	private void addNewFilter(boolean cloneSelected) {
399
		InputDialog newDialog = new InputDialog(getShell(),
400
				MarkerMessages.MarkerFilterDialog_title,
401
				MarkerMessages.MarkerFilterDialog_message,
402
				MarkerMessages.MarkerFilter_newFilterName,
403
				new IInputValidator() {
404
					public String isValid(String newText) {
405
						if (newText.length() == 0)
406
							return MarkerMessages.MarkerFilterDialog_emptyMessage;
407
						Iterator filterIterator = filterGroups
408
								.iterator();
409
						while (filterIterator.hasNext()) {
410
							if (((MarkerFieldFilterGroup) filterIterator
411
									.next()).getName().equals(newText))
412
								return NLS
413
										.bind(
414
												MarkerMessages.filtersDialog_conflictingName,
415
												newText);
416
						}
417
418
						return null;
419
					}
420
				});
421
		if (Window.OK == newDialog.open()) {
422
			String newName = newDialog.getValue();
423
			if (newName != null) {
424
				createNewFilter(newName,cloneSelected);
425
			}
426
		}
427
	}
428
	/**
429
	 * Create a new filterGroup, and adds it to the filterGroups 
430
	 * @param cloneSelected true clones the selected filterGroup
431
	 * @param newName name of new filterGroup
417
	 */
432
	 */
418
	private void createNewFilter(String newName) {
433
	private void createNewFilter(String newName,boolean cloneSelected) {
419
		MarkerFieldFilterGroup group = new MarkerFieldFilterGroup(null, builder);
434
		MarkerFieldFilterGroup group = new MarkerFieldFilterGroup(null, builder);
435
		if(cloneSelected&&selectedFilterGroup!=null){
436
			captureStateInto(group); //copy current values from UI
437
		}
420
		group.setName(newName);
438
		group.setName(newName);
421
		filterGroups.add(group);
439
		filterGroups.add(group);
422
		filtersList.refresh();
440
		filtersList.refresh();
Lines 519-527 Link Here
519
					.next();
537
					.next();
520
			group.setEnabled(filtersList.getChecked(group));
538
			group.setEnabled(filtersList.getChecked(group));
521
		}
539
		}
522
		if (selectedFilterGroup != null) {
540
		captureStateInto(selectedFilterGroup);
541
542
		super.okPressed();
543
544
	}
545
546
	/**
547
	 * 
548
	 * Updates the filterGroup with the values showing in the dialog's GUI.
549
	 * @param filterGroup 
550
	 * 
551
	 */
552
	private void captureStateInto(MarkerFieldFilterGroup filterGroup) {
553
		if (filterGroup != null) {
523
554
524
			scopeArea.applyToGroup(selectedFilterGroup);
555
			scopeArea.applyToGroup(filterGroup);
525
			Iterator areas = filterAreas.iterator();
556
			Iterator areas = filterAreas.iterator();
526
			while (areas.hasNext()) {
557
			while (areas.hasNext()) {
527
				FilterConfigurationArea area = (FilterConfigurationArea) areas
558
				FilterConfigurationArea area = (FilterConfigurationArea) areas
Lines 530-542 Link Here
530
				// Handle the internal special cases
561
				// Handle the internal special cases
531
				if (area instanceof GroupFilterConfigurationArea)
562
				if (area instanceof GroupFilterConfigurationArea)
532
					((GroupFilterConfigurationArea) area)
563
					((GroupFilterConfigurationArea) area)
533
							.applyToGroup(selectedFilterGroup);
564
							.applyToGroup(filterGroup);
534
				area.apply(selectedFilterGroup.getFilter(area.getField()));
565
				area.apply(filterGroup.getFilter(area.getField()));
535
			}
566
			}
536
		}
567
		}
537
538
		super.okPressed();
539
540
	}
568
	}
541
569
542
	/**
570
	/**
Lines 609-615 Link Here
609
		removeButton
637
		removeButton
610
				.setEnabled(!(markerFieldFilterGroup == null || markerFieldFilterGroup
638
				.setEnabled(!(markerFieldFilterGroup == null || markerFieldFilterGroup
611
						.isSystem()));
639
						.isSystem()));
612
640
		cloneButton.setEnabled(markerFieldFilterGroup != null);
641
		
613
		MarkerFieldFilterGroup old = selectedFilterGroup;
642
		MarkerFieldFilterGroup old = selectedFilterGroup;
614
		selectedFilterGroup = markerFieldFilterGroup;
643
		selectedFilterGroup = markerFieldFilterGroup;
615
		if (old != null)
644
		if (old != null)
(-)src/org/eclipse/ui/views/markers/internal/MarkerMessages.java (+1 lines)
Lines 196-201 Link Here
196
	public static String MarkerFilter_newFilterName;
196
	public static String MarkerFilter_newFilterName;
197
	public static String MarkerFilter_filtersTitle;
197
	public static String MarkerFilter_filtersTitle;
198
	public static String MarkerFilter_addFilterName;
198
	public static String MarkerFilter_addFilterName;
199
	public static String MarkerFilter_cloneFilterName;
199
	public static String MarkerFilter_deleteSelectedName;
200
	public static String MarkerFilter_deleteSelectedName;
200
	public static String MarkerFilter_showAllCommand_title;
201
	public static String MarkerFilter_showAllCommand_title;
201
	public static String MarkerFilter_ConfigureContentsCommand_title;
202
	public static String MarkerFilter_ConfigureContentsCommand_title;
(-)src/org/eclipse/ui/views/markers/internal/messages.properties (+1 lines)
Lines 177-182 Link Here
177
MarkerFilter_newFilterName=New Filter
177
MarkerFilter_newFilterName=New Filter
178
MarkerFilter_filtersTitle=User f&ilters:
178
MarkerFilter_filtersTitle=User f&ilters:
179
MarkerFilter_addFilterName=&New...
179
MarkerFilter_addFilterName=&New...
180
MarkerFilter_cloneFilterName=&Duplicate...
180
MarkerFilter_deleteSelectedName = Remo&ve
181
MarkerFilter_deleteSelectedName = Remo&ve
181
MarkerFilter_showAllCommand_title = &Show All
182
MarkerFilter_showAllCommand_title = &Show All
182
MarkerFilter_ConfigureContentsCommand_title = &Configure Contents...
183
MarkerFilter_ConfigureContentsCommand_title = &Configure Contents...

Return to bug 257956