1
1
package net .sourceforge .squirrel_sql .fw .datasetviewer .coloring ;
2
2
3
- import java .awt .Color ;
4
-
5
3
import net .sourceforge .squirrel_sql .client .Main ;
6
4
import net .sourceforge .squirrel_sql .client .session .ISession ;
7
5
import net .sourceforge .squirrel_sql .client .session .properties .SessionProperties ;
8
6
import net .sourceforge .squirrel_sql .fw .datasetviewer .DataSetViewerTable ;
9
7
8
+ import java .awt .Color ;
9
+
10
10
public class NullValueColorHandler
11
11
{
12
12
private boolean _colorNullValues ;
@@ -18,20 +18,28 @@ public NullValueColorHandler(DataSetViewerTable dataSetViewerTable)
18
18
{
19
19
_dataSetViewerTable = dataSetViewerTable ;
20
20
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 ;
21
33
final ISession session = _dataSetViewerTable .getSessionOrNull ();
22
34
if (null == session )
23
35
{
24
- final SessionProperties newSessionProperties = Main .getApplication ().getSquirrelPreferences ().getSessionProperties ();
25
- _nullValueColor = new Color (newSessionProperties .getNullValueColorRGB ());
26
- _colorNullValues = newSessionProperties .isColorNullValues ();
36
+ sessionProperties = Main .getApplication ().getSquirrelPreferences ().getSessionProperties ();
27
37
}
28
38
else
29
39
{
30
- _nullValueColor = new Color (session .getProperties ().getNullValueColorRGB ());
31
- _colorNullValues = session .getProperties ().isColorNullValues ();
40
+ sessionProperties = session .getProperties ();
32
41
}
33
-
34
- _lastPropertiesCheckTime = System .currentTimeMillis ();
42
+ return sessionProperties ;
35
43
}
36
44
37
45
public Color getNullValueColor ()
@@ -56,16 +64,13 @@ private void checkForPropertiesUpdates()
56
64
57
65
_lastPropertiesCheckTime = currentTimeMillis ;
58
66
59
- if ( null != _dataSetViewerTable .getSessionOrNull () )
60
- {
61
- return ;
62
- }
67
+ SessionProperties sessionProperties = getSessionProperties ();
63
68
64
- if ( _nullValueColor .getRGB () != _dataSetViewerTable . getSessionOrNull (). getProperties () .getNullValueColorRGB ()
65
- || _colorNullValues != _dataSetViewerTable . getSessionOrNull (). getProperties () .isColorNullValues ())
69
+ if ( _nullValueColor .getRGB () != sessionProperties .getNullValueColorRGB ()
70
+ || _colorNullValues != sessionProperties .isColorNullValues ())
66
71
{
67
- _nullValueColor = new Color (_dataSetViewerTable . getSessionOrNull (). getProperties () .getNullValueColorRGB ());
68
- _colorNullValues = _dataSetViewerTable . getSessionOrNull (). getProperties () .isColorNullValues ();
72
+ _nullValueColor = new Color (sessionProperties .getNullValueColorRGB ());
73
+ _colorNullValues = sessionProperties .isColorNullValues ();
69
74
_dataSetViewerTable .repaint ();
70
75
}
71
76
0 commit comments