11package net .sourceforge .squirrel_sql .fw .datasetviewer .coloring ;
22
3- import java .awt .Color ;
4-
53import net .sourceforge .squirrel_sql .client .Main ;
64import net .sourceforge .squirrel_sql .client .session .ISession ;
75import net .sourceforge .squirrel_sql .client .session .properties .SessionProperties ;
86import net .sourceforge .squirrel_sql .fw .datasetviewer .DataSetViewerTable ;
97
8+ import java .awt .Color ;
9+
1010public class NullValueColorHandler
1111{
1212 private boolean _colorNullValues ;
@@ -18,20 +18,28 @@ public NullValueColorHandler(DataSetViewerTable dataSetViewerTable)
1818 {
1919 _dataSetViewerTable = dataSetViewerTable ;
2020
21+ final SessionProperties sessionProperties ;
22+
23+ sessionProperties = getSessionProperties ();
24+ _nullValueColor = new Color (sessionProperties .getNullValueColorRGB ());
25+ _colorNullValues = sessionProperties .isColorNullValues ();
26+
27+ _lastPropertiesCheckTime = System .currentTimeMillis ();
28+ }
29+
30+ private SessionProperties getSessionProperties ()
31+ {
32+ final SessionProperties sessionProperties ;
2133 final ISession session = _dataSetViewerTable .getSessionOrNull ();
2234 if (null == session )
2335 {
24- final SessionProperties newSessionProperties = Main .getApplication ().getSquirrelPreferences ().getSessionProperties ();
25- _nullValueColor = new Color (newSessionProperties .getNullValueColorRGB ());
26- _colorNullValues = newSessionProperties .isColorNullValues ();
36+ sessionProperties = Main .getApplication ().getSquirrelPreferences ().getSessionProperties ();
2737 }
2838 else
2939 {
30- _nullValueColor = new Color (session .getProperties ().getNullValueColorRGB ());
31- _colorNullValues = session .getProperties ().isColorNullValues ();
40+ sessionProperties = session .getProperties ();
3241 }
33-
34- _lastPropertiesCheckTime = System .currentTimeMillis ();
42+ return sessionProperties ;
3543 }
3644
3745 public Color getNullValueColor ()
@@ -56,16 +64,13 @@ private void checkForPropertiesUpdates()
5664
5765 _lastPropertiesCheckTime = currentTimeMillis ;
5866
59- if ( null != _dataSetViewerTable .getSessionOrNull () )
60- {
61- return ;
62- }
67+ SessionProperties sessionProperties = getSessionProperties ();
6368
64- if ( _nullValueColor .getRGB () != _dataSetViewerTable . getSessionOrNull (). getProperties () .getNullValueColorRGB ()
65- || _colorNullValues != _dataSetViewerTable . getSessionOrNull (). getProperties () .isColorNullValues ())
69+ if ( _nullValueColor .getRGB () != sessionProperties .getNullValueColorRGB ()
70+ || _colorNullValues != sessionProperties .isColorNullValues ())
6671 {
67- _nullValueColor = new Color (_dataSetViewerTable . getSessionOrNull (). getProperties () .getNullValueColorRGB ());
68- _colorNullValues = _dataSetViewerTable . getSessionOrNull (). getProperties () .isColorNullValues ();
72+ _nullValueColor = new Color (sessionProperties .getNullValueColorRGB ());
73+ _colorNullValues = sessionProperties .isColorNullValues ();
6974 _dataSetViewerTable .repaint ();
7075 }
7176
0 commit comments