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