View | Details | Raw Unified | Return to bug 231081 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/views/markers/FiltersConfigurationDialog.java (-177 / +414 lines)
Lines 17-27 Link Here
17
import java.util.Collection;
17
import java.util.Collection;
18
import java.util.Iterator;
18
import java.util.Iterator;
19
19
20
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.IDialogSettings;
22
import org.eclipse.jface.dialogs.IDialogSettings;
22
import org.eclipse.jface.dialogs.IInputValidator;
23
import org.eclipse.jface.dialogs.IInputValidator;
23
import org.eclipse.jface.dialogs.InputDialog;
24
import org.eclipse.jface.dialogs.InputDialog;
24
import org.eclipse.jface.dialogs.MessageDialog;
25
import org.eclipse.jface.viewers.CheckStateChangedEvent;
25
import org.eclipse.jface.viewers.CheckStateChangedEvent;
26
import org.eclipse.jface.viewers.CheckboxTableViewer;
26
import org.eclipse.jface.viewers.CheckboxTableViewer;
27
import org.eclipse.jface.viewers.ICheckStateListener;
27
import org.eclipse.jface.viewers.ICheckStateListener;
Lines 45-59 Link Here
45
import org.eclipse.swt.widgets.Button;
45
import org.eclipse.swt.widgets.Button;
46
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Composite;
47
import org.eclipse.swt.widgets.Control;
47
import org.eclipse.swt.widgets.Control;
48
import org.eclipse.swt.widgets.Event;
49
import org.eclipse.swt.widgets.Group;
48
import org.eclipse.swt.widgets.Label;
50
import org.eclipse.swt.widgets.Label;
51
import org.eclipse.swt.widgets.Listener;
49
import org.eclipse.swt.widgets.Shell;
52
import org.eclipse.swt.widgets.Shell;
53
import org.eclipse.swt.widgets.Text;
50
import org.eclipse.ui.forms.events.ExpansionEvent;
54
import org.eclipse.ui.forms.events.ExpansionEvent;
51
import org.eclipse.ui.forms.events.IExpansionListener;
55
import org.eclipse.ui.forms.events.IExpansionListener;
52
import org.eclipse.ui.forms.widgets.ExpandableComposite;
56
import org.eclipse.ui.forms.widgets.ExpandableComposite;
53
import org.eclipse.ui.forms.widgets.FormToolkit;
57
import org.eclipse.ui.forms.widgets.FormToolkit;
54
import org.eclipse.ui.forms.widgets.ScrolledForm;
58
import org.eclipse.ui.forms.widgets.ScrolledForm;
59
import org.eclipse.ui.internal.ide.IDEInternalPreferences;
55
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
60
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
56
import org.eclipse.ui.preferences.ViewSettingsDialog;
57
import org.eclipse.ui.views.markers.FilterConfigurationArea;
61
import org.eclipse.ui.views.markers.FilterConfigurationArea;
58
import org.eclipse.ui.views.markers.internal.MarkerMessages;
62
import org.eclipse.ui.views.markers.internal.MarkerMessages;
59
63
Lines 63-69 Link Here
63
 * @since 3.3
67
 * @since 3.3
64
 * 
68
 * 
65
 */
69
 */
66
public class FiltersConfigurationDialog extends ViewSettingsDialog {
70
public class FiltersConfigurationDialog extends ViewerSettingsAndStatusDialog {
67
71
68
	private static final String SELECTED_FILTER_GROUP = "SELECTED_FILTER_GROUP"; //$NON-NLS-1$
72
	private static final String SELECTED_FILTER_GROUP = "SELECTED_FILTER_GROUP"; //$NON-NLS-1$
69
73
Lines 79-105 Link Here
79
83
80
	private MarkerContentGenerator generator;
84
	private MarkerContentGenerator generator;
81
85
82
	private Collection filterAreas;
86
	private int limitValue = -1;
83
87
	private boolean limitEnabled = false;
84
	private boolean andFilters = false;
88
	private boolean andFilters = false;
85
89
86
	private Button removeButton;
90
	private Collection filterAreas;
87
91
92
	private Button removeButton;
88
	private Button renameButton;
93
	private Button renameButton;
89
	
90
	private Button cloneButton;
94
	private Button cloneButton;
91
92
	private Button andButton;
95
	private Button andButton;
93
94
	private Button orButton;
96
	private Button orButton;
95
97
96
	private Label andOrLabel;
98
	private Label andOrLabel;
99
	private Text limitEditor;
100
	private Button limitBttn;
97
101
98
	/**
102
	/**
99
	 * Create a new instance of the receiver on builder.
103
	 * Create a new instance of the receiver on builder.
100
	 * 
104
	 * 
101
	 * @param parentShell
105
	 * @param parentShell
102
	 * @param generator 
106
	 * @param generator
103
	 */
107
	 */
104
	public FiltersConfigurationDialog(Shell parentShell,
108
	public FiltersConfigurationDialog(Shell parentShell,
105
			MarkerContentGenerator generator) {
109
			MarkerContentGenerator generator) {
Lines 131-248 Link Here
131
	/*
135
	/*
132
	 * (non-Javadoc)
136
	 * (non-Javadoc)
133
	 * 
137
	 * 
134
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
138
	 * @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog#
139
	 * configureShell(org.eclipse.swt.widgets.Shell)
135
	 */
140
	 */
136
	protected Control createDialogArea(Composite parent) {
141
	protected void configureShell(Shell newShell) {
142
		super.configureShell(newShell);
143
		newShell.setText(MarkerMessages.configureFiltersDialog_title);
144
	}
137
145
138
		parent.getShell().setText(MarkerMessages.configureFiltersDialog_title);
146
	/*
147
	 * (non-Javadoc)
148
	 * 
149
	 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
150
	 */
151
	protected boolean isResizable() {
152
		return true;
153
	}
139
154
140
		Composite top = (Composite) super.createDialogArea(parent);
155
	/*
156
	 * (non-Javadoc)
157
	 * 
158
	 * @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog#
159
	 * initializeDialog()
160
	 */
161
	protected void initializeDialog() {
162
		super.initializeDialog();
163
		validateState();
164
	}
141
165
142
		initializeDialogUnits(top);
166
	/*
167
	 * (non-Javadoc)
168
	 * 
169
	 * @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog#
170
	 * createDialogContentArea(org.eclipse.swt.widgets.Composite)
171
	 */
172
	protected Control createDialogContentArea(Composite parent) {
173
174
		createViewCommonUI(parent).setLayoutData(
175
				new GridData(SWT.FILL, SWT.NONE, true, false));
143
176
144
		GridLayout layout = new GridLayout();
177
		Group top = new Group(parent, SWT.NONE);
145
		layout.numColumns = 3;
178
		top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
146
		layout.makeColumnsEqualWidth = false;
179
		GridLayout layout = new GridLayout(3, false);
147
		top.setLayout(layout);
180
		top.setLayout(layout);
181
		top.setBackground(parent.getBackground());
182
		initializeDialogUnits(top);
148
183
149
		createFilterSelectionArea(top);
184
		createFilterSelectionArea(top);
150
		
185
		createVerticalSeperator(top).setLayoutData(
151
		Label seprator=new Label(top, SWT.SEPARATOR|SWT.VERTICAL);
186
				new GridData(SWT.NONE, SWT.FILL, false, true));
152
		seprator.setLayoutData(new GridData(SWT.NONE, SWT.FILL, false, true));
187
		createFilterAreas(top).setLayoutData(
153
		
188
				new GridData(SWT.FILL, SWT.FILL, true, true));
154
		final FormToolkit toolkit = new FormToolkit(top.getDisplay());
155
		parent.addDisposeListener(new DisposeListener() {
156
157
			public void widgetDisposed(DisposeEvent e) {
158
				toolkit.dispose();
159
160
			}
161
		});
162
		form = toolkit.createScrolledForm(top);
163
		form.setBackground(parent.getBackground());
164
165
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
166
		form.setLayoutData(data);
167
		form.getBody().setLayout(new GridLayout());
168
169
		filterAreas = generator.createFilterConfigurationFields();
170
171
		createFieldArea(toolkit, form, scopeArea, true);
172
		Iterator areas = filterAreas.iterator();
173
174
		while (areas.hasNext()) {
175
			createFieldArea(toolkit, form, (FilterConfigurationArea) areas
176
					.next(), true);
177
		}
178
189
179
		if (filterGroups.isEmpty())
190
		if (filterGroups.isEmpty())
180
			setFieldsEnabled(false);
191
			setFieldsEnabled(false);
181
		else
192
		else
182
			loadDialogSettings();
193
			loadDialogSettings();
183
184
		applyDialogFont(top);
194
		applyDialogFont(top);
185
		return top;
195
		return top;
186
	}
196
	}
187
197
188
	/**
198
	/**
189
	 * Create a field area in the form for the FilterConfigurationArea
199
	 * @param parent
190
	 * 
200
	 *            parent
191
	 * @param toolkit
201
	 * @return {@link Control}
192
	 * @param form
202
	 */
193
	 * @param area
203
	private Control createViewCommonUI(Composite parent) {
194
	 * @param expand
204
		Group group = new Group(parent, SWT.NONE);
195
	 *            <code>true</code> if the area should be expanded by default
205
		group.setLayout(new GridLayout(1, true));
196
	 */
206
		createLimitArea(group);
197
	private void createFieldArea(final FormToolkit toolkit,
207
		return group;
198
			final ScrolledForm form, final FilterConfigurationArea area,
208
	}
199
			boolean expand) {
200
		final ExpandableComposite expandable = toolkit
201
				.createExpandableComposite(form.getBody(),
202
						ExpandableComposite.TWISTIE);
203
		expandable.setText(area.getTitle());
204
		expandable.setBackground(form.getBackground());
205
		expandable.setLayout(new GridLayout());
206
		expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, area.grabExcessVerticalSpace()));
207
		expandable.addExpansionListener(new IExpansionListener() {
208
			/*
209
			 * (non-Javadoc)
210
			 * 
211
			 * @see org.eclipse.ui.forms.events.IExpansionListener#expansionStateChanged(org.eclipse.ui.forms.events.ExpansionEvent)
212
			 */
213
			public void expansionStateChanged(ExpansionEvent e) {
214
				expandable.getParent().layout(true);
215
216
			}
217
218
			/*
219
			 * (non-Javadoc)
220
			 * 
221
			 * @see org.eclipse.ui.forms.events.IExpansionListener#expansionStateChanging(org.eclipse.ui.forms.events.ExpansionEvent)
222
			 */
223
			public void expansionStateChanging(ExpansionEvent e) {
224
209
210
	/**
211
	 * Create element limit area.
212
	 * 
213
	 * @param parent
214
	 */
215
	private Control createLimitArea(Composite parent) {
216
		Composite composite = new Composite(parent, SWT.NONE);
217
		composite.setLayout(new GridLayout(2, false));
218
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
219
		limitBttn = new Button(composite, SWT.CHECK);
220
		limitBttn.setText(MarkerMessages.MarkerPreferences_VisibleItems);
221
		limitBttn.setLayoutData(new GridData());
222
223
		limitEditor = new Text(composite, SWT.BORDER);
224
		limitEditor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
225
		Listener listener = new Listener() {
226
			public void handleEvent(Event event) {
227
				switch (event.type) {
228
				case SWT.Selection:
229
					boolean limited = limitBttn.getSelection();
230
					setLimitEnabled(limited);
231
					limitEditor.setEditable(limited);
232
					limitEditor.setText(Integer.toString(getLimitValue()));
233
					break;
234
				case SWT.Modify:
235
					try {
236
						int limit = Integer.parseInt(event.text);
237
						if (limit > 0) {
238
							setLimitValue(limit);
239
						} else {
240
							limitEditor.setFocus();
241
						}
242
					} catch (Exception e) {
243
						limitEditor.setFocus();
244
					}
245
					break;
246
				}
247
				validateState();
225
			}
248
			}
226
		});
249
		};
227
250
		limitEditor.addListener(SWT.Modify, listener);
228
		Composite sectionClient = toolkit.createComposite(expandable);
251
		limitBttn.addListener(SWT.Selection, listener);
229
		sectionClient.setLayout(new GridLayout());
252
		setLimitEnabled(IDEWorkbenchPlugin.getDefault().getPreferenceStore()
230
		sectionClient.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true,
253
				.getBoolean(IDEInternalPreferences.USE_MARKER_LIMITS));
231
				false));
254
		setLimitValue(IDEWorkbenchPlugin.getDefault().getPreferenceStore()
232
		sectionClient.setBackground(form.getBackground());
255
				.getInt(IDEInternalPreferences.MARKER_LIMITS_VALUE));
233
		area.createContents(sectionClient);
256
234
		expandable.setClient(sectionClient);
257
		limitBttn.setSelection(isLimitEnabled());
235
		expandable.setExpanded(expand);
258
		limitEditor.setText(Integer.toString(getLimitValue()));
259
		limitEditor.setEditable(isLimitEnabled());
260
		return composite;
236
	}
261
	}
237
262
238
	/**
263
	/**
239
	 * Create the area for selecting the filters and enabling/disabling them.
264
	 * Create the area for selecting the filters and enabling/disabling them.
240
	 * 
265
	 * 
241
	 * @param top
266
	 * @param main
267
	 * @return {@link Control}
242
	 */
268
	 */
243
	private void createFilterSelectionArea(Composite top) {
269
	private Control createFilterSelectionArea(Composite main) {
244
270
245
		Composite filtersComposite = new Composite(top, SWT.NONE);
271
		Composite filtersComposite = new Composite(main, SWT.NONE);
246
		filtersComposite.setLayout(new GridLayout(2, false));
272
		filtersComposite.setLayout(new GridLayout(2, false));
247
		filtersComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
273
		filtersComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
248
				true));
274
				true));
Lines 255-261 Link Here
255
281
256
		filtersList = CheckboxTableViewer.newCheckList(filtersComposite,
282
		filtersList = CheckboxTableViewer.newCheckList(filtersComposite,
257
				SWT.BORDER);
283
				SWT.BORDER);
258
		
284
259
		filtersList.setContentProvider(new IStructuredContentProvider() {
285
		filtersList.setContentProvider(new IStructuredContentProvider() {
260
			/*
286
			/*
261
			 * (non-Javadoc)
287
			 * (non-Javadoc)
Lines 269-275 Link Here
269
			/*
295
			/*
270
			 * (non-Javadoc)
296
			 * (non-Javadoc)
271
			 * 
297
			 * 
272
			 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
298
			 * @see
299
			 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements
300
			 * (java.lang.Object)
273
			 */
301
			 */
274
			public Object[] getElements(Object inputElement) {
302
			public Object[] getElements(Object inputElement) {
275
				return filterGroups.toArray();
303
				return filterGroups.toArray();
Lines 278-285 Link Here
278
			/*
306
			/*
279
			 * (non-Javadoc)
307
			 * (non-Javadoc)
280
			 * 
308
			 * 
281
			 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
309
			 * @see
282
			 *      java.lang.Object, java.lang.Object)
310
			 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
311
			 * .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
283
			 */
312
			 */
284
			public void inputChanged(Viewer viewer, Object oldInput,
313
			public void inputChanged(Viewer viewer, Object oldInput,
285
					Object newInput) {
314
					Object newInput) {
Lines 291-297 Link Here
291
			/*
320
			/*
292
			 * (non-Javadoc)
321
			 * (non-Javadoc)
293
			 * 
322
			 * 
294
			 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
323
			 * @see
324
			 * org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object
325
			 * )
295
			 */
326
			 */
296
			public String getText(Object element) {
327
			public String getText(Object element) {
297
				return ((MarkerFieldFilterGroup) element).getName();
328
				return ((MarkerFieldFilterGroup) element).getName();
Lines 308-314 Link Here
308
					/*
339
					/*
309
					 * (non-Javadoc)
340
					 * (non-Javadoc)
310
					 * 
341
					 * 
311
					 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
342
					 * @see org.eclipse.jface.viewers.ISelectionChangedListener#
343
					 * selectionChanged
344
					 * (org.eclipse.jface.viewers.SelectionChangedEvent)
312
					 */
345
					 */
313
					public void selectionChanged(SelectionChangedEvent event) {
346
					public void selectionChanged(SelectionChangedEvent event) {
314
						setSelectedFilter((MarkerFieldFilterGroup) ((IStructuredSelection) event
347
						setSelectedFilter((MarkerFieldFilterGroup) ((IStructuredSelection) event
Lines 342-352 Link Here
342
		addNew.addSelectionListener(new SelectionAdapter() {
375
		addNew.addSelectionListener(new SelectionAdapter() {
343
			public void widgetSelected(SelectionEvent e) {
376
			public void widgetSelected(SelectionEvent e) {
344
				addNewFilter(false);
377
				addNewFilter(false);
345
			}			
378
			}
346
		});
379
		});
347
		setButtonLayoutData(addNew);
380
		setButtonLayoutData(addNew);
348
		
381
349
		cloneButton= new Button(buttons, SWT.PUSH);
382
		cloneButton = new Button(buttons, SWT.PUSH);
350
		cloneButton.setText(MarkerMessages.MarkerFilter_cloneFilterName);
383
		cloneButton.setText(MarkerMessages.MarkerFilter_cloneFilterName);
351
		cloneButton.addSelectionListener(new SelectionAdapter() {
384
		cloneButton.addSelectionListener(new SelectionAdapter() {
352
			public void widgetSelected(SelectionEvent e) {
385
			public void widgetSelected(SelectionEvent e) {
Lines 363-369 Link Here
363
			}
396
			}
364
		});
397
		});
365
		setButtonLayoutData(removeButton);
398
		setButtonLayoutData(removeButton);
366
		
399
367
		renameButton = new Button(buttons, SWT.PUSH);
400
		renameButton = new Button(buttons, SWT.PUSH);
368
		renameButton.setText(MarkerMessages.MarkerFilter_renameName);
401
		renameButton.setText(MarkerMessages.MarkerFilter_renameName);
369
		renameButton.addSelectionListener(new SelectionAdapter() {
402
		renameButton.addSelectionListener(new SelectionAdapter() {
Lines 374-386 Link Here
374
			}
407
			}
375
		});
408
		});
376
		setButtonLayoutData(renameButton);
409
		setButtonLayoutData(renameButton);
377
		
410
378
		andOrLabel = new Label(filtersComposite, SWT.NONE);
411
		andOrLabel = new Label(filtersComposite, SWT.NONE);
379
		GridData labelData = new GridData();
412
		GridData labelData = new GridData();
380
		labelData.horizontalSpan = 2;
413
		labelData.horizontalSpan = 2;
381
		andOrLabel.setLayoutData(labelData);
414
		andOrLabel.setLayoutData(labelData);
382
		andOrLabel.setText(MarkerMessages.AND_OR_Label);
415
		andOrLabel.setText(MarkerMessages.AND_OR_Label);
383
		
416
384
		andButton = new Button(filtersComposite, SWT.RADIO);
417
		andButton = new Button(filtersComposite, SWT.RADIO);
385
		GridData data = new GridData(GridData.FILL_HORIZONTAL, SWT.NONE, true,
418
		GridData data = new GridData(GridData.FILL_HORIZONTAL, SWT.NONE, true,
386
				false);
419
				false);
Lines 394-400 Link Here
394
			/*
427
			/*
395
			 * (non-Javadoc)
428
			 * (non-Javadoc)
396
			 * 
429
			 * 
397
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
430
			 * @see
431
			 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
432
			 * .swt.events.SelectionEvent)
398
			 */
433
			 */
399
			public void widgetSelected(SelectionEvent e) {
434
			public void widgetSelected(SelectionEvent e) {
400
				andFilters = true;
435
				andFilters = true;
Lines 413-419 Link Here
413
			/*
448
			/*
414
			 * (non-Javadoc)
449
			 * (non-Javadoc)
415
			 * 
450
			 * 
416
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
451
			 * @see
452
			 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
453
			 * .swt.events.SelectionEvent)
417
			 */
454
			 */
418
			public void widgetSelected(SelectionEvent e) {
455
			public void widgetSelected(SelectionEvent e) {
419
				andFilters = false;
456
				andFilters = false;
Lines 421-451 Link Here
421
		});
458
		});
422
		filtersList.addCheckStateListener(new ICheckStateListener() {
459
		filtersList.addCheckStateListener(new ICheckStateListener() {
423
			public void checkStateChanged(CheckStateChangedEvent event) {
460
			public void checkStateChanged(CheckStateChangedEvent event) {
424
				updateAndOrEnblement();				
461
				updateAndOrEnblement();
462
				validateState();
463
			}
464
		});
465
		return filtersComposite;
466
	}
467
468
	/**
469
	 * 
470
	 * @param parent
471
	 * @return {@link Control}
472
	 */
473
	private Control createVerticalSeperator(Composite parent) {
474
		Label seprator = new Label(parent, SWT.SEPARATOR | SWT.VERTICAL);
475
		return seprator;
476
	}
477
478
	/**
479
	 * 
480
	 * @param parent
481
	 * @return {@link Control}
482
	 */
483
	private Control createFilterAreas(Composite parent) {
484
		final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
485
		parent.addDisposeListener(new DisposeListener() {
486
			public void widgetDisposed(DisposeEvent e) {
487
				toolkit.dispose();
488
			}
489
		});
490
		form = toolkit.createScrolledForm(parent);
491
		form.setBackground(parent.getBackground());
492
493
		form.getBody().setLayout(new GridLayout());
494
495
		filterAreas = generator.createFilterConfigurationFields();
496
497
		createFieldArea(toolkit, form, scopeArea, true);
498
		Iterator areas = filterAreas.iterator();
499
		while (areas.hasNext()) {
500
			createFieldArea(toolkit, form,
501
					(FilterConfigurationArea) areas.next(), true);
502
		}
503
		return form;
504
	}
505
506
	/**
507
	 * Create a field area in the form for the FilterConfigurationArea
508
	 * 
509
	 * @param toolkit
510
	 * @param form
511
	 * @param area
512
	 * @param expand
513
	 *            <code>true</code> if the area should be expanded by default
514
	 */
515
	private void createFieldArea(final FormToolkit toolkit,
516
			final ScrolledForm form, final FilterConfigurationArea area,
517
			boolean expand) {
518
		final ExpandableComposite expandable = toolkit
519
				.createExpandableComposite(form.getBody(),
520
						ExpandableComposite.TWISTIE);
521
		expandable.setText(area.getTitle());
522
		expandable.setBackground(form.getBackground());
523
		expandable.setLayout(new GridLayout());
524
		expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, area
525
				.grabExcessVerticalSpace()));
526
		expandable.addExpansionListener(new IExpansionListener() {
527
			/*
528
			 * (non-Javadoc)
529
			 * 
530
			 * @see
531
			 * org.eclipse.ui.forms.events.IExpansionListener#expansionStateChanged
532
			 * (org.eclipse.ui.forms.events.ExpansionEvent)
533
			 */
534
			public void expansionStateChanged(ExpansionEvent e) {
535
				expandable.getParent().layout(true);
536
537
			}
538
539
			/*
540
			 * (non-Javadoc)
541
			 * 
542
			 * @see
543
			 * org.eclipse.ui.forms.events.IExpansionListener#expansionStateChanging
544
			 * (org.eclipse.ui.forms.events.ExpansionEvent)
545
			 */
546
			public void expansionStateChanging(ExpansionEvent e) {
547
425
			}
548
			}
426
		});
549
		});
550
551
		Composite sectionClient = toolkit.createComposite(expandable);
552
		sectionClient.setLayout(new GridLayout());
553
		sectionClient.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true,
554
				false));
555
		sectionClient.setBackground(form.getBackground());
556
		area.createContents(sectionClient);
557
		expandable.setClient(sectionClient);
558
		expandable.setExpanded(expand);
559
	}
560
561
	/**
562
	 * Get a collection of names of the filters currently in the list
563
	 * 
564
	 * @return Collection
565
	 */
566
	private Collection getCurrentFilterNames() {
567
		Collection names = new ArrayList();
568
		Iterator filterIterator = filterGroups.iterator();
569
		while (filterIterator.hasNext()) {
570
			names.add(((MarkerFieldFilterGroup) filterIterator.next())
571
					.getName());
572
		}
573
		return names;
427
	}
574
	}
428
575
429
	/**
576
	/**
430
	 * Opens Input Dialog for name,creates a 
577
	 * Opens Input Dialog for name,creates a new filterGroup, and adds it to the
431
	 * new filterGroup, and adds it to the filterGroups 
578
	 * filterGroups
432
	 * @param cloneSelected true clones the selected filterGroup
579
	 * 
433
	 * 				
580
	 * @param cloneSelected
581
	 *            true clones the selected filterGroup
582
	 * 
434
	 */
583
	 */
435
	private void addNewFilter(boolean cloneSelected) {
584
	private void addNewFilter(boolean cloneSelected) {
436
		String newName =getNewFilterName(getCurrentFilterNames(),null);
585
		String newName = getNewFilterName(getCurrentFilterNames(), null);
437
		if (newName != null) {
586
		if (newName != null) {
438
			createNewFilter(newName,cloneSelected);
587
			createNewFilter(newName, cloneSelected);
439
		}
588
		}
440
	}
589
	}
590
441
	/**
591
	/**
442
	 * Opens Input Dialog for a new filter name
592
	 * Opens Input Dialog for a new filter name
443
	 * @param avoidNames filter names to avoid
593
	 * 
444
	 * @param initialName initial name of the filter
594
	 * @param avoidNames
595
	 *            filter names to avoid
596
	 * @param initialName
597
	 *            initial name of the filter
445
	 * @return new filter name or null if canceled
598
	 * @return new filter name or null if canceled
446
	 * 				
599
	 * 
447
	 */
600
	 */
448
	private String getNewFilterName(final Collection avoidNames,String initialName){
601
	private String getNewFilterName(final Collection avoidNames,
602
			String initialName) {
449
		InputDialog newDialog = new InputDialog(getShell(),
603
		InputDialog newDialog = new InputDialog(getShell(),
450
				MarkerMessages.MarkerFilterDialog_title,
604
				MarkerMessages.MarkerFilterDialog_title,
451
				MarkerMessages.MarkerFilterDialog_message,
605
				MarkerMessages.MarkerFilterDialog_message,
Lines 460-472 Link Here
460
614
461
	/**
615
	/**
462
	 * Get IInputValidator for checking if the new name is valid
616
	 * Get IInputValidator for checking if the new name is valid
617
	 * 
463
	 * @param avoidNames
618
	 * @param avoidNames
464
	 * @return IInputValidator
619
	 * @return IInputValidator
465
	 */
620
	 */
466
	private IInputValidator getNameValidator(final Collection avoidNames) {
621
	private IInputValidator getNameValidator(final Collection avoidNames) {
467
		return new IInputValidator() {
622
		return new IInputValidator() {
468
			public String isValid(String value) {
623
			public String isValid(String value) {
469
				String newText=value.trim();
624
				String newText = value.trim();
470
				if (newText.length() == 0)
625
				if (newText.length() == 0)
471
					return MarkerMessages.MarkerFilterDialog_emptyMessage;
626
					return MarkerMessages.MarkerFilterDialog_emptyMessage;
472
				if (avoidNames.contains(newText))
627
				if (avoidNames.contains(newText))
Lines 477-504 Link Here
477
			}
632
			}
478
		};
633
		};
479
	}
634
	}
480
	
635
481
	/**
482
	 * Get a collection of names of the filters currently in the list
483
	 * @return Collection
484
	 */
485
	private Collection getCurrentFilterNames() {
486
		Collection names = new ArrayList();
487
		Iterator filterIterator = filterGroups.iterator();
488
		while (filterIterator.hasNext()) {
489
			names.add(((MarkerFieldFilterGroup) filterIterator.next()).getName());
490
		}
491
		return names;
492
	}
493
	/**
636
	/**
494
	 * Create a new filterGroup, and adds it to the filterGroups 
637
	 * Create a new filterGroup, and adds it to the filterGroups
495
	 * @param cloneSelected true clones the selected filterGroup
638
	 * 
496
	 * @param newName name of new filterGroup
639
	 * @param cloneSelected
497
	 */
640
	 *            true clones the selected filterGroup
498
	private void createNewFilter(String newName,boolean cloneSelected) {
641
	 * @param newName
499
		MarkerFieldFilterGroup group = new MarkerFieldFilterGroup(null, generator);
642
	 *            name of new filterGroup
500
		if(cloneSelected&&selectedFilterGroup!=null){
643
	 */
501
			captureStateInto(group); //copy current values from UI
644
	private void createNewFilter(String newName, boolean cloneSelected) {
645
		MarkerFieldFilterGroup group = new MarkerFieldFilterGroup(null,
646
				generator);
647
		if (cloneSelected && selectedFilterGroup != null) {
648
			captureStateInto(group); // copy current values from UI
502
		}
649
		}
503
		group.setName(newName);
650
		group.setName(newName);
504
		filterGroups.add(group);
651
		filterGroups.add(group);
Lines 510-515 Link Here
510
657
511
	/**
658
	/**
512
	 * Renames the supplied MarkerFieldFilterGroup
659
	 * Renames the supplied MarkerFieldFilterGroup
660
	 * 
513
	 * @param filterGroup
661
	 * @param filterGroup
514
	 */
662
	 */
515
	private void renameFilter(MarkerFieldFilterGroup filterGroup) {
663
	private void renameFilter(MarkerFieldFilterGroup filterGroup) {
Lines 518-544 Link Here
518
			String initial = null;
666
			String initial = null;
519
			initial = filterGroup.getName();
667
			initial = filterGroup.getName();
520
			names.remove(initial);
668
			names.remove(initial);
521
			String newName=getNewFilterName(names, initial);
669
			String newName = getNewFilterName(names, initial);
522
			if(newName!=null){
670
			if (newName != null) {
523
				filterGroup.setName(newName);
671
				filterGroup.setName(newName);
524
				filtersList.update(filterGroup, null);
672
				filtersList.update(filterGroup, null);
525
			}
673
			}
526
		}
674
		}
527
	}
675
	}
676
528
	/**
677
	/**
529
	 * Enable/disable 'and', 'or' buttons
678
	 * Enable/disable 'and', 'or' buttons
530
	 */
679
	 */
531
	private void updateAndOrEnblement() {
680
	private void updateAndOrEnblement() {
532
		if(filtersList.getCheckedElements().length==0){
681
		if (filtersList.getCheckedElements().length == 0) {
533
			andOrLabel.setEnabled(false);
682
			andOrLabel.setEnabled(false);
534
			andButton.setEnabled(false);
683
			andButton.setEnabled(false);
535
			orButton.setEnabled(false);
684
			orButton.setEnabled(false);
536
		}else{
685
		} else {
537
			andOrLabel.setEnabled(true);
686
			andOrLabel.setEnabled(true);
538
			andButton.setEnabled(true);
687
			andButton.setEnabled(true);
539
			orButton.setEnabled(true);
688
			orButton.setEnabled(true);
540
		}
689
		}
541
	}
690
	}
691
542
	/**
692
	/**
543
	 * Return the dialog settings for the receiver.
693
	 * Return the dialog settings for the receiver.
544
	 * 
694
	 * 
Lines 565-579 Link Here
565
		return filterGroups;
715
		return filterGroups;
566
	}
716
	}
567
717
568
	/*
569
	 * (non-Javadoc)
570
	 * 
571
	 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
572
	 */
573
	protected boolean isResizable() {
574
		return true;
575
	}
576
577
	/**
718
	/**
578
	 * Load the dialog settings.
719
	 * Load the dialog settings.
579
	 */
720
	 */
Lines 618-623 Link Here
618
		return returnFilters;
759
		return returnFilters;
619
	}
760
	}
620
761
762
	private void validateState() {
763
		if (limitBttn == null || limitBttn.isDisposed()) {
764
			handleStatusUdpate(IStatus.INFO, null);
765
		} else {
766
			boolean limitLess = !limitBttn.getSelection();
767
			if (limitLess) {
768
				if (filtersList == null
769
						|| filtersList.getControl().isDisposed()) {
770
					handleStatusUdpate(IStatus.INFO, null);
771
				} else {
772
					boolean warnning = filtersList.getCheckedElements() == null
773
							|| filtersList.getCheckedElements().length == 0;
774
					if (warnning) {
775
						handleStatusUdpate(
776
								IStatus.WARNING,
777
								MarkerMessages.filtersDialogDeselectedFiltersMessage
778
										+ MarkerMessages.MarkerFilterDialog_YouHaveDisabledMarkerLimit);
779
780
					} else {
781
						handleStatusUdpate(
782
								IStatus.WARNING,
783
								MarkerMessages.MarkerFilterDialog_YouHaveDisabledMarkerLimit);
784
					}
785
				}
786
			} else {
787
				if (limitEditor == null || limitEditor.isDisposed()) {
788
					handleStatusUdpate(IStatus.INFO, null);
789
				} else {
790
					String value = limitEditor.getText().trim();
791
					boolean validLimit = value.length() != 0;
792
					if (validLimit) {
793
						try {
794
							int limit = Integer.parseInt(value);
795
							if (limit <= 0) {
796
								validLimit = false;
797
							}
798
						} catch (Exception e) {
799
							validLimit = false;
800
						}
801
					}
802
					if (filtersList == null
803
							|| filtersList.getControl().isDisposed()) {
804
						handleStatusUdpate(IStatus.INFO, null);
805
					} else {
806
						boolean warnning = filtersList.getCheckedElements().length == 0;
807
						if (validLimit) {
808
							if (warnning) {
809
								handleStatusUdpate(
810
										IStatus.WARNING,
811
										MarkerMessages.filtersDialogDeselectedFiltersMessage);
812
							} else {
813
								handleStatusUdpate(IStatus.INFO, null);
814
							}
815
						} else {
816
							handleStatusUdpate(IStatus.ERROR, null);
817
						}
818
					}
819
				}
820
			}
821
		}
822
	}
823
621
	/*
824
	/*
622
	 * (non-Javadoc)
825
	 * (non-Javadoc)
623
	 * 
826
	 * 
Lines 625-632 Link Here
625
	 */
828
	 */
626
	protected void okPressed() {
829
	protected void okPressed() {
627
830
628
		if (!shouldContinue())
831
		IDEWorkbenchPlugin
629
			return;
832
				.getDefault()
833
				.getPreferenceStore()
834
				.setValue(IDEInternalPreferences.MARKER_LIMITS_VALUE,
835
						getLimitValue());
836
		IDEWorkbenchPlugin
837
				.getDefault()
838
				.getPreferenceStore()
839
				.setValue(IDEInternalPreferences.USE_MARKER_LIMITS,
840
						isLimitEnabled());
841
		IDEWorkbenchPlugin.getDefault().savePluginPreferences();
630
842
631
		Iterator filterGroupIterator = filterGroups.iterator();
843
		Iterator filterGroupIterator = filterGroups.iterator();
632
		while (filterGroupIterator.hasNext()) {
844
		while (filterGroupIterator.hasNext()) {
Lines 643-649 Link Here
643
	/**
855
	/**
644
	 * 
856
	 * 
645
	 * Updates the filterGroup with the values showing in the dialog's GUI.
857
	 * Updates the filterGroup with the values showing in the dialog's GUI.
646
	 * @param filterGroup 
858
	 * 
859
	 * @param filterGroup
647
	 * 
860
	 * 
648
	 */
861
	 */
649
	private void captureStateInto(MarkerFieldFilterGroup filterGroup) {
862
	private void captureStateInto(MarkerFieldFilterGroup filterGroup) {
Lines 663-701 Link Here
663
			}
876
			}
664
		}
877
		}
665
	}
878
	}
666
	
879
667
	/*
880
	/*
668
	 * (non-Javadoc)
881
	 * (non-Javadoc)
882
	 * 
669
	 * @see org.eclipse.ui.preferences.ViewSettingsDialog#performDefaults()
883
	 * @see org.eclipse.ui.preferences.ViewSettingsDialog#performDefaults()
670
	 */
884
	 */
671
	protected void performDefaults() {
885
	protected void performDefaults() {
886
		setLimitEnabled(IDEWorkbenchPlugin.getDefault().getPreferenceStore()
887
				.getDefaultBoolean(IDEInternalPreferences.USE_MARKER_LIMITS));
888
		limitBttn.setSelection(isLimitEnabled());
889
890
		setLimitValue(IDEWorkbenchPlugin.getDefault().getPreferenceStore()
891
				.getDefaultInt(IDEInternalPreferences.MARKER_LIMITS_VALUE));
892
		limitEditor.setText(Integer.toString(getLimitValue()));
893
672
		filterGroups.clear();
894
		filterGroups.clear();
673
		filterGroups.addAll(generator.getDeclaredFilters());
895
		filterGroups.addAll(generator.getDeclaredFilters());
674
		filtersList.refresh();
896
		filtersList.refresh();
675
		filtersList.setSelection(new StructuredSelection(
897
		filtersList.setSelection(new StructuredSelection(
676
				filterGroups.size() > 1 ? filterGroups.iterator().next()
898
				filterGroups.size() > 1 ? filterGroups.iterator().next()
677
						: new Object[0]));
899
						: new Object[0]));
678
		andFilters=false;
900
		andFilters = false;
679
		andButton.setSelection(andFilters);
901
		andButton.setSelection(andFilters);
680
		orButton.setSelection(!andFilters);
902
		orButton.setSelection(!andFilters);
681
	}
903
	}
682
904
683
	/**
905
	/**
684
	 * Return whether or not deselected elements should have been selected.
685
	 * 
686
	 * @return boolean
687
	 */
688
	private boolean shouldContinue() {
689
		if (filtersList.getCheckedElements().length == 0) {
690
			return MessageDialog.openQuestion(getShell(),
691
					MarkerMessages.filtersDialogDeselectedFiltersTitle,
692
					MarkerMessages.filtersDialogDeselectedFiltersMessage);
693
		}
694
695
		return true;
696
	}
697
698
	/**
699
	 * Remove the filters in selection.
906
	 * Remove the filters in selection.
700
	 * 
907
	 * 
701
	 * @param selection
908
	 * @param selection
Lines 719-724 Link Here
719
	}
926
	}
720
927
721
	/**
928
	/**
929
	 * @return Returns the limitValue.
930
	 */
931
	private int getLimitValue() {
932
		return limitValue;
933
	}
934
935
	/**
936
	 * @param limitValue
937
	 *            The limitValue to set.
938
	 */
939
	private void setLimitValue(int limitValue) {
940
		this.limitValue = limitValue;
941
	}
942
943
	/**
944
	 * @return Returns true if limit is enabled.
945
	 */
946
	private boolean isLimitEnabled() {
947
		return limitEnabled;
948
	}
949
950
	/**
951
	 * @param limitEnabled
952
	 *            The limitEnabled to set.
953
	 */
954
	private void setLimitEnabled(boolean limitEnabled) {
955
		this.limitEnabled = limitEnabled;
956
	}
957
958
	/**
722
	 * Set the control and all of it's visibility state to visible.
959
	 * Set the control and all of it's visibility state to visible.
723
	 * 
960
	 * 
724
	 * @param visible
961
	 * @param visible
Lines 747-753 Link Here
747
	 * @param markerFieldFilterGroup
984
	 * @param markerFieldFilterGroup
748
	 */
985
	 */
749
	private void setSelectedFilter(MarkerFieldFilterGroup markerFieldFilterGroup) {
986
	private void setSelectedFilter(MarkerFieldFilterGroup markerFieldFilterGroup) {
750
		if(selectedFilterGroup==markerFieldFilterGroup){
987
		if (selectedFilterGroup == markerFieldFilterGroup) {
751
			return;
988
			return;
752
		}
989
		}
753
		removeButton
990
		removeButton
Lines 757-763 Link Here
757
				.setEnabled(!(markerFieldFilterGroup == null || markerFieldFilterGroup
994
				.setEnabled(!(markerFieldFilterGroup == null || markerFieldFilterGroup
758
						.isSystem()));
995
						.isSystem()));
759
		cloneButton.setEnabled(markerFieldFilterGroup != null);
996
		cloneButton.setEnabled(markerFieldFilterGroup != null);
760
		
997
761
		MarkerFieldFilterGroup old = selectedFilterGroup;
998
		MarkerFieldFilterGroup old = selectedFilterGroup;
762
		selectedFilterGroup = markerFieldFilterGroup;
999
		selectedFilterGroup = markerFieldFilterGroup;
763
		if (old != null)
1000
		if (old != null)
(-)src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java (-26 / +34 lines)
Lines 758-794 Link Here
758
	 */
758
	 */
759
	boolean select(MarkerEntry entry) {
759
	boolean select(MarkerEntry entry) {
760
		try {
760
		try {
761
			Collection enabledFilters = getEnabledFilters();
761
			return select(entry, getSelectedResources(), getEnabledFilters(), andFilters());
762
			IResource[] resources = getSelectedResources();
762
		} finally {
763
			boolean andFilters = andFilters();
763
			entry.clearCache();
764
			if (enabledFilters.size() > 0) {
764
		}
765
				Iterator filtersIterator = enabledFilters.iterator();
765
	}
766
				if (andFilters) {
767
					while (filtersIterator.hasNext()) {
768
						MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filtersIterator
769
								.next();
770
						if (!group.selectByScope(entry, resources)
771
								|| !group.selectByFilters(entry)) {
772
							return false;
773
						}
774
					}
775
					return true;
776
				}
777
766
767
	boolean select(MarkerEntry entry, IResource[] selResources,
768
			Collection enabledFilters, boolean andFilters) {
769
		if (enabledFilters.size() > 0) {
770
			Iterator filtersIterator = enabledFilters.iterator();
771
			if (andFilters) {
778
				while (filtersIterator.hasNext()) {
772
				while (filtersIterator.hasNext()) {
779
					MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filtersIterator
773
					MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filtersIterator
780
							.next();
774
							.next();
781
					if (group.selectByScope(entry, resources)
775
					if (!group.selectByScope(entry, selResources)
782
							&& group.selectByFilters(entry)) {
776
							|| !group.selectByFilters(entry)) {
783
						return true;
777
						return false;
784
					}
778
					}
785
				}
779
				}
786
				return false;
780
				return true;
787
			}
781
			}
788
			return true;
782
789
		} finally {
783
			while (filtersIterator.hasNext()) {
790
			entry.clearCache();
784
				MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filtersIterator
785
						.next();
786
				if (group.selectByScope(entry, selResources)
787
						&& group.selectByFilters(entry)) {
788
					return true;
789
				}
790
			}
791
			return false;
791
		}
792
		}
793
		return true;
792
	}
794
	}
793
795
794
	/**
796
	/**
Lines 1049-1054 Link Here
1049
		if (monitor.isCanceled()) {
1051
		if (monitor.isCanceled()) {
1050
			return false;
1052
			return false;
1051
		}
1053
		}
1054
		IResource[] selected = getSelectedResources();
1055
		Collection filters = getEnabledFilters();
1056
		boolean andFilters = andFilters();
1052
		Iterator iterator = resources.iterator();
1057
		Iterator iterator = resources.iterator();
1053
		while (iterator.hasNext()) {
1058
		while (iterator.hasNext()) {
1054
			IMarker[] markers = null;
1059
			IMarker[] markers = null;
Lines 1068-1078 Link Here
1068
			if (monitor.isCanceled()) {
1073
			if (monitor.isCanceled()) {
1069
				return false;
1074
				return false;
1070
			}
1075
			}
1071
			for (int i = 0; i < markers.length; i++) {
1076
			MarkerEntry entry = null;
1072
				MarkerEntry entry = new MarkerEntry(markers[i]);
1077
			int lenght =  markers.length;
1073
				if (select(entry)) {
1078
			for (int i = 0; i < lenght; i++) {
1079
				entry = new MarkerEntry(markers[i]);
1080
				if (select(entry, selected, filters, andFilters)) {
1074
					result.add(entry);
1081
					result.add(entry);
1075
				}
1082
				}
1083
				entry.clearCache();
1076
				if (i % 500 == 0) {
1084
				if (i % 500 == 0) {
1077
					if (monitor.isCanceled()) {
1085
					if (monitor.isCanceled()) {
1078
						return false;
1086
						return false;
(-)src/org/eclipse/ui/internal/views/markers/MarkerFieldFilterGroup.java (-6 / +37 lines)
Lines 95-100 Link Here
95
	private static final String TAG_SCOPE = "scope"; //$NON-NLS-1$
95
	private static final String TAG_SCOPE = "scope"; //$NON-NLS-1$
96
	private static final String TAG_FIELD_FILTER_ENTRY = "fieldFilter"; //$NON-NLS-1$
96
	private static final String TAG_FIELD_FILTER_ENTRY = "fieldFilter"; //$NON-NLS-1$
97
	private static final String TAG_WORKING_SET = "workingSet"; //$NON-NLS-1$
97
	private static final String TAG_WORKING_SET = "workingSet"; //$NON-NLS-1$
98
	private static final String TAG_LIMIT = "filterLimit"; //$NON-NLS-1$
98
	// The identifier for user filters
99
	// The identifier for user filters
99
	private static String USER = "USER"; //$NON-NLS-1$
100
	private static String USER = "USER"; //$NON-NLS-1$
100
101
Lines 106-111 Link Here
106
	private boolean enabled = true;
107
	private boolean enabled = true;
107
	protected MarkerFieldFilter[] fieldFilters;
108
	protected MarkerFieldFilter[] fieldFilters;
108
	private int scope;
109
	private int scope;
110
	private int limit;
111
	
109
	private String name;
112
	private String name;
110
	private String id;
113
	private String id;
111
114
Lines 131-141 Link Here
131
134
132
		if (configurationElement == null)
135
		if (configurationElement == null)
133
			return;
136
			return;
134
		String enablementString = configurationElement
137
		String stringValue = configurationElement
135
				.getAttribute(MarkerSupportRegistry.ENABLED);
138
				.getAttribute(MarkerSupportRegistry.ENABLED);
136
		if (MarkerSupportInternalUtilities.FALSE.equals(enablementString))
139
		if (MarkerSupportInternalUtilities.FALSE.equals(stringValue)) {
137
			enabled = false;
140
			enabled = false;
138
141
		}
142
		stringValue = configurationElement
143
				.getAttribute(MarkerSupportRegistry.FILTER_LIMIT);
144
		if (stringValue == null || stringValue.length() == 0) {
145
			limit = -1;
146
		}
139
	}
147
	}
140
148
141
	/**
149
	/**
Lines 433-441 Link Here
433
	 */
441
	 */
434
	void loadSettings(IMemento memento) {
442
	void loadSettings(IMemento memento) {
435
443
436
		String enabledString = memento.getString(TAG_ENABLED);
444
		String stringValue = memento.getString(TAG_ENABLED);
437
		if (enabledString != null && enabledString.length() > 0)
445
		if (stringValue != null && stringValue.length() > 0){
438
			enabled = Boolean.valueOf(enabledString).booleanValue();
446
			enabled = Boolean.valueOf(stringValue).booleanValue();
447
		}
439
		scope = memento.getInteger(TAG_SCOPE).intValue();
448
		scope = memento.getInteger(TAG_SCOPE).intValue();
440
449
441
		String workingSetName = memento.getString(TAG_WORKING_SET);
450
		String workingSetName = memento.getString(TAG_WORKING_SET);
Lines 444-449 Link Here
444
			setWorkingSet(PlatformUI.getWorkbench().getWorkingSetManager()
453
			setWorkingSet(PlatformUI.getWorkbench().getWorkingSetManager()
445
					.getWorkingSet(workingSetName));
454
					.getWorkingSet(workingSetName));
446
455
456
		stringValue = memento.getString(TAG_LIMIT);
457
		if (stringValue != null && stringValue.length() > 0) {
458
			setLimit(Integer.parseInt(stringValue));
459
		}
460
		
447
		Map filterMap = new HashMap();
461
		Map filterMap = new HashMap();
448
		MarkerFieldFilter[] filters = getFieldFilters();
462
		MarkerFieldFilter[] filters = getFieldFilters();
449
		for (int i = 0; i < filters.length; i++) {
463
		for (int i = 0; i < filters.length; i++) {
Lines 502-507 Link Here
502
	 */
516
	 */
503
	protected boolean populateClone(MarkerFieldFilterGroup clone) {
517
	protected boolean populateClone(MarkerFieldFilterGroup clone) {
504
		clone.scope = this.scope;
518
		clone.scope = this.scope;
519
		clone.limit = limit;
505
		clone.workingSet = this.workingSet;
520
		clone.workingSet = this.workingSet;
506
		clone.enabled = this.enabled;
521
		clone.enabled = this.enabled;
507
		clone.fieldFilters = new MarkerFieldFilter[getFieldFilters().length];
522
		clone.fieldFilters = new MarkerFieldFilter[getFieldFilters().length];
Lines 560-565 Link Here
560
	void saveFilterSettings(IMemento memento) {
575
	void saveFilterSettings(IMemento memento) {
561
		memento.putString(TAG_ENABLED, String.valueOf(enabled));
576
		memento.putString(TAG_ENABLED, String.valueOf(enabled));
562
		memento.putString(TAG_SCOPE, String.valueOf(scope));
577
		memento.putString(TAG_SCOPE, String.valueOf(scope));
578
		memento.putString(TAG_LIMIT, String.valueOf(limit));
563
579
564
		if (workingSet != null) {
580
		if (workingSet != null) {
565
			memento.putString(TAG_WORKING_SET, workingSet.getName());
581
			memento.putString(TAG_WORKING_SET, workingSet.getName());
Lines 661-666 Link Here
661
	void setWorkingSet(IWorkingSet workingSet) {
677
	void setWorkingSet(IWorkingSet workingSet) {
662
		this.workingSet = workingSet;
678
		this.workingSet = workingSet;
663
	}
679
	}
680
	
681
	/**
682
	 * @return Returns -1 for no limit else the limit.
683
	 */
684
	int getLimit() {
685
		return limit;
686
	}
687
688
	/**
689
	 * @param limit
690
	 *            The limit to set, -1 or 0 for no limit.
691
	 */
692
	void setLimit(int limit) {
693
		this.limit = limit;
694
	}
664
695
665
	/**
696
	/**
666
	 * Refresh the MarkerFieldFilterGroup .
697
	 * Refresh the MarkerFieldFilterGroup .
(-)src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java (-5 / +8 lines)
Lines 317-328 Link Here
317
	 */
317
	 */
318
	static int getMarkerLimit() {
318
	static int getMarkerLimit() {
319
319
320
		int value = IDEWorkbenchPlugin.getDefault().getPreferenceStore()
320
		// If limits are enabled return it. Otherwise return -1
321
				.getInt(IDEInternalPreferences.MARKER_LIMITS_VALUE);
321
		if (IDEWorkbenchPlugin.getDefault().getPreferenceStore().getBoolean(
322
		if (value <= 0) {
322
				IDEInternalPreferences.USE_MARKER_LIMITS)) {
323
			return -1;
323
			return IDEWorkbenchPlugin.getDefault().getPreferenceStore().getInt(
324
					IDEInternalPreferences.MARKER_LIMITS_VALUE);
325
324
		}
326
		}
325
		return value;
327
		return -1;
328
326
	}
329
	}
327
330
328
	/**
331
	/**
(-)src/org/eclipse/ui/internal/views/markers/MarkersViewColumnsDialog.java (-12 lines)
Lines 22-29 Link Here
22
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.swt.widgets.Shell;
25
import org.eclipse.ui.internal.ide.IDEInternalPreferences;
26
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
27
import org.eclipse.ui.views.markers.MarkerField;
25
import org.eclipse.ui.views.markers.MarkerField;
28
26
29
/**
27
/**
Lines 48-55 Link Here
48
		super(view.getSite().getShell());
46
		super(view.getSite().getShell());
49
		this.extendedView = view;
47
		this.extendedView = view;
50
		initialize(false);
48
		initialize(false);
51
		setLimitValue(IDEWorkbenchPlugin.getDefault().getPreferenceStore()
52
				.getInt(IDEInternalPreferences.MARKER_LIMITS_VALUE));
53
	}
49
	}
54
50
55
	/*
51
	/*
Lines 92-103 Link Here
92
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
88
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
93
	 */
89
	 */
94
	protected void okPressed() {
90
	protected void okPressed() {
95
		IDEWorkbenchPlugin
96
				.getDefault()
97
				.getPreferenceStore()
98
				.setValue(IDEInternalPreferences.MARKER_LIMITS_VALUE,
99
						getLimitValue());
100
		IDEWorkbenchPlugin.getDefault().savePluginPreferences();
101
		extendedView.setVisibleFields(getVisibleFields(), getNewWidths());
91
		extendedView.setVisibleFields(getVisibleFields(), getNewWidths());
102
		super.okPressed();
92
		super.okPressed();
103
	}
93
	}
Lines 133-140 Link Here
133
	 */
123
	 */
134
	protected void performDefaults() {
124
	protected void performDefaults() {
135
		initialize(true);
125
		initialize(true);
136
		setLimitValue(IDEWorkbenchPlugin.getDefault().getPreferenceStore()
137
				.getDefaultInt(IDEInternalPreferences.MARKER_LIMITS_VALUE));
138
		super.performDefaults();
126
		super.performDefaults();
139
	}
127
	}
140
128
(-)src/org/eclipse/ui/internal/views/markers/ViewerColumnsDialog.java (-266 / +53 lines)
Lines 19-25 Link Here
19
import java.util.Random;
19
import java.util.Random;
20
20
21
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.jface.dialogs.Dialog;
23
import org.eclipse.jface.resource.JFaceResources;
22
import org.eclipse.jface.resource.JFaceResources;
24
import org.eclipse.jface.viewers.ISelection;
23
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.ISelectionChangedListener;
24
import org.eclipse.jface.viewers.ISelectionChangedListener;
Lines 31-37 Link Here
31
import org.eclipse.jface.viewers.TableViewer;
30
import org.eclipse.jface.viewers.TableViewer;
32
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.jface.viewers.Viewer;
33
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.SWT;
34
import org.eclipse.swt.custom.CLabel;
35
import org.eclipse.swt.graphics.Image;
33
import org.eclipse.swt.graphics.Image;
36
import org.eclipse.swt.layout.FillLayout;
34
import org.eclipse.swt.layout.FillLayout;
37
import org.eclipse.swt.layout.GridData;
35
import org.eclipse.swt.layout.GridData;
Lines 48-54 Link Here
48
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.swt.widgets.Table;
49
import org.eclipse.swt.widgets.TableColumn;
47
import org.eclipse.swt.widgets.TableColumn;
50
import org.eclipse.swt.widgets.Text;
48
import org.eclipse.swt.widgets.Text;
51
import org.eclipse.ui.preferences.ViewSettingsDialog;
52
import org.eclipse.ui.views.markers.internal.MarkerMessages;
49
import org.eclipse.ui.views.markers.internal.MarkerMessages;
53
50
54
/**
51
/**
Lines 64-70 Link Here
64
 * @noextend This class is not intended to be subclassed by clients.
61
 * @noextend This class is not intended to be subclassed by clients.
65
 * 
62
 * 
66
 */
63
 */
67
abstract class ViewerColumnsDialog extends ViewSettingsDialog {
64
abstract class ViewerColumnsDialog extends ViewerSettingsAndStatusDialog {
68
65
69
	/** The list contains columns that are currently visible in viewer */
66
	/** The list contains columns that are currently visible in viewer */
70
	private List visible;
67
	private List visible;
Lines 72-99 Link Here
72
	/** The list contains columns that are note shown in viewer */
69
	/** The list contains columns that are note shown in viewer */
73
	private List nonVisible;
70
	private List nonVisible;
74
71
75
	/**
76
	 * The number of elements to show at Max. A zero value may indicate
77
	 * disablement of limit
78
	 */
79
	private int limitValue;
80
81
	/** The message area */
82
	private CLabel messageLabel;
83
84
	private TableViewer visibleViewer, nonVisibleViewer;
72
	private TableViewer visibleViewer, nonVisibleViewer;
85
73
86
	private Button upButton, downButton;
74
	private Button upButton, downButton;
87
75
88
	private Button toVisibleBtt, toNonVisibleBtt;
76
	private Button toVisibleBtt, toNonVisibleBtt;
89
77
90
	private Text widthText, limitEditor;
78
	private Text widthText;
91
79
92
	/**
80
	/**
93
	 * A listener to validate positive integer numbers only
81
	 * A listener to validate positive integer numbers only
94
	 */
82
	 */
95
	Listener postivIntTextListener = new Listener() {
83
	Listener postiveIntTextListener = new Listener() {
96
97
		private String intialValue;
84
		private String intialValue;
98
85
99
		public void handleEvent(Event event) {
86
		public void handleEvent(Event event) {
Lines 139-253 Link Here
139
		}
126
		}
140
	}
127
	}
141
128
142
	/*
129
	/* (non-Javadoc)
143
	 * (non-Javadoc)
130
	 * @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog#createDialogContentArea(org.eclipse.swt.widgets.Composite)
144
	 * 
145
	 * @see
146
	 * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
147
	 * .Shell)
148
	 */
149
	protected void configureShell(Shell newShell) {
150
		super.configureShell(newShell);
151
		newShell.setText(JFaceResources
152
				.getString("ConfigureColumnsDialog_Title")); //$NON-NLS-1$
153
	}
154
155
	/*
156
	 * (non-Javadoc)
157
	 * 
158
	 * @see org.eclipse.jface.window.Window#getShellStyle()
159
	 */
160
	protected int getShellStyle() {
161
		return super.getShellStyle() | SWT.RESIZE;
162
	}
163
164
	/*
165
	 * (non-Javadoc)
166
	 * 
167
	 * @see
168
	 * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
169
	 * .Composite)
170
	 */
171
	protected Control createDialogArea(Composite parent) {
172
173
		Composite dialogArea = (Composite) super.createDialogArea(parent);
174
175
		dialogArea.setLayout(new GridLayout(1, true));
176
177
		initializeDialogUnits(dialogArea);
178
179
		createMessageArea(dialogArea);
180
181
		createLimitArea(dialogArea);
182
183
		createColumnsArea(dialogArea);
184
185
		applyDialogFont(dialogArea);
186
187
		initializeDlg();
188
189
		return dialogArea;
190
	}
191
192
	/**
193
	 * 
194
	 */
131
	 */
195
	void initializeDlg() {
132
	protected Control createDialogContentArea(Composite dialogArea) {
196
		handleStatusUdpate(IStatus.INFO, getDefaultMessage());
133
		return createColumnsArea(dialogArea);
197
	}
134
	}
198
135
	
199
	/**
200
	 * Create message area.
201
	 * 
202
	 * @param parent
203
	 */
204
	void createMessageArea(Composite parent) {
205
		messageLabel = new CLabel(parent, SWT.NONE);
206
		messageLabel.setImage(JFaceResources
207
				.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
208
		messageLabel
209
				.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
210
	}
211
212
	/**
213
	 * Create element limit area.
214
	 * 
215
	 * @param parent
216
	 */
217
	void createLimitArea(Composite parent) {
218
		Composite composite = new Group(parent, SWT.NONE);
219
		composite.setLayout(new GridLayout(2, false));
220
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
221
222
		CLabel cLabel = new CLabel(composite, SWT.NONE);
223
		cLabel.setText(MarkerMessages.MarkerPreferences_VisibleItems);
224
		cLabel.setLayoutData(new GridData());
225
226
		limitEditor = new Text(composite, SWT.BORDER);
227
		limitEditor.setText(Integer.toString(getLimitValue()));
228
		limitEditor.setLayoutData(new GridData());
229
		limitEditor.addListener(SWT.FocusOut, postivIntTextListener);
230
		limitEditor.addListener(SWT.KeyDown, postivIntTextListener);
231
		limitEditor.addListener(SWT.Modify, new Listener() {
232
			public void handleEvent(Event event) {
233
				int limit = 0;
234
				try {
235
					limit = Integer.parseInt(limitEditor.getText().trim());
236
				} catch (Exception e) {
237
					return;// ignore this one
238
				}
239
				setLimitValue(limit);
240
			}
241
		});
242
		limitEditor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
243
	}
244
245
	/**
136
	/**
246
	 * Create the controls to configure columns.
137
	 * Create the controls to configure columns.
247
	 * 
138
	 * 
248
	 * @param dialogArea
139
	 * @param dialogArea
140
	 * @return {@link Control}
249
	 */
141
	 */
250
	void createColumnsArea(Composite dialogArea) {
142
	Control createColumnsArea(Composite dialogArea) {
251
		Group columnArea = new Group(dialogArea, SWT.NONE);
143
		Group columnArea = new Group(dialogArea, SWT.NONE);
252
		columnArea.setLayout(new GridLayout(4, false));
144
		columnArea.setLayout(new GridLayout(4, false));
253
		GridData gData = new GridData(GridData.FILL_BOTH
145
		GridData gData = new GridData(GridData.FILL_BOTH
Lines 260-265 Link Here
260
		createVisibleTable(columnArea);
152
		createVisibleTable(columnArea);
261
		createUpDownBtt(columnArea);
153
		createUpDownBtt(columnArea);
262
		createWidthArea(columnArea);
154
		createWidthArea(columnArea);
155
		return columnArea;
263
	}
156
	}
264
157
265
	/**
158
	/**
Lines 267-273 Link Here
267
	 * 
160
	 * 
268
	 * @param parent
161
	 * @param parent
269
	 */
162
	 */
270
	void createUpDownBtt(Composite parent) {
163
	Control createUpDownBtt(Composite parent) {
271
		Composite composite = new Composite(parent, SWT.NONE);
164
		Composite composite = new Composite(parent, SWT.NONE);
272
		GridLayout layout = new GridLayout(1, true);
165
		GridLayout layout = new GridLayout(1, true);
273
		layout.horizontalSpacing = 0;
166
		layout.horizontalSpacing = 0;
Lines 297-310 Link Here
297
		});
190
		});
298
		downButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
191
		downButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
299
		downButton.setEnabled(false);
192
		downButton.setEnabled(false);
193
		return composite;
300
	}
194
	}
301
195
302
	/**
196
	/**
303
	 * Create the controls responsible to display/edit column widths.
197
	 * Create the controls responsible to display/edit column widths.
304
	 * 
198
	 * 
305
	 * @param parent
199
	 * @param parent
200
	 * @return {@link Control}
306
	 */
201
	 */
307
	void createWidthArea(Composite parent) {
202
	Control createWidthArea(Composite parent) {
308
		Label widthLabel = new Label(parent, SWT.NONE);
203
		Label widthLabel = new Label(parent, SWT.NONE);
309
		widthLabel.setText(JFaceResources
204
		widthLabel.setText(JFaceResources
310
				.getString("ConfigureColumnsDialog_WidthOfSelectedColumn")); //$NON-NLS-1$
205
				.getString("ConfigureColumnsDialog_WidthOfSelectedColumn")); //$NON-NLS-1$
Lines 319-346 Link Here
319
				| GridData.HORIZONTAL_ALIGN_CENTER);
214
				| GridData.HORIZONTAL_ALIGN_CENTER);
320
		gridData.widthHint = convertWidthInCharsToPixels(5);
215
		gridData.widthHint = convertWidthInCharsToPixels(5);
321
		widthText.setLayoutData(gridData);
216
		widthText.setLayoutData(gridData);
322
		widthText.addListener(SWT.KeyDown, postivIntTextListener);
217
		widthText.addListener(SWT.Modify, postiveIntTextListener);
323
		widthText.addListener(SWT.FocusOut, postivIntTextListener);
324
		widthText.addListener(SWT.Modify, new Listener() {
218
		widthText.addListener(SWT.Modify, new Listener() {
325
			public void handleEvent(Event event) {
219
			public void handleEvent(Event event) {
326
				if (widthText.isEnabled()) {
220
				if (widthText.isEnabled()) {
327
					int width = 0;
328
					try {
221
					try {
329
						width = Integer.parseInt(widthText.getText().trim());
222
						int width = Integer
223
								.parseInt(widthText.getText().trim());
224
						Object data = ((IStructuredSelection) visibleViewer
225
								.getSelection()).getFirstElement();
226
						if (data != null) {
227
							IColumnUpdater updater = getColumnUpdater();
228
							updater.setColumnWidth(data, width);
229
						}
330
					} catch (Exception e) {
230
					} catch (Exception e) {
331
						return;// ignore this one
231
						return;// ignore
332
					}
333
					Object data = ((IStructuredSelection) visibleViewer
334
							.getSelection()).getFirstElement();
335
					if (data != null) {
336
						IColumnUpdater updater = getColumnUpdater();
337
						updater.setColumnWidth(data, width);
338
					}
232
					}
339
				}
233
				}
340
			}
234
			}
341
		});
235
		});
342
		widthText.setText(MarkerSupportInternalUtilities.EMPTY_STRING);
236
		widthText.setText(MarkerSupportInternalUtilities.EMPTY_STRING);
343
		widthText.setEditable(false);
237
		widthText.setEditable(false);
238
		return widthText;
344
	}
239
	}
345
240
346
	/**
241
	/**
Lines 359-366 Link Here
359
	 * Creates the table that lists out visible columns in the viewer
254
	 * Creates the table that lists out visible columns in the viewer
360
	 * 
255
	 * 
361
	 * @param parent
256
	 * @param parent
257
	 * @return {@link Control}
362
	 */
258
	 */
363
	void createVisibleTable(Composite parent) {
259
	Control createVisibleTable(Composite parent) {
364
		final Table table = new Table(parent, SWT.BORDER | SWT.MULTI);
260
		final Table table = new Table(parent, SWT.BORDER | SWT.MULTI);
365
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
261
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
366
		data.widthHint = convertWidthInCharsToPixels(30);
262
		data.widthHint = convertWidthInCharsToPixels(30);
Lines 396-409 Link Here
396
			}
292
			}
397
		});
293
		});
398
		visibleViewer.setInput(this);
294
		visibleViewer.setInput(this);
295
		return table;
399
	}
296
	}
400
297
401
	/**
298
	/**
402
	 * Creates the table that lists out non-visible columns in the viewer
299
	 * Creates the table that lists out non-visible columns in the viewer
403
	 * 
300
	 * 
404
	 * @param parent
301
	 * @param parent
302
	 * @return {@link Control}
405
	 */
303
	 */
406
	void createInvisibleTable(Composite parent) {
304
	Control createInvisibleTable(Composite parent) {
407
		final Table table = new Table(parent, SWT.BORDER | SWT.MULTI);
305
		final Table table = new Table(parent, SWT.BORDER | SWT.MULTI);
408
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
306
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
409
		data.widthHint = convertWidthInCharsToPixels(30);
307
		data.widthHint = convertWidthInCharsToPixels(30);
Lines 439-444 Link Here
439
			}
337
			}
440
		});
338
		});
441
		nonVisibleViewer.setInput(this);
339
		nonVisibleViewer.setInput(this);
340
		return table;
442
	}
341
	}
443
342
444
	/**
343
	/**
Lines 446-453 Link Here
446
	 * vice-versa
345
	 * vice-versa
447
	 * 
346
	 * 
448
	 * @param parent
347
	 * @param parent
348
	 * @return {@link Control}
449
	 */
349
	 */
450
	void createMoveButtons(Composite parent) {
350
	Control createMoveButtons(Composite parent) {
451
		Composite bttArea = new Composite(parent, SWT.NONE);
351
		Composite bttArea = new Composite(parent, SWT.NONE);
452
		bttArea.setLayout(new GridLayout(1, true));
352
		bttArea.setLayout(new GridLayout(1, true));
453
		bttArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
353
		bttArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
Lines 476-594 Link Here
476
			}
376
			}
477
		});
377
		});
478
		toVisibleBtt.setEnabled(false);
378
		toVisibleBtt.setEnabled(false);
479
	}
379
		return bttArea;
480
481
	/**
482
	 * Display the error message and an appropriate icon.
483
	 * 
484
	 * @param messgage
485
	 * @param severity
486
	 */
487
	protected void handleStatusUdpate(int severity, String messgage) {
488
		Image image = null;
489
		switch (severity) {
490
		case IStatus.ERROR: {
491
			if (messgage == null) {
492
				messgage = getErrorMessage();
493
			}
494
			image = getErrorImage();
495
			break;
496
		}
497
		case IStatus.WARNING: {
498
			image = getWarningImage();
499
			break;
500
		}
501
		case IStatus.OK:
502
		case IStatus.INFO:
503
		default:
504
			image = getInfoImage();
505
		}
506
		messageLabel.setImage(image);
507
		if (messgage == null) {
508
			messgage = getDefaultMessage();
509
		}
510
		if (messgage == null) {
511
			messgage = MarkerSupportInternalUtilities.EMPTY_STRING;
512
		}
513
		messageLabel.setText(messgage);
514
	}
515
516
	/**
517
	 * Return the message to display when dialog is opened.
518
	 */
519
	protected String getDefaultMessage() {
520
		return MarkerMessages.MarkerPreferences_ZeroOrBlankValueCanBeUsedToDisableTheLimit;
521
	}
522
523
	/**
524
	 * @return Returns the error message to display for a wrong limit value.
525
	 */
526
	protected String getErrorMessage() {
527
		return JFaceResources.getString("IntegerFieldEditor.errorMessage"); //$NON-NLS-1$
528
	}
529
530
	/**
531
	 */
532
	protected Image getInfoImage() {
533
		return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
534
	}
535
536
	/**
537
	 */
538
	protected Image getWarningImage() {
539
		return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
540
	}
541
542
	/**
543
	 */
544
	protected Image getErrorImage() {
545
		return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
546
	}
547
548
	/*
549
	 * (non-Javadoc)
550
	 * 
551
	 * @see org.eclipse.ui.preferences.ViewSettingsDialog#performDefaults()
552
	 */
553
	protected void performDefaults() {
554
		refreshViewers();
555
		super.performDefaults();
556
	}
380
	}
557
381
558
	/**
382
	/**
559
	 * 
383
	 * 
560
	 * @param event
384
	 * @param event
561
	 * @param intialvalue
385
	 * @param intialvalue
562
	 * @return new integer value
386
	 * @return new value in String
563
	 */
387
	 */
564
	String handleIntegerFieldChange(Event event, String intialvalue) {
388
	String handleIntegerFieldChange(Event event, String intialvalue) {
565
		Text text = (Text) event.widget;
389
		String value = ((Text) event.widget).getText().trim();
566
		String value = text.getText().trim();
567
		switch (event.type) {
390
		switch (event.type) {
568
		case SWT.KeyDown:
391
		case SWT.KeyDown:
569
			if (!Character.isDigit(event.character)) {
392
		case SWT.Modify:
570
				if (!Character.isISOControl(event.character)) {
571
					handleStatusUdpate(IStatus.ERROR, getErrorMessage());
572
					event.doit = false;
573
					return intialvalue;
574
				}
575
			}
576
		case SWT.FocusOut:
393
		case SWT.FocusOut:
577
			if (value.length() == 0) {
394
			if (value.length() == 0) {
578
				value = Integer.toString(0);
395
				handleStatusUdpate(IStatus.ERROR, null);
579
				text.setText(value);
580
				text.selectAll();
581
				handleStatusUdpate(IStatus.INFO, null);
582
			} else {
396
			} else {
583
				try {
397
				try {
584
					Integer.parseInt(value);
398
					int number = Integer.parseInt(value);
585
					handleStatusUdpate(IStatus.INFO, null);
399
					if (number > 0) {
400
						handleStatusUdpate(IStatus.INFO, null);
401
					} else {
402
						value = intialvalue;
403
						((Text) event.widget).selectAll();
404
						handleStatusUdpate(IStatus.ERROR, getErrorMessage());
405
					}
586
				} catch (Exception e) {
406
				} catch (Exception e) {
587
					value = intialvalue;
407
					value = intialvalue;
588
					text.setText(value);
408
					((Text) event.widget).selectAll();
589
					text.selectAll();
590
					handleStatusUdpate(IStatus.ERROR, getErrorMessage());
409
					handleStatusUdpate(IStatus.ERROR, getErrorMessage());
591
					event.doit = false;
592
				}
410
				}
593
			}
411
			}
594
		}
412
		}
Lines 785-798 Link Here
785
			updater.setColumnVisible(iterator.next(), visibility);
603
			updater.setColumnVisible(iterator.next(), visibility);
786
		}
604
		}
787
	}
605
	}
606
	
607
	protected void performDefaults() {
608
		refreshViewers();
609
		super.performDefaults();
610
	}
788
611
789
	/**
612
	/**
790
	 * Updates the UI based on values of the variable
613
	 * Updates the UI based on values of the variable
791
	 */
614
	 */
792
	void refreshViewers() {
615
	void refreshViewers() {
793
		if (limitEditor != null) {
794
			limitEditor.setText(Integer.toString(getLimitValue()));
795
		}
796
		if (nonVisibleViewer != null) {
616
		if (nonVisibleViewer != null) {
797
			nonVisibleViewer.refresh();
617
			nonVisibleViewer.refresh();
798
		}
618
		}
Lines 801-839 Link Here
801
		}
621
		}
802
	}
622
	}
803
623
804
	/*
805
	 * (non-Javadoc)
806
	 * 
807
	 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
808
	 */
809
	protected boolean isResizable() {
810
		return true;
811
	}
812
813
	/*
814
	 * (non-Javadoc)
815
	 * 
816
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
817
	 */
818
	protected void okPressed() {
819
		super.okPressed();
820
	}
821
822
	/**
823
	 * @return Returns the limitValue.
824
	 */
825
	public int getLimitValue() {
826
		return limitValue;
827
	}
828
829
	/**
830
	 * @param limitValue
831
	 *            The limitValue to set.
832
	 */
833
	void setLimitValue(int limitValue) {
834
		this.limitValue = limitValue;
835
	}
836
837
	/**
624
	/**
838
	 * @return List of visible columns
625
	 * @return List of visible columns
839
	 */
626
	 */
(-)src/org/eclipse/ui/internal/views/markers/ViewerSettingsAndStatusDialog.java (+300 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.views.markers;
13
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.resource.JFaceResources;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.graphics.Color;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Point;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.swt.widgets.Label;
27
import org.eclipse.swt.widgets.Shell;
28
import org.eclipse.swt.widgets.Text;
29
import org.eclipse.ui.preferences.ViewSettingsDialog;
30
31
/**
32
 * @since 3.7
33
 * @author Hitesh Soliwal
34
 * @noextend This class is not intended to be subclassed by clients.
35
 */
36
public abstract class ViewerSettingsAndStatusDialog extends ViewSettingsDialog {
37
38
	private Label imageLabel;
39
	/** The message area */
40
	private Text messageArea;
41
	private Composite msgParent;
42
43
	/**
44
	 * @param parentShell
45
	 */
46
	public ViewerSettingsAndStatusDialog(Shell parentShell) {
47
		super(parentShell);
48
	}
49
50
	/*
51
	 * (non-Javadoc)
52
	 * 
53
	 * @see
54
	 * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
55
	 * .Shell)
56
	 */
57
	protected void configureShell(Shell newShell) {
58
		super.configureShell(newShell);
59
	}
60
61
	/*
62
	 * (non-Javadoc)
63
	 * 
64
	 * @see org.eclipse.jface.window.Window#getShellStyle()
65
	 */
66
	protected int getShellStyle() {
67
		return super.getShellStyle() | SWT.RESIZE;
68
	}
69
70
	/*
71
	 * (non-Javadoc)
72
	 * 
73
	 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
74
	 */
75
	protected Point getInitialSize() {
76
		Point size = super.getInitialSize();
77
		size.y += convertHeightInCharsToPixels(3);
78
		return size;
79
	}
80
81
	protected Control createDialogArea(Composite parent) {
82
83
		Composite dialogArea = (Composite) super.createDialogArea(parent);
84
85
		dialogArea.setLayout(new GridLayout(1, true));
86
87
		initializeDialogUnits(dialogArea);
88
89
		createMessageArea(dialogArea).setLayoutData(
90
				new GridData(SWT.FILL, SWT.NONE, true, false));
91
92
		createDialogContentArea(dialogArea).setLayoutData(
93
				new GridData(SWT.FILL, SWT.FILL, true, true));
94
95
		applyDialogFont(dialogArea);
96
97
		initializeDialog();
98
99
		return dialogArea;
100
	}
101
102
	/**
103
	 * @param dialogArea
104
	 */
105
	protected abstract Control createDialogContentArea(Composite dialogArea);
106
107
	/**
108
	 * 
109
	 */
110
	protected void initializeDialog() {
111
		handleStatusUdpate(IStatus.INFO, getDefaultMessage());
112
	}
113
114
	/**
115
	 * Create message area.
116
	 * 
117
	 * @param parent
118
	 */
119
	Control createMessageArea(Composite parent) {
120
		msgParent = new Composite(parent, SWT.BORDER);
121
		msgParent.setBackground(getMessageBackground());
122
		msgParent.setLayout(new GridLayout(2, false));
123
124
		imageLabel = new Label(msgParent, SWT.NONE);
125
		imageLabel.setBackground(msgParent.getBackground());
126
		imageLabel.setImage(JFaceResources
127
				.getImage(Dialog.DLG_IMG_MESSAGE_INFO));
128
		imageLabel
129
				.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
130
131
		messageArea = new Text(msgParent, SWT.READ_ONLY | SWT.NONE | SWT.WRAP
132
				| SWT.MULTI | SWT.NO_FOCUS);
133
		messageArea.setEditable(false);
134
		messageArea.setBackground(msgParent.getBackground());
135
		messageArea
136
				.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
137
		return msgParent;
138
	}
139
140
	/**
141
	 * Display the message and an appropriate icon.
142
	 * 
143
	 * @param status
144
	 */
145
	protected void handleStatusUdpate(IStatus status) {
146
		handleStatusUdpate(status.getSeverity(), status.getMessage());
147
	}
148
149
	/**
150
	 * Display the message and an appropriate icon.
151
	 * 
152
	 * @param messgage
153
	 * @param severity
154
	 */
155
	protected void handleStatusUdpate(int severity, String messgage) {
156
		Image image = null;
157
		Button okBttn = getButton(OK);
158
		switch (severity) {
159
		case IStatus.ERROR: {
160
			if (messgage == null) {
161
				messgage = getErrorMessage();
162
			}
163
			image = getErrorImage();
164
			break;
165
		}
166
		case IStatus.WARNING: {
167
			image = getWarningImage();
168
			break;
169
		}
170
		case IStatus.OK:
171
		case IStatus.INFO:
172
		default:
173
			image = getInfoImage();
174
		}
175
		if (messgage == null) {
176
			messgage = getDefaultMessage();
177
		}
178
		if (messgage.equals(MarkerSupportInternalUtilities.EMPTY_STRING)) {
179
			handleMessageAreaVisibility(false);
180
			image = null;
181
		} else {
182
			handleMessageAreaVisibility(true);
183
		}
184
		if (okBttn != null) {
185
			okBttn.setEnabled(severity == IStatus.OK
186
					|| severity == IStatus.INFO || severity == IStatus.WARNING);
187
		}
188
		if (msgParent != null) {
189
			setMessageImage(image);
190
			setMessageText(messgage);
191
			msgParent.layout();
192
		}
193
	}
194
195
	/**
196
	 * @param image
197
	 */
198
	protected void setMessageImage(Image image) {
199
		if (imageLabel != null) {
200
			imageLabel.setImage(image);
201
		}
202
	}
203
204
	/**
205
	 * @param messgage
206
	 */
207
	protected void setMessageText(String messgage) {
208
		if (messageArea != null) {
209
			messageArea.setText(messgage);
210
		}
211
	}
212
213
	/**
214
	 * 
215
	 */
216
	protected Image getMessageImage() {
217
		if (imageLabel != null) {
218
			imageLabel.getImage();
219
		}
220
		return null;
221
	}
222
223
	/**
224
	 */
225
	protected String getMessageText() {
226
		if (messageArea != null) {
227
			return messageArea.getText();
228
		}
229
		return null;
230
	}
231
232
	/**
233
	 * 
234
	 * @param visible
235
	 */
236
	protected void handleMessageAreaVisibility(boolean visible) {
237
		if (msgParent == null || msgParent.isDisposed()) {
238
			return;
239
		}
240
		GridData data = (GridData) msgParent.getLayoutData();
241
		if (data.exclude == visible) {
242
			data.exclude = !visible;
243
			msgParent.setVisible(visible);
244
			msgParent.getParent().layout();
245
		}
246
	}
247
248
	/**
249
	 * Return the Color to display when dialog is opened.
250
	 */
251
	protected Color getMessageBackground() {
252
		return getShell().getDisplay()
253
				.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
254
	}
255
256
	/**
257
	 * Return the message to display when dialog is opened.
258
	 */
259
	protected String getDefaultMessage() {
260
		return MarkerSupportInternalUtilities.EMPTY_STRING;
261
	}
262
263
	/**
264
	 * @return Returns the error message to display for a wrong limit value.
265
	 */
266
	protected String getErrorMessage() {
267
		return JFaceResources.getString("StringFieldEditor.errorMessage"); //$NON-NLS-1$
268
	}
269
270
	/**
271
	 */
272
	protected Image getInfoImage() {
273
		return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
274
	}
275
276
	/**
277
	 */
278
	protected Image getWarningImage() {
279
		return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
280
	}
281
282
	/**
283
	 */
284
	protected Image getErrorImage() {
285
		return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
286
	}
287
288
	protected void performDefaults() {
289
		super.performDefaults();
290
	}
291
292
	protected boolean isResizable() {
293
		return true;
294
	}
295
296
	protected void okPressed() {
297
		super.okPressed();
298
	}
299
300
}
(-)src/org/eclipse/ui/views/markers/internal/MarkerMessages.java (-3 / +2 lines)
Lines 206-212 Link Here
206
	public static String MarkerFilterDialog_title;
206
	public static String MarkerFilterDialog_title;
207
	public static String MarkerFilterDialog_message;
207
	public static String MarkerFilterDialog_message;
208
	public static String MarkerFilterDialog_emptyMessage;
208
	public static String MarkerFilterDialog_emptyMessage;
209
209
	public static String MarkerFilterDialog_YouHaveDisabledMarkerLimit;
210
	public static String MarkerFilterDialog_errorTitle;
210
	public static String MarkerFilterDialog_errorTitle;
211
	public static String MarkerFilterDialog_failedFilterMessage;
211
	public static String MarkerFilterDialog_failedFilterMessage;
212
212
Lines 219-226 Link Here
219
	public static String MarkerPreferences_VisibleColumnsTitle;
219
	public static String MarkerPreferences_VisibleColumnsTitle;
220
	public static String MarkerPreferences_HiddenColumnsTitle;
220
	public static String MarkerPreferences_HiddenColumnsTitle;
221
	public static String MarkerPreferences_AtLeastOneVisibleColumn;
221
	public static String MarkerPreferences_AtLeastOneVisibleColumn;
222
	public static String MarkerPreferences_ZeroOrBlankValueCanBeUsedToDisableTheLimit;
222
	
223
224
	public static String ProblemFilterDialog_System_Filters_Title;
223
	public static String ProblemFilterDialog_System_Filters_Title;
225
	public static String ProblemFilterDialog_All_Problems;
224
	public static String ProblemFilterDialog_All_Problems;
226
	public static String ProblemFilterDialog_Selected_Types;
225
	public static String ProblemFilterDialog_Selected_Types;
(-)src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java (+6 lines)
Lines 60-65 Link Here
60
	private static final Object WARNING = "WARNING";//$NON-NLS-1$
60
	private static final Object WARNING = "WARNING";//$NON-NLS-1$
61
61
62
	private static final String MARKER_ID = "markerId"; //$NON-NLS-1$
62
	private static final String MARKER_ID = "markerId"; //$NON-NLS-1$
63
	
64
	/**
65
	 * Filter enablement : A zero/negative integer implies that the limit is
66
	 * disabled.
67
	 */
68
	public static final String FILTER_LIMIT = "filterLimit"; //$NON-NLS-1$
63
69
64
	/**
70
	/**
65
	 * The tag for the marker support extension
71
	 * The tag for the marker support extension
(-)src/org/eclipse/ui/views/markers/internal/messages.properties (-2 / +2 lines)
Lines 77-83 Link Here
77
filtersDialog_deselectAllTypes = Dese&lect All
77
filtersDialog_deselectAllTypes = Dese&lect All
78
filtersDialog_conflictingName =  A filter already exists with the name {0}
78
filtersDialog_conflictingName =  A filter already exists with the name {0}
79
filtersDialogDeselectedFiltersTitle = Confirm Show All
79
filtersDialogDeselectedFiltersTitle = Confirm Show All
80
filtersDialogDeselectedFiltersMessage = You have not checked any configurations. This will show all entries. Continue?
80
filtersDialogDeselectedFiltersMessage = You have not checked any configurations. This will show all entries.
81
81
82
filtersDialog_descriptionLabel = Te&xt: 
82
filtersDialog_descriptionLabel = Te&xt: 
83
filtersDialog_contains = contains
83
filtersDialog_contains = contains
Lines 203-209 Link Here
203
MarkerPreferences_VisibleColumnsTitle = &Show
203
MarkerPreferences_VisibleColumnsTitle = &Show
204
MarkerPreferences_HiddenColumnsTitle = &Hide
204
MarkerPreferences_HiddenColumnsTitle = &Hide
205
MarkerPreferences_AtLeastOneVisibleColumn = There must be at least one visible column.
205
MarkerPreferences_AtLeastOneVisibleColumn = There must be at least one visible column.
206
MarkerPreferences_ZeroOrBlankValueCanBeUsedToDisableTheLimit = Please enter a positive number (zero or blank can be used to disable the limit).
206
MarkerFilterDialog_YouHaveDisabledMarkerLimit= You have selected to disable limiting items per group.
207
207
208
ProblemFilterDialog_System_Filters_Title = System filte&rs:
208
ProblemFilterDialog_System_Filters_Title = System filte&rs:
209
ProblemFilterDialog_All_Problems = Enabled for all problems
209
ProblemFilterDialog_All_Problems = Enabled for all problems

Return to bug 231081