Revision 21683 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/reproject/ui/LayerReprojectListener.java

View differences:

LayerReprojectListener.java
18 18
 */
19 19
package org.gvsig.rastertools.reproject.ui;
20 20

  
21
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionListener;
21
import java.io.File;
23 22

  
24 23
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
25 24
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
26

  
25
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
26
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
27
import org.gvsig.raster.IProcessActions;
28
import org.gvsig.raster.RasterProcess;
29
import org.gvsig.raster.util.RasterNotLoadException;
30
import org.gvsig.raster.util.RasterToolsUtil;
31
import org.gvsig.rastertools.reproject.ReprojectProcess;
32
import org.gvsig.rastertools.saveraster.ui.info.EndInfoDialog;
27 33
/**
28 34
 * Listener del panel de selecci?n de proyecci?n.
29 35
 * 
30 36
 * 29/04/2008
31 37
 * @author Nacho Brodin nachobrodin@gmail.com
32 38
 */
33
public class LayerReprojectListener implements ActionListener {
34
	private LayerReprojectPanel    dialog  = null;
35
	private FLyrRasterSE           lyr    = null;
39
public class LayerReprojectListener implements ButtonsPanelListener, IProcessActions {
40
	private LayerReprojectPanel dialog       = null;
41
	private FLyrRasterSE        lyr          = null;
36 42
	
37 43
	/**
38 44
	 * Constructor. Asigna el dialogo y la capa y registra los listener.
39 45
	 * @param lyr Capa
40 46
	 * @param dialog Dialogo
41 47
	 */
42
	public LayerReprojectListener(FLyrRasterSE lyr, LayerReprojectPanel dialog) {
48
	public LayerReprojectListener(LayerReprojectPanel dialog) {
43 49
		this.dialog = dialog;
50
	}
51

  
52
	/**
53
	 * Se asigna la capa al listener
54
	 * @param lyr
55
	 */
56
	public void setLayer(FLyrRasterSE lyr) {
44 57
		this.lyr = lyr;
45
		dialog.getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this);
46
		dialog.getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this);
47 58
	}
48
	
49
	public void actionPerformed(ActionEvent e) {
50
//		if(e.getSource() == dialog.getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) {
51
//			IProjection proj = dialog.getProjectionSelector().getProjection();
52
//      	    RasterProcess process = new ReprojectProcess();
53
//      	    process.addParam("layer", lyr);
54
//      	    process.addParam("path", "/tmp/p.tif");
55
//      	    process.addParam("projection", proj);
56
//      	    process.start();
57
//      	    RasterToolsUtil.closeWindow(dialog);
58
//		}
59

  
60
	/*
61
	 * (non-Javadoc)
62
	 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
63
	 */
64
	public void actionButtonPressed(ButtonsPanelEvent e) {
65
		if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
66
			RasterToolsUtil.closeWindow(dialog);
67
			return;
68
		}
69
		if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
70
			String path = null;
71
			path = dialog.getNewLayerPanel().getFileSelected();
72
			if (path == null)
73
				return;
74
			
75
			RasterProcess process = new ReprojectProcess();
76
			process.addParam("layer", lyr);
77
			process.addParam("path", path);
78
			process.addParam("projection", dialog.getProjectionDst());
79
			process.addParam("srcprojection", dialog.getProjectionSrc());
80
			process.setActions(this);
81
			process.start();
82
			RasterToolsUtil.closeWindow(dialog);
83
		}
59 84
	}
60 85

  
61
}
86
	/**
87
	 * Acciones que se realizan al finalizar de crear los recortes de imagen.
88
	 * Este m?todo es llamado por el thread TailRasterProcess al finalizar.
89
	 */
90
	public void loadLayerInToc(String fileName, Long milis) {
91
		if (!new File(fileName).exists())
92
			return;
93
		try {
94
			RasterToolsUtil.loadLayer(dialog.getViewName(), fileName, null);
95
			EndInfoDialog.show(fileName, milis.longValue());
96
		} catch (RasterNotLoadException e) {
97
			RasterToolsUtil.messageBoxError("error_cargar_capa", this, e);
98
		}
99
	}
100

  
101
	/*
102
	 * (non-Javadoc)
103
	 * @see org.gvsig.raster.IProcessActions#end(java.lang.Object)
104
	 */
105
	public void end(Object params) {
106
		if(	params instanceof Object[] &&
107
				((Object[])params).length == 2 &&
108
				((Object[])params)[0] instanceof String &&
109
				((Object[])params)[1] instanceof Long) {
110
			Object[] objects = (Object[]) params;
111
			loadLayerInToc((String) objects[0], (Long) objects[1]);
112
		}
113
	}
114

  
115
	public void interrupted() {}
116
}

Also available in: Unified diff