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) |