]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / preferences / formatter / LineWrappingTabPage.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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 package org.eclipse.jdt.internal.ui.preferences.formatter;
12
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.HashMap;
16 import java.util.Iterator;
17 import java.util.List;
18 import java.util.Map;
19
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.events.SelectionAdapter;
22 import org.eclipse.swt.events.SelectionEvent;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.widgets.Button;
25 import org.eclipse.swt.widgets.Combo;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Control;
28 import org.eclipse.swt.widgets.Group;
29 import org.eclipse.swt.widgets.Label;
30
31 import org.eclipse.core.runtime.IStatus;
32 import org.eclipse.core.runtime.Status;
33
34 import org.eclipse.jface.dialogs.IDialogSettings;
35 import org.eclipse.jface.viewers.DoubleClickEvent;
36 import org.eclipse.jface.viewers.IDoubleClickListener;
37 import org.eclipse.jface.viewers.ISelection;
38 import org.eclipse.jface.viewers.ISelectionChangedListener;
39 import org.eclipse.jface.viewers.IStructuredSelection;
40 import org.eclipse.jface.viewers.ITreeContentProvider;
41 import org.eclipse.jface.viewers.LabelProvider;
42 import org.eclipse.jface.viewers.SelectionChangedEvent;
43 import org.eclipse.jface.viewers.StructuredSelection;
44 import org.eclipse.jface.viewers.TreeViewer;
45 import org.eclipse.jface.viewers.Viewer;
46
47 import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
48
49 import org.eclipse.jdt.internal.corext.util.Messages;
50
51 import org.eclipse.jdt.ui.JavaUI;
52
53 import org.eclipse.jdt.internal.ui.JavaPlugin;
54 import org.eclipse.jdt.internal.ui.util.SWTUtil;
55
56
57 /**
58  * The line wrapping tab page.
59  */
60 public class LineWrappingTabPage extends FormatterTabPage {
61         /**
62      * Represents a line wrapping category. All members are final.
63      */
64         final static class Category {
65                 public final String key;
66                 public final String name;
67                 public final String previewText;
68                 public final List<Category> children;
69                 public final List<Preference> preferences;
70
71                 public int index;
72
73                 public Category(String _key, String _previewText, String _name) {
74                         this.key= _key;
75                         this.name= _name;
76                         this.previewText= _previewText != null ? createPreviewHeader(_name) + _previewText : null;
77                         children= new ArrayList<Category>();
78                         preferences= new ArrayList<Preference>();
79                 }
80
81                 /**
82                  * @param _name Category name
83                  */
84                 public Category(String _name) {
85                     this(null, null, _name);
86                 }
87
88                 @Override
89                 public String toString() {
90                         return name;
91                 }
92
93                 public void addPreference(Preference specificPreference) {
94                         preferences.add(specificPreference);
95                 }
96
97                 public Preference[] getSpecificPreferences() {
98                         return preferences.toArray(new Preference[preferences.size()]);
99                 }
100
101                 public void setEnabled(boolean state) {
102                         for (Preference preference : preferences)
103                                 preference.setEnabled(state);
104                 }
105
106                 public List<Category> generated_5026085346794046769(final Category annotations, final Category classDeclarations, final Category constructorDeclarations, final Category methodDeclarations, final Category enumDeclarations, LineWrappingTabPage linewrappingtabpage) {
107                         children.add(linewrappingtabpage.fMessageSendArgumentsCategory);
108                         children.add(linewrappingtabpage.fMessageSendSelectorCategory);
109                         children.add(linewrappingtabpage.fExplicitConstructorArgumentsCategory);
110                         children.add(linewrappingtabpage.fAllocationExpressionArgumentsCategory);
111                         children.add(linewrappingtabpage.fQualifiedAllocationExpressionCategory);
112                 
113                         final Category expressions= new Category(FormatterMessages.LineWrappingTabPage_expressions);
114                         expressions.children.add(linewrappingtabpage.fBinaryExpressionCategory);
115                         expressions.children.add(linewrappingtabpage.fConditionalExpressionCategory);
116                         expressions.children.add(linewrappingtabpage.fArrayInitializerExpressionsCategory);
117                         expressions.children.add(linewrappingtabpage.fAssignmentCategory);
118                 
119                         final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
120                         statements.children.add(linewrappingtabpage.fCompactIfCategory);
121                         statements.children.add(linewrappingtabpage.fTryCategory);
122                         statements.children.add(linewrappingtabpage.fCatchCategory);
123                 
124                         final List<Category> root= new ArrayList<Category>();
125                         root.add(annotations);
126                         root.add(classDeclarations);
127                         root.add(constructorDeclarations);
128                         root.add(methodDeclarations);
129                         root.add(enumDeclarations);
130                         root.add(this);
131                         root.add(expressions);
132                         root.add(statements);
133                         return root;
134                 }
135
136                 public void generated_6148527569529654916(List<Category> categoriesList, CategoryListener categorylistener) {
137                         index= categorylistener.fIndex++;
138                         categoriesList.add(this);
139                         categorylistener.flatten(categoriesList, children);
140                 }
141
142                 public String generated_2284278817571461453(CategoryListener categorylistener) {
143                         return Messages.format(FormatterMessages.LineWrappingTabPage_group, name.toLowerCase());
144                 }
145
146                 public void generated_5019980853133752670(SelectionState selectionstate) {
147                         String value;
148                         value= fWorkingValues.get(key);
149                         if (value != null) {
150                             if (!selectionstate.fElements.contains(this))
151                                 selectionstate.fElements.add(this);
152                         }
153                         else {
154                             selectionstate.evaluateElements(children.iterator());
155                         }
156                 }
157
158                 public String generated_659765559651578846(String previewText, SelectionState selectionstate) {
159                         previewText= previewText + this.previewText + "\n\n";
160                         return previewText;
161                 }
162
163                 public void generated_6071857012505743656(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap, SelectionState selectionstate) {
164                         final String value= fWorkingValues.get(key);
165                     Integer wrappingStyle;
166                     Integer indentStyle;
167                     Boolean forceWrapping;
168                 
169                     try {
170                         wrappingStyle= new Integer(DefaultCodeFormatterConstants.getWrappingStyle(value));
171                         indentStyle= new Integer(DefaultCodeFormatterConstants.getIndentStyle(value));
172                         forceWrapping= new Boolean(DefaultCodeFormatterConstants.getForceWrapping(value));
173                     } catch (IllegalArgumentException e) {
174                                 forceWrapping= new Boolean(false);
175                                 indentStyle= new Integer(DefaultCodeFormatterConstants.INDENT_DEFAULT);
176                                 wrappingStyle= new Integer(DefaultCodeFormatterConstants.WRAP_NO_SPLIT);
177                         }
178                 
179                     selectionstate.increaseMapEntry(wrappingMap, wrappingStyle);
180                     selectionstate.increaseMapEntry(indentMap, indentStyle);
181                     selectionstate.increaseMapEntry(forceMap, forceWrapping);
182                 }
183         }
184
185
186         private final static String PREF_CATEGORY_INDEX= JavaUI.ID_PLUGIN + "formatter_page.line_wrapping_tab_page.last_category_index"; //$NON-NLS-1$
187
188
189         final class CategoryListener implements ISelectionChangedListener, IDoubleClickListener {
190
191                 private final List<Category> fCategoriesList;
192
193                 private int fIndex= 0;
194
195                 public CategoryListener(List<Category> categoriesTree) {
196                         fCategoriesList= new ArrayList<Category>();
197                         flatten(fCategoriesList, categoriesTree);
198                 }
199
200                 void flatten(List<Category> categoriesList, List<Category> categoriesTree) {
201                         for (final Iterator<Category> iter= categoriesTree.iterator(); iter.hasNext(); ) {
202                                 final Category category= iter.next();
203                                 category.generated_6148527569529654916(categoriesList, CategoryListener.this);
204                         }
205                 }
206
207                 public void selectionChanged(SelectionChangedEvent event) {
208                     if (event != null)
209                         fSelection= (IStructuredSelection)event.getSelection();
210
211                     if (fSelection.size() == 0) {
212                         disableAll();
213                         return;
214                     }
215
216                     if (!fOptionsGroup.isEnabled())
217                         enableDefaultComponents(true);
218
219                     fSelectionState.refreshState(fSelection);
220
221                         final Category category= (Category)fSelection.getFirstElement();
222                         fDialogSettings.put(PREF_CATEGORY_INDEX, category.index);
223
224                         fOptionsGroup.setText(getGroupLabel(category));
225                 }
226
227                 private String getGroupLabel(Category category) {
228                     if (fSelection.size() == 1) {
229                             if (fSelectionState.getElements().size() == 1)
230                                         return category.generated_2284278817571461453(CategoryListener.this);
231                             return Messages.format(FormatterMessages.LineWrappingTabPage_multi_group, new String[] {category.name.toLowerCase(), Integer.toString(fSelectionState.getElements().size())});
232                     }
233                         return Messages.format(FormatterMessages.LineWrappingTabPage_multiple_selections, new String[] {Integer.toString(fSelectionState.getElements().size())});
234                 }
235
236                 private void disableAll() {
237             enableDefaultComponents(false);
238             fIndentStyleCombo.setEnabled(false);
239             fForceSplit.setEnabled(false);
240         }
241
242         private void enableDefaultComponents(boolean enabled) {
243             fOptionsGroup.setEnabled(enabled);
244             fWrappingStyleCombo.setEnabled(enabled);
245             fWrappingStylePolicy.setEnabled(enabled);
246         }
247
248         public void restoreSelection() {
249                         int index;
250                         try {
251                                 index= fDialogSettings.getInt(PREF_CATEGORY_INDEX);
252                         } catch (NumberFormatException ex) {
253                                 index= -1;
254                         }
255                         if (index < 0 || index > fCategoriesList.size() - 1) {
256                                 index= 1; // In order to select a category with preview initially
257                         }
258                         final Category category= fCategoriesList.get(index);
259                         fCategoriesViewer.setSelection(new StructuredSelection(new Category[] {category}));
260                 }
261
262         public void doubleClick(DoubleClickEvent event) {
263             final ISelection selection= event.getSelection();
264             if (selection instanceof IStructuredSelection) {
265                 final Category node= (Category)((IStructuredSelection)selection).getFirstElement();
266                 fCategoriesViewer.setExpandedState(node, !fCategoriesViewer.getExpandedState(node));
267             }
268         }
269         }
270
271         class SelectionState {
272             private List<Category> fElements= new ArrayList<Category>();
273             private boolean fRequiresRelayout;
274
275             public void refreshState(IStructuredSelection selection) {
276                 Map<Object, Integer> wrappingStyleMap= new HashMap<Object, Integer>();
277                     Map<Object, Integer> indentStyleMap= new HashMap<Object, Integer>();
278                     Map<Object, Integer> forceWrappingMap= new HashMap<Object, Integer>();
279                     fRequiresRelayout= false;
280                     showSpecificControls(false);
281                 fElements.clear();
282                 evaluateElements(selection.iterator());
283                 evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
284                 setPreviewText(getPreviewText());
285                 refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
286             }
287
288                 public List<Category> getElements() {
289                 return fElements;
290             }
291
292             void evaluateElements(Iterator<Category> iterator) {
293             Category category;
294             String value;
295             while (iterator.hasNext()) {
296                 category= iterator.next();
297                 category.generated_5019980853133752670(SelectionState.this);
298             }
299         }
300
301                 private void evaluateMaps(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap, Map<Object, Integer> forceWrappingMap) {
302                 Iterator<Category> iterator= fElements.iterator();
303             while (iterator.hasNext()) {
304                 insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, iterator.next());
305             }
306             }
307
308         private String getPreviewText() {
309             Iterator<Category> iterator= fElements.iterator();
310             String previewText= ""; //$NON-NLS-1$
311             while (iterator.hasNext()) {
312                 Category category= iterator.next();
313                 previewText= category.generated_659765559651578846(previewText, SelectionState.this); //$NON-NLS-1$
314             }
315             return previewText;
316         }
317
318                 private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap, Category category) {
319             category.generated_6071857012505743656(wrappingMap, indentMap, forceMap, SelectionState.this);
320         }
321
322                 void increaseMapEntry(Map<Object, Integer> map, Object type) {
323             Integer count= map.get(type);
324             if (count == null) // not in map yet -> count == 0
325                 map.put(type, new Integer(1));
326             else
327                 map.put(type, new Integer(count.intValue() + 1));
328         }
329
330         private void refreshControls(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap, Map<Object, Integer> forceWrappingMap) {
331             updateCombos(wrappingStyleMap, indentStyleMap);
332             updateButton(forceWrappingMap);
333             Integer wrappingStyleMax= getWrappingStyleMax(wrappingStyleMap);
334                         boolean isInhomogeneous= (fElements.size() != wrappingStyleMap.get(wrappingStyleMax).intValue());
335                         updateControlEnablement(isInhomogeneous, wrappingStyleMax.intValue());
336                         showSpecificControls(true);
337                         if (fRequiresRelayout) {
338                                 fOptionsComposite.layout(true, true);
339                         }
340                     doUpdatePreview();
341                         notifyValuesModified();
342         }
343
344         private void showSpecificControls(boolean show) {
345                 if (fElements.size() != 1)
346                         return;
347
348                 Preference[] preferences= fElements.get(0).getSpecificPreferences();
349                 if (preferences.length == 0)
350                         return;
351
352                 fRequiresRelayout= true;
353                 for (int i= 0; i < preferences.length; i++) {
354                                 Preference preference= preferences[i];
355                                 Control control= preference.getControl();
356                                 control.setVisible(show);
357                                 ((GridData)control.getLayoutData()).exclude= !show;
358                         }
359                 }
360
361                 private Integer getWrappingStyleMax(Map<Object, Integer> wrappingStyleMap) {
362             int maxCount= 0, maxStyle= 0;
363             for (int i=0; i<WRAPPING_NAMES.length; i++) {
364                 Integer count= wrappingStyleMap.get(new Integer(i));
365                 if (count == null)
366                     continue;
367                 if (count.intValue() > maxCount) {
368                     maxCount= count.intValue();
369                     maxStyle= i;
370                 }
371             }
372             return new Integer(maxStyle);
373         }
374
375         private void updateButton(Map<Object, Integer> forceWrappingMap) {
376             Integer nrOfTrue= forceWrappingMap.get(Boolean.TRUE);
377             Integer nrOfFalse= forceWrappingMap.get(Boolean.FALSE);
378
379             if (nrOfTrue == null || nrOfFalse == null)
380                 fForceSplit.setSelection(nrOfTrue != null);
381             else
382                 fForceSplit.setSelection(nrOfTrue.intValue() > nrOfFalse.intValue());
383
384             int max= getMax(nrOfTrue, nrOfFalse);
385             String label= FormatterMessages.LineWrappingTabPage_force_split_checkbox_text;
386             fForceSplit.setText(getLabelText(label, max, fElements.size()));
387         }
388
389         private String getLabelText(String label, int count, int nElements) {
390             if (nElements == 1 || count == 0)
391                 return label;
392             return Messages.format(FormatterMessages.LineWrappingTabPage_occurences, new String[] {label, Integer.toString(count), Integer.toString(nElements)});
393         }
394
395         private int getMax(Integer nrOfTrue, Integer nrOfFalse) {
396             if (nrOfTrue == null)
397                 return nrOfFalse.intValue();
398             if (nrOfFalse == null)
399                 return nrOfTrue.intValue();
400             if (nrOfTrue.compareTo(nrOfFalse) >= 0)
401                 return nrOfTrue.intValue();
402             return nrOfFalse.intValue();
403         }
404
405         private void updateCombos(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap) {
406             updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES);
407             updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES);
408         }
409
410         private void updateCombo(Combo combo, Map<Object, Integer> map, final String[] items) {
411             String[] newItems= new String[items.length];
412             int maxCount= 0, maxStyle= 0;
413
414             for(int i = 0; i < items.length; i++) {
415                 Integer count= map.get(new Integer(i));
416                 int val= (count == null) ? 0 : count.intValue();
417                 if (val > maxCount) {
418                     maxCount= val;
419                     maxStyle= i;
420                 }
421                 newItems[i]= getLabelText(items[i], val, fElements.size());
422             }
423             combo.setItems(newItems);
424             combo.setText(newItems[maxStyle]);
425         }
426
427                 public void generated_5638102687846375772(LineWrappingTabPage linewrappingtabpage, boolean forceSplit) {
428                         Iterator<Category> iterator= fElements.iterator();
429                     String currentKey;
430                     while (iterator.hasNext()) {
431                         currentKey= iterator.next().key;
432                         try {
433                             linewrappingtabpage.changeForceSplit(currentKey, forceSplit);
434                         } catch (IllegalArgumentException e) {
435                                         linewrappingtabpage.fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT));
436                                         JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
437                                                 Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
438                                 }
439                     }
440                     refreshState(linewrappingtabpage.fSelection);
441                 }
442
443                 public void generated_6265589040558390253(LineWrappingTabPage linewrappingtabpage, int wrappingStyle) {
444                         Iterator<Category> iterator= fElements.iterator();
445                        String currentKey;
446                         while (iterator.hasNext()) {
447                                 currentKey= iterator.next().key;
448                                 try {
449                                     linewrappingtabpage.changeWrappingStyle(currentKey, wrappingStyle);
450                                 } catch (IllegalArgumentException e) {
451                                         linewrappingtabpage.fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle, DefaultCodeFormatterConstants.INDENT_DEFAULT));
452                                         JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
453                                                 Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
454                                 }
455                         }
456                         refreshState(linewrappingtabpage.fSelection);
457                 }
458
459                 public void generated_5207790117885213284(LineWrappingTabPage linewrappingtabpage, int indentStyle) {
460                         Iterator<Category> iterator= fElements.iterator();
461                     String currentKey;
462                     while (iterator.hasNext()) {
463                         currentKey= iterator.next().key;
464                         try {
465                                 linewrappingtabpage.changeIndentStyle(currentKey, indentStyle);
466                         } catch (IllegalArgumentException e) {
467                                         linewrappingtabpage.fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
468                                         JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
469                                                 Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
470                                 }
471                     }
472                     refreshState(linewrappingtabpage.fSelection);
473                 }
474         }
475
476         protected static final String[] INDENT_NAMES = {
477             FormatterMessages.LineWrappingTabPage_indentation_default,
478             FormatterMessages.LineWrappingTabPage_indentation_on_column,
479             FormatterMessages.LineWrappingTabPage_indentation_by_one
480         };
481
482
483         protected static final String[] WRAPPING_NAMES = {
484             FormatterMessages.LineWrappingTabPage_splitting_do_not_split,
485             FormatterMessages.LineWrappingTabPage_splitting_wrap_when_necessary, // COMPACT_SPLIT
486             FormatterMessages.LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary, // COMPACT_FIRST_BREAK_SPLIT
487             FormatterMessages.LineWrappingTabPage_splitting_wrap_always, // ONE_PER_LINE_SPLIT
488             FormatterMessages.LineWrappingTabPage_splitting_wrap_always_indent_all_but_first, // NEXT_SHIFTED_SPLIT
489             FormatterMessages.LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary
490         };
491
492
493         private final Category fCompactIfCategory= new Category(
494             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF,
495             "class Example {" + //$NON-NLS-1$
496             "int foo(int argument) {" + //$NON-NLS-1$
497             "  if (argument==0) return 0;" + //$NON-NLS-1$
498             "  if (argument==1) return 42; else return 43;" + //$NON-NLS-1$
499             "}}", //$NON-NLS-1$
500             FormatterMessages.LineWrappingTabPage_compact_if_else
501         );
502
503         private final Category fTryCategory= new Category(
504                         DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_RESOURCES_IN_TRY,
505                         "class Example {" + //$NON-NLS-1$
506                         "void foo() {" + //$NON-NLS-1$
507                         "try (FileReader reader1 = new FileReader(\"file1\"); " + //$NON-NLS-1$
508                         "  FileReader reader2 = new FileReader(\"file2\")) {" + //$NON-NLS-1$
509                         "}" + //$NON-NLS-1$
510                         "}}", //$NON-NLS-1$
511                         FormatterMessages.LineWrappingTabPage_try
512                         );
513
514         final Category fCatchCategory= new Category(
515                         DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_UNION_TYPE_IN_MULTICATCH,
516                         "class Example {" + //$NON-NLS-1$
517                         "void foo() {" + //$NON-NLS-1$
518                         "try {" + //$NON-NLS-1$
519                         "} catch (IllegalArgumentException | NullPointerException | ClassCastException e) {" + //$NON-NLS-1$
520                         "  e.printStackTrace();" + //$NON-NLS-1$
521                         "}" + //$NON-NLS-1$
522                         "}}", //$NON-NLS-1$
523                         FormatterMessages.LineWrappingTabPage_catch
524                         );
525
526
527         private final Category fTypeDeclarationSuperclassCategory= new Category(
528             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION,
529             "class Example extends OtherClass {}", //$NON-NLS-1$
530             FormatterMessages.LineWrappingTabPage_extends_clause
531         );
532
533
534         private final Category fTypeDeclarationSuperinterfacesCategory= new Category(
535             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION,
536             "class Example implements I1, I2, I3 {}", //$NON-NLS-1$
537             FormatterMessages.LineWrappingTabPage_implements_clause
538         );
539
540
541         private final Category fConstructorDeclarationsParametersCategory= new Category(
542             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
543             "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$
544             "Example() {}}", //$NON-NLS-1$
545             FormatterMessages.LineWrappingTabPage_parameters
546         );
547
548         private final Category fMethodDeclarationsCategory= new Category(
549             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION,
550             "class Example {public final synchronized java.lang.String a_method_with_a_long_name() {}}", //$NON-NLS-1$
551             FormatterMessages.LineWrappingTabPage_declaration
552         );
553
554         private final Category fMethodDeclarationsParametersCategory= new Category(
555             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
556             "class Example {void foo(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {}}", //$NON-NLS-1$
557             FormatterMessages.LineWrappingTabPage_parameters
558         );
559
560         private final Category fMessageSendArgumentsCategory= new Category(
561             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
562                         "class Example {void foo() {Other.bar( 100,\nnested(200,\n300,\n400,\n500,\n600,\n700,\n800,\n900 ));}}", //$NON-NLS-1$
563             FormatterMessages.LineWrappingTabPage_arguments
564         );
565
566         private final Category fMessageSendSelectorCategory= new Category(
567             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION,
568             "class Example {int foo(Some a) {return a.getFirst();}}", //$NON-NLS-1$
569             FormatterMessages.LineWrappingTabPage_qualified_invocations
570         );
571
572         private final Category fMethodThrowsClauseCategory= new Category(
573             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
574             "class Example {" + //$NON-NLS-1$
575             "int foo() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
576             "  return Other.doSomething();}}", //$NON-NLS-1$
577             FormatterMessages.LineWrappingTabPage_throws_clause
578         );
579
580         private final Category fConstructorThrowsClauseCategory= new Category(
581             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION,
582             "class Example {" + //$NON-NLS-1$
583             "Example() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
584             "  return Other.doSomething();}}", //$NON-NLS-1$
585             FormatterMessages.LineWrappingTabPage_throws_clause
586         );
587
588
589         private final Category fAllocationExpressionArgumentsCategory= new Category(
590             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION,
591                         "class Example {SomeClass foo() {return new SomeClass(100,\n200,\n300,\n400,\n500,\n600,\n700,\n800,\n900 );}}", //$NON-NLS-1$
592             FormatterMessages.LineWrappingTabPage_object_allocation
593         );
594
595         private final Category fQualifiedAllocationExpressionCategory= new Category (
596             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION,
597                         "class Example {SomeClass foo() {return SomeOtherClass.new SomeClass(100,\n200,\n300,\n400,\n500 );}}", //$NON-NLS-1$
598                 FormatterMessages.LineWrappingTabPage_qualified_object_allocation
599         );
600
601         private final Category fArrayInitializerExpressionsCategory= new Category(
602             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER,
603                         "class Example {int [] fArray= {1,\n2,\n3,\n4,\n5,\n6,\n7,\n8,\n9,\n10,\n11,\n12};}", //$NON-NLS-1$
604             FormatterMessages.LineWrappingTabPage_array_init
605         );
606
607         private final Category fExplicitConstructorArgumentsCategory= new Category(
608             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL,
609                         "class Example extends AnotherClass {Example() {super(100,\n200,\n300,\n400,\n500,\n600,\n700);}}", //$NON-NLS-1$
610             FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations
611         );
612
613         private final Category fConditionalExpressionCategory= new Category(
614             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION,
615             "class Example extends AnotherClass {int Example(boolean Argument) {return argument ? 100000 : 200000;}}", //$NON-NLS-1$
616             FormatterMessages.LineWrappingTabPage_conditionals
617         );
618
619         private final Category fBinaryExpressionCategory= new Category(
620             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION,
621             "class Example extends AnotherClass {" + //$NON-NLS-1$
622             "int foo() {" + //$NON-NLS-1$
623                         "  int sum= 100\n + 200\n + 300\n + 400\n + 500\n + 600\n + 700\n + 800;" + //$NON-NLS-1$
624                         "  int product= 1\n * 2\n * 3\n * 4\n * 5\n * 6\n * 7\n * 8\n * 9\n * 10;" + //$NON-NLS-1$
625             "  boolean val= true && false && true && false && true;" +  //$NON-NLS-1$
626             "  return product / sum;}}", //$NON-NLS-1$
627             FormatterMessages.LineWrappingTabPage_binary_exprs
628         );
629
630         private final Category fAnnotationArgumentsCategory= new Category(
631             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ANNOTATION,
632                         "@MyAnnotation(value1 = \"this is an example\", value2 = \"of an annotation\", value3 = \"with several arguments\", value4 = \"which may need to be wrapped\")\n" + //$NON-NLS-1$
633                         "class Example {}", //$NON-NLS-1$
634             FormatterMessages.LineWrappingTabPage_annotations_arguments
635         );
636
637         private final Category fEnumConstArgumentsCategory= new Category(
638             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT,
639             "enum Example {" + //$NON-NLS-1$
640             "GREEN(0, 255, 0), RED(255, 0, 0)  }", //$NON-NLS-1$
641             FormatterMessages.LineWrappingTabPage_enum_constant_arguments
642         );
643
644         private final Category fEnumDeclInterfacesCategory= new Category(
645             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION,
646             "enum Example implements A, B, C {" + //$NON-NLS-1$
647             "}", //$NON-NLS-1$
648             FormatterMessages.LineWrappingTabPage_enum_superinterfaces
649         );
650
651         private final Category fEnumConstantsCategory= new Category(
652             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
653             "enum Example {" + //$NON-NLS-1$
654             "CANCELLED, RUNNING, WAITING, FINISHED }" + //$NON-NLS-1$
655             "enum Example {" + //$NON-NLS-1$
656             "GREEN(0, 255, 0), RED(255, 0, 0)  }", //$NON-NLS-1$
657             FormatterMessages.LineWrappingTabPage_enum_constants
658         );
659
660         private final Category fAssignmentCategory= new Category(
661                     DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT,
662                     "class Example {" + //$NON-NLS-1$
663                     "private static final String string = \"TextTextText\";" + //$NON-NLS-1$
664                     "void foo() {" + //$NON-NLS-1$
665                     "for (int i = 0; i < 10; i++) {}" + //$NON-NLS-1$
666                     "String s;" + //$NON-NLS-1$
667                     "s = \"TextTextText\";}}", //$NON-NLS-1$
668                 FormatterMessages.LineWrappingTabPage_assignment_alignment
669                 );
670
671         /**
672          * The default preview line width.
673          */
674         private static int DEFAULT_PREVIEW_WINDOW_LINE_WIDTH= 40;
675
676         /**
677          * The key to save the user's preview window width in the dialog settings.
678          */
679         static final String PREF_PREVIEW_LINE_WIDTH= JavaUI.ID_PLUGIN + ".codeformatter.line_wrapping_tab_page.preview_line_width"; //$NON-NLS-1$
680
681         /**
682          * The dialog settings.
683          */
684         protected final IDialogSettings fDialogSettings;
685
686         protected TreeViewer fCategoriesViewer;
687         protected Label fWrappingStylePolicy;
688         protected Combo fWrappingStyleCombo;
689         protected Label fIndentStylePolicy;
690         protected Combo fIndentStyleCombo;
691         protected Button fForceSplit;
692
693         protected CompilationUnitPreview fPreview;
694
695         protected Group fOptionsGroup;
696
697         /**
698          * A collection containing the categories tree. This is used as model for the tree viewer.
699          * @see TreeViewer
700          */
701         private final List<Category> fCategories;
702
703         /**
704          * The category listener which makes the selection persistent.
705          */
706         protected final CategoryListener fCategoryListener;
707
708         /**
709          * The current selection of elements.
710          */
711         protected IStructuredSelection fSelection;
712
713         /**
714          * An object containing the state for the UI.
715          */
716         SelectionState fSelectionState;
717
718         /**
719          * A special options store wherein the preview line width is kept.
720          */
721         protected final Map<String, String> fPreviewPreferences;
722
723         /**
724          * The key for the preview line width.
725          */
726         final String LINE_SPLIT= DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT;
727
728
729         private Composite fOptionsComposite;
730
731         /**
732          * Create a new line wrapping tab page.
733          * 
734          * @param modifyDialog the modify dialog
735          * @param workingValues the values
736          */
737         public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
738                 super(modifyDialog, workingValues);
739
740                 fDialogSettings= JavaPlugin.getDefault().getDialogSettings();
741
742                 final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH);
743
744                 fPreviewPreferences= new HashMap<String, String>();
745                 fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ? previewLineWidth : Integer.toString(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH));
746
747                 fCategories= createCategories();
748                 fCategoryListener= new CategoryListener(fCategories);
749         }
750
751         /**
752          * @return Create the categories tree.
753          */
754         protected List<Category> createCategories() {
755
756                 final Category annotations = new Category(FormatterMessages.LineWrappingTabPage_annotations);
757                 annotations.children.add(fAnnotationArgumentsCategory);
758
759                 final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls);
760                 classDeclarations.children.add(fTypeDeclarationSuperclassCategory);
761                 classDeclarations.children.add(fTypeDeclarationSuperinterfacesCategory);
762
763                 final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls);
764                 constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory);
765                 constructorDeclarations.children.add(fConstructorThrowsClauseCategory);
766
767                 final Category methodDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_method_decls);
768                 methodDeclarations.children.add(fMethodDeclarationsCategory);
769                 methodDeclarations.children.add(fMethodDeclarationsParametersCategory);
770                 methodDeclarations.children.add(fMethodThrowsClauseCategory);
771
772                 final Category enumDeclarations= new Category(FormatterMessages.LineWrappingTabPage_enum_decls);
773                 enumDeclarations.children.add(fEnumConstantsCategory);
774                 enumDeclarations.children.add(fEnumDeclInterfacesCategory);
775                 enumDeclarations.children.add(fEnumConstArgumentsCategory);
776
777                 final Category functionCalls= new Category(FormatterMessages.LineWrappingTabPage_function_calls);
778                 final List<Category> root= functionCalls.generated_5026085346794046769(annotations, classDeclarations, constructorDeclarations, methodDeclarations, enumDeclarations, this);
779
780                 return root;
781         }
782
783         @Override
784         protected void doCreatePreferences(Composite composite, int numColumns) {
785
786                 fOptionsComposite= composite;
787
788                 final Group lineWidthGroup= createGroup(numColumns, composite, FormatterMessages.LineWrappingTabPage_general_settings);
789
790                 createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999);
791                 createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999);
792                 createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, 0, 9999);
793                 createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, TRUE_FALSE);
794                 createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_wrap_outer_expressions_when_nested, DefaultCodeFormatterConstants.FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED, FALSE_TRUE);
795
796                 fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL );
797                 fCategoriesViewer.setContentProvider(new ITreeContentProvider() {
798                         public Object[] getElements(Object inputElement) {
799                                 return ((Collection<?>)inputElement).toArray();
800                         }
801                         public Object[] getChildren(Object parentElement) {
802                                 return ((Category)parentElement).children.toArray();
803                         }
804                         public Object getParent(Object element) { return null; }
805                         public boolean hasChildren(Object element) {
806                                 return !((Category)element).children.isEmpty();
807                         }
808                         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
809                         public void dispose() {}
810                 });
811                 fCategoriesViewer.setLabelProvider(new LabelProvider());
812                 fCategoriesViewer.setInput(fCategories);
813
814                 fCategoriesViewer.setExpandedElements(fCategories.toArray());
815
816                 final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT);
817                 gd.heightHint= fPixelConverter.convertHeightInCharsToPixels(5);
818                 fCategoriesViewer.getControl().setLayoutData(gd);
819
820                 fOptionsGroup = createGroup(numColumns, composite, "");  //$NON-NLS-1$
821
822                 // label "Select split style:"
823                 fWrappingStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text);
824
825                 // combo SplitStyleCombo
826                 fWrappingStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
827                 SWTUtil.setDefaultVisibleItemCount(fWrappingStyleCombo);
828                 fWrappingStyleCombo.setItems(WRAPPING_NAMES);
829                 fWrappingStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
830
831                 // button "Force split"
832                 fForceSplit= new Button(fOptionsGroup, SWT.CHECK);
833                 String label= FormatterMessages.LineWrappingTabPage_force_split_checkbox_text;
834                 fForceSplit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, numColumns - 1, 1));
835                 fForceSplit.setText(label);
836                 
837                 // button "Wrap before operator"
838                 Preference expressionWrapPositionPreference= createCheckboxPref(fOptionsGroup, 1, FormatterMessages.LineWrappingTabPage_binary_expression_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR, FALSE_TRUE);
839                 Control control= expressionWrapPositionPreference.getControl();
840                 control.setVisible(false);
841                 GridData layoutData= (GridData)control.getLayoutData();
842                 layoutData.exclude= true;
843                 layoutData.horizontalAlignment= SWT.BEGINNING;
844                 layoutData.horizontalSpan= numColumns - 1;
845                 layoutData.grabExcessHorizontalSpace= false;
846                 fBinaryExpressionCategory.addPreference(expressionWrapPositionPreference);
847                 
848                 // button "Wrap before '|' operator" in multi-catch
849                 Preference expressionWrapMulticatchPositionPreference= createCheckboxPref(fOptionsGroup, 1, FormatterMessages.LineWrappingTabPage_multicatch_wrap_operator, DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_OR_OPERATOR_MULTICATCH, FALSE_TRUE);
850                 expressionWrapMulticatchPositionPreference.generated_8795498692018477341(numColumns, this);
851                 
852                 // label "Select indentation style:"
853                 fIndentStylePolicy= createLabel(numColumns, fOptionsGroup, FormatterMessages.LineWrappingTabPage_indentation_policy_label_text);
854
855                 // combo IndentStyleCombo
856                 fIndentStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
857                 SWTUtil.setDefaultVisibleItemCount(fIndentStyleCombo);
858                 fIndentStyleCombo.setItems(INDENT_NAMES);
859                 fIndentStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
860
861                 // selection state object
862                 fSelectionState= new SelectionState();
863
864         }
865
866         @Override
867         protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
868
869                 super.doCreatePreviewPane(composite, numColumns);
870                 
871                 Composite previewLineWidthContainer= new Composite(composite, SWT.NONE);
872                 previewLineWidthContainer.setLayout(createGridLayout(2, false));
873                 
874                 final NumberPreference previewLineWidth= new NumberPreference(previewLineWidthContainer, 2, fPreviewPreferences, LINE_SPLIT,
875                     0, 9999, FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_text);
876                 previewLineWidth.generated_1702283291770472824(this);
877
878                 return composite;
879         }
880
881         /* (non-Javadoc)
882      * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateJavaPreview(org.eclipse.swt.widgets.Composite)
883      */
884     @Override
885         protected JavaPreview doCreateJavaPreview(Composite parent) {
886         fPreview= new CompilationUnitPreview(fWorkingValues, parent);
887         return fPreview;
888     }
889
890
891         @Override
892         protected void initializePage() {
893
894                 fCategoriesViewer.addSelectionChangedListener(fCategoryListener);
895                 fCategoriesViewer.addDoubleClickListener(fCategoryListener);
896
897                 fForceSplit.addSelectionListener(new SelectionAdapter() {
898                         @Override
899                         public void widgetSelected(SelectionEvent e) {
900                                 forceSplitChanged(fForceSplit.getSelection());
901                         }
902                 });
903                 fIndentStyleCombo.addSelectionListener( new SelectionAdapter() {
904                         @Override
905                         public void widgetSelected(SelectionEvent e) {
906                                 indentStyleChanged(((Combo)e.widget).getSelectionIndex());
907                         }
908                 });
909                 fWrappingStyleCombo.addSelectionListener( new SelectionAdapter() {
910                         @Override
911                         public void widgetSelected(SelectionEvent e) {
912                                 wrappingStyleChanged(((Combo)e.widget).getSelectionIndex());
913                         }
914                 });
915
916                 fCategoryListener.restoreSelection();
917
918                 fDefaultFocusManager.generated_4449091096061266128(this);
919         }
920
921         @Override
922         protected void doUpdatePreview() {
923                 super.doUpdatePreview();
924                 final String normalSetting= fWorkingValues.get(LINE_SPLIT);
925                 fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
926                 fPreview.update();
927                 fWorkingValues.put(LINE_SPLIT, normalSetting);
928         }
929
930         protected void setPreviewText(String text) {
931                 final String normalSetting= fWorkingValues.get(LINE_SPLIT);
932                 fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
933                 fPreview.setPreviewText(text);
934                 fWorkingValues.put(LINE_SPLIT, normalSetting);
935         }
936
937         protected void forceSplitChanged(boolean forceSplit) {
938             fSelectionState.generated_5638102687846375772(this, forceSplit);
939         }
940
941         private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException{
942                 String value= fWorkingValues.get(currentKey);
943                 value= DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit);
944                 if (value == null)
945                     throw new IllegalArgumentException();
946                 fWorkingValues.put(currentKey, value);
947         }
948
949         protected void wrappingStyleChanged(int wrappingStyle) {
950                fSelectionState.generated_6265589040558390253(this, wrappingStyle);
951         }
952
953         private void changeWrappingStyle(String currentKey, int wrappingStyle) throws IllegalArgumentException {
954             String value= fWorkingValues.get(currentKey);
955                 value= DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle);
956                 if (value == null)
957                     throw new IllegalArgumentException();
958                 fWorkingValues.put(currentKey, value);
959         }
960
961         protected void indentStyleChanged(int indentStyle) {
962             fSelectionState.generated_5207790117885213284(this, indentStyle);
963         }
964
965         private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException{
966                 String value= fWorkingValues.get(currentKey);
967                 value= DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle);
968                 if (value == null)
969                     throw new IllegalArgumentException();
970                 fWorkingValues.put(currentKey, value);
971         }
972
973     protected void updateControlEnablement(boolean inhomogenous, int wrappingStyle) {
974             boolean doSplit= wrappingStyle != DefaultCodeFormatterConstants.WRAP_NO_SPLIT;
975             fIndentStylePolicy.setEnabled(true);
976
977                 boolean isEnabled= inhomogenous || doSplit;
978                 fIndentStyleCombo.setEnabled(isEnabled);
979                 fForceSplit.setEnabled(isEnabled);
980                 fBinaryExpressionCategory.setEnabled(isEnabled);
981                 fCatchCategory.setEnabled(isEnabled);
982         }
983 }