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 / export / dbf / swing / panels / EncodingPanel.java @ 43968
History | View | Annotate | Download (4.5 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
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 |
* as published by the Free Software Foundation; either version 3
|
9 |
* 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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.export.dbf.swing.panels; |
25 |
|
26 |
import javax.swing.DefaultListModel; |
27 |
import javax.swing.JComponent; |
28 |
|
29 |
import org.gvsig.fmap.dal.DataStoreParameters; |
30 |
|
31 |
import org.gvsig.tools.ToolsLocator; |
32 |
import org.gvsig.tools.dynobject.DynField; |
33 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
34 |
import org.gvsig.tools.dynobject.DynStruct; |
35 |
import org.gvsig.tools.i18n.I18nManager; |
36 |
import org.gvsig.tools.swing.api.ListElement; |
37 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
38 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
39 |
import org.gvsig.export.dbf.service.ExportDBFParameters; |
40 |
import org.gvsig.export.ExportParameters; |
41 |
import org.gvsig.export.swing.JExportProcessPanel; |
42 |
import org.gvsig.export.swing.spi.ExportPanel; |
43 |
import org.gvsig.export.swing.spi.ExportPanelValidationException; |
44 |
import org.slf4j.Logger; |
45 |
import org.slf4j.LoggerFactory; |
46 |
|
47 |
/**
|
48 |
* @author gvSIG Team
|
49 |
* @version $Id$
|
50 |
*
|
51 |
*/
|
52 |
public class EncodingPanel |
53 |
extends EncodingPanelView
|
54 |
implements ExportPanel
|
55 |
{ |
56 |
|
57 |
private static final Logger LOG = LoggerFactory.getLogger(EncodingPanel.class); |
58 |
|
59 |
private final ExportDBFParameters parameters; |
60 |
private final JExportProcessPanel processPanel; |
61 |
|
62 |
public EncodingPanel(JExportProcessPanel processPanel, ExportParameters parameters) {
|
63 |
super();
|
64 |
this.processPanel = processPanel;
|
65 |
this.parameters = (ExportDBFParameters) parameters;
|
66 |
this.initComponents();
|
67 |
} |
68 |
|
69 |
private void initComponents() { |
70 |
DynStruct parametersDefinition = ToolsLocator.getPersistenceManager().getDefinition("DBFStoreParameters");
|
71 |
DynField dynField = parametersDefinition.getDynField("Encoding");
|
72 |
|
73 |
DefaultListModel model = new DefaultListModel(); |
74 |
DynObjectValueItem[] encodings = dynField.getAvailableValues();
|
75 |
for (DynObjectValueItem encoding : encodings) {
|
76 |
model.addElement(new ListElement(encoding.getLabel(),encoding.getValue()));
|
77 |
} |
78 |
this.lstEncoding.setModel(model);
|
79 |
this.lstEncoding.setSelectedIndex(0); |
80 |
|
81 |
String sourceProviderName = this.parameters.getSourceFeatureStore().getProviderName(); |
82 |
if( sourceProviderName.equalsIgnoreCase("Shape") || sourceProviderName.equalsIgnoreCase("DBF") ) { |
83 |
DataStoreParameters params = this.parameters.getSourceFeatureStore().getParameters();
|
84 |
String encoding = (String) params.getDynValue("Encoding"); |
85 |
ListElement.setSelected(this.lstEncoding, encoding);
|
86 |
} |
87 |
this.translate();
|
88 |
} |
89 |
|
90 |
private void translate() { |
91 |
ToolsSwingManager i18nc = ToolsSwingLocator.getToolsSwingManager(); |
92 |
i18nc.translate(this.lblEncoding);
|
93 |
} |
94 |
|
95 |
public String getEncoding() { |
96 |
ListElement encoding = (ListElement) this.lstEncoding.getSelectedValue();
|
97 |
if( encoding==null ) { |
98 |
return null; |
99 |
} |
100 |
return (String) encoding.getValue(); |
101 |
} |
102 |
|
103 |
@Override
|
104 |
public JComponent asJComponent() { |
105 |
return this; |
106 |
} |
107 |
|
108 |
@Override
|
109 |
public String getIdPanel() { |
110 |
return this.getClass().getSimpleName(); |
111 |
} |
112 |
|
113 |
@Override
|
114 |
public String getTitlePanel() { |
115 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
116 |
return i18nManager.getTranslation("_Select_encoding"); |
117 |
} |
118 |
|
119 |
@Override
|
120 |
public boolean validatePanel() throws ExportPanelValidationException { |
121 |
return true; |
122 |
} |
123 |
|
124 |
@Override
|
125 |
public void enterPanel() { |
126 |
// Do nothing
|
127 |
} |
128 |
|
129 |
@Override
|
130 |
public void previousPanel() { |
131 |
|
132 |
} |
133 |
|
134 |
@Override
|
135 |
public void nextPanel() { |
136 |
this.parameters.setEncoding(this.getEncoding()); |
137 |
} |
138 |
} |