svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.daltransform.app.mainplugin / src / main / java / org / gvsig / daltransform / swing / impl / SelectTransformWizardPanel.java @ 40354
History | View | Annotate | Download (6.39 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.daltransform.swing.impl; |
29 |
|
30 |
import java.awt.Dimension; |
31 |
import java.awt.Font; |
32 |
import java.util.List; |
33 |
|
34 |
import javax.swing.DefaultListModel; |
35 |
import javax.swing.JList; |
36 |
import javax.swing.JScrollPane; |
37 |
import javax.swing.JTextArea; |
38 |
import javax.swing.event.ListSelectionEvent; |
39 |
import javax.swing.event.ListSelectionListener; |
40 |
|
41 |
import org.gvsig.andami.PluginServices; |
42 |
import org.gvsig.daltransform.DataTransformLocator; |
43 |
import org.gvsig.daltransform.DataTransformManager; |
44 |
import org.gvsig.daltransform.swing.DataTransformGui; |
45 |
|
46 |
|
47 |
/**
|
48 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
49 |
*/
|
50 |
public class SelectTransformWizardPanel extends AbstractDataTransformWizardPanel implements ListSelectionListener{ |
51 |
/**
|
52 |
*
|
53 |
*/
|
54 |
private static final long serialVersionUID = -4191590513663444616L; |
55 |
private JList transformList; |
56 |
private JScrollPane transformScrollPane; |
57 |
private JScrollPane descriptionScrollPane; |
58 |
private JTextArea descriptionText; |
59 |
private int maxWidth = 315; |
60 |
private int maxHeight = 600; |
61 |
|
62 |
/**
|
63 |
* @param wizardComponents
|
64 |
*/
|
65 |
public SelectTransformWizardPanel() {
|
66 |
super();
|
67 |
initComponents(); |
68 |
addTransforms(); |
69 |
transformList.addListSelectionListener(this);
|
70 |
} |
71 |
|
72 |
private void initComponents() { |
73 |
java.awt.GridBagConstraints gridBagConstraints; |
74 |
|
75 |
transformScrollPane = new javax.swing.JScrollPane();
|
76 |
transformList = new javax.swing.JList();
|
77 |
descriptionScrollPane = new javax.swing.JScrollPane();
|
78 |
descriptionText = new javax.swing.JTextArea();
|
79 |
|
80 |
setLayout(new java.awt.GridBagLayout());
|
81 |
|
82 |
transformScrollPane.setViewportView(transformList); |
83 |
|
84 |
transformList.setModel(new DefaultListModel()); |
85 |
|
86 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
87 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
88 |
gridBagConstraints.weightx = 1.0;
|
89 |
gridBagConstraints.weighty = 1.0;
|
90 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2); |
91 |
add(transformScrollPane, gridBagConstraints); |
92 |
|
93 |
descriptionText.setColumns(20);
|
94 |
descriptionText.setEditable(false);
|
95 |
descriptionText.setRows(5);
|
96 |
descriptionText.setLineWrap(true);
|
97 |
descriptionText.setWrapStyleWord(true);
|
98 |
descriptionText.setBackground(this.getBackground());
|
99 |
|
100 |
|
101 |
Font fnt = descriptionText.getFont();
|
102 |
fnt = fnt.deriveFont(Font.PLAIN);
|
103 |
descriptionText.setFont(fnt); |
104 |
|
105 |
descriptionText.setBorder(null);
|
106 |
descriptionScrollPane.setBorder(null);
|
107 |
descriptionScrollPane.setViewportView(descriptionText); |
108 |
|
109 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
110 |
gridBagConstraints.gridx = 0;
|
111 |
gridBagConstraints.gridy = 1;
|
112 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
113 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
114 |
gridBagConstraints.weightx = 1.0;
|
115 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); |
116 |
add(descriptionScrollPane, gridBagConstraints); |
117 |
} |
118 |
|
119 |
/**
|
120 |
* Adding the objects
|
121 |
*/
|
122 |
protected void addTransforms(){ |
123 |
DataTransformManager featureTransformManager = |
124 |
DataTransformLocator.getDataTransformManager(); |
125 |
List<DataTransformGui> dataTransformGui =
|
126 |
featureTransformManager.getDataTransforms(); |
127 |
for (int i=0 ; i<dataTransformGui.size() ; i++){ |
128 |
((DefaultListModel)transformList.getModel()).addElement(new FeatureTransformGuiWrapper(dataTransformGui.get(i))); |
129 |
Dimension dimension = dataTransformGui.get(i).getMinDimension();
|
130 |
if (dimension != null){ |
131 |
if (dimension.getHeight() > maxHeight){
|
132 |
maxHeight = (int)dimension.getHeight();
|
133 |
} |
134 |
if (dimension.getWidth() > maxWidth){
|
135 |
maxWidth = (int)dimension.getWidth();
|
136 |
} |
137 |
} |
138 |
} |
139 |
updatePanel(); |
140 |
} |
141 |
|
142 |
/*
|
143 |
* (non-Javadoc)
|
144 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel()
|
145 |
*/
|
146 |
@Override
|
147 |
public void updatePanel() { |
148 |
if (transformList.getSelectedIndex() == -1){ |
149 |
if (transformList.getModel().getSize() > 0){ |
150 |
transformList.setSelectedIndex(0);
|
151 |
valueChanged(null);
|
152 |
} |
153 |
}else{
|
154 |
if (transformList.getModel().getSize() == 0){ |
155 |
getDataTransformWizard().setApplicable(false);
|
156 |
} |
157 |
} |
158 |
} |
159 |
|
160 |
/* (non-Javadoc)
|
161 |
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
|
162 |
*/
|
163 |
public void valueChanged(ListSelectionEvent e) { |
164 |
Object obj = transformList.getSelectedValue();
|
165 |
if (obj != null){ |
166 |
descriptionText.setText(((FeatureTransformGuiWrapper)obj).getFeatureTransformGui().getDescription()); |
167 |
} |
168 |
} |
169 |
|
170 |
public DataTransformGui getFeatureTransformGui(){
|
171 |
Object obj = transformList.getSelectedValue();
|
172 |
if (obj != null){ |
173 |
return ((FeatureTransformGuiWrapper)obj).getFeatureTransformGui();
|
174 |
} |
175 |
return null; |
176 |
} |
177 |
|
178 |
/* (non-Javadoc)
|
179 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformWizard#getPanelTitle()
|
180 |
*/
|
181 |
public String getPanelTitle() { |
182 |
return PluginServices.getText(this, "transform_selection"); |
183 |
} |
184 |
|
185 |
/**
|
186 |
* @return the maxWidth
|
187 |
*/
|
188 |
public int getMaxWidth() { |
189 |
return maxWidth;
|
190 |
} |
191 |
|
192 |
/**
|
193 |
* @return the maxHeight
|
194 |
*/
|
195 |
public int getMaxHeight() { |
196 |
return maxHeight;
|
197 |
} |
198 |
|
199 |
private class FeatureTransformGuiWrapper{ |
200 |
private DataTransformGui featureTransformGui = null; |
201 |
|
202 |
/**
|
203 |
* @param featureTransformGui
|
204 |
*/
|
205 |
public FeatureTransformGuiWrapper(
|
206 |
DataTransformGui featureTransformGui) { |
207 |
super();
|
208 |
this.featureTransformGui = featureTransformGui;
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* @return the featureTransformGui
|
213 |
*/
|
214 |
public DataTransformGui getFeatureTransformGui() {
|
215 |
return featureTransformGui;
|
216 |
} |
217 |
|
218 |
/* (non-Javadoc)
|
219 |
* @see java.lang.Object#toString()
|
220 |
*/
|
221 |
public String toString() { |
222 |
return featureTransformGui.getName();
|
223 |
} |
224 |
} |
225 |
} |
226 |
|