svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.prov / org.gvsig.exportto.swing.prov.dbf / src / main / java / org / gvsig / exportto / swing / prov / dbf / panel / EncodingPanel.java @ 43920
History | View | Annotate | Download (4.05 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.exportto.swing.prov.dbf.panel; |
||
25 | |||
26 | 43920 | jjdelcerro | import javax.swing.DefaultListModel; |
27 | import javax.swing.JComponent; |
||
28 | 40435 | jjdelcerro | |
29 | 43920 | jjdelcerro | import org.gvsig.exportto.swing.prov.dbf.ExportDBFOptions; |
30 | import org.gvsig.exportto.swing.spi.ExporttoPanelValidationException; |
||
31 | import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
||
32 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
33 | 40435 | jjdelcerro | |
34 | import org.gvsig.metadata.MetadataLocator; |
||
35 | import org.gvsig.metadata.MetadataManager; |
||
36 | 43920 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
37 | 40435 | jjdelcerro | import org.gvsig.tools.dynobject.DynField; |
38 | import org.gvsig.tools.dynobject.DynObjectValueItem; |
||
39 | import org.gvsig.tools.dynobject.DynStruct; |
||
40 | 43920 | jjdelcerro | import org.gvsig.tools.i18n.I18nManager; |
41 | import org.gvsig.tools.swing.api.ListElement; |
||
42 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
43 | import org.gvsig.tools.swing.api.ToolsSwingManager; |
||
44 | 40435 | jjdelcerro | |
45 | /**
|
||
46 | * @author gvSIG Team
|
||
47 | * @version $Id$
|
||
48 | *
|
||
49 | */
|
||
50 | 43920 | jjdelcerro | public class EncodingPanel |
51 | extends EncodingPanelView
|
||
52 | implements ExporttoSwingProviderPanel
|
||
53 | { |
||
54 | 40435 | jjdelcerro | |
55 | 43920 | jjdelcerro | private final ExportDBFOptions options; |
56 | 40435 | jjdelcerro | |
57 | 43920 | jjdelcerro | |
58 | public EncodingPanel(ExportDBFOptions options) {
|
||
59 | 40435 | jjdelcerro | super();
|
60 | 43920 | jjdelcerro | this.options = options;
|
61 | 40435 | jjdelcerro | initComponents(); |
62 | } |
||
63 | |||
64 | private void initComponents() { |
||
65 | MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
||
66 | DynStruct dynStruct = metadataManager.getDefinition("DBF");
|
||
67 | DynField dynField = dynStruct.getDynField("Encoding");
|
||
68 | 43920 | jjdelcerro | |
69 | DefaultListModel model = new DefaultListModel(); |
||
70 | DynObjectValueItem[] encodings = dynField.getAvailableValues();
|
||
71 | for (DynObjectValueItem encoding : encodings) {
|
||
72 | model.addElement(new ListElement(encoding.getLabel(),encoding.getValue()));
|
||
73 | 40435 | jjdelcerro | } |
74 | 43920 | jjdelcerro | this.lstEncoding.setModel(model);
|
75 | this.lstEncoding.setSelectedIndex(0); |
||
76 | |||
77 | String sourceProviderName = this.options.getSourceFeatureStore().getProviderName(); |
||
78 | if( sourceProviderName.equalsIgnoreCase("Shape") || sourceProviderName.equalsIgnoreCase("DBF") ) { |
||
79 | DataStoreParameters params = this.options.getSourceFeatureStore().getParameters();
|
||
80 | String encoding = (String) params.getDynValue("Encoding"); |
||
81 | ListElement.setSelected(this.lstEncoding, encoding);
|
||
82 | } |
||
83 | this.translate();
|
||
84 | 40435 | jjdelcerro | } |
85 | 43920 | jjdelcerro | |
86 | private void translate() { |
||
87 | ToolsSwingManager i18nc = ToolsSwingLocator.getToolsSwingManager(); |
||
88 | i18nc.translate(this.lblEncoding);
|
||
89 | } |
||
90 | 40435 | jjdelcerro | |
91 | public String getEncoding() { |
||
92 | 43920 | jjdelcerro | ListElement encoding = (ListElement) this.lstEncoding.getSelectedValue();
|
93 | if( encoding==null ) { |
||
94 | 40435 | jjdelcerro | return null; |
95 | } |
||
96 | 43920 | jjdelcerro | return (String) encoding.getValue(); |
97 | 40435 | jjdelcerro | } |
98 | 43920 | jjdelcerro | |
99 | @Override
|
||
100 | public String getPanelTitle() { |
||
101 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
102 | return i18nManager.getTranslation("_Select_encoding"); |
||
103 | } |
||
104 | |||
105 | @Override
|
||
106 | public boolean isValidPanel() throws ExporttoPanelValidationException { |
||
107 | this.options.setEncoding(this.getEncoding()); |
||
108 | return true; |
||
109 | } |
||
110 | |||
111 | @Override
|
||
112 | public void enterPanel() { |
||
113 | // Do nothing
|
||
114 | } |
||
115 | |||
116 | @Override
|
||
117 | public JComponent asJComponent() { |
||
118 | return this; |
||
119 | } |
||
120 | 40435 | jjdelcerro | } |