Revision 1356 org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.app/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/panel/WCSParamsPanel.java
WCSParamsPanel.java | ||
---|---|---|
38 | 38 |
import org.gvsig.fmap.dal.DALLocator; |
39 | 39 |
import org.gvsig.fmap.dal.DataManager; |
40 | 40 |
import org.gvsig.fmap.dal.DataStoreParameters; |
41 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
41 | 42 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
42 | 43 |
import org.gvsig.fmap.dal.exception.InitializeException; |
43 | 44 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
... | ... | |
49 | 50 |
import org.gvsig.raster.wcs.io.WCSDataParameters; |
50 | 51 |
import org.gvsig.raster.wcs.io.WCSLayerNode; |
51 | 52 |
import org.gvsig.raster.wcs.io.WCSServerExplorer; |
52 |
import org.slf4j.Logger; |
|
53 |
import org.slf4j.LoggerFactory; |
|
54 | 53 |
|
55 | 54 |
|
56 | 55 |
/** |
... | ... | |
70 | 69 |
public class WCSParamsPanel extends WizardPanel { |
71 | 70 |
private static final long serialVersionUID = 1L; |
72 | 71 |
public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
73 |
private Logger log = LoggerFactory.getLogger(WCSParamsPanel.class); |
|
74 | 72 |
protected WCSServerExplorer explorer = null; |
75 | 73 |
private LayerPanel layerPanel = null; |
76 | 74 |
private InfoPanel infoPanel = null; |
... | ... | |
117 | 115 |
* @return |
118 | 116 |
* @throws LoadLayerException |
119 | 117 |
*/ |
120 |
public FLayer getLayer() throws LoadLayerException {
|
|
118 |
public FLayer getLayer() throws InitializeException {
|
|
121 | 119 |
return getLayer(lastCached); |
122 | 120 |
} |
123 | 121 |
|
124 | 122 |
@SuppressWarnings("unchecked") |
125 |
public FLayer getLayer(boolean cached) throws LoadLayerException {
|
|
123 |
public FLayer getLayer(boolean cached) throws InitializeException {
|
|
126 | 124 |
lastCached = cached; |
127 | 125 |
FLyrWCS layer = new FLyrWCS(); |
128 | 126 |
WCSDataParameters par = (WCSDataParameters)explorer.getStoreParameters(); |
... | ... | |
133 | 131 |
TileDataParameters tileParams = null; |
134 | 132 |
try { |
135 | 133 |
tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store"); |
136 |
} catch (InitializeException e) { |
|
137 |
throw new LoadLayerException("", e); |
|
138 | 134 |
} catch (ProviderNotRegisteredException e) { |
139 |
throw new LoadLayerException("", e);
|
|
135 |
throw new InitializeException(e.getMessage(), e);
|
|
140 | 136 |
} |
141 | 137 |
tileParams.setDataParameters(par); |
142 | 138 |
parameters = tileParams; |
... | ... | |
160 | 156 |
layer.setFullExtent(getExtent()); |
161 | 157 |
layer.setName(getLayerName()); |
162 | 158 |
} catch (InitializeException e) { |
163 |
if (e.getCause() instanceof InvocationTargetException) { |
|
164 |
Throwable t = ((InvocationTargetException)e.getCause()).getTargetException().getCause(); |
|
165 |
if(t != null) { |
|
166 |
String msg = t.getMessage(); |
|
167 |
JOptionPane.showMessageDialog(this, msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
|
168 |
} |
|
169 |
} |
|
170 |
log.info(e.getMessage(), e); |
|
171 |
return null; |
|
159 |
String msg = getDriverExceptionMessage(e); |
|
160 |
if(msg != null) { |
|
161 |
JOptionPane.showMessageDialog(this, msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
|
162 |
return null; |
|
163 |
} else |
|
164 |
throw e; |
|
172 | 165 |
} |
173 | 166 |
return layer; |
174 | 167 |
} |
168 |
|
|
169 |
/** |
|
170 |
* Gets the <code>RasterDriverException</code> message. The message |
|
171 |
* of this exception is returned by the server |
|
172 |
* @param e |
|
173 |
* @return |
|
174 |
*/ |
|
175 |
private String getDriverExceptionMessage(InitializeException e) { |
|
176 |
Throwable ex = e; |
|
177 |
final int MAX_DEEP = 10; |
|
178 |
int deep = 0; |
|
179 |
while(deep < MAX_DEEP) { |
|
180 |
Throwable t = null; |
|
181 |
if(ex instanceof RasterDriverException) { |
|
182 |
return ex.getMessage(); |
|
183 |
} else if(ex instanceof InitializeException) { |
|
184 |
t = ex.getCause(); |
|
185 |
} else if(ex instanceof InvocationTargetException) { |
|
186 |
t = ((InvocationTargetException)ex).getTargetException(); |
|
187 |
} |
|
188 |
if(t == null) |
|
189 |
return null; |
|
190 |
else |
|
191 |
ex = t; |
|
192 |
deep++; |
|
193 |
} |
|
194 |
return null; |
|
195 |
} |
|
175 | 196 |
|
176 | 197 |
/** |
177 | 198 |
* Refreshes the content shown by this. |
178 | 199 |
*/ |
200 |
@SuppressWarnings("unchecked") |
|
179 | 201 |
public void refreshData(WCSDataParameters par) { |
180 | 202 |
String coverageName = getLayerPanel().getSelectedInListCoverageName(); |
181 | 203 |
if(coverageName == null && par != null) { |
Also available in: Unified diff