Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2007, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2007, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 17-43
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; |
|
|
21 |
import org.eclipse.jface.dialogs.IDialogConstants; |
20 |
import org.eclipse.jface.dialogs.IDialogConstants; |
22 |
import org.eclipse.jface.dialogs.IDialogSettings; |
21 |
import org.eclipse.jface.dialogs.IDialogSettings; |
23 |
import org.eclipse.jface.dialogs.IInputValidator; |
22 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
24 |
import org.eclipse.jface.dialogs.InputDialog; |
|
|
25 |
import org.eclipse.jface.viewers.CheckStateChangedEvent; |
23 |
import org.eclipse.jface.viewers.CheckStateChangedEvent; |
26 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
24 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
|
|
25 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
27 |
import org.eclipse.jface.viewers.ICheckStateListener; |
26 |
import org.eclipse.jface.viewers.ICheckStateListener; |
|
|
27 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
28 |
import org.eclipse.jface.viewers.ISelection; |
28 |
import org.eclipse.jface.viewers.ISelection; |
29 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
29 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
30 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
|
31 |
import org.eclipse.jface.viewers.IStructuredSelection; |
30 |
import org.eclipse.jface.viewers.IStructuredSelection; |
32 |
import org.eclipse.jface.viewers.LabelProvider; |
31 |
import org.eclipse.jface.viewers.LabelProvider; |
33 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
32 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
34 |
import org.eclipse.jface.viewers.StructuredSelection; |
33 |
import org.eclipse.jface.viewers.StructuredSelection; |
35 |
import org.eclipse.jface.viewers.Viewer; |
|
|
36 |
import org.eclipse.jface.window.Window; |
34 |
import org.eclipse.jface.window.Window; |
37 |
import org.eclipse.osgi.util.NLS; |
|
|
38 |
import org.eclipse.swt.SWT; |
35 |
import org.eclipse.swt.SWT; |
39 |
import org.eclipse.swt.events.DisposeEvent; |
|
|
40 |
import org.eclipse.swt.events.DisposeListener; |
41 |
import org.eclipse.swt.events.SelectionAdapter; |
36 |
import org.eclipse.swt.events.SelectionAdapter; |
42 |
import org.eclipse.swt.events.SelectionEvent; |
37 |
import org.eclipse.swt.events.SelectionEvent; |
43 |
import org.eclipse.swt.layout.GridData; |
38 |
import org.eclipse.swt.layout.GridData; |
Lines 45-64
Link Here
|
45 |
import org.eclipse.swt.widgets.Button; |
40 |
import org.eclipse.swt.widgets.Button; |
46 |
import org.eclipse.swt.widgets.Composite; |
41 |
import org.eclipse.swt.widgets.Composite; |
47 |
import org.eclipse.swt.widgets.Control; |
42 |
import org.eclipse.swt.widgets.Control; |
48 |
import org.eclipse.swt.widgets.Event; |
|
|
49 |
import org.eclipse.swt.widgets.Group; |
50 |
import org.eclipse.swt.widgets.Label; |
43 |
import org.eclipse.swt.widgets.Label; |
51 |
import org.eclipse.swt.widgets.Listener; |
|
|
52 |
import org.eclipse.swt.widgets.Shell; |
44 |
import org.eclipse.swt.widgets.Shell; |
53 |
import org.eclipse.swt.widgets.Text; |
45 |
import org.eclipse.swt.widgets.Spinner; |
54 |
import org.eclipse.ui.forms.events.ExpansionEvent; |
|
|
55 |
import org.eclipse.ui.forms.events.IExpansionListener; |
56 |
import org.eclipse.ui.forms.widgets.ExpandableComposite; |
57 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
58 |
import org.eclipse.ui.forms.widgets.ScrolledForm; |
59 |
import org.eclipse.ui.internal.ide.IDEInternalPreferences; |
46 |
import org.eclipse.ui.internal.ide.IDEInternalPreferences; |
60 |
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; |
47 |
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; |
61 |
import org.eclipse.ui.views.markers.FilterConfigurationArea; |
48 |
import org.eclipse.ui.preferences.ViewSettingsDialog; |
62 |
import org.eclipse.ui.views.markers.internal.MarkerMessages; |
49 |
import org.eclipse.ui.views.markers.internal.MarkerMessages; |
63 |
|
50 |
|
64 |
/** |
51 |
/** |
Lines 67-103
Link Here
|
67 |
* @since 3.3 |
54 |
* @since 3.3 |
68 |
* |
55 |
* |
69 |
*/ |
56 |
*/ |
70 |
public class FiltersConfigurationDialog extends ViewerSettingsAndStatusDialog { |
57 |
public class FiltersConfigurationDialog extends ViewSettingsDialog { |
71 |
|
58 |
|
72 |
private static final String SELECTED_FILTER_GROUP = "SELECTED_FILTER_GROUP"; //$NON-NLS-1$ |
59 |
private static final String SELECTED_FILTER_GROUP = "SELECTED_FILTER_GROUP"; //$NON-NLS-1$ |
73 |
|
60 |
|
74 |
private Collection filterGroups; |
61 |
private Collection filterGroups; |
75 |
|
62 |
|
76 |
private CheckboxTableViewer filtersList; |
63 |
private CheckboxTableViewer configsTable; |
77 |
|
|
|
78 |
private GroupFilterConfigurationArea scopeArea = new ScopeArea(); |
79 |
|
64 |
|
80 |
private MarkerFieldFilterGroup selectedFilterGroup; |
65 |
private MarkerFieldFilterGroup selectedFilterGroup; |
81 |
|
66 |
|
82 |
private ScrolledForm form; |
|
|
83 |
|
84 |
private MarkerContentGenerator generator; |
67 |
private MarkerContentGenerator generator; |
85 |
|
68 |
|
86 |
private int limitValue = -1; |
|
|
87 |
private boolean limitEnabled = false; |
88 |
private boolean andFilters = false; |
69 |
private boolean andFilters = false; |
89 |
|
70 |
|
90 |
private Collection filterAreas; |
|
|
91 |
|
92 |
private Button removeButton; |
71 |
private Button removeButton; |
93 |
private Button renameButton; |
72 |
private Button editButton; |
94 |
private Button cloneButton; |
73 |
private Button allButton; |
95 |
private Button andButton; |
74 |
private Button andButton; |
96 |
private Button orButton; |
75 |
private Button orButton; |
97 |
|
76 |
|
98 |
private Label andOrLabel; |
77 |
private Button limitButton; |
99 |
private Text limitEditor; |
78 |
private Spinner limitSpinner; |
100 |
private Button limitBttn; |
|
|
101 |
|
79 |
|
102 |
/** |
80 |
/** |
103 |
* Create a new instance of the receiver on builder. |
81 |
* Create a new instance of the receiver on builder. |
Lines 125-140
Link Here
|
125 |
/* |
103 |
/* |
126 |
* (non-Javadoc) |
104 |
* (non-Javadoc) |
127 |
* |
105 |
* |
128 |
* @see org.eclipse.jface.dialogs.Dialog#close() |
|
|
129 |
*/ |
130 |
public boolean close() { |
131 |
saveDialogSettings(); |
132 |
return super.close(); |
133 |
} |
134 |
|
135 |
/* |
136 |
* (non-Javadoc) |
137 |
* |
138 |
* @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog# |
106 |
* @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog# |
139 |
* configureShell(org.eclipse.swt.widgets.Shell) |
107 |
* configureShell(org.eclipse.swt.widgets.Shell) |
140 |
*/ |
108 |
*/ |
Lines 156-368
Link Here
|
156 |
* (non-Javadoc) |
124 |
* (non-Javadoc) |
157 |
* |
125 |
* |
158 |
* @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog# |
126 |
* @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog# |
159 |
* initializeDialog() |
|
|
160 |
*/ |
161 |
protected void initializeDialog() { |
162 |
super.initializeDialog(); |
163 |
validateState(); |
164 |
} |
165 |
|
166 |
/* |
167 |
* (non-Javadoc) |
168 |
* |
169 |
* @see org.eclipse.ui.internal.views.markers.ViewerSettingsAndStatusDialog# |
170 |
* createDialogContentArea(org.eclipse.swt.widgets.Composite) |
127 |
* createDialogContentArea(org.eclipse.swt.widgets.Composite) |
171 |
*/ |
128 |
*/ |
172 |
protected Control createDialogContentArea(Composite parent) { |
129 |
protected Control createDialogArea(Composite parent) { |
173 |
|
130 |
|
174 |
createViewCommonUI(parent).setLayoutData( |
131 |
Composite container = (Composite) super.createDialogArea(parent); |
175 |
new GridData(SWT.FILL, SWT.NONE, true, false)); |
132 |
|
|
|
133 |
Composite composite = new Composite(container, SWT.NONE); |
134 |
composite.setLayout(new GridLayout()); |
135 |
composite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
136 |
|
137 |
createAndOrButtons(composite); |
138 |
|
139 |
createFilters(composite); |
140 |
|
141 |
createMarkerLimits(composite); |
142 |
|
143 |
loadDialogSettings(); |
144 |
applyDialogFont(container); |
145 |
|
146 |
initUI(); |
147 |
|
148 |
return container; |
149 |
} |
150 |
|
151 |
private void initUI() { |
152 |
|
153 |
if (selectedFilterGroup != null) { |
154 |
configsTable.setSelection(new StructuredSelection( |
155 |
selectedFilterGroup)); |
156 |
} |
176 |
|
157 |
|
177 |
Group top = new Group(parent, SWT.NONE); |
158 |
configsTable.setInput(filterGroups); |
178 |
top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
159 |
Iterator iterator = filterGroups.iterator(); |
179 |
GridLayout layout = new GridLayout(3, false); |
160 |
while (iterator.hasNext()) { |
180 |
top.setLayout(layout); |
161 |
MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) iterator |
181 |
top.setBackground(parent.getBackground()); |
162 |
.next(); |
182 |
initializeDialogUnits(top); |
163 |
boolean enabled = group.isEnabled(); |
183 |
|
164 |
configsTable.setChecked(group, enabled); |
184 |
createFilterSelectionArea(top); |
165 |
} |
185 |
createVerticalSeperator(top).setLayoutData( |
|
|
186 |
new GridData(SWT.NONE, SWT.FILL, false, true)); |
187 |
createFilterAreas(top).setLayoutData( |
188 |
new GridData(SWT.FILL, SWT.FILL, true, true)); |
189 |
|
166 |
|
190 |
if (filterGroups.isEmpty()) |
167 |
andButton.setSelection(andFilters); |
191 |
setFieldsEnabled(false); |
168 |
orButton.setSelection(!andFilters); |
|
|
169 |
updateRadioButtonsFromTable(); |
170 |
int limits = generator.getMarkerLimits(); |
171 |
boolean limitsEnabled = limits != -1; |
172 |
limitButton.setSelection(limitsEnabled); |
173 |
limitSpinner.setEnabled(limitsEnabled); |
174 |
if(limitsEnabled) |
175 |
limitSpinner.setSelection(limits); |
192 |
else |
176 |
else |
193 |
loadDialogSettings(); |
177 |
limitSpinner.setSelection(1); |
194 |
applyDialogFont(top); |
178 |
updateButtonEnablement(); |
195 |
return top; |
179 |
configsTable.getTable().setFocus(); |
|
|
180 |
|
181 |
} |
182 |
|
183 |
private void updateRadioButtonsFromTable() { |
184 |
|
185 |
boolean showAll = isShowAll(); |
186 |
allButton.setSelection(showAll); |
187 |
andButton.setEnabled(!showAll); |
188 |
orButton.setEnabled(!showAll); |
189 |
} |
190 |
|
191 |
private void updateShowAll(boolean showAll) { |
192 |
|
193 |
allButton.setSelection(showAll); |
194 |
andButton.setEnabled(!showAll); |
195 |
orButton.setEnabled(!showAll); |
196 |
if(showAll) { |
197 |
configsTable.setAllChecked(false); |
198 |
}else { |
199 |
// make the first entry checked |
200 |
if(filterGroups.size() > 0) { |
201 |
Object group = filterGroups.iterator().next(); |
202 |
configsTable.setChecked(group, true); |
203 |
} |
204 |
} |
196 |
} |
205 |
} |
197 |
|
206 |
|
|
|
207 |
private boolean isShowAll() { |
208 |
return configsTable.getCheckedElements().length == 0; |
209 |
} |
198 |
/** |
210 |
/** |
199 |
* @param parent |
211 |
* @param parent |
200 |
* parent |
|
|
201 |
* @return {@link Control} |
202 |
*/ |
212 |
*/ |
203 |
private Control createViewCommonUI(Composite parent) { |
213 |
private void createMarkerLimits(Composite parent) { |
204 |
Group group = new Group(parent, SWT.NONE); |
214 |
|
205 |
group.setLayout(new GridLayout(1, true)); |
215 |
limitButton = new Button(parent, SWT.CHECK); |
206 |
createLimitArea(group); |
216 |
limitButton.setText(MarkerMessages.MarkerPreferences_MarkerLimits); |
207 |
return group; |
217 |
limitButton.addSelectionListener(new SelectionAdapter() { |
|
|
218 |
|
219 |
public void widgetSelected(SelectionEvent e) { |
220 |
limitSpinner.setEnabled(limitButton.getSelection()); |
221 |
} |
222 |
}); |
223 |
|
224 |
Composite composite = new Composite(parent, SWT.NONE); |
225 |
composite.setLayout(new GridLayout(2, false)); |
226 |
GridData compositeData = new GridData(GridData.FILL_HORIZONTAL); |
227 |
compositeData.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.INDENT); |
228 |
composite.setLayoutData(compositeData); |
229 |
|
230 |
Label label = new Label(composite, SWT.NONE); |
231 |
label.setText(MarkerMessages.MarkerPreferences_VisibleItems); |
232 |
|
233 |
limitSpinner = new Spinner(composite, SWT.BORDER); |
234 |
limitSpinner.setMinimum(1); |
235 |
limitSpinner.setMaximum(Integer.MAX_VALUE); |
236 |
limitSpinner.setIncrement(1); |
237 |
limitSpinner.setPageIncrement(100); |
238 |
GridData spinnerData = new GridData(); |
239 |
spinnerData.minimumWidth = convertWidthInCharsToPixels(6); |
240 |
limitSpinner.setLayoutData(spinnerData); |
241 |
|
208 |
} |
242 |
} |
209 |
|
243 |
|
210 |
/** |
244 |
/** |
211 |
* Create element limit area. |
|
|
212 |
* |
213 |
* @param parent |
245 |
* @param parent |
214 |
*/ |
246 |
*/ |
215 |
private Control createLimitArea(Composite parent) { |
247 |
private void createFilters(Composite parent) { |
|
|
248 |
|
216 |
Composite composite = new Composite(parent, SWT.NONE); |
249 |
Composite composite = new Composite(parent, SWT.NONE); |
217 |
composite.setLayout(new GridLayout(2, false)); |
250 |
composite.setLayout(new GridLayout(2, false)); |
218 |
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
251 |
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
219 |
limitBttn = new Button(composite, SWT.CHECK); |
252 |
composite.setBackground(parent.getBackground()); |
220 |
limitBttn.setText(MarkerMessages.MarkerPreferences_VisibleItems); |
253 |
|
221 |
limitBttn.setLayoutData(new GridData()); |
254 |
configsTable = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); |
222 |
|
255 |
GridData tableData = new GridData(SWT.FILL, SWT.FILL, true, true); |
223 |
limitEditor = new Text(composite, SWT.BORDER); |
256 |
tableData.widthHint = convertHorizontalDLUsToPixels(200); |
224 |
limitEditor.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
257 |
configsTable.getControl().setLayoutData(tableData); |
225 |
Listener listener = new Listener() { |
258 |
|
226 |
public void handleEvent(Event event) { |
259 |
configsTable.setContentProvider(ArrayContentProvider.getInstance()); |
227 |
switch (event.type) { |
260 |
configsTable.setLabelProvider(new LabelProvider() { |
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(limitEditor.getText()); |
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(); |
248 |
} |
249 |
}; |
250 |
limitEditor.addListener(SWT.Modify, listener); |
251 |
limitBttn.addListener(SWT.Selection, listener); |
252 |
setLimitEnabled(IDEWorkbenchPlugin.getDefault().getPreferenceStore() |
253 |
.getBoolean(IDEInternalPreferences.USE_MARKER_LIMITS)); |
254 |
setLimitValue(IDEWorkbenchPlugin.getDefault().getPreferenceStore() |
255 |
.getInt(IDEInternalPreferences.MARKER_LIMITS_VALUE)); |
256 |
|
257 |
limitBttn.setSelection(isLimitEnabled()); |
258 |
limitEditor.setText(Integer.toString(getLimitValue())); |
259 |
limitEditor.setEditable(isLimitEnabled()); |
260 |
return composite; |
261 |
} |
262 |
|
263 |
/** |
264 |
* Create the area for selecting the filters and enabling/disabling them. |
265 |
* |
266 |
* @param main |
267 |
* @return {@link Control} |
268 |
*/ |
269 |
private Control createFilterSelectionArea(Composite main) { |
270 |
|
271 |
Composite filtersComposite = new Composite(main, SWT.NONE); |
272 |
filtersComposite.setLayout(new GridLayout(2, false)); |
273 |
filtersComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, |
274 |
true)); |
275 |
|
276 |
Label title = new Label(filtersComposite, SWT.NONE); |
277 |
title.setText(MarkerMessages.filtersDialog_entriesTitle); |
278 |
GridData titleData = new GridData(); |
279 |
titleData.horizontalSpan = 2; |
280 |
title.setLayoutData(titleData); |
281 |
|
282 |
filtersList = CheckboxTableViewer.newCheckList(filtersComposite, |
283 |
SWT.BORDER); |
284 |
|
285 |
filtersList.setContentProvider(new IStructuredContentProvider() { |
286 |
/* |
287 |
* (non-Javadoc) |
288 |
* |
289 |
* @see org.eclipse.jface.viewers.IContentProvider#dispose() |
290 |
*/ |
291 |
public void dispose() { |
292 |
// Do nothing |
293 |
} |
294 |
|
295 |
/* |
296 |
* (non-Javadoc) |
297 |
* |
298 |
* @see |
299 |
* org.eclipse.jface.viewers.IStructuredContentProvider#getElements |
300 |
* (java.lang.Object) |
301 |
*/ |
302 |
public Object[] getElements(Object inputElement) { |
303 |
return filterGroups.toArray(); |
304 |
} |
305 |
|
306 |
/* |
307 |
* (non-Javadoc) |
308 |
* |
309 |
* @see |
310 |
* org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse |
311 |
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
312 |
*/ |
313 |
public void inputChanged(Viewer viewer, Object oldInput, |
314 |
Object newInput) { |
315 |
// Do nothing |
316 |
} |
317 |
}); |
318 |
|
319 |
filtersList.setLabelProvider(new LabelProvider() { |
320 |
/* |
321 |
* (non-Javadoc) |
322 |
* |
323 |
* @see |
324 |
* org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object |
325 |
* ) |
326 |
*/ |
327 |
public String getText(Object element) { |
261 |
public String getText(Object element) { |
328 |
return ((MarkerFieldFilterGroup) element).getName(); |
262 |
return ((MarkerFieldFilterGroup) element).getName(); |
329 |
} |
263 |
} |
330 |
}); |
264 |
}); |
331 |
|
265 |
|
332 |
if (selectedFilterGroup != null) |
266 |
configsTable.addCheckStateListener(new ICheckStateListener() { |
333 |
filtersList.setSelection(new StructuredSelection( |
267 |
public void checkStateChanged(CheckStateChangedEvent event) { |
334 |
selectedFilterGroup)); |
268 |
updateRadioButtonsFromTable(); |
|
|
269 |
} |
270 |
}); |
335 |
|
271 |
|
336 |
filtersList |
272 |
configsTable |
337 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
273 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
338 |
|
|
|
339 |
/* |
340 |
* (non-Javadoc) |
341 |
* |
342 |
* @see org.eclipse.jface.viewers.ISelectionChangedListener# |
343 |
* selectionChanged |
344 |
* (org.eclipse.jface.viewers.SelectionChangedEvent) |
345 |
*/ |
346 |
public void selectionChanged(SelectionChangedEvent event) { |
274 |
public void selectionChanged(SelectionChangedEvent event) { |
347 |
setSelectedFilter((MarkerFieldFilterGroup) ((IStructuredSelection) event |
275 |
updateButtonEnablement(); |
348 |
.getSelection()).getFirstElement()); |
|
|
349 |
} |
276 |
} |
350 |
}); |
277 |
}); |
351 |
|
278 |
|
352 |
filtersList.setInput(this); |
279 |
configsTable.addDoubleClickListener(new IDoubleClickListener() { |
|
|
280 |
|
281 |
public void doubleClick(DoubleClickEvent event) { |
282 |
IStructuredSelection selection = (IStructuredSelection) configsTable.getSelection(); |
283 |
MarkerFieldFilterGroup configuration = (MarkerFieldFilterGroup) selection.getFirstElement(); |
284 |
editConfiguration(configuration); |
285 |
} |
286 |
}); |
353 |
|
287 |
|
354 |
Iterator filterIterator = filterGroups.iterator(); |
288 |
createButtons(composite); |
355 |
while (filterIterator.hasNext()) { |
|
|
356 |
MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filterIterator |
357 |
.next(); |
358 |
filtersList.setChecked(group, group.isEnabled()); |
359 |
} |
360 |
|
289 |
|
361 |
GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true); |
290 |
} |
362 |
listData.widthHint = convertHorizontalDLUsToPixels(100); |
|
|
363 |
filtersList.getControl().setLayoutData(listData); |
364 |
|
291 |
|
365 |
Composite buttons = new Composite(filtersComposite, SWT.NONE); |
292 |
/** |
|
|
293 |
* @param composite |
294 |
*/ |
295 |
private void createButtons(Composite composite) { |
296 |
Composite buttons = new Composite(composite, SWT.NONE); |
366 |
GridLayout buttonLayout = new GridLayout(); |
297 |
GridLayout buttonLayout = new GridLayout(); |
367 |
buttonLayout.marginWidth = 0; |
298 |
buttonLayout.marginWidth = 0; |
368 |
buttons.setLayout(buttonLayout); |
299 |
buttons.setLayout(buttonLayout); |
Lines 374-561
Link Here
|
374 |
addNew.setText(MarkerMessages.MarkerFilter_addFilterName); |
305 |
addNew.setText(MarkerMessages.MarkerFilter_addFilterName); |
375 |
addNew.addSelectionListener(new SelectionAdapter() { |
306 |
addNew.addSelectionListener(new SelectionAdapter() { |
376 |
public void widgetSelected(SelectionEvent e) { |
307 |
public void widgetSelected(SelectionEvent e) { |
377 |
addNewFilter(false); |
308 |
addConfiguration(); |
378 |
} |
309 |
} |
379 |
}); |
310 |
}); |
380 |
setButtonLayoutData(addNew); |
311 |
setButtonLayoutData(addNew); |
381 |
|
312 |
|
382 |
cloneButton = new Button(buttons, SWT.PUSH); |
313 |
editButton = new Button(buttons, SWT.PUSH); |
383 |
cloneButton.setText(MarkerMessages.MarkerFilter_cloneFilterName); |
314 |
editButton.setText(MarkerMessages.MarkerFilter_editFilterName); |
384 |
cloneButton.addSelectionListener(new SelectionAdapter() { |
315 |
editButton.addSelectionListener(new SelectionAdapter() { |
385 |
public void widgetSelected(SelectionEvent e) { |
316 |
public void widgetSelected(SelectionEvent e) { |
386 |
addNewFilter(true); |
317 |
IStructuredSelection selection = (IStructuredSelection) configsTable.getSelection(); |
|
|
318 |
MarkerFieldFilterGroup configuration = (MarkerFieldFilterGroup) selection.getFirstElement(); |
319 |
editConfiguration(configuration); |
387 |
} |
320 |
} |
388 |
}); |
321 |
}); |
389 |
setButtonLayoutData(cloneButton); |
322 |
setButtonLayoutData(editButton); |
390 |
|
323 |
|
391 |
removeButton = new Button(buttons, SWT.PUSH); |
324 |
removeButton = new Button(buttons, SWT.PUSH); |
392 |
removeButton.setText(MarkerMessages.MarkerFilter_deleteSelectedName); |
325 |
removeButton.setText(MarkerMessages.MarkerFilter_deleteSelectedName); |
393 |
removeButton.addSelectionListener(new SelectionAdapter() { |
326 |
removeButton.addSelectionListener(new SelectionAdapter() { |
394 |
public void widgetSelected(SelectionEvent e) { |
327 |
public void widgetSelected(SelectionEvent e) { |
395 |
removeFilters(filtersList.getSelection()); |
328 |
removeFilters(configsTable.getSelection()); |
396 |
} |
329 |
} |
397 |
}); |
330 |
}); |
398 |
setButtonLayoutData(removeButton); |
331 |
setButtonLayoutData(removeButton); |
|
|
332 |
} |
333 |
|
334 |
private boolean editConfiguration(MarkerFieldFilterGroup configuration) { |
335 |
|
336 |
ConfigurationEditDialog dialog = new ConfigurationEditDialog(getShell(), generator, configuration); |
337 |
dialog.setCurrentConfigurationNames(getCurrentConfigurationNames()); |
338 |
if(dialog.open() == Window.CANCEL) |
339 |
return false; |
340 |
return true; |
341 |
|
342 |
} |
399 |
|
343 |
|
400 |
renameButton = new Button(buttons, SWT.PUSH); |
344 |
private void createAndOrButtons(Composite parent) { |
401 |
renameButton.setText(MarkerMessages.MarkerFilter_renameName); |
345 |
|
402 |
renameButton.addSelectionListener(new SelectionAdapter() { |
346 |
allButton = new Button(parent, SWT.CHECK); |
|
|
347 |
allButton.setText(MarkerMessages.ALL_Title); |
348 |
allButton.addSelectionListener(new SelectionAdapter() { |
403 |
public void widgetSelected(SelectionEvent e) { |
349 |
public void widgetSelected(SelectionEvent e) { |
404 |
MarkerFieldFilterGroup filterGroup = (MarkerFieldFilterGroup) ((IStructuredSelection) filtersList |
350 |
updateShowAll(allButton.getSelection()); |
405 |
.getSelection()).getFirstElement(); |
|
|
406 |
renameFilter(filterGroup); |
407 |
} |
351 |
} |
408 |
}); |
352 |
}); |
409 |
setButtonLayoutData(renameButton); |
|
|
410 |
|
353 |
|
411 |
andOrLabel = new Label(filtersComposite, SWT.NONE); |
354 |
andButton = new Button(parent, SWT.RADIO); |
412 |
GridData labelData = new GridData(); |
|
|
413 |
labelData.horizontalSpan = 2; |
414 |
andOrLabel.setLayoutData(labelData); |
415 |
andOrLabel.setText(MarkerMessages.AND_OR_Label); |
416 |
|
417 |
andButton = new Button(filtersComposite, SWT.RADIO); |
418 |
GridData data = new GridData(GridData.FILL_HORIZONTAL, SWT.NONE, true, |
419 |
false); |
420 |
data.horizontalSpan = 2; |
421 |
data.horizontalIndent = IDialogConstants.INDENT; |
422 |
andButton.setLayoutData(data); |
423 |
andButton.setText(MarkerMessages.AND_Title); |
355 |
andButton.setText(MarkerMessages.AND_Title); |
424 |
andButton.setSelection(andFilters); |
|
|
425 |
andButton.addSelectionListener(new SelectionAdapter() { |
356 |
andButton.addSelectionListener(new SelectionAdapter() { |
426 |
|
|
|
427 |
/* |
428 |
* (non-Javadoc) |
429 |
* |
430 |
* @see |
431 |
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
432 |
* .swt.events.SelectionEvent) |
433 |
*/ |
434 |
public void widgetSelected(SelectionEvent e) { |
357 |
public void widgetSelected(SelectionEvent e) { |
435 |
andFilters = true; |
358 |
andFilters = true; |
436 |
} |
359 |
} |
437 |
}); |
360 |
}); |
|
|
361 |
GridData andData = new GridData(); |
362 |
andData.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.INDENT); |
363 |
andButton.setLayoutData(andData); |
438 |
|
364 |
|
439 |
orButton = new Button(filtersComposite, SWT.RADIO); |
365 |
orButton = new Button(parent, SWT.RADIO); |
440 |
data = new GridData(GridData.FILL_HORIZONTAL, SWT.NONE, true, false); |
|
|
441 |
data.horizontalSpan = 2; |
442 |
data.horizontalIndent = IDialogConstants.INDENT; |
443 |
orButton.setLayoutData(data); |
444 |
orButton.setText(MarkerMessages.OR_Title); |
366 |
orButton.setText(MarkerMessages.OR_Title); |
445 |
orButton.setSelection(!andFilters); |
|
|
446 |
orButton.addSelectionListener(new SelectionAdapter() { |
367 |
orButton.addSelectionListener(new SelectionAdapter() { |
447 |
|
|
|
448 |
/* |
449 |
* (non-Javadoc) |
450 |
* |
451 |
* @see |
452 |
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
453 |
* .swt.events.SelectionEvent) |
454 |
*/ |
455 |
public void widgetSelected(SelectionEvent e) { |
368 |
public void widgetSelected(SelectionEvent e) { |
456 |
andFilters = false; |
369 |
andFilters = false; |
457 |
} |
370 |
} |
458 |
}); |
371 |
}); |
459 |
filtersList.addCheckStateListener(new ICheckStateListener() { |
372 |
GridData orData = new GridData(); |
460 |
public void checkStateChanged(CheckStateChangedEvent event) { |
373 |
orData.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.INDENT); |
461 |
updateAndOrEnblement(); |
374 |
orButton.setLayoutData(orData); |
462 |
validateState(); |
375 |
|
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 |
|
548 |
} |
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 |
} |
376 |
} |
560 |
|
377 |
|
561 |
/** |
378 |
/** |
Lines 563-569
Link Here
|
563 |
* |
380 |
* |
564 |
* @return Collection |
381 |
* @return Collection |
565 |
*/ |
382 |
*/ |
566 |
private Collection getCurrentFilterNames() { |
383 |
private Collection getCurrentConfigurationNames() { |
567 |
Collection names = new ArrayList(); |
384 |
Collection names = new ArrayList(); |
568 |
Iterator filterIterator = filterGroups.iterator(); |
385 |
Iterator filterIterator = filterGroups.iterator(); |
569 |
while (filterIterator.hasNext()) { |
386 |
while (filterIterator.hasNext()) { |
Lines 573-692
Link Here
|
573 |
return names; |
390 |
return names; |
574 |
} |
391 |
} |
575 |
|
392 |
|
576 |
/** |
393 |
private void addConfiguration() { |
577 |
* Opens Input Dialog for name,creates a new filterGroup, and adds it to the |
394 |
String newName = getNewConfigurationName(getCurrentConfigurationNames(), MarkerMessages.MarkerFilter_newFilterName); |
578 |
* filterGroups |
395 |
MarkerFieldFilterGroup configuration = createConfiguration(newName); |
579 |
* |
396 |
boolean cancelPressed = editConfiguration(configuration); |
580 |
* @param cloneSelected |
397 |
if(cancelPressed) { |
581 |
* true clones the selected filterGroup |
398 |
filterGroups.add(configuration); |
582 |
* |
399 |
configsTable.refresh(); |
583 |
*/ |
400 |
configsTable.setSelection(new StructuredSelection(configuration)); |
584 |
private void addNewFilter(boolean cloneSelected) { |
401 |
configsTable.setChecked(configuration, true); |
585 |
String newName = getNewFilterName(getCurrentFilterNames(), null); |
402 |
updateRadioButtonsFromTable(); |
586 |
if (newName != null) { |
|
|
587 |
createNewFilter(newName, cloneSelected); |
588 |
} |
403 |
} |
589 |
} |
404 |
} |
590 |
|
405 |
|
591 |
/** |
406 |
private String getNewConfigurationName(final Collection avoidNames, |
592 |
* Opens Input Dialog for a new filter name |
|
|
593 |
* |
594 |
* @param avoidNames |
595 |
* filter names to avoid |
596 |
* @param initialName |
597 |
* initial name of the filter |
598 |
* @return new filter name or null if canceled |
599 |
* |
600 |
*/ |
601 |
private String getNewFilterName(final Collection avoidNames, |
602 |
String initialName) { |
407 |
String initialName) { |
603 |
InputDialog newDialog = new InputDialog(getShell(), |
408 |
|
604 |
MarkerMessages.MarkerFilterDialog_title, |
409 |
String configName = initialName; |
605 |
MarkerMessages.MarkerFilterDialog_message, |
410 |
for (int i = 1; avoidNames.contains(configName); i++) { |
606 |
initialName != null ? initialName |
411 |
configName = initialName+ ' '+ i; |
607 |
: MarkerMessages.MarkerFilter_newFilterName, |
|
|
608 |
getNameValidator(avoidNames)); |
609 |
if (Window.OK == newDialog.open()) { |
610 |
return newDialog.getValue(); |
611 |
} |
412 |
} |
612 |
return null; |
413 |
return configName; |
613 |
} |
414 |
} |
614 |
|
415 |
|
615 |
/** |
416 |
private MarkerFieldFilterGroup createConfiguration(String newName) { |
616 |
* Get IInputValidator for checking if the new name is valid |
|
|
617 |
* |
618 |
* @param avoidNames |
619 |
* @return IInputValidator |
620 |
*/ |
621 |
private IInputValidator getNameValidator(final Collection avoidNames) { |
622 |
return new IInputValidator() { |
623 |
public String isValid(String value) { |
624 |
String newText = value.trim(); |
625 |
if (newText.length() == 0) |
626 |
return MarkerMessages.MarkerFilterDialog_emptyMessage; |
627 |
if (avoidNames.contains(newText)) |
628 |
return NLS.bind( |
629 |
MarkerMessages.filtersDialog_conflictingName, |
630 |
newText); |
631 |
return null; |
632 |
} |
633 |
}; |
634 |
} |
635 |
|
417 |
|
636 |
/** |
418 |
MarkerFieldFilterGroup config = new MarkerFieldFilterGroup(null, |
637 |
* Create a new filterGroup, and adds it to the filterGroups |
|
|
638 |
* |
639 |
* @param cloneSelected |
640 |
* true clones the selected filterGroup |
641 |
* @param newName |
642 |
* name of new filterGroup |
643 |
*/ |
644 |
private void createNewFilter(String newName, boolean cloneSelected) { |
645 |
MarkerFieldFilterGroup group = new MarkerFieldFilterGroup(null, |
646 |
generator); |
419 |
generator); |
647 |
if (cloneSelected && selectedFilterGroup != null) { |
420 |
config.setName(newName); |
648 |
captureStateInto(group); // copy current values from UI |
421 |
return config; |
649 |
} |
|
|
650 |
group.setName(newName); |
651 |
filterGroups.add(group); |
652 |
filtersList.refresh(); |
653 |
filtersList.setSelection(new StructuredSelection(group)); |
654 |
filtersList.setChecked(group, true); |
655 |
updateAndOrEnblement(); |
656 |
} |
657 |
|
658 |
/** |
659 |
* Renames the supplied MarkerFieldFilterGroup |
660 |
* |
661 |
* @param filterGroup |
662 |
*/ |
663 |
private void renameFilter(MarkerFieldFilterGroup filterGroup) { |
664 |
if (filterGroup != null) { |
665 |
Collection names = getCurrentFilterNames(); |
666 |
String initial = null; |
667 |
initial = filterGroup.getName(); |
668 |
names.remove(initial); |
669 |
String newName = getNewFilterName(names, initial); |
670 |
if (newName != null) { |
671 |
filterGroup.setName(newName); |
672 |
filtersList.update(filterGroup, null); |
673 |
} |
674 |
} |
675 |
} |
676 |
|
677 |
/** |
678 |
* Enable/disable 'and', 'or' buttons |
679 |
*/ |
680 |
private void updateAndOrEnblement() { |
681 |
if (filtersList.getCheckedElements().length == 0) { |
682 |
andOrLabel.setEnabled(false); |
683 |
andButton.setEnabled(false); |
684 |
orButton.setEnabled(false); |
685 |
} else { |
686 |
andOrLabel.setEnabled(true); |
687 |
andButton.setEnabled(true); |
688 |
orButton.setEnabled(true); |
689 |
} |
690 |
} |
422 |
} |
691 |
|
423 |
|
692 |
/** |
424 |
/** |
Lines 729-743
Link Here
|
729 |
MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) groups |
461 |
MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) groups |
730 |
.next(); |
462 |
.next(); |
731 |
if (group.getName().equals(selection)) { |
463 |
if (group.getName().equals(selection)) { |
732 |
filtersList.setSelection(new StructuredSelection(group)); |
464 |
configsTable.setSelection(new StructuredSelection(group)); |
733 |
return; |
465 |
return; |
734 |
} |
466 |
} |
735 |
} |
467 |
} |
736 |
} |
468 |
} |
737 |
|
469 |
|
738 |
// If there is no initial selection make one |
470 |
// If there is no initial selection make one |
739 |
filtersList.setSelection(new StructuredSelection(filterGroups |
471 |
if(filterGroups.size() > 0) { |
740 |
.iterator().next())); |
472 |
configsTable.setSelection(new StructuredSelection(filterGroups |
|
|
473 |
.iterator().next())); |
474 |
} |
741 |
} |
475 |
} |
742 |
|
476 |
|
743 |
/** |
477 |
/** |
Lines 759-825
Link Here
|
759 |
return returnFilters; |
493 |
return returnFilters; |
760 |
} |
494 |
} |
761 |
|
495 |
|
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 |
|
496 |
|
824 |
/* |
497 |
/* |
825 |
* (non-Javadoc) |
498 |
* (non-Javadoc) |
Lines 828-905
Link Here
|
828 |
*/ |
501 |
*/ |
829 |
protected void okPressed() { |
502 |
protected void okPressed() { |
830 |
|
503 |
|
831 |
IDEWorkbenchPlugin |
504 |
int limits; |
832 |
.getDefault() |
505 |
|
833 |
.getPreferenceStore() |
506 |
if(limitButton.getSelection()) |
834 |
.setValue(IDEInternalPreferences.MARKER_LIMITS_VALUE, |
507 |
limits = limitSpinner.getSelection(); |
835 |
getLimitValue()); |
508 |
else |
836 |
IDEWorkbenchPlugin |
509 |
limits = -1; |
837 |
.getDefault() |
510 |
|
838 |
.getPreferenceStore() |
511 |
generator.setMarkerLimits(limits); |
839 |
.setValue(IDEInternalPreferences.USE_MARKER_LIMITS, |
512 |
|
840 |
isLimitEnabled()); |
|
|
841 |
IDEWorkbenchPlugin.getDefault().savePluginPreferences(); |
842 |
|
843 |
Iterator filterGroupIterator = filterGroups.iterator(); |
513 |
Iterator filterGroupIterator = filterGroups.iterator(); |
844 |
while (filterGroupIterator.hasNext()) { |
514 |
while (filterGroupIterator.hasNext()) { |
845 |
MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filterGroupIterator |
515 |
MarkerFieldFilterGroup group = (MarkerFieldFilterGroup) filterGroupIterator |
846 |
.next(); |
516 |
.next(); |
847 |
group.setEnabled(filtersList.getChecked(group)); |
517 |
group.setEnabled(configsTable.getChecked(group)); |
848 |
} |
518 |
} |
849 |
captureStateInto(selectedFilterGroup); |
519 |
saveDialogSettings(); |
850 |
|
520 |
|
851 |
super.okPressed(); |
521 |
super.okPressed(); |
852 |
|
522 |
|
853 |
} |
523 |
} |
854 |
|
524 |
|
855 |
/** |
|
|
856 |
* |
857 |
* Updates the filterGroup with the values showing in the dialog's GUI. |
858 |
* |
859 |
* @param filterGroup |
860 |
* |
861 |
*/ |
862 |
private void captureStateInto(MarkerFieldFilterGroup filterGroup) { |
863 |
if (filterGroup != null) { |
864 |
|
865 |
scopeArea.applyToGroup(filterGroup); |
866 |
Iterator areas = filterAreas.iterator(); |
867 |
while (areas.hasNext()) { |
868 |
FilterConfigurationArea area = (FilterConfigurationArea) areas |
869 |
.next(); |
870 |
|
871 |
// Handle the internal special cases |
872 |
if (area instanceof GroupFilterConfigurationArea) |
873 |
((GroupFilterConfigurationArea) area) |
874 |
.applyToGroup(filterGroup); |
875 |
area.apply(filterGroup.getFilter(area.getField())); |
876 |
} |
877 |
} |
878 |
} |
879 |
|
880 |
/* |
881 |
* (non-Javadoc) |
882 |
* |
883 |
* @see org.eclipse.ui.preferences.ViewSettingsDialog#performDefaults() |
884 |
*/ |
885 |
protected void performDefaults() { |
525 |
protected void performDefaults() { |
886 |
setLimitEnabled(IDEWorkbenchPlugin.getDefault().getPreferenceStore() |
526 |
|
887 |
.getDefaultBoolean(IDEInternalPreferences.USE_MARKER_LIMITS)); |
527 |
limitButton.setSelection(true); |
888 |
limitBttn.setSelection(isLimitEnabled()); |
528 |
limitSpinner.setSelection(IDEWorkbenchPlugin.getDefault().getPreferenceStore() |
889 |
|
|
|
890 |
setLimitValue(IDEWorkbenchPlugin.getDefault().getPreferenceStore() |
891 |
.getDefaultInt(IDEInternalPreferences.MARKER_LIMITS_VALUE)); |
529 |
.getDefaultInt(IDEInternalPreferences.MARKER_LIMITS_VALUE)); |
892 |
limitEditor.setText(Integer.toString(getLimitValue())); |
|
|
893 |
|
530 |
|
894 |
filterGroups.clear(); |
531 |
filterGroups.clear(); |
895 |
filterGroups.addAll(generator.getDeclaredFilters()); |
532 |
filterGroups.addAll(generator.getDeclaredFilters()); |
896 |
filtersList.refresh(); |
533 |
configsTable.refresh(); |
897 |
filtersList.setSelection(new StructuredSelection( |
534 |
configsTable.setSelection(new StructuredSelection( |
898 |
filterGroups.size() > 1 ? filterGroups.iterator().next() |
535 |
filterGroups.size() > 1 ? filterGroups.iterator().next() |
899 |
: new Object[0])); |
536 |
: new Object[0])); |
900 |
andFilters = false; |
537 |
andFilters = false; |
901 |
andButton.setSelection(andFilters); |
538 |
andButton.setSelection(andFilters); |
902 |
orButton.setSelection(!andFilters); |
539 |
orButton.setSelection(!andFilters); |
|
|
540 |
updateRadioButtonsFromTable(); |
903 |
} |
541 |
} |
904 |
|
542 |
|
905 |
/** |
543 |
/** |
Lines 910-917
Link Here
|
910 |
private void removeFilters(ISelection selection) { |
548 |
private void removeFilters(ISelection selection) { |
911 |
filterGroups.remove(((IStructuredSelection) selection) |
549 |
filterGroups.remove(((IStructuredSelection) selection) |
912 |
.getFirstElement()); |
550 |
.getFirstElement()); |
913 |
filtersList.refresh(); |
551 |
configsTable.refresh(); |
914 |
updateAndOrEnblement(); |
552 |
updateRadioButtonsFromTable(); |
915 |
} |
553 |
} |
916 |
|
554 |
|
917 |
/** |
555 |
/** |
Lines 925-1025
Link Here
|
925 |
|
563 |
|
926 |
} |
564 |
} |
927 |
|
565 |
|
928 |
/** |
566 |
private void updateButtonEnablement() { |
929 |
* @return Returns the limitValue. |
567 |
boolean empty = configsTable.getSelection().isEmpty(); |
930 |
*/ |
568 |
editButton.setEnabled(!empty); |
931 |
private int getLimitValue() { |
569 |
removeButton.setEnabled(!empty); |
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 |
} |
570 |
} |
949 |
|
571 |
|
950 |
/** |
|
|
951 |
* @param limitEnabled |
952 |
* The limitEnabled to set. |
953 |
*/ |
954 |
private void setLimitEnabled(boolean limitEnabled) { |
955 |
this.limitEnabled = limitEnabled; |
956 |
} |
957 |
|
958 |
/** |
959 |
* Set the control and all of it's visibility state to visible. |
960 |
* |
961 |
* @param visible |
962 |
* @param control |
963 |
*/ |
964 |
private void setEnabled(boolean visible, Control control) { |
965 |
control.setEnabled(visible); |
966 |
if (control instanceof Composite) { |
967 |
Control[] children = ((Composite) control).getChildren(); |
968 |
for (int i = 0; i < children.length; i++) { |
969 |
setEnabled(visible, children[i]); |
970 |
} |
971 |
} |
972 |
} |
973 |
|
974 |
/** |
975 |
* Set the enablement state of the fields to enabled. |
976 |
*/ |
977 |
private void setFieldsEnabled(boolean visible) { |
978 |
setEnabled(visible, form); |
979 |
} |
980 |
|
981 |
/** |
982 |
* Set the filter that is being worked on. |
983 |
* |
984 |
* @param markerFieldFilterGroup |
985 |
*/ |
986 |
private void setSelectedFilter(MarkerFieldFilterGroup markerFieldFilterGroup) { |
987 |
if (selectedFilterGroup == markerFieldFilterGroup) { |
988 |
return; |
989 |
} |
990 |
removeButton |
991 |
.setEnabled(!(markerFieldFilterGroup == null || markerFieldFilterGroup |
992 |
.isSystem())); |
993 |
renameButton |
994 |
.setEnabled(!(markerFieldFilterGroup == null || markerFieldFilterGroup |
995 |
.isSystem())); |
996 |
cloneButton.setEnabled(markerFieldFilterGroup != null); |
997 |
|
998 |
MarkerFieldFilterGroup old = selectedFilterGroup; |
999 |
selectedFilterGroup = markerFieldFilterGroup; |
1000 |
if (old != null) |
1001 |
scopeArea.applyToGroup(old); |
1002 |
|
1003 |
if (selectedFilterGroup == null) { |
1004 |
setFieldsEnabled(false); |
1005 |
return; |
1006 |
} |
1007 |
|
1008 |
setFieldsEnabled(true); |
1009 |
scopeArea.initializeFromGroup(selectedFilterGroup); |
1010 |
Iterator areas = filterAreas.iterator(); |
1011 |
while (areas.hasNext()) { |
1012 |
FilterConfigurationArea area = (FilterConfigurationArea) areas |
1013 |
.next(); |
1014 |
if (old != null) { |
1015 |
if (area instanceof GroupFilterConfigurationArea) |
1016 |
((GroupFilterConfigurationArea) area).applyToGroup(old); |
1017 |
area.apply(old.getFilter(area.getField())); |
1018 |
} |
1019 |
if (area instanceof GroupFilterConfigurationArea) |
1020 |
((GroupFilterConfigurationArea) area) |
1021 |
.initializeFromGroup(selectedFilterGroup); |
1022 |
area.initialize(selectedFilterGroup.getFilter(area.getField())); |
1023 |
} |
1024 |
} |
1025 |
} |
572 |
} |