Revision 866 org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/DefaultCoordinateReferenceSystemSwingManager.java
DefaultCoordinateReferenceSystemSwingManager.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.proj.swing.impl; |
25 | 25 |
|
26 |
import java.awt.EventQueue; |
|
27 |
import java.net.URL; |
|
26 |
import java.util.LinkedHashSet; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Set; |
|
29 |
import java.util.concurrent.CopyOnWriteArrayList; |
|
28 | 30 |
|
29 | 31 |
import org.gvsig.proj.CoordinateReferenceSystem; |
30 | 32 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
... | ... | |
32 | 34 |
import org.gvsig.proj.CoordinateTransformation; |
33 | 35 |
import org.gvsig.proj.catalog.CRSCatalogLocator; |
34 | 36 |
import org.gvsig.proj.catalog.CRSCatalogManager; |
37 |
import org.gvsig.proj.catalog.CRSDefinition; |
|
38 |
import org.gvsig.proj.catalog.TransformationDefinition; |
|
35 | 39 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSelectorComponent; |
36 | 40 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingManager; |
37 | 41 |
import org.gvsig.proj.swing.CoordinateTransformationSelectorComponent; |
38 | 42 |
import org.gvsig.proj.swing.RecentHistory; |
39 | 43 |
import org.gvsig.proj.swing.impl.history.History; |
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.i18n.I18nManager; |
|
42 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
43 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
44 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
44 |
import org.gvsig.tools.dynobject.DynObject; |
|
45 | 45 |
import org.slf4j.Logger; |
46 | 46 |
import org.slf4j.LoggerFactory; |
47 | 47 |
|
... | ... | |
54 | 54 |
public class DefaultCoordinateReferenceSystemSwingManager implements |
55 | 55 |
CoordinateReferenceSystemSwingManager { |
56 | 56 |
private static Logger logger = LoggerFactory.getLogger(DefaultCoordinateReferenceSystemSwingManager.class); |
57 |
private I18nManager i18nmanager = null; |
|
58 |
private RecentHistory<CoordinateReferenceSystem> crsHistory; |
|
59 |
private RecentHistory<CoordinateTransformation> transformationHistory; |
|
57 |
private RecentHistory<CRSDefinition> crsHistory; |
|
58 |
private RecentHistory<TransformationDefinition> transformationHistory; |
|
60 | 59 |
private RecentHistory<String> crsTextFilterHistory; |
61 | 60 |
private RecentHistory<String> transformationTextFilterHistory; |
62 |
private volatile IconTheme iconTheme = null; |
|
63 |
private volatile boolean registeredIcons = false; |
|
61 |
private LinkedHashSet<CRSDefinition> crsFavorites; |
|
62 |
private LinkedHashSet<TransformationDefinition> transformationFavorites; |
|
63 |
private DynObject preferences = null; |
|
64 |
|
|
65 |
private static final String CRS_HISTORY_FIELD = "crsHistory"; |
|
66 |
private static final String CRS_HISTORY_SIZE_FIELD = "crsHistorySize"; |
|
67 |
private static final String TRANSFORMATION_HISTORY_FIELD = "transformationHistory"; |
|
68 |
private static final String TRANSFORMATION_HISTORY_SIZE_FIELD = "transformationHistorySize"; |
|
69 |
private static final String CRS_TEXT_FILTER_HISTORY_FIELD = "crsTextFilterHistory"; |
|
70 |
private static final String CRS_TEXT_FILTER_HISTORY_SIZE_FIELD = "crsTextFilterHistorySize"; |
|
71 |
private static final String TRANSFORMATION_TEXT_FILTER_HISTORY_FIELD = "transformationTextFilterHistory"; |
|
72 |
private static final String TRANSFORMATION_TEXT_FILTER_HISTORY_SIZE_FIELD = "transformationTextFilterHistorySize"; |
|
73 |
private static final String CRS_FAVORITES_FIELD = "crsFavorites"; |
|
74 |
private static final String TRANSFORMATION_FAVORITES_FIELD = "transformationFavorites"; |
|
64 | 75 |
|
65 | 76 |
public DefaultCoordinateReferenceSystemSwingManager() { |
66 |
//this.iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
67 |
//this.manager = CoordinateReferenceSystemLocator.getManager(); |
|
68 |
//this.i18nmanager = ToolsLocator.getI18nManager(); |
|
69 |
crsHistory = new History<CoordinateReferenceSystem>(); |
|
70 |
transformationHistory = new History<CoordinateTransformation>(); |
|
77 |
crsHistory = new History<CRSDefinition>(); |
|
78 |
transformationHistory = new History<TransformationDefinition>(); |
|
71 | 79 |
crsTextFilterHistory = new History<String>(); |
72 | 80 |
transformationTextFilterHistory = new History<String>(); |
81 |
crsFavorites = new LinkedHashSet<CRSDefinition>(); |
|
82 |
transformationFavorites = new LinkedHashSet<TransformationDefinition>(); |
|
73 | 83 |
} |
74 | 84 |
|
75 | 85 |
@Override |
76 | 86 |
public CoordinateReferenceSystemManager getCRSManager() { |
77 | 87 |
return CoordinateReferenceSystemLocator.getManager(); |
78 |
//return this.manager; |
|
79 | 88 |
} |
80 | 89 |
|
81 | 90 |
public CoordinateReferenceSystemSelectorComponent createCoordinateReferenceSystemSelectionComponent() { |
... | ... | |
92 | 101 |
* Ensures the icons have been registered. We can't do it at manager initialization because the |
93 | 102 |
* IconThemeManager may not be initialized at that point |
94 | 103 |
*/ |
95 |
return null;
|
|
104 |
return new CtSelectorController(this);
|
|
96 | 105 |
} |
97 | 106 |
|
98 | 107 |
@Override |
... | ... | |
101 | 110 |
} |
102 | 111 |
|
103 | 112 |
@Override |
104 |
public RecentHistory<CoordinateReferenceSystem> getCoordinateReferenceSystemHistory() {
|
|
113 |
public RecentHistory<CRSDefinition> getCoordinateReferenceSystemHistory() {
|
|
105 | 114 |
return crsHistory; |
106 | 115 |
} |
107 | 116 |
|
108 | 117 |
@Override |
109 |
public RecentHistory<CoordinateTransformation> getTransformationHistory() {
|
|
118 |
public RecentHistory<TransformationDefinition> getTransformationHistory() {
|
|
110 | 119 |
return transformationHistory; |
111 | 120 |
} |
112 | 121 |
|
... | ... | |
119 | 128 |
public RecentHistory<String> getTransformationTextFilterHistory() { |
120 | 129 |
return transformationTextFilterHistory; |
121 | 130 |
} |
131 |
|
|
132 |
@Override |
|
133 |
public Set<CRSDefinition> getCoordinateReferenceSystemFavorites() { |
|
134 |
return crsFavorites; |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public Set<TransformationDefinition> getTransformationFavorites() { |
|
139 |
return transformationFavorites; |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
public DynObject getPreferences() { |
|
144 |
if (preferences != null) { |
|
145 |
preferences.setDynValue(CRS_HISTORY_FIELD, crsHistory.toList()); |
|
146 |
preferences.setDynValue(CRS_HISTORY_SIZE_FIELD, (Integer) crsHistory.getMaxSize()); |
|
147 |
preferences.setDynValue(TRANSFORMATION_HISTORY_FIELD, transformationHistory.toList()); |
|
148 |
preferences.setDynValue(TRANSFORMATION_HISTORY_SIZE_FIELD, (Integer) transformationHistory.getMaxSize()); |
|
149 |
preferences.setDynValue(CRS_TEXT_FILTER_HISTORY_FIELD, crsTextFilterHistory.toList()); |
|
150 |
preferences.setDynValue(CRS_TEXT_FILTER_HISTORY_SIZE_FIELD, (Integer) crsTextFilterHistory.getMaxSize()); |
|
151 |
preferences.setDynValue(TRANSFORMATION_TEXT_FILTER_HISTORY_FIELD, transformationTextFilterHistory.toList()); |
|
152 |
preferences.setDynValue(TRANSFORMATION_TEXT_FILTER_HISTORY_SIZE_FIELD, (Integer) transformationTextFilterHistory.getMaxSize()); |
|
153 |
preferences.setDynValue(CRS_FAVORITES_FIELD, crsFavorites); |
|
154 |
preferences.setDynValue(TRANSFORMATION_FAVORITES_FIELD, transformationFavorites); |
|
155 |
} |
|
156 |
return preferences; |
|
157 |
} |
|
158 |
|
|
159 |
@Override |
|
160 |
public void setPreferences(DynObject preferences) { |
|
161 |
this.preferences = preferences; |
|
162 |
Integer size; |
|
163 |
if (preferences.hasDynValue(CRS_HISTORY_FIELD)) { |
|
164 |
List history = (List) preferences.getDynValue(CRS_HISTORY_FIELD); |
|
165 |
if (preferences.hasDynValue(CRS_HISTORY_SIZE_FIELD)) { |
|
166 |
size = (Integer) preferences.getDynValue(CRS_HISTORY_SIZE_FIELD); |
|
167 |
} |
|
168 |
else { |
|
169 |
size = History.DEFAULT_MAX_SIZE; |
|
170 |
} |
|
171 |
crsHistory = new History<CRSDefinition>(history, size); |
|
172 |
} |
|
173 |
|
|
174 |
if (preferences.hasDynValue(TRANSFORMATION_HISTORY_FIELD)) { |
|
175 |
List history = (List) preferences.getDynValue(TRANSFORMATION_HISTORY_FIELD); |
|
176 |
if (preferences.hasDynValue(TRANSFORMATION_HISTORY_SIZE_FIELD)) { |
|
177 |
size = (Integer) preferences.getDynValue(TRANSFORMATION_HISTORY_SIZE_FIELD); |
|
178 |
} |
|
179 |
else { |
|
180 |
size = History.DEFAULT_MAX_SIZE; |
|
181 |
} |
|
182 |
transformationHistory = new History<TransformationDefinition>(history, size); |
|
183 |
} |
|
184 |
|
|
185 |
|
|
186 |
if (preferences.hasDynValue(CRS_TEXT_FILTER_HISTORY_FIELD)) { |
|
187 |
List history = (List) preferences.getDynValue(CRS_TEXT_FILTER_HISTORY_FIELD); |
|
188 |
if (preferences.hasDynValue(CRS_TEXT_FILTER_HISTORY_SIZE_FIELD)) { |
|
189 |
size = (Integer) preferences.getDynValue(CRS_TEXT_FILTER_HISTORY_SIZE_FIELD); |
|
190 |
} |
|
191 |
else { |
|
192 |
size = History.DEFAULT_MAX_SIZE; |
|
193 |
} |
|
194 |
crsTextFilterHistory = new History<String>(history, size); |
|
195 |
} |
|
196 |
|
|
197 |
if (preferences.hasDynValue(TRANSFORMATION_TEXT_FILTER_HISTORY_FIELD)) { |
|
198 |
List history = (List) preferences.getDynValue(TRANSFORMATION_TEXT_FILTER_HISTORY_FIELD); |
|
199 |
if (preferences.hasDynValue(TRANSFORMATION_TEXT_FILTER_HISTORY_SIZE_FIELD)) { |
|
200 |
size = (Integer) preferences.getDynValue(TRANSFORMATION_TEXT_FILTER_HISTORY_SIZE_FIELD); |
|
201 |
} |
|
202 |
else { |
|
203 |
size = History.DEFAULT_MAX_SIZE; |
|
204 |
} |
|
205 |
transformationTextFilterHistory = new History<String>(history, size); |
|
206 |
} |
|
207 |
|
|
208 |
if (preferences.hasDynValue(CRS_FAVORITES_FIELD)) { |
|
209 |
List favorites = (List) preferences.getDynValue(CRS_FAVORITES_FIELD); |
|
210 |
crsFavorites = new LinkedHashSet<CRSDefinition>(favorites); |
|
211 |
} |
|
212 |
|
|
213 |
if (preferences.hasDynValue(TRANSFORMATION_FAVORITES_FIELD)) { |
|
214 |
List favorites = (List) preferences.getDynValue(TRANSFORMATION_FAVORITES_FIELD); |
|
215 |
transformationFavorites = new LinkedHashSet<TransformationDefinition>(favorites); |
|
216 |
} |
|
217 |
} |
|
122 | 218 |
} |
Also available in: Unified diff