Revision 854 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/CrsSelectorComponent.java
CrsSelectorComponent.java | ||
---|---|---|
19 | 19 |
import javax.swing.tree.TreePath; |
20 | 20 |
import javax.swing.tree.TreeSelectionModel; |
21 | 21 |
|
22 |
import org.apache.commons.io.FilenameUtils; |
|
22 | 23 |
import org.gvsig.proj.CoordinateReferenceSystem; |
23 | 24 |
import org.gvsig.proj.catalog.CRSDefinition; |
24 | 25 |
import org.gvsig.proj.catalog.CRSType; |
25 | 26 |
import org.gvsig.proj.catalog.exception.UnsupportedCoordinateReferenceSystemException; |
27 |
import org.gvsig.proj.catalog.extent.GeographicBoundingBox; |
|
26 | 28 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSelectorComponent; |
27 | 29 |
import org.gvsig.proj.swing.impl.tree.AsyncLoadedGroup; |
28 | 30 |
import org.gvsig.proj.swing.impl.tree.BranchNode; |
... | ... | |
33 | 35 |
import org.gvsig.proj.swing.impl.tree.LeafNode; |
34 | 36 |
import org.gvsig.proj.swing.impl.tree.LoadingNode; |
35 | 37 |
import org.gvsig.proj.swing.impl.tree.TreeContainer; |
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.i18n.I18nManager; |
|
36 | 40 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
37 | 41 |
import org.gvsig.tools.swing.api.Component; |
38 | 42 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
43 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
44 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
39 | 45 |
import org.slf4j.Logger; |
40 | 46 |
import org.slf4j.LoggerFactory; |
41 | 47 |
|
... | ... | |
56 | 62 |
protected DefaultTreeModel model; |
57 | 63 |
protected BranchNode root; |
58 | 64 |
protected RecentCRSs recent; |
65 |
protected IconTheme iconTheme = null; |
|
66 |
protected I18nManager i18nManager = null; |
|
67 |
final protected DefaultCoordinateReferenceSystemSwingManager manager; |
|
68 |
|
|
59 | 69 |
|
60 | 70 |
public CrsSelectorComponent(DefaultCoordinateReferenceSystemSwingManager manager) { |
61 |
super(manager); |
|
71 |
super(); |
|
72 |
this.manager = manager; |
|
62 | 73 |
initIcons(); |
63 | 74 |
initComponents(); |
64 | 75 |
initTree(); |
... | ... | |
68 | 79 |
|
69 | 80 |
@Override |
70 | 81 |
public ImageIcon loadImage( String imageName ) { |
71 |
if (imageName.toLowerCase().endsWith(".png") || imageName.toLowerCase().endsWith(".gif")) { |
|
72 |
return this.manager.getIconTheme().get(imageName.substring(0, (imageName.length()-4))); |
|
82 |
return getIconTheme().get(FilenameUtils.getBaseName(imageName)); |
|
83 |
} |
|
84 |
|
|
85 |
private IconTheme getIconTheme() { |
|
86 |
if (iconTheme == null) { |
|
87 |
iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
73 | 88 |
} |
74 |
return this.manager.getIconTheme().get(imageName);
|
|
89 |
return iconTheme;
|
|
75 | 90 |
} |
76 | 91 |
|
92 |
private I18nManager getI18nManager() { |
|
93 |
if (i18nManager == null) { |
|
94 |
i18nManager = ToolsLocator.getI18nManager(); |
|
95 |
} |
|
96 |
return i18nManager; |
|
97 |
} |
|
98 |
|
|
99 |
|
|
77 | 100 |
protected void initComponents() { |
101 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
78 | 102 |
// hide spatial filter since it is currently not supported |
79 | 103 |
this.btnFilterDropdown.setVisible(false); |
80 | 104 |
this.pnl_filterType.setVisible(false); |
81 | 105 |
this.cboFilterSpatial.setVisible(false); |
106 |
|
|
107 |
swingManager.translate(this.btnSearch); |
|
108 |
swingManager.translate(this.btnSearchRemove); |
|
109 |
swingManager.translate(this.btnFavoritesAdd); |
|
110 |
swingManager.translate(this.btnFavoritesAdd1); |
|
111 |
swingManager.translate(this.btnCrsAdd); |
|
112 |
swingManager.translate(this.btnFavoritesAdd2); |
|
113 |
swingManager.translate(this.lbl_currentCrs); |
|
114 |
swingManager.translate(this.btnFavoritesAdd2); |
|
115 |
|
|
116 |
this.jtxt_description.setEditable(false); |
|
117 |
this.jtxt_description.setText(""); |
|
118 |
this.jtxt_description.setLineWrap(true); |
|
119 |
this.jtxt_description.setWrapStyleWord(true); |
|
120 |
this.txtCrsWkt.setEditable(false); |
|
121 |
this.txtCrsWkt.setText(""); |
|
122 |
/** |
|
123 |
* TODO Update strings in CrsPanel and change the name of some components |
|
124 |
* |
|
82 | 125 |
this.btnSearch.setToolTipText(manager.getTranslation("Search")); |
83 | 126 |
this.btnSearchRemove.setToolTipText(manager.getTranslation("Clear search")); |
84 | 127 |
this.btnFavoritesAdd.setToolTipText(manager.getTranslation("Add selected CRS to favorites")); |
... | ... | |
92 | 135 |
this.jtxt_description.setWrapStyleWord(true); |
93 | 136 |
this.txtCrsWkt.setEditable(false); |
94 | 137 |
this.txtCrsWkt.setText(""); |
138 |
*/ |
|
95 | 139 |
} |
96 | 140 |
|
97 | 141 |
protected void search() { |
98 | 142 |
String filter = getAlphanumericFilter(); |
99 |
//this.cboFilterAlpha.removei |
|
100 |
//this.cboFilterAlpha.insertItemAt(filter, 0); |
|
101 | 143 |
if (filter != null && !filter.equals("")) { |
102 |
//this.cboFilterAlpha.addItem(filter); |
|
103 | 144 |
manager.getCoordinateReferenceSystemTextFilterHistory().add(filter); |
104 | 145 |
} |
105 | 146 |
for (int i=0; i<root.getChildCount(); i++) { |
... | ... | |
210 | 251 |
} |
211 | 252 |
|
212 | 253 |
protected void initIcons() { |
213 |
RECENT_ICON = manager.getIconTheme().get("recent");
|
|
214 |
FAVOURITE_ICON = manager.getIconTheme().get("favourite");
|
|
215 |
FOLDER_OPEN_ICON = manager.getIconTheme().get("folder_open");
|
|
216 |
FOLDER_CLOSED_ICON = manager.getIconTheme().get("folder_closed");
|
|
217 |
CRS_ICON = manager.getIconTheme().get("crs");
|
|
218 |
LOADING_ICON = manager.getIconTheme().get("spinner");
|
|
254 |
RECENT_ICON = getIconTheme().get("recent"); |
|
255 |
FAVOURITE_ICON = getIconTheme().get("favourite"); |
|
256 |
FOLDER_OPEN_ICON = getIconTheme().get("folder_open"); |
|
257 |
FOLDER_CLOSED_ICON = getIconTheme().get("folder_closed"); |
|
258 |
CRS_ICON = getIconTheme().get("crs"); |
|
259 |
LOADING_ICON = getIconTheme().get("spinner"); |
|
219 | 260 |
} |
220 | 261 |
|
221 | 262 |
protected void initTree() { |
... | ... | |
223 | 264 |
model = new DefaultTreeModel(root, false); |
224 | 265 |
|
225 | 266 |
JTree tree = this.treeResults; |
226 |
|
|
227 |
|
|
228 | 267 |
tree.getSelectionModel().setSelectionMode |
229 | 268 |
(TreeSelectionModel.SINGLE_TREE_SELECTION); |
230 | 269 |
listenerSupport = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport(); |
231 | 270 |
tree.addTreeSelectionListener(this); |
232 | 271 |
tree.setCellRenderer(new CellRenderer()); |
233 | 272 |
|
234 |
recent = new RecentCRSs(root, manager.getTranslation("Recent"));
|
|
273 |
recent = new RecentCRSs(root, getI18nManager().getTranslation("Recent"));
|
|
235 | 274 |
recent.loadChildren(); |
236 | 275 |
|
237 | 276 |
root.add(recent); |
238 |
BranchNode epsg = new BranchNode(root, this, manager.getTranslation("EPSG"));
|
|
277 |
BranchNode epsg = new BranchNode(root, this, getI18nManager().getTranslation("EPSG"));
|
|
239 | 278 |
root.add(epsg); |
240 | 279 |
CRSSearchFilter projectedCRSs = new CRSSearchFilter(); |
241 | 280 |
projectedCRSs.setAuthority("EPSG"); |
242 | 281 |
projectedCRSs.setIncludedTypes(new CRSType[]{CRSType.ProjectedCRSType}); |
243 |
epsg.add(new AuthorityLoadedGroup(epsg, projectedCRSs, manager.getTranslation("Projected")));
|
|
282 |
epsg.add(new AuthorityLoadedGroup(epsg, projectedCRSs, getI18nManager().getTranslation("Projected")));
|
|
244 | 283 |
|
245 | 284 |
CRSSearchFilter geographicCRSs = new CRSSearchFilter(); |
246 | 285 |
geographicCRSs.setAuthority("EPSG"); |
247 | 286 |
geographicCRSs.setIncludedTypes(new CRSType[]{CRSType.GeographicCRSType}); |
248 |
epsg.add(new AuthorityLoadedGroup(epsg, geographicCRSs, manager.getTranslation("Geographic")));
|
|
287 |
epsg.add(new AuthorityLoadedGroup(epsg, geographicCRSs, getI18nManager().getTranslation("Geographic")));
|
|
249 | 288 |
|
250 | 289 |
CRSSearchFilter otherCRSs = new CRSSearchFilter(); |
251 | 290 |
otherCRSs.setAuthority("EPSG"); |
252 | 291 |
otherCRSs.setExcludedTypes(new CRSType[]{CRSType.ProjectedCRSType, CRSType.GeographicCRSType}); |
253 |
epsg.add(new AuthorityLoadedGroup(epsg, otherCRSs, manager.getTranslation("Other")));
|
|
292 |
epsg.add(new AuthorityLoadedGroup(epsg, otherCRSs, getI18nManager().getTranslation("Other")));
|
|
254 | 293 |
tree.setModel(model); |
255 | 294 |
|
256 | 295 |
tree.expandPath(new TreePath(model.getPathToRoot(epsg))); |
... | ... | |
309 | 348 |
} |
310 | 349 |
|
311 | 350 |
@Override |
312 |
public void addCRSSpatialFilter(String label, double minLon, double maxLon, double minLat, double maxLat) {
|
|
351 |
public void addCRSSpatialFilter(String label, GeographicBoundingBox boundingBox) {
|
|
313 | 352 |
// TODO Auto-generated method stub |
314 | 353 |
} |
315 | 354 |
|
... | ... | |
423 | 462 |
public LoadingNode createLoadingNode(BranchNode parent) { |
424 | 463 |
return new LoadingNode(parent, |
425 | 464 |
this, |
426 |
this.manager.getTranslation("Loading..."));
|
|
465 |
getI18nManager().getTranslation("Loading..."));
|
|
427 | 466 |
} |
428 | 467 |
|
429 | 468 |
|
Also available in: Unified diff