gvsig-gdal / trunk / org.gvsig.gdal2 / org.gvsig.gdal2.app / org.gvsig.gdal2.app.ogr.mainplugin / src / main / java / org / gvsig / gdal / app / ogr / mainplugin / gui / OGRDataStoreParameterTableModel.java @ 368
History | View | Annotate | Download (2.79 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2016 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 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 |
* 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.gdal.app.ogr.mainplugin.gui; |
25 |
|
26 |
import java.util.List; |
27 |
|
28 |
import javax.swing.table.AbstractTableModel; |
29 |
import javax.swing.table.TableModel; |
30 |
|
31 |
import org.gvsig.gdal.prov.ogr.OGRDataStoreParameters; |
32 |
import org.gvsig.tools.ToolsLocator; |
33 |
import org.gvsig.tools.i18n.I18nManager; |
34 |
|
35 |
/**
|
36 |
*
|
37 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
38 |
*
|
39 |
*/
|
40 |
public class OGRDataStoreParameterTableModel extends AbstractTableModel implements TableModel { |
41 |
|
42 |
private static final long serialVersionUID = 315018176923252280L; |
43 |
|
44 |
private List<OGRDataStoreParameters> parameters; |
45 |
|
46 |
private Object[][] data; |
47 |
|
48 |
private String[] columnNames = { "name" }; |
49 |
|
50 |
/**
|
51 |
*
|
52 |
* @param parameters
|
53 |
*/
|
54 |
public OGRDataStoreParameterTableModel(List<OGRDataStoreParameters> parameters) { |
55 |
this.data = new Object[parameters.size()][columnNames.length]; |
56 |
this.parameters = parameters;
|
57 |
fillData(parameters); |
58 |
} |
59 |
|
60 |
private void fillData(List<OGRDataStoreParameters> parameters) { |
61 |
|
62 |
for (int i = 0; i < parameters.size(); i++) { |
63 |
data[i][0] = parameters.get(i).getLayerName();
|
64 |
} |
65 |
} |
66 |
|
67 |
@Override
|
68 |
public int getRowCount() { |
69 |
return parameters.size();
|
70 |
} |
71 |
|
72 |
@Override
|
73 |
public int getColumnCount() { |
74 |
return columnNames.length;
|
75 |
} |
76 |
|
77 |
@Override
|
78 |
public Object getValueAt(int rowIndex, int columnIndex) { |
79 |
return data[rowIndex][columnIndex];
|
80 |
} |
81 |
|
82 |
@Override
|
83 |
public String getColumnName(int col) { |
84 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
85 |
return i18nManager.getTranslation(columnNames[col]);
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* Get OGR layer
|
90 |
*
|
91 |
* @param rowIndex
|
92 |
* index of layer
|
93 |
* @return OGR layer
|
94 |
*/
|
95 |
public OGRDataStoreParameters getDataStoreParameter(int rowIndex) { |
96 |
return this.parameters.get(rowIndex); |
97 |
} |
98 |
|
99 |
} |