@@ -532,94 +532,127 @@ public void focusGained(FocusEvent e) {
532532 _displayRightMargin = DrJava .getConfig ().getSetting (DISPLAY_RIGHT_MARGIN );
533533 _numRightMarginColumns = DrJava .getConfig ().getSetting (RIGHT_MARGIN_COLUMNS );
534534 _rightMarginColor = DrJava .getConfig ().getSetting (RIGHT_MARGIN_COLOR );
535-
536- OptionListener <Color > cListener ;
537- Pair <Option <Color >, OptionListener <Color >> cPair ;
538535
539536 // Setup the color listeners. NOTE: the Foreground/Background listeners add themselves to DrJava.getConfig()
540- // in their own constructors. Rather than refactor it, we decided to work with that design decision.
541- cListener = new ForegroundColorListener (this );
542- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEFINITIONS_NORMAL_COLOR , cListener );
543- _colorOptionListeners .add (cPair );
537+ // in their own constructors. Rather than refactor it, we decided to work with that design decision.
538+ // A separate block is used for each listener to avoid polluting the variable name space.
539+ {
540+ final OptionListener <Color > fcListener = new ForegroundColorListener (this );
541+ final Pair <Option <Color >, OptionListener <Color >> fcPair =
542+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEFINITIONS_NORMAL_COLOR , fcListener );
543+ _colorOptionListeners .add (fcPair );
544+ }
545+
546+ {
547+ final OptionListener <Color > bcListener = new BackgroundColorListener (this );
548+ final Pair <Option <Color >, OptionListener <Color >> bcPair =
549+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEFINITIONS_BACKGROUND_COLOR , bcListener );
550+ _colorOptionListeners .add (bcPair );
551+ }
544552
545- cListener = new BackgroundColorListener (this );
546- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEFINITIONS_BACKGROUND_COLOR , cListener );
547- _colorOptionListeners .add (cPair );
548-
549553 // These listeners do not register themselves in their own constructors. We do.
550- cListener = new MatchColorOptionListener ();
551- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEFINITIONS_MATCH_COLOR , cListener );
552- _colorOptionListeners .add (cPair );
553- DrJava .getConfig ().addOptionListener (OptionConstants .DEFINITIONS_MATCH_COLOR , cListener );
554+ {
555+ final OptionListener <Color > mcListener = new MatchColorOptionListener ();
556+ final Pair <Option <Color >, OptionListener <Color >> mcPair =
557+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEFINITIONS_MATCH_COLOR , mcListener );
558+ _colorOptionListeners .add (mcPair );
559+ DrJava .getConfig ().addOptionListener (OptionConstants .DEFINITIONS_MATCH_COLOR , mcListener );
560+ }
554561
555- cListener = new ErrorColorOptionListener ();
556- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .COMPILER_ERROR_COLOR , cListener );
557- _colorOptionListeners .add (cPair );
558- DrJava .getConfig ().addOptionListener (OptionConstants .COMPILER_ERROR_COLOR , cListener );
562+ {
563+ final OptionListener <Color > ecListener = new ErrorColorOptionListener ();
564+ final Pair <Option <Color >, OptionListener <Color >> ecPair =
565+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .COMPILER_ERROR_COLOR , ecListener );
566+ _colorOptionListeners .add (ecPair );
567+ DrJava .getConfig ().addOptionListener (OptionConstants .COMPILER_ERROR_COLOR , ecListener );
568+ }
559569
560- cListener = new BookmarkColorOptionListener ();
561- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .BOOKMARK_COLOR , cListener );
562- _colorOptionListeners .add (cPair );
563- DrJava .getConfig ().addOptionListener (OptionConstants .BOOKMARK_COLOR , cListener );
570+ {
571+ final OptionListener <Color > bcListener = new BookmarkColorOptionListener ();
572+ final Pair <Option <Color >, OptionListener <Color >> bcPair =
573+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .BOOKMARK_COLOR , bcListener );
574+ _colorOptionListeners .add (bcPair );
575+ DrJava .getConfig ().addOptionListener (OptionConstants .BOOKMARK_COLOR , bcListener );
576+ }
564577
565578 for (int i = 0 ; i < FIND_RESULTS_COLORS .length ; ++i ) {
566- cListener = new FindResultsColorOptionListener (i );
567- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .FIND_RESULTS_COLORS [i ], cListener );
579+ final OptionListener <Color > cListener = new FindResultsColorOptionListener (i );
580+ final Pair <Option <Color >, OptionListener <Color >> cPair =
581+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .FIND_RESULTS_COLORS [i ], cListener );
568582 _colorOptionListeners .add (cPair );
569583 DrJava .getConfig ().addOptionListener (OptionConstants .FIND_RESULTS_COLORS [i ], cListener );
570584 }
571585
572- cListener = new BreakpointColorOptionListener ();
573- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEBUG_BREAKPOINT_COLOR , cListener );
574- _colorOptionListeners .add (cPair );
575- DrJava .getConfig ().addOptionListener (OptionConstants .DEBUG_BREAKPOINT_COLOR , cListener );
586+ {
587+ final OptionListener <Color > bcListener = new BreakpointColorOptionListener ();
588+ final Pair <Option <Color >, OptionListener <Color >> bcPair =
589+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEBUG_BREAKPOINT_COLOR , bcListener );
590+ _colorOptionListeners .add (bcPair );
591+ DrJava .getConfig ().addOptionListener (OptionConstants .DEBUG_BREAKPOINT_COLOR , bcListener );
592+ }
576593
577- cListener = new DisabledBreakpointColorOptionListener ();
578- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEBUG_BREAKPOINT_DISABLED_COLOR , cListener );
579- _colorOptionListeners .add (cPair );
580- DrJava .getConfig ().addOptionListener ( OptionConstants .DEBUG_BREAKPOINT_DISABLED_COLOR , cListener );
594+ {
595+ final OptionListener <Color > dbcListener = new DisabledBreakpointColorOptionListener ();
596+ final Pair <Option <Color >, OptionListener <Color >> dbcPair =
597+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEBUG_BREAKPOINT_DISABLED_COLOR , dbcListener );
598+ _colorOptionListeners .add (dbcPair );
599+ DrJava .getConfig ().addOptionListener ( OptionConstants .DEBUG_BREAKPOINT_DISABLED_COLOR , dbcListener );
600+ }
581601
582- cListener = new ThreadColorOptionListener ();
583- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEBUG_THREAD_COLOR , cListener );
584- _colorOptionListeners .add (cPair );
585- DrJava .getConfig ().addOptionListener ( OptionConstants .DEBUG_THREAD_COLOR , cListener );
586-
587- OptionListener <Boolean > bListener = new AntiAliasOptionListener ();
588- Pair <Option <Boolean >, OptionListener <Boolean >> bPair =
589- new Pair <Option <Boolean >, OptionListener <Boolean >>(OptionConstants .TEXT_ANTIALIAS , bListener );
590- _booleanOptionListeners .add (bPair );
591- DrJava .getConfig ().addOptionListener (OptionConstants .TEXT_ANTIALIAS , bListener );
592-
593- bListener = new OptionListener <Boolean >() {
594- public void optionChanged (OptionEvent <Boolean > oce ) {
595- _displayRightMargin = oce .value ;
596- DefinitionsPane .this .repaint ();
597- }
598- };
599- bPair = new Pair <Option <Boolean >, OptionListener <Boolean >>(OptionConstants .DISPLAY_RIGHT_MARGIN , bListener );
600- _booleanOptionListeners .add (bPair );
601- DrJava .getConfig ().addOptionListener (OptionConstants .DISPLAY_RIGHT_MARGIN , bListener );
602-
603- OptionListener <Integer > iTemp = new OptionListener <Integer >() {
604- public void optionChanged (OptionEvent <Integer > oce ) {
605- _numRightMarginColumns = oce .value ;
606- DefinitionsPane .this .repaint ();
607- }
608- };
609- Pair <Option <Integer >, OptionListener <Integer >> iPair =
610- new Pair <Option <Integer >, OptionListener <Integer >>(OptionConstants .RIGHT_MARGIN_COLUMNS , iTemp );
611- _integerOptionListeners .add (iPair );
612- DrJava .getConfig ().addOptionListener (OptionConstants .RIGHT_MARGIN_COLUMNS , iTemp );
602+ {
603+ final OptionListener <Color > tcListener = new ThreadColorOptionListener ();
604+ final Pair <Option <Color >, OptionListener <Color >> tcPair =
605+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .DEBUG_THREAD_COLOR , tcListener );
606+ _colorOptionListeners .add (tcPair );
607+ DrJava .getConfig ().addOptionListener ( OptionConstants .DEBUG_THREAD_COLOR , tcListener );
608+ }
609+
610+ {
611+ final OptionListener <Boolean > aaListener = new AntiAliasOptionListener ();
612+ final Pair <Option <Boolean >, OptionListener <Boolean >> aaPair =
613+ new Pair <Option <Boolean >, OptionListener <Boolean >>(OptionConstants .TEXT_ANTIALIAS , aaListener );
614+ _booleanOptionListeners .add (aaPair );
615+ DrJava .getConfig ().addOptionListener (OptionConstants .TEXT_ANTIALIAS , aaListener );
616+ }
613617
614- cListener = new OptionListener <Color >() {
615- public void optionChanged (OptionEvent <Color > oce ) {
616- _rightMarginColor = oce .value ;
617- DefinitionsPane .this .repaint ();
618- }
619- };
620- cPair = new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .RIGHT_MARGIN_COLOR , cListener );
621- _colorOptionListeners .add (cPair );
622- DrJava .getConfig ().addOptionListener (OptionConstants .RIGHT_MARGIN_COLOR , cListener );
618+ {
619+ final OptionListener <Boolean > rmListener = new OptionListener <Boolean >() {
620+ public void optionChanged (OptionEvent <Boolean > oce ) {
621+ _displayRightMargin = oce .value ;
622+ DefinitionsPane .this .repaint ();
623+ }
624+ };
625+ final Pair <Option <Boolean >, OptionListener <Boolean >> rmPair =
626+ new Pair <Option <Boolean >, OptionListener <Boolean >>(OptionConstants .DISPLAY_RIGHT_MARGIN , rmListener );
627+ _booleanOptionListeners .add (rmPair );
628+ DrJava .getConfig ().addOptionListener (OptionConstants .DISPLAY_RIGHT_MARGIN , rmListener );
629+ }
630+
631+ {
632+ final OptionListener <Integer > iListener = new OptionListener <Integer >() {
633+ public void optionChanged (OptionEvent <Integer > oce ) {
634+ _numRightMarginColumns = oce .value ;
635+ DefinitionsPane .this .repaint ();
636+ }
637+ };
638+ final Pair <Option <Integer >, OptionListener <Integer >> iPair =
639+ new Pair <Option <Integer >, OptionListener <Integer >>(OptionConstants .RIGHT_MARGIN_COLUMNS , iListener );
640+ _integerOptionListeners .add (iPair );
641+ DrJava .getConfig ().addOptionListener (OptionConstants .RIGHT_MARGIN_COLUMNS , iListener );
642+ }
643+
644+ {
645+ final OptionListener <Color > rmcListener = new OptionListener <Color >() {
646+ public void optionChanged (OptionEvent <Color > oce ) {
647+ _rightMarginColor = oce .value ;
648+ DefinitionsPane .this .repaint ();
649+ }
650+ };
651+ final Pair <Option <Color >, OptionListener <Color >> rmcPair =
652+ new Pair <Option <Color >, OptionListener <Color >>(OptionConstants .RIGHT_MARGIN_COLOR , rmcListener );
653+ _colorOptionListeners .add (rmcPair );
654+ DrJava .getConfig ().addOptionListener (OptionConstants .RIGHT_MARGIN_COLOR , rmcListener );
655+ }
623656
624657 createPopupMenu ();
625658
0 commit comments