27 |
27 |
|
28 |
28 |
package org.gvsig.daltransform.swing.impl;
|
29 |
29 |
|
|
30 |
import java.awt.Font;
|
30 |
31 |
import java.awt.event.ItemEvent;
|
31 |
32 |
import java.awt.event.ItemListener;
|
32 |
33 |
import java.util.List;
|
33 |
34 |
|
34 |
|
import javax.swing.DefaultListModel;
|
35 |
35 |
import javax.swing.JCheckBox;
|
|
36 |
import javax.swing.JComboBox;
|
36 |
37 |
import javax.swing.JLabel;
|
37 |
|
import javax.swing.JList;
|
38 |
38 |
import javax.swing.JPanel;
|
39 |
39 |
import javax.swing.JScrollPane;
|
40 |
40 |
import javax.swing.JTextArea;
|
41 |
41 |
|
|
42 |
import org.slf4j.Logger;
|
|
43 |
import org.slf4j.LoggerFactory;
|
|
44 |
|
42 |
45 |
import org.gvsig.andami.PluginServices;
|
43 |
46 |
import org.gvsig.andami.ui.mdiManager.IWindow;
|
44 |
47 |
import org.gvsig.app.project.ProjectManager;
|
... | ... | |
54 |
57 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
|
55 |
58 |
import org.gvsig.fmap.dal.feature.FeatureType;
|
56 |
59 |
import org.gvsig.fmap.mapcontext.MapContext;
|
57 |
|
import org.slf4j.Logger;
|
58 |
|
import org.slf4j.LoggerFactory;
|
59 |
60 |
|
60 |
61 |
|
61 |
62 |
/**
|
... | ... | |
73 |
74 |
private JTextArea messageTextArea = null;
|
74 |
75 |
private JPanel northPanel = null;
|
75 |
76 |
private JLabel selectViewLabel;
|
76 |
|
private JList selectViewList;
|
77 |
|
private JScrollPane selectViewScroll;
|
|
77 |
private JComboBox selectViewCombo;
|
78 |
78 |
private JPanel centerPanel;
|
79 |
79 |
private FeatureStoreTransform transform = null;
|
80 |
|
// private boolean hasViews = false;
|
81 |
80 |
|
82 |
81 |
/**
|
83 |
82 |
* @param wizardComponents
|
84 |
83 |
*/
|
85 |
84 |
public LoadLayerWizardPanel() {
|
86 |
85 |
super();
|
|
86 |
|
87 |
87 |
initComponents();
|
88 |
88 |
initLabels();
|
89 |
89 |
addViews();
|
90 |
90 |
loadLayerCb.addItemListener(this);
|
91 |
|
itemStateChanged(null);
|
|
91 |
itemStateChanged(null);
|
92 |
92 |
}
|
93 |
93 |
|
94 |
94 |
private void initLabels(){
|
... | ... | |
105 |
105 |
loadLayerCb = new javax.swing.JCheckBox();
|
106 |
106 |
selectViewLabel = new javax.swing.JLabel();
|
107 |
107 |
centerPanel = new javax.swing.JPanel();
|
108 |
|
selectViewScroll = new javax.swing.JScrollPane();
|
109 |
|
selectViewList = new javax.swing.JList();
|
110 |
|
selectViewList.setModel(new DefaultListModel());
|
|
108 |
selectViewCombo = new JComboBox();
|
111 |
109 |
|
112 |
110 |
setLayout(new java.awt.BorderLayout());
|
113 |
111 |
|
... | ... | |
118 |
116 |
messageTextArea.setColumns(20);
|
119 |
117 |
messageTextArea.setEditable(false);
|
120 |
118 |
messageTextArea.setLineWrap(true);
|
|
119 |
|
|
120 |
messageTextArea.setWrapStyleWord(true);
|
|
121 |
messageTextArea.setBackground(northPanel.getBackground());
|
|
122 |
Font fnt = messageTextArea.getFont();
|
|
123 |
fnt = fnt.deriveFont(Font.PLAIN);
|
|
124 |
messageTextArea.setFont(fnt);
|
|
125 |
|
|
126 |
|
121 |
127 |
messageTextArea.setRows(5);
|
122 |
128 |
messageTextArea.setBorder(null);
|
123 |
129 |
messageScroll.setViewportView(messageTextArea);
|
124 |
130 |
|
125 |
131 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
126 |
132 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
133 |
gridBagConstraints.gridx = 0;
|
|
134 |
gridBagConstraints.gridy = 0;
|
127 |
135 |
gridBagConstraints.weightx = 1.0;
|
128 |
136 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
|
129 |
137 |
northPanel.add(messageScroll, gridBagConstraints);
|
... | ... | |
137 |
145 |
gridBagConstraints.weightx = 1.0;
|
138 |
146 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
|
139 |
147 |
northPanel.add(loadLayerCb, gridBagConstraints);
|
|
148 |
|
|
149 |
add(northPanel, java.awt.BorderLayout.NORTH);
|
|
150 |
|
|
151 |
centerPanel.setLayout(new java.awt.GridBagLayout());
|
140 |
152 |
|
141 |
153 |
selectViewLabel.setText("jLabel1");
|
142 |
154 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
143 |
155 |
gridBagConstraints.gridx = 0;
|
144 |
|
gridBagConstraints.gridy = 2;
|
|
156 |
gridBagConstraints.gridy = 0;
|
145 |
157 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
146 |
158 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
147 |
159 |
gridBagConstraints.weightx = 1.0;
|
148 |
160 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 5, 2);
|
149 |
|
northPanel.add(selectViewLabel, gridBagConstraints);
|
|
161 |
centerPanel.add(selectViewLabel, gridBagConstraints);
|
150 |
162 |
|
151 |
|
add(northPanel, java.awt.BorderLayout.NORTH);
|
152 |
|
|
153 |
|
centerPanel.setLayout(new java.awt.GridBagLayout());
|
154 |
|
|
155 |
|
selectViewScroll.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
156 |
|
selectViewScroll.setPreferredSize(null);
|
157 |
|
|
158 |
|
selectViewScroll.setViewportView(selectViewList);
|
159 |
|
|
160 |
163 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
161 |
164 |
gridBagConstraints.gridx = 0;
|
162 |
|
gridBagConstraints.gridy = 0;
|
163 |
|
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
|
165 |
gridBagConstraints.gridy = 1;
|
|
166 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
|
167 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
164 |
168 |
gridBagConstraints.weightx = 1.0;
|
165 |
169 |
gridBagConstraints.weighty = 1.0;
|
166 |
170 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
|
167 |
|
centerPanel.add(selectViewScroll, gridBagConstraints);
|
|
171 |
centerPanel.add(selectViewCombo, gridBagConstraints);
|
168 |
172 |
|
169 |
173 |
add(centerPanel, java.awt.BorderLayout.CENTER);
|
170 |
174 |
}
|
... | ... | |
210 |
214 |
}
|
211 |
215 |
}
|
212 |
216 |
if (hasGeometry){
|
213 |
|
if (selectViewList.getModel().getSize() == 0){
|
|
217 |
if (selectViewCombo.getItemCount() == 0){
|
214 |
218 |
messageTextArea.setText(PluginServices.getText(this, "transform_layout_not_view_to_load"));
|
215 |
219 |
setLoadLayerVisible(false);
|
216 |
220 |
}else{
|
... | ... | |
231 |
235 |
private void setLoadLayerVisible(boolean isVisible){
|
232 |
236 |
loadLayerCb.setVisible(isVisible);
|
233 |
237 |
selectViewLabel.setVisible(isVisible);
|
234 |
|
selectViewScroll.setVisible(isVisible);
|
235 |
|
selectViewList.setVisible(isVisible);
|
|
238 |
selectViewCombo.setVisible(isVisible);
|
236 |
239 |
}
|
237 |
240 |
|
238 |
241 |
/**
|
239 |
242 |
* Add the project views
|
240 |
243 |
*/
|
241 |
244 |
private void addViews(){
|
242 |
|
selectViewList.removeAll();
|
|
245 |
selectViewCombo.removeAllItems();
|
243 |
246 |
|
244 |
247 |
List<Document> views = ProjectManager.getInstance().getCurrentProject().getDocuments(ViewManager.TYPENAME);
|
245 |
248 |
for (Document view : views) {
|
246 |
|
((DefaultListModel)selectViewList.getModel()).addElement(view);
|
|
249 |
selectViewCombo.addItem(view);
|
247 |
250 |
}
|
248 |
251 |
// ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
|
249 |
252 |
// ArrayList<ProjectDocument> projects = ext.getProject().getDocumentsByType(ProjectViewFactory.registerName);
|
... | ... | |
256 |
259 |
// }
|
257 |
260 |
IWindow window = PluginServices.getMDIManager().getActiveWindow();
|
258 |
261 |
if (window instanceof IView){
|
259 |
|
selectViewList.setSelectedValue(window, true);
|
260 |
|
}else{
|
261 |
|
selectViewList.setSelectedIndex(0);
|
|
262 |
selectViewCombo.setSelectedItem(window);
|
262 |
263 |
}
|
263 |
264 |
}
|
264 |
265 |
|
|
266 |
public boolean isNextButtonEnabled() {
|
|
267 |
return true;
|
|
268 |
}
|
|
269 |
|
|
270 |
|
265 |
271 |
/**
|
266 |
272 |
* Update the form when the transform has been applied in
|
267 |
273 |
* to a layer
|
... | ... | |
294 |
300 |
* @return The mapcontext
|
295 |
301 |
*/
|
296 |
302 |
public MapContext getMapContext(){
|
297 |
|
Object obj = selectViewList.getSelectedValue();
|
|
303 |
Object obj = selectViewCombo.getSelectedItem();
|
298 |
304 |
if (obj != null){
|
299 |
305 |
return ((BaseViewDocument)obj).getMapContext();
|
300 |
306 |
}
|
... | ... | |
307 |
313 |
public void itemStateChanged(ItemEvent arg0) {
|
308 |
314 |
boolean isSelected = loadLayerCb.isSelected();
|
309 |
315 |
selectViewLabel.setEnabled(isSelected);
|
310 |
|
selectViewList.setEnabled(isSelected);
|
|
316 |
selectViewCombo.setEnabled(isSelected);
|
311 |
317 |
}
|
312 |
318 |
|
313 |
319 |
/* (non-Javadoc)
|
... | ... | |
316 |
322 |
public String getPanelTitle() {
|
317 |
323 |
return PluginServices.getText(this, "transform_apply");
|
318 |
324 |
}
|
|
325 |
|
319 |
326 |
}
|
320 |
327 |
|