Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / 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 @ 40558

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

    
26
import java.awt.Font;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30

    
31
import javax.swing.JLabel;
32
import javax.swing.JTextField;
33

    
34
import jwizardcomponent.JWizardComponents;
35
import jwizardcomponent.JWizardPanel;
36

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

    
42
public class TableWizardStep extends JWizardPanel {
43

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

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

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

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

    
85
    }
86

    
87
    private void initialize() {
88
        this.setLayout(new GridBagLayout());
89

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

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

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

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

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

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

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

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

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

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

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

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

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

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