svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / daltransform / gui / FeatureTransformSelectionAction.java @ 28833
History | View | Annotate | Download (3.11 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 jwizardcomponent.FinishAction; |
31 |
|
32 |
import org.gvsig.fmap.dal.exception.DataException; |
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
34 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
35 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
36 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
37 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
38 |
import org.slf4j.Logger; |
39 |
import org.slf4j.LoggerFactory; |
40 |
|
41 |
import com.iver.andami.PluginServices; |
42 |
|
43 |
/**
|
44 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
45 |
*/
|
46 |
public class FeatureTransformSelectionAction extends FinishAction{ |
47 |
private static final Logger logger = LoggerFactory.getLogger(FeatureTransformSelectionAction.class); |
48 |
private FeatureTransformWizardModel featureTransformWizardModel = null; |
49 |
|
50 |
public FeatureTransformSelectionAction(FeatureTransformWizardModel featureTransformWizardModel) {
|
51 |
super(featureTransformWizardModel.getWizard().getWizardComponents());
|
52 |
this.featureTransformWizardModel = featureTransformWizardModel;
|
53 |
} |
54 |
|
55 |
/* (non-Javadoc)
|
56 |
* @see jwizardcomponent.Action#performAction()
|
57 |
*/
|
58 |
public void performAction() { |
59 |
//Gets the selected transformation
|
60 |
FeatureTransformGui featureTransformGui = featureTransformWizardModel.getSelectedFeatureTransformGui(); |
61 |
|
62 |
//Gets the selected FeatureStore
|
63 |
FeatureStore featureStore = featureTransformWizardModel.getSelectedFeatureStore(); |
64 |
|
65 |
//Gets the transform
|
66 |
FeatureStoreTransform featureStoreTransform = featureTransformWizardModel.getTransform(); |
67 |
|
68 |
//Apply the transformation
|
69 |
try {
|
70 |
featureStore.getTransforms().add(featureStoreTransform); |
71 |
//Create and load a new layer...
|
72 |
if (featureTransformWizardModel.isLayerLoaded()){
|
73 |
FLayer layer = LayerFactory.getInstance().createLayer(featureTransformGui.toString(), |
74 |
featureStore); |
75 |
featureTransformWizardModel.getMapContext().getLayers().addLayer(layer); |
76 |
} |
77 |
} catch (DataException e) {
|
78 |
logger.error("Error creating the transformation", e);
|
79 |
} catch (LoadLayerException e) {
|
80 |
logger.error("Error loading the layer", e);
|
81 |
} |
82 |
//Closing the window
|
83 |
PluginServices.getMDIManager().closeWindow(featureTransformWizardModel.getWizard()); |
84 |
} |
85 |
|
86 |
} |
87 |
|