root / branches / v2_0_0_prep / extensions / org.gvsig.daltransform.app.mainplugin / src / main / java / org / gvsig / daltransform / swing / impl / SelectTransformWizardPanel.java @ 38552
History | View | Annotate | Download (6.16 KB)
1 | 28893 | jpiera | /* 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 | 35512 | nfrancisco | package org.gvsig.daltransform.swing.impl; |
29 | 28893 | jpiera | |
30 | 29790 | jpiera | import java.awt.Dimension; |
31 | 35605 | nfrancisco | import java.util.List; |
32 | 28893 | jpiera | |
33 | import javax.swing.DefaultListModel; |
||
34 | import javax.swing.JList; |
||
35 | import javax.swing.JScrollPane; |
||
36 | import javax.swing.JTextArea; |
||
37 | import javax.swing.event.ListSelectionEvent; |
||
38 | import javax.swing.event.ListSelectionListener; |
||
39 | |||
40 | 29627 | jpiera | import org.gvsig.andami.PluginServices; |
41 | 35512 | nfrancisco | import org.gvsig.daltransform.DataTransformLocator; |
42 | import org.gvsig.daltransform.DataTransformManager; |
||
43 | import org.gvsig.daltransform.swing.DataTransformGui; |
||
44 | 28893 | jpiera | |
45 | |||
46 | /**
|
||
47 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
||
48 | */
|
||
49 | 29164 | jpiera | public class SelectTransformWizardPanel extends AbstractDataTransformWizardPanel implements ListSelectionListener{ |
50 | 35605 | nfrancisco | /**
|
51 | *
|
||
52 | */
|
||
53 | private static final long serialVersionUID = -4191590513663444616L; |
||
54 | private JList transformList; |
||
55 | 28893 | jpiera | private JScrollPane transformScrollPane; |
56 | private JScrollPane descriptionScrollPane; |
||
57 | private JTextArea descriptionText; |
||
58 | 29790 | jpiera | private int maxWidth = 315; |
59 | private int maxHeight = 600; |
||
60 | 28893 | jpiera | |
61 | /**
|
||
62 | * @param wizardComponents
|
||
63 | */
|
||
64 | 29164 | jpiera | public SelectTransformWizardPanel() {
|
65 | super();
|
||
66 | 28893 | jpiera | initComponents(); |
67 | addTransforms(); |
||
68 | 29164 | jpiera | transformList.addListSelectionListener(this);
|
69 | 28893 | jpiera | } |
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 | DataTransformManager featureTransformManager = |
||
115 | DataTransformLocator.getDataTransformManager(); |
||
116 | 35605 | nfrancisco | List<DataTransformGui> dataTransformGui =
|
117 | 28893 | jpiera | featureTransformManager.getDataTransforms(); |
118 | 29790 | jpiera | for (int i=0 ; i<dataTransformGui.size() ; i++){ |
119 | ((DefaultListModel)transformList.getModel()).addElement(new FeatureTransformGuiWrapper(dataTransformGui.get(i))); |
||
120 | Dimension dimension = dataTransformGui.get(i).getMinDimension();
|
||
121 | if (dimension != null){ |
||
122 | if (dimension.getHeight() > maxHeight){
|
||
123 | maxHeight = (int)dimension.getHeight();
|
||
124 | } |
||
125 | if (dimension.getWidth() > maxWidth){
|
||
126 | maxWidth = (int)dimension.getWidth();
|
||
127 | } |
||
128 | } |
||
129 | 28893 | jpiera | } |
130 | 29164 | jpiera | updatePanel(); |
131 | 28893 | jpiera | } |
132 | |||
133 | 29164 | jpiera | /*
|
134 | * (non-Javadoc)
|
||
135 | * @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel()
|
||
136 | */
|
||
137 | @Override
|
||
138 | public void updatePanel() { |
||
139 | 28893 | jpiera | if (transformList.getSelectedIndex() == -1){ |
140 | if (transformList.getModel().getSize() > 0){ |
||
141 | transformList.setSelectedIndex(0);
|
||
142 | valueChanged(null);
|
||
143 | } |
||
144 | }else{
|
||
145 | if (transformList.getModel().getSize() == 0){ |
||
146 | 29164 | jpiera | getDataTransformWizard().setApplicable(false);
|
147 | 28893 | jpiera | } |
148 | } |
||
149 | } |
||
150 | |||
151 | /* (non-Javadoc)
|
||
152 | * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
|
||
153 | */
|
||
154 | public void valueChanged(ListSelectionEvent e) { |
||
155 | Object obj = transformList.getSelectedValue();
|
||
156 | if (obj != null){ |
||
157 | descriptionText.setText(((FeatureTransformGuiWrapper)obj).getFeatureTransformGui().getDescription()); |
||
158 | } |
||
159 | } |
||
160 | |||
161 | public DataTransformGui getFeatureTransformGui(){
|
||
162 | Object obj = transformList.getSelectedValue();
|
||
163 | if (obj != null){ |
||
164 | return ((FeatureTransformGuiWrapper)obj).getFeatureTransformGui();
|
||
165 | } |
||
166 | return null; |
||
167 | } |
||
168 | |||
169 | /* (non-Javadoc)
|
||
170 | * @see org.gvsig.app.daltransform.gui.FeatureTransformWizard#getPanelTitle()
|
||
171 | */
|
||
172 | public String getPanelTitle() { |
||
173 | return PluginServices.getText(this, "transform_selection"); |
||
174 | } |
||
175 | 29790 | jpiera | |
176 | /**
|
||
177 | * @return the maxWidth
|
||
178 | */
|
||
179 | public int getMaxWidth() { |
||
180 | return maxWidth;
|
||
181 | } |
||
182 | |||
183 | /**
|
||
184 | * @return the maxHeight
|
||
185 | */
|
||
186 | public int getMaxHeight() { |
||
187 | return maxHeight;
|
||
188 | } |
||
189 | |||
190 | 28893 | jpiera | private class FeatureTransformGuiWrapper{ |
191 | private DataTransformGui featureTransformGui = null; |
||
192 | |||
193 | /**
|
||
194 | * @param featureTransformGui
|
||
195 | */
|
||
196 | public FeatureTransformGuiWrapper(
|
||
197 | DataTransformGui featureTransformGui) { |
||
198 | super();
|
||
199 | this.featureTransformGui = featureTransformGui;
|
||
200 | } |
||
201 | |||
202 | /**
|
||
203 | * @return the featureTransformGui
|
||
204 | */
|
||
205 | public DataTransformGui getFeatureTransformGui() {
|
||
206 | return featureTransformGui;
|
||
207 | } |
||
208 | |||
209 | /* (non-Javadoc)
|
||
210 | * @see java.lang.Object#toString()
|
||
211 | */
|
||
212 | public String toString() { |
||
213 | return featureTransformGui.getName();
|
||
214 | } |
||
215 | } |
||
216 | } |