Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / daltransform / gui / SelectTransformWizard.java @ 28666

History | View | Annotate | Download (4.74 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

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

    
28
package org.gvsig.app.daltransform.gui;
29

    
30
import java.util.ArrayList;
31

    
32
import javax.swing.DefaultListModel;
33
import javax.swing.JList;
34
import javax.swing.JScrollPane;
35
import javax.swing.JTextArea;
36
import javax.swing.event.ListSelectionEvent;
37
import javax.swing.event.ListSelectionListener;
38

    
39
import jwizardcomponent.JWizardComponents;
40
import jwizardcomponent.JWizardPanel;
41

    
42
import org.gvsig.AppGvSigLocator;
43
import org.gvsig.app.daltransform.FeatureTransformManager;
44

    
45
import com.iver.andami.PluginServices;
46

    
47
/**
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
49
 */
50
public class SelectTransformWizard extends JWizardPanel implements ListSelectionListener{
51
        private JList transformList;
52
        private JScrollPane transformScrollPane;
53
        private JScrollPane descriptionScrollPane;
54
        private JTextArea descriptionText;
55

    
56
        /**
57
         * @param wizardComponents
58
         */
59
        public SelectTransformWizard(JWizardComponents wizardComponents) {
60
                super(wizardComponents);        
61
                initComponents();
62
                initLabels();
63
                addTransforms();
64
                transformList.addListSelectionListener(this);
65
        }
66

    
67
        private void initLabels(){
68
                setBorder(javax.swing.BorderFactory.createTitledBorder(PluginServices.getText(this, "transform_selection")));
69
        }
70

    
71
        private void initComponents() {
72
                java.awt.GridBagConstraints gridBagConstraints;
73

    
74
                transformScrollPane = new javax.swing.JScrollPane();
75
                transformList = new javax.swing.JList();
76
                descriptionScrollPane = new javax.swing.JScrollPane();
77
                descriptionText = new javax.swing.JTextArea();
78

    
79
                setLayout(new java.awt.GridBagLayout());
80

    
81
                transformScrollPane.setViewportView(transformList);
82
                
83
                transformList.setModel(new DefaultListModel());
84

    
85
                gridBagConstraints = new java.awt.GridBagConstraints();
86
                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
87
                gridBagConstraints.weightx = 1.0;
88
                gridBagConstraints.weighty = 1.0;
89
                gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
90
                add(transformScrollPane, gridBagConstraints);
91

    
92
                descriptionText.setColumns(20);
93
                descriptionText.setEditable(false);
94
                descriptionText.setRows(5);
95
                descriptionText.setLineWrap(true);
96
                descriptionText.setBorder(null);
97
                descriptionScrollPane.setBorder(null);
98
                descriptionScrollPane.setViewportView(descriptionText);
99

    
100
                gridBagConstraints = new java.awt.GridBagConstraints();
101
                gridBagConstraints.gridx = 0;
102
                gridBagConstraints.gridy = 1;
103
                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
104
                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
105
                gridBagConstraints.weightx = 1.0;
106
                gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
107
                add(descriptionScrollPane, gridBagConstraints);
108
        }
109

    
110
        /**
111
         * Adding the objects
112
         */
113
        protected void addTransforms(){
114
                FeatureTransformManager featureTransformManager = 
115
                        AppGvSigLocator.getFeatureTransformManager();
116
                ArrayList<FeatureTransformGui> featureTransformGui =
117
                        featureTransformManager.getFeatureTransforms();
118
                for (int i=0 ; i<featureTransformGui.size() ; i++){
119
                        ((DefaultListModel)transformList.getModel()).addElement(featureTransformGui.get(i));
120
                }        
121
                update();
122
        }
123
        
124
        /* (non-Javadoc)
125
         * @see jwizardcomponent.JWizardPanel#update()
126
         */        
127
        public void update() {
128
                if (transformList.getModel().getSize() > 0){
129
                        transformList.setSelectedIndex(0);
130
                        valueChanged(null);
131
                }else{
132
                        getWizardComponents().getNextButton().setEnabled(false);
133
                }
134
        }
135

    
136
        /* (non-Javadoc)
137
         * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
138
         */
139
        public void valueChanged(ListSelectionEvent e) {
140
                Object obj = transformList.getSelectedValue();
141
                if (obj != null){
142
                        descriptionText.setText(((FeatureTransformGui)obj).getDescription());
143
                }
144
        }
145
        
146
        public FeatureTransformGui getSelectedFeatureTransformGui(){
147
                Object obj = transformList.getSelectedValue();
148
                if (obj != null){
149
                        return (FeatureTransformGui)obj;
150
                }
151
                return null;
152
        }
153

    
154
}
155