Revision 1356 org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/gui/panel/WMSParamsPanel.java

View differences:

WMSParamsPanel.java
30 30
import java.awt.event.MouseAdapter;
31 31
import java.awt.event.MouseEvent;
32 32
import java.awt.geom.Rectangle2D;
33
import java.lang.reflect.InvocationTargetException;
33 34
import java.util.AbstractCollection;
34 35
import java.util.ArrayList;
35 36
import java.util.Hashtable;
......
60 61
import org.gvsig.fmap.dal.DataManager;
61 62
import org.gvsig.fmap.dal.DataParameters;
62 63
import org.gvsig.fmap.dal.DataStoreParameters;
64
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
63 65
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
64 66
import org.gvsig.fmap.dal.exception.InitializeException;
65 67
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
......
67 69
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException;
68 70
import org.gvsig.fmap.mapcontext.layers.FLayer;
69 71
import org.gvsig.fmap.mapcontext.layers.FLayers;
72
import org.gvsig.gui.beans.Messages;
70 73
import org.gvsig.gui.beans.controls.dnd.JDnDListModel;
71 74
import org.gvsig.gui.beans.listeners.BeanListener;
72 75
import org.gvsig.raster.wms.app.wmsclient.gui.wizard.LayerTreeModel;
......
77 80
import org.gvsig.raster.wms.io.WMSLayerNode;
78 81
import org.gvsig.raster.wms.io.WMSServerExplorer;
79 82
import org.gvsig.raster.wms.io.time.RemoteTimeDimension;
83
import org.slf4j.Logger;
84
import org.slf4j.LoggerFactory;
80 85

  
81 86

  
82 87
/**
......
146 151
	protected WMSServerExplorer     explorer               = null;
147 152
	private boolean                 updating               = fPrefs.getBoolean("refresh_capabilities", false);
148 153
	public static Preferences       fPrefs                 = Preferences.userRoot().node("gvsig.wms-wizard");
154
	private Logger                  log                    = LoggerFactory.getLogger(WMSParamsPanel.class);
149 155
	private JCheckBox               chkDisagregate         = null;
150 156
	private boolean                 lastCached;
151 157
	private String                  groupName              = "WMS Group";
......
1494 1500
	// changed by Laura:
1495 1501
	// To delegate getLayer to ParamsPanel from WMSWizard and WMSProps
1496 1502
	// public FLayer getLayer() { return null; }
1497
	public FLayer getLayer(boolean cached) throws LoadLayerException {
1503
	public FLayer getLayer(boolean cached) throws InitializeException {
1498 1504
		lastCached = cached;
1499 1505
		if (getDisagregatedLayers()) {
1500 1506
			return getLayerTree();
......
1503 1509
		}
1504 1510
	}
1505 1511
	
1506
	public FLayer getLayer() throws LoadLayerException {
1512
	public FLayer getLayer() throws InitializeException {
1507 1513
		return getLayer(lastCached);
1508 1514
	}
1509 1515

  
......
1514 1520
	 * @return
1515 1521
	 * @throws LoadLayerException 
1516 1522
	 */
1517
	protected FLayer getLayerTree() throws LoadLayerException {
1523
	protected FLayer getLayerTree() throws InitializeException {
1518 1524
		LayerTree layerTree = getLayerStructure();
1519 1525
		TreePath[] selection = (TreePath[]) getSelectedPaths().toArray(new TreePath[0]);
1520 1526
		if (selection != null) {
......
1538 1544
		return false;
1539 1545
	}
1540 1546

  
1541
	protected FLayer getSubTree(WMSLayerNode node, TreePath[] selection) throws LoadLayerException {
1547
	protected FLayer getSubTree(WMSLayerNode node, TreePath[] selection) throws InitializeException {
1542 1548
		if (node.getChildren().size() > 0) {
1543 1549
			FLayers l = null;
1544 1550
			if (this.getMapCtrl() == null) {
......
1597 1603
					layer.setExplorer(explorer);
1598 1604
					layer.setFullExtent(getLayersRectangle());
1599 1605
				} catch (InitializeException e) {
1600
					throw new LoadLayerException("Error initializating layer", e);
1606
					if (e.getCause() instanceof InvocationTargetException) {
1607
						Throwable t = ((InvocationTargetException)e.getCause()).getTargetException().getCause();
1608
						if(t != null) {
1609
							String msg = t.getMessage();
1610
							JOptionPane.showMessageDialog(this, msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE);
1611
						}
1612
						log.info(e.getMessage(), e);
1613
					} else {
1614
						throw e;
1615
					}
1616
					return null;
1617
				} catch (ProjectionLayerException e) {
1618
					throw new InitializeException(e);
1601 1619
				}
1602 1620
				return layer;
1603 1621

  
......
1613 1631
	 *
1614 1632
	 * @return
1615 1633
	 */
1616
	protected FLayer getLayerPlain(boolean cached) throws LoadLayerException {
1634
	protected FLayer getLayerPlain(boolean cached) throws InitializeException {
1617 1635
		WMSDataParameters par = (WMSDataParameters)explorer.getStoreParameters();
1618 1636
		DataStoreParameters parameters = par;
1619 1637
		
......
1622 1640
			TileDataParameters tileParams = null;
1623 1641
			try {
1624 1642
				tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
1625
			} catch (InitializeException e) {
1626
				throw new LoadLayerException("", e);
1627 1643
			} catch (ProviderNotRegisteredException e) {
1628
				throw new LoadLayerException("", e);
1644
				throw new InitializeException(e.getMessage(), e);
1629 1645
			}
1630 1646
			tileParams.setDataParameters(par);
1631 1647
			parameters = tileParams;
......
1653 1669
			layer.setFullExtent(getLayersRectangle());
1654 1670
			layer.setName(getLayerName());
1655 1671
		} catch (InitializeException e) {
1656
			throw new LoadLayerException("Error initializating layer", e);
1672
			String msg = getDriverExceptionMessage(e);
1673
			if(msg != null) {
1674
				JOptionPane.showMessageDialog(this, msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE);
1675
				return null;
1676
			} else
1677
				throw e;
1678
		} catch (ProjectionLayerException e) {
1679
			throw new InitializeException(e);
1657 1680
		}
1658 1681
		return layer;
1659 1682
	}
1660 1683

  
1661
	// ---------------------
1684
	/**
1685
	 * Gets the <code>RasterDriverException</code> message. The message 
1686
	 * of this exception is returned by the server
1687
	 * @param e
1688
	 * @return
1689
	 */
1690
	private String getDriverExceptionMessage(InitializeException e) {
1691
		Throwable ex = e;
1692
		final int MAX_DEEP = 10;
1693
		int deep = 0;
1694
		while(deep < MAX_DEEP) {
1695
			Throwable t = null;
1696
			if(ex instanceof RasterDriverException) {
1697
				return ex.getMessage();
1698
			} else if(ex instanceof InitializeException) {
1699
				t = ex.getCause();
1700
			} else if(ex instanceof InvocationTargetException) {
1701
				t = ((InvocationTargetException)ex).getTargetException();
1702
			} 
1703
			if(t == null)
1704
				return null;
1705
			else
1706
				ex = t;
1707
			deep++;
1708
		}
1709
		return null;
1710
	}
1662 1711

  
1663 1712
	public Dimension getFixedSize() {
1664 1713
		return sizeFixed;

Also available in: Unified diff