Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.app.document.table.app / org.gvsig.app.document.table.app.mainplugin / src / main / java / org / gvsig / app / project / documents / table / gui / TableWizardStep.java @ 36443

History | View | Annotate | Download (6.75 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.app.project.documents.table.gui;
23

    
24
import java.awt.Font;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.Insets;
28

    
29
import javax.swing.JLabel;
30
import javax.swing.JTextField;
31

    
32
import jwizardcomponent.JWizardComponents;
33
import jwizardcomponent.JWizardPanel;
34

    
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.messages.NotificationManager;
37
import org.gvsig.utils.swing.JComboBox;
38
import org.gvsig.utils.swing.objectSelection.ObjectSelectionModel;
39

    
40
public class TableWizardStep extends JWizardPanel {
41

    
42
    private JLabel lbl_header = null;
43
    private static final long serialVersionUID = 1L;
44
    private JLabel tableNameLbl = null;
45
    private JComboBox tableNameCmb = null;
46
    private JLabel fieldNameLbl = null;
47
    private JComboBox fieldNameCmb = null;
48
    private JLabel fieldPrefixLbl = null;
49
    private JTextField fieldPrefixTxt = null;
50

    
51
    public TableWizardStep(JWizardComponents wizardComponents, String title) {
52
        super(wizardComponents, title);
53
        initialize();
54
    }
55

    
56
    public void setTableModel(ObjectSelectionModel model) {
57
        getTableNameCmb().removeAllItems();
58
        Object[] tableNames;
59
        try {
60
            tableNames = model.getObjects();
61
            for (int i = 0; i < tableNames.length; i++) {
62
                getTableNameCmb().addItem(tableNames[i]);
63
            }
64
        } catch (Exception e) {
65
            NotificationManager.addError(
66
                PluginServices.getText(this, "Error_getting_table_fields"), e);
67
        }
68
    }
69

    
70
    public void setFieldModel(ObjectSelectionModel model) {
71
        getFieldNameCmb().removeAllItems();
72
        Object[] fieldNames;
73
        try {
74
            fieldNames = model.getObjects();
75
            for (int i = 0; i < fieldNames.length; i++) {
76
                getFieldNameCmb().addItem(fieldNames[i]);
77
            }
78
        } catch (Exception e) {
79
            NotificationManager.addError(
80
                PluginServices.getText(this, "Error_getting_table_fields"), e);
81
        }
82

    
83
    }
84

    
85
    private void initialize() {
86
        this.setLayout(new GridBagLayout());
87

    
88
        GridBagConstraints constraints = new GridBagConstraints();
89
        constraints.gridx = 0;
90
        constraints.gridy = 0;
91
        constraints.gridwidth = 2;
92
        constraints.anchor = GridBagConstraints.NORTH;
93
        constraints.fill = GridBagConstraints.HORIZONTAL;
94
        constraints.weightx = 1.0;
95
        constraints.weighty = 0.0;
96
        constraints.insets = new Insets(4, 10, 8, 4);
97
        this.add(getHeaderLbl(), constraints);
98

    
99
        constraints.gridx = 0;
100
        constraints.gridy = 1;
101
        constraints.gridwidth = 1;
102
        constraints.anchor = GridBagConstraints.NORTHWEST;
103
        constraints.fill = GridBagConstraints.NONE;
104
        constraints.weightx = 0.0;
105
        constraints.weighty = 0.0;
106
        constraints.insets = new Insets(4, 10, 4, 6);
107
        this.add(getTableNameLbl(), constraints);
108

    
109
        constraints.gridx = 1;
110
        constraints.gridy = 1;
111
        constraints.gridwidth = 1;
112
        constraints.anchor = GridBagConstraints.NORTHWEST;
113
        constraints.fill = GridBagConstraints.HORIZONTAL;
114
        constraints.weightx = 0.5;
115
        constraints.weighty = 0.0;
116
        this.add(getTableNameCmb(), constraints);
117

    
118
        constraints.gridx = 0;
119
        constraints.gridy = 2;
120
        constraints.gridwidth = 1;
121
        constraints.anchor = GridBagConstraints.NORTHWEST;
122
        constraints.fill = GridBagConstraints.NONE;
123
        constraints.weightx = 0.0;
124
        constraints.weighty = 0.0;
125
        constraints.insets = new Insets(4, 10, 4, 6);
126
        this.add(getFieldNameLbl(), constraints);
127

    
128
        constraints.gridx = 1;
129
        constraints.gridy = 2;
130
        constraints.gridwidth = 1;
131
        constraints.anchor = GridBagConstraints.NORTHWEST;
132
        constraints.fill = GridBagConstraints.HORIZONTAL;
133
        constraints.weightx = 0.5;
134
        constraints.weighty = 0.0;
135
        this.add(getFieldNameCmb(), constraints);
136

    
137
        constraints.gridx = 0;
138
        constraints.gridy = 3;
139
        constraints.gridwidth = 1;
140
        constraints.anchor = GridBagConstraints.NORTHWEST;
141
        constraints.fill = GridBagConstraints.NONE;
142
        constraints.weightx = 0.0;
143
        constraints.weighty = 0.0;
144
        constraints.insets = new Insets(4, 10, 4, 6);
145
        this.add(getFieldPrefixLbl(), constraints);
146

    
147
        constraints.gridx = 1;
148
        constraints.gridy = 3;
149
        constraints.gridwidth = 1;
150
        constraints.anchor = GridBagConstraints.NORTHWEST;
151
        constraints.fill = GridBagConstraints.HORIZONTAL;
152
        constraints.weightx = 0.5;
153
        constraints.weighty = 0.0;
154
        this.add(getFieldPrefixTxt(), constraints);
155
    }
156

    
157
    public JLabel getHeaderLbl() {
158
        if (lbl_header == null) {
159
            lbl_header = new JLabel();
160
            Font font = lbl_header.getFont();
161
            lbl_header.setFont(font.deriveFont(Font.BOLD));
162
        }
163
        return lbl_header;
164
    }
165

    
166
    public JLabel getTableNameLbl() {
167
        if (tableNameLbl == null) {
168
            tableNameLbl = new JLabel();
169
        }
170
        return tableNameLbl;
171
    }
172

    
173
    public JComboBox getTableNameCmb() {
174
        if (tableNameCmb == null) {
175
            tableNameCmb = new JComboBox();
176
        }
177
        return tableNameCmb;
178
    }
179

    
180
    public JLabel getFieldNameLbl() {
181
        if (fieldNameLbl == null) {
182
            fieldNameLbl = new JLabel();
183
        }
184
        return fieldNameLbl;
185
    }
186

    
187
    public JComboBox getFieldNameCmb() {
188
        if (fieldNameCmb == null) {
189
            fieldNameCmb = new JComboBox();
190
        }
191
        return fieldNameCmb;
192
    }
193

    
194
    public JLabel getFieldPrefixLbl() {
195
        if (fieldPrefixLbl == null) {
196
            fieldPrefixLbl = new JLabel();
197
        }
198
        return fieldPrefixLbl;
199
    }
200

    
201
    public JTextField getFieldPrefixTxt() {
202
        if (fieldPrefixTxt == null) {
203
            fieldPrefixTxt = new JTextField();
204
        }
205
        return fieldPrefixTxt;
206
    }
207
}