svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / daltransform / gui / SelectTransformWizard.java @ 28833
History | View | Annotate | Download (4.7 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 org.gvsig.AppGvSigLocator; |
40 |
import org.gvsig.app.daltransform.FeatureTransformManager; |
41 |
|
42 |
import com.iver.andami.PluginServices; |
43 |
|
44 |
/**
|
45 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
46 |
*/
|
47 |
public class SelectTransformWizard extends FeatureTransformWizard implements ListSelectionListener{ |
48 |
private JList transformList; |
49 |
private JScrollPane transformScrollPane; |
50 |
private JScrollPane descriptionScrollPane; |
51 |
private JTextArea descriptionText; |
52 |
|
53 |
/**
|
54 |
* @param wizardComponents
|
55 |
*/
|
56 |
public SelectTransformWizard(FeatureTransformWizardModel featureTransformWizardModel) {
|
57 |
super(featureTransformWizardModel);
|
58 |
initComponents(); |
59 |
initLabels(); |
60 |
addTransforms(); |
61 |
transformList.addListSelectionListener(this);
|
62 |
} |
63 |
|
64 |
private void initLabels(){ |
65 |
setBorder(javax.swing.BorderFactory.createTitledBorder(PluginServices.getText(this, "transform_selection"))); |
66 |
} |
67 |
|
68 |
private void initComponents() { |
69 |
java.awt.GridBagConstraints gridBagConstraints; |
70 |
|
71 |
transformScrollPane = new javax.swing.JScrollPane();
|
72 |
transformList = new javax.swing.JList();
|
73 |
descriptionScrollPane = new javax.swing.JScrollPane();
|
74 |
descriptionText = new javax.swing.JTextArea();
|
75 |
|
76 |
setLayout(new java.awt.GridBagLayout());
|
77 |
|
78 |
transformScrollPane.setViewportView(transformList); |
79 |
|
80 |
transformList.setModel(new DefaultListModel()); |
81 |
|
82 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
83 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
84 |
gridBagConstraints.weightx = 1.0;
|
85 |
gridBagConstraints.weighty = 1.0;
|
86 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2); |
87 |
add(transformScrollPane, gridBagConstraints); |
88 |
|
89 |
descriptionText.setColumns(20);
|
90 |
descriptionText.setEditable(false);
|
91 |
descriptionText.setRows(5);
|
92 |
descriptionText.setLineWrap(true);
|
93 |
descriptionText.setBorder(null);
|
94 |
descriptionScrollPane.setBorder(null);
|
95 |
descriptionScrollPane.setViewportView(descriptionText); |
96 |
|
97 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
98 |
gridBagConstraints.gridx = 0;
|
99 |
gridBagConstraints.gridy = 1;
|
100 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
101 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
102 |
gridBagConstraints.weightx = 1.0;
|
103 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); |
104 |
add(descriptionScrollPane, gridBagConstraints); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Adding the objects
|
109 |
*/
|
110 |
protected void addTransforms(){ |
111 |
FeatureTransformManager featureTransformManager = |
112 |
AppGvSigLocator.getFeatureTransformManager(); |
113 |
ArrayList<FeatureTransformGui> featureTransformGui =
|
114 |
featureTransformManager.getFeatureTransforms(); |
115 |
for (int i=0 ; i<featureTransformGui.size() ; i++){ |
116 |
((DefaultListModel)transformList.getModel()).addElement(featureTransformGui.get(i));
|
117 |
} |
118 |
update(); |
119 |
} |
120 |
|
121 |
/* (non-Javadoc)
|
122 |
* @see jwizardcomponent.JWizardPanel#update()
|
123 |
*/
|
124 |
public void update() { |
125 |
if (transformList.getModel().getSize() > 0){ |
126 |
transformList.setSelectedIndex(0);
|
127 |
valueChanged(null);
|
128 |
}else{
|
129 |
getWizardComponents().getNextButton().setEnabled(false);
|
130 |
} |
131 |
} |
132 |
|
133 |
/* (non-Javadoc)
|
134 |
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
|
135 |
*/
|
136 |
public void valueChanged(ListSelectionEvent e) { |
137 |
Object obj = transformList.getSelectedValue();
|
138 |
if (obj != null){ |
139 |
descriptionText.setText(((FeatureTransformGui)obj).getDescription()); |
140 |
} |
141 |
} |
142 |
|
143 |
public FeatureTransformGui getSelectedFeatureTransformGui(){
|
144 |
Object obj = transformList.getSelectedValue();
|
145 |
if (obj != null){ |
146 |
return (FeatureTransformGui)obj;
|
147 |
} |
148 |
return null; |
149 |
} |
150 |
|
151 |
} |
152 |
|