svn-gvsig-desktop / branches / v2_0_0_prep / libraries / 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 @ 37780
History | View | Annotate | Download (3.24 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.exportto.swing.prov.dbf.panel; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.GridBagConstraints; |
26 |
import java.awt.GridBagLayout; |
27 |
|
28 |
import javax.swing.JComboBox; |
29 |
import javax.swing.JLabel; |
30 |
import javax.swing.JPanel; |
31 |
|
32 |
import org.gvsig.i18n.Messages; |
33 |
import org.gvsig.metadata.MetadataLocator; |
34 |
import org.gvsig.metadata.MetadataManager; |
35 |
import org.gvsig.tools.dynobject.DynField; |
36 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
37 |
import org.gvsig.tools.dynobject.DynStruct; |
38 |
|
39 |
/**
|
40 |
* @author gvSIG Team
|
41 |
* @version $Id$
|
42 |
*
|
43 |
*/
|
44 |
public class EncodingPanel extends JPanel { |
45 |
|
46 |
private JLabel encodingLabel; |
47 |
private JComboBox encodingCombo; |
48 |
|
49 |
public EncodingPanel() {
|
50 |
super();
|
51 |
initComponents(); |
52 |
initEncodingCombo(); |
53 |
} |
54 |
|
55 |
private void initComponents() { |
56 |
this.setLayout(new BorderLayout()); |
57 |
|
58 |
java.awt.GridBagConstraints gridBagConstraints; |
59 |
|
60 |
JPanel northPanel = new JPanel(); |
61 |
encodingLabel = new JLabel(); |
62 |
encodingCombo = new JComboBox(); |
63 |
|
64 |
northPanel.setLayout(new GridBagLayout()); |
65 |
|
66 |
encodingLabel.setText(Messages.getText("encoding ") + ": "); |
67 |
gridBagConstraints = new GridBagConstraints(); |
68 |
gridBagConstraints.gridx = 0;
|
69 |
gridBagConstraints.gridy = 0;
|
70 |
northPanel.add(encodingLabel, gridBagConstraints); |
71 |
|
72 |
gridBagConstraints = new GridBagConstraints(); |
73 |
gridBagConstraints.gridx = 1;
|
74 |
gridBagConstraints.gridy = 0;
|
75 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
76 |
gridBagConstraints.weightx = 1.0;
|
77 |
northPanel.add(encodingCombo, gridBagConstraints); |
78 |
|
79 |
add(northPanel, BorderLayout.NORTH);
|
80 |
} |
81 |
|
82 |
private void initEncodingCombo() { |
83 |
MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
84 |
DynStruct dynStruct = metadataManager.getDefinition("DBF");
|
85 |
DynField dynField = dynStruct.getDynField("Encoding");
|
86 |
DynObjectValueItem[] dynObjectValueItem = dynField.getAvailableValues();
|
87 |
for (int i = 0; i < dynObjectValueItem.length; i++) { |
88 |
encodingCombo.addItem(dynObjectValueItem[i].getValue()); |
89 |
} |
90 |
} |
91 |
|
92 |
/**
|
93 |
* @return
|
94 |
*/
|
95 |
public String getEncoding() { |
96 |
String encoding = (String) encodingCombo.getSelectedItem(); |
97 |
if ("".equals(encoding)) { |
98 |
return null; |
99 |
} |
100 |
return encoding;
|
101 |
} |
102 |
} |