Revision 4181 org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/layerdatatype/ProcessEndActions.java

View differences:

ProcessEndActions.java
21 21
package org.gvsig.raster.tools.app.basic.tool.layerdatatype;
22 22

  
23 23
import java.io.File;
24
import java.net.URI;
25
import java.net.URISyntaxException;
24 26
import java.util.HashMap;
25 27

  
26 28
import org.gvsig.andami.PluginServices;
......
48 50

  
49 51
/**
50 52
 * Actions when the process finalizes or is interrupted
51
 * 
53
 *
52 54
 * Nacho Brodin (nachobrodin@gmail.com)
53 55
 */
54 56
public class ProcessEndActions implements IProcessActions {
......
65 67
		this.window = window;
66 68
		this.inputLyr = lyr;
67 69
	}
68
	
70

  
69 71
	@SuppressWarnings("unchecked")
70 72
	public void end(Object params) {
71 73
		if(window != null) {
......
81 83
		}
82 84

  
83 85
	}
84
	
86

  
85 87
	/**
86 88
	 * Acciones que se realizan al finalizar de crear los recortes de imagen.
87 89
	 * Este m?todo es llamado por el thread TailRasterProcess al finalizar.
......
98 100
			}
99 101
		}
100 102
	}
101
	
103

  
102 104
	/**
103
	 * Gets the view 
105
	 * Gets the view
104 106
	 * @return
105 107
	 */
106 108
	private AbstractViewPanel getView() {
......
118 120
		}
119 121
		return null;
120 122
	}
121
	
123

  
122 124
	@SuppressWarnings("deprecation")
123 125
	private void loadLayer(String fileName, String layerName) throws RasterNotLoadException {
124 126
		if(fileName ==  null)
......
131 133

  
132 134
		try {
133 135
			DataManager dataManager = DALLocator.getDataManager();
134
			
136

  
135 137
			ProviderServices provServ = RasterLocator.getManager().getProviderServices();
136 138
			RasterDataParameters storeParameters = provServ.createParameters(fileName);
137
			storeParameters.setURI(fileName);
138
			
139
			URI uri;
140
            try {
141
                uri = new URI(fileName);
142
            } catch (URISyntaxException e1) {
143
                throw new RasterNotLoadException("Can't create URI from "+fileName, e1);
144
            }
145
			storeParameters.setURI(uri);
146

  
139 147
			MapContextManager mcm = MapContextLocator.getMapContextManager();
140
			
148

  
141 149
			DataStore dataStore = null;
142 150
			try {
143 151
				dataStore = dataManager.createStore(storeParameters);
......
148 156
			} catch (ProviderNotRegisteredException e) {
149 157
				throw new RasterNotLoadException("Error al cargar la capa.");
150 158
			}
151
			
159

  
152 160
			if(layerName == null) {
153 161
				int endIndex = fileName.lastIndexOf(".");
154 162
				if (endIndex < 0)
155 163
					endIndex = fileName.length();
156
				
164

  
157 165
				layerName = fileName.substring(fileName.lastIndexOf(File.separator) + 1, endIndex);
158 166
			}
159
			
167

  
160 168
			FLayer lyr = mcm.createLayer(layerName, dataStore);
161 169
			theView.getMapControl().getMapContext().getLayers().addLayer(lyr);
162 170

  
163 171
		} catch (LoadLayerException e) {
164
			throw new RasterNotLoadException("Error al cargar la capa.");
165
		} 
172
			throw new RasterNotLoadException("Error al cargar la capa.", e);
173
		}
166 174
		theView.getMapControl().getMapContext().invalidate();
167 175
		theView.getMapControl().getMapContext().endAtomicEvent();
168 176
	}
169
	
177

  
170 178
	public void interrupted() {
171 179

  
172 180
    }
173
	
181

  
174 182
	public void updateProgress(int current, int total) {
175
		
183

  
176 184
	}
177 185
}

Also available in: Unified diff