Revision 1219

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ViewControls.java
49 49
import com.iver.andami.PluginServices;
50 50
import com.iver.andami.messages.NotificationManager;
51 51
import com.iver.andami.plugins.Extension;
52
import com.iver.andami.ui.mdiManager.MDIManager;
53 52

  
54 53
import com.iver.cit.gvsig.fmap.DriverException;
55 54
import com.iver.cit.gvsig.fmap.FMap;
56 55
import com.iver.cit.gvsig.fmap.NewMapControl;
57
import com.iver.cit.gvsig.fmap.drivers.shp.SHP;
58 56
import com.iver.cit.gvsig.fmap.layers.FLayer;
59
import com.iver.cit.gvsig.fmap.layers.layerOperations.Selectable;
60 57
import com.iver.cit.gvsig.gui.Encuadrator;
61 58
import com.iver.cit.gvsig.gui.ExtentListSelectorModel;
62 59
import com.iver.cit.gvsig.gui.FPanelExtentSelector;
......
69 66
import com.iver.cit.gvsig.project.castor.Project;
70 67
import com.iver.cit.gvsig.project.castor.ProjectExtent;
71 68
import com.iver.cit.gvsig.project.castor.ProjectView;
72
import com.iver.utiles.GenericFileFilter;
73 69

  
74

  
75 70
import org.apache.log4j.Logger;
76
import org.geotools.map.MapContext;
77 71

  
78
import java.awt.Component;
79
import java.awt.geom.Rectangle2D;
80
import java.io.File;
81
import java.util.BitSet;
82 72

  
83
import javax.swing.JFileChooser;
84

  
85

  
86 73
//import com.iver.utiles.FPanelExtentSelector;
87 74

  
88 75
/**
89
 * DOCUMENT ME!
76
 * Extensi?n que controla las operaciones basicas realizadas sobre la vista.
90 77
 *
91 78
 * @author vcn
92 79
 */
......
94 81
	private static Logger logger = Logger.getLogger(ViewControls.class.getName());
95 82

  
96 83
	/**
97
	 * DOCUMENT ME!
98
	 *
99
	 * @param s DOCUMENT ME!
84
	 * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
100 85
	 */
101 86
	public void execute(String s) {
102 87
		View vista = (View) PluginServices.getMDIManager().getActiveView();
......
143 128
			mapCtrl.setTool("zoomIn");
144 129
		} else if (s.compareTo("ZOOM_OUT") == 0) {
145 130
			mapCtrl.setTool("zoomOut");
146
		}  else if (s.compareTo("MEDICION") == 0) {
131
		} else if (s.compareTo("MEDICION") == 0) {
147 132
			mapCtrl.setTool("medicion");
148 133
		} else if (s.compareTo("AREA") == 0) {
149 134
			mapCtrl.setTool("area");
......
154 139
		} else if (s.compareTo("PROPERTIES") == 0) {
155 140
			ViewProperties viewProperties = new ViewProperties(model);
156 141
			PluginServices.getMDIManager().addView(viewProperties);
157
		} else if (s.compareTo("TEMAS_VISIBLES") == 0){
158
			setVisibles(true,mapa);
159
		} else if (s.compareTo("TEMAS_NOVISIBLES") == 0){
160
			setVisibles(false,mapa);
161
		} else if (s.compareTo("TEMAS_ACTIVOS") == 0){
162
			setActives(true,mapa);
163
		} else if (s.compareTo("TEMAS_NOACTIVOS") == 0){
164
			setActives(false,mapa);
142
		} else if (s.compareTo("TEMAS_VISIBLES") == 0) {
143
			setVisibles(true, mapa);
144
		} else if (s.compareTo("TEMAS_NOVISIBLES") == 0) {
145
			setVisibles(false, mapa);
146
		} else if (s.compareTo("TEMAS_ACTIVOS") == 0) {
147
			setActives(true, mapa);
148
		} else if (s.compareTo("TEMAS_NOACTIVOS") == 0) {
149
			setActives(false, mapa);
165 150
		}
166 151
	}
167
	private void setVisibles(boolean visible,FMap mapa){
168
		for (int i=0;i<mapa.getLayers().getLayersCount();i++){
169
			FLayer layer=mapa.getLayers().getLayer(i);
152

  
153
	/**
154
	 * Pone todas las capas visibles o no visibles.
155
	 *
156
	 * @param visible true si que quieren poner a visibles.
157
	 * @param mapa FMap sobre el que actuar.
158
	 */
159
	private void setVisibles(boolean visible, FMap mapa) {
160
		for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) {
161
			FLayer layer = mapa.getLayers().getLayer(i);
170 162
			layer.setVisible(visible);
171 163
		}
172 164
	}
173
	private void setActives(boolean active,FMap mapa){
174
		for (int i=0;i<mapa.getLayers().getLayersCount();i++){
175
			FLayer layer=mapa.getLayers().getLayer(i);
165

  
166
	/**
167
	 * Pone todas las capas activas o no activas.
168
	 *
169
	 * @param active true si que quieren poner a activas.
170
	 * @param mapa FMap sobre el que actuar.
171
	 */
172
	private void setActives(boolean active, FMap mapa) {
173
		for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) {
174
			FLayer layer = mapa.getLayers().getLayer(i);
176 175
			layer.setActive(active);
177 176
		}
178 177
	}
178

  
179 179
	/**
180 180
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
181 181
	 */
......
191 191
			View vista = (View) f;
192 192
			ProjectView model = vista.getModel();
193 193
			FMap mapa = model.getMapContext();
194

  
194 195
			return mapa.getLayers().getLayersCount() > 0;
195 196
		} else {
196 197
			return false;
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/Abrir.java
40 40
 */
41 41
package com.iver.cit.gvsig;
42 42

  
43
import java.awt.geom.Rectangle2D;
44
import java.io.File;
45

  
46
import javax.swing.JOptionPane;
47

  
48
import org.cresques.cts.ICoordTrans;
49
import org.cresques.cts.IProjection;
50
import org.cresques.cts.gt2.CoordSys;
51
import org.cresques.cts.gt2.CoordTrans;
52

  
53 43
import com.iver.andami.PluginServices;
54 44
import com.iver.andami.messages.NotificationManager;
55 45
import com.iver.andami.plugins.Extension;
46

  
56 47
import com.iver.cit.gvsig.fmap.DriverException;
57
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
58 48
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
59 49
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
60 50
import com.iver.cit.gvsig.fmap.layers.FLayer;
61 51
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
62
import com.iver.cit.gvsig.fmap.layers.XMLException;
63 52
import com.iver.cit.gvsig.gui.FOpenDialog;
64 53
import com.iver.cit.gvsig.gui.FileOpenDialog;
65 54
import com.iver.cit.gvsig.gui.View;
66 55
import com.iver.cit.gvsig.gui.WMSDataSourceAdapter;
67 56
import com.iver.cit.gvsig.gui.wms.WMSWizard;
68 57

  
58
import org.cresques.cts.ICoordTrans;
59
import org.cresques.cts.IProjection;
60
import org.cresques.cts.gt2.CoordSys;
61
import org.cresques.cts.gt2.CoordTrans;
69 62

  
63
import java.awt.geom.Rectangle2D;
64

  
65
import java.io.File;
66

  
67
import javax.swing.JOptionPane;
68

  
69

  
70 70
/**
71
 * DOCUMENT ME!
71
 * Extensi?n que abre un di?logo para seleccionar la capa o capas que se
72
 * quieren a?adir a la vista.
72 73
 *
73 74
 * @author Fernando Gonz?lez Cort?s
74 75
 */
......
146 147
							if (theView.getMapControl().getMapContext().getViewPort().getExtent()==null){
147 148
								first=true;
148 149
							}
150

  
149 151
							// Comprobar que la projecci?n es la misma que la vista
150
							if (proj != theView.getProjection())
151
							{
152
					        	int option = JOptionPane.showConfirmDialog(null, 
153
					        			"La proyecci?n de la capa no es igual que la de la vista", "?Desea reproyectar?", JOptionPane.YES_NO_OPTION);
152
							if (proj != theView.getProjection()) {
153
								int option = JOptionPane.showConfirmDialog(null,
154
										"La proyecci?n de la capa no es igual que la de la vista",
155
										"?Desea reproyectar?",
156
										JOptionPane.YES_NO_OPTION);
154 157

  
155
					        	if (option == JOptionPane.NO_OPTION)
156
					        	{
158
								if (option == JOptionPane.NO_OPTION) {
157 159
									continue;
158
					        	}
159
					        	else
160
					        	{
161
					        		ICoordTrans ct = new CoordTrans((CoordSys) proj, (CoordSys) theView.getProjection());
162
					        		lyr.setCoordTrans(ct);
163
					        		System.err.println("coordTrans = " + 
164
					        				proj.getAbrev() + " " + theView.getProjection().getAbrev());
165
					        	}
166
				
167
							
160
								} else {
161
									ICoordTrans ct = new CoordTrans((CoordSys) proj,
162
											(CoordSys) theView.getProjection());
163
									lyr.setCoordTrans(ct);
164
									System.err.println("coordTrans = " +
165
										proj.getAbrev() + " " +
166
										theView.getProjection().getAbrev());
167
								}
168 168
							}
169

  
169 170
							theView.getMapControl().getMapContext().getLayers()
170 171
								   .addLayer(lyr);
171 172
							rects[iFile]=lyr.getFullExtent();
......
174 175
							// todas las capas hayan sido cargadas.
175 176
							// TODO Se deber? de redibujar mediante la captura de los eventos, por
176 177
							//eso se comenta la parte anterior
177
//							theView.getMapControl().drawMap();
178
//							theView.getTOC().refresh();
178
							//							theView.getMapControl().drawMap();
179
							//							theView.getTOC().refresh();
179 180
						}
180 181

  
181 182
					} catch (DriverException e) {
182 183
						NotificationManager.addError("Error al crear la capa", e);
183
    				}
184
					}
184 185
				}
186

  
185 187
				//Esto permite que cuando se cargan varias capas de golpe y la vista est? vacia,se ponga como extent la suma de todos sus extents.
186
				if (rects.length>1){
187
					Rectangle2D rect=new Rectangle2D.Double();
188
				if (rects.length > 1) {
189
					Rectangle2D rect = new Rectangle2D.Double();
188 190
					rect.setRect(rects[0]);
189
					if (first){
190
						for (int i=0;i<rects.length;i++){
191

  
192
					if (first) {
193
						for (int i = 0; i < rects.length; i++) {
191 194
							rect.add(rects[i]);
192 195
						}
193
						theView.getMapControl().getMapContext().getViewPort().setExtent(rect);
196

  
197
						theView.getMapControl().getMapContext().getViewPort()
198
							   .setExtent(rect);
194 199
					}
195 200
				}
196 201
				theView.getMapControl().getMapContext()
......
210 215
					theView.getMapControl().getMapContext().getLayers()
211 216
						   .addLayer(lyr);
212 217
					theView.getMapControl().getMapContext().endAtomicEvent();
213

  
214 218
				}
215 219
			} // for
216 220
		}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/GraphicControls.java
46 46
 */
47 47
package com.iver.cit.gvsig;
48 48

  
49
import org.apache.log4j.Logger;
50

  
51 49
import com.iver.andami.PluginServices;
52 50
import com.iver.andami.plugins.Extension;
53 51
import com.iver.andami.ui.mdiManager.View;
52

  
54 53
import com.iver.cit.gvsig.gui.layout.FLayoutGraphics;
55 54
import com.iver.cit.gvsig.gui.layout.Layout;
56 55

  
56
import org.apache.log4j.Logger;
57 57

  
58

  
58 59
/**
60
 * Extensi?n que actua sobre el Layout para controlas las diferentes
61
 * operaciones sobre los gr?ficos.
62
 *
59 63
 * @author Vicente Caballero Navarro
60 64
 */
61 65
public class GraphicControls implements Extension {
62
	private static Logger logger = Logger.getLogger(LayoutControls.class.getName());
66
	private static Logger logger = Logger.getLogger(GraphicControls.class.getName());
63 67

  
64 68
	/**
65
	 * DOCUMENT ME!
66
	 *
67
	 * @param s DOCUMENT ME!
69
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
68 70
	 */
69 71
	public void execute(String s) {
70 72
		Layout layout = (Layout) PluginServices.getMDIManager().getActiveView();
71
		FLayoutGraphics lg= new FLayoutGraphics(layout);
73
		FLayoutGraphics lg = new FLayoutGraphics(layout);
72 74
		logger.debug("Comand : " + s);
73 75

  
74 76
		if (s.compareTo("SIMPLIFICAR") == 0) {
......
89 91
			lg.border();
90 92
		} else if (s.compareTo("POSICIONAR") == 0) {
91 93
			lg.position();
92
		} 
94
		}
93 95
	}
94 96

  
95 97
	/**
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/LayoutControls.java
46 46
 */
47 47
package com.iver.cit.gvsig;
48 48

  
49
import org.apache.log4j.Logger;
50

  
51 49
import com.iver.andami.PluginServices;
52 50
import com.iver.andami.plugins.Extension;
53 51
import com.iver.andami.ui.mdiManager.View;
52

  
54 53
import com.iver.cit.gvsig.fmap.DriverException;
55
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
56 54
import com.iver.cit.gvsig.gui.layout.FLayoutZooms;
57 55
import com.iver.cit.gvsig.gui.layout.Layout;
58 56

  
57
import org.apache.log4j.Logger;
59 58

  
59

  
60 60
/**
61
 * DOCUMENT ME!
61
 * Extensi?n para controlar las operaciones basicas sobre el Layout.
62 62
 *
63 63
 * @author Vicente Caballero Navarro
64 64
 */
65 65
public class LayoutControls implements Extension {
66
    private static Logger logger = Logger.getLogger(LayoutControls.class.getName());
67
    private Layout layout=null;
68
    /**
69
     * DOCUMENT ME!
70
     *
71
     * @param status DOCUMENT ME!
72
     * @param s DOCUMENT ME!
73
     */
74
    public void execute(String s) {
75
        layout = (Layout) PluginServices.getMDIManager().getActiveView();
76
        FLayoutZooms zooms = new FLayoutZooms(layout);
77
        logger.debug("Comand : " + s);
78
        
79
        
80
        if (s.compareTo("PAN") == 0) {
81
            layout.setTool(Layout.PAN);
82
        } else if (s.compareTo("ZOOM_IN") == 0) {
83
            layout.setTool(Layout.ZOOM_MAS);
84
        } else if (s.compareTo("ZOOM_OUT") == 0) {
85
            layout.setTool(Layout.ZOOM_MENOS);
86
        } else if (s.compareTo("RECTANGLEVIEW") == 0) {
87
            layout.setTool(Layout.RECTANGLEVIEW);
88
        } else if (s.compareTo("RECTANGLEPICTURE") == 0) {
89
            layout.setTool(Layout.RECTANGLEPICTURE);
90
        } else if (s.compareTo("RECTANGLESCALEBAR") == 0) {
91
            layout.setTool(Layout.RECTANGLESCALEBAR);
92
        } else if (s.compareTo("RECTANGLELEGEND") == 0) {
93
            layout.setTool(Layout.RECTANGLELEGEND);
94
        } else if (s.compareTo("RECTANGLETEXT") == 0) {
95
            layout.setTool(Layout.RECTANGLETEXT);
96
        } else if (s.compareTo("SELECT") == 0) {
97
            layout.setTool(Layout.SELECT);
98
        } else if (s.compareTo("POINT") == 0) {
99
            layout.setTool(Layout.POINT);
100
        } else if (s.compareTo("LINE") == 0) {
101
            layout.setTool(Layout.LINE);
102
        } else if (s.compareTo("POLYLINE") == 0) {
103
            layout.setTool(Layout.POLYLINE);
104
        } else if (s.compareTo("CIRCLE") == 0) {
105
            layout.setTool(Layout.CIRCLE);
106
        } else if (s.compareTo("RECTANGLESIMPLE") == 0) {
107
            layout.setTool(Layout.RECTANGLESIMPLE);
108
        } else if (s.compareTo("POLYGON") == 0) {
109
            layout.setTool(Layout.POLYGON);
110
        } else if (s.compareTo("CONFIG") == 0) {
111
            layout.showFConfig();
112
        } else if (s.compareTo("PROPERTIES") == 0) {
113
            layout.showFProperties();
114
        } else if (s.compareTo("FULL") == 0) {
115
            layout.fullRect();
116
        } else if (s.compareTo("REALZOOM") == 0) {
117
            zooms.realZoom();
118
        } else if (s.compareTo("ZOOMOUT") == 0) {
119
            zooms.zoomOut();
120
        } else if (s.compareTo("ZOOMIN") == 0) {
121
            zooms.zoomIn();
122
        } else if (s.compareTo("ZOOMSELECT") == 0) {
123
            zooms.zoomSelect();
124
        } else if (s.compareTo("VIEW_ZOOMIN") == 0) {
125
            layout.setTool(Layout.VIEW_ZOOMIN);
126
        } else if (s.compareTo("VIEW_ZOOMOUT") == 0) {
127
            layout.setTool(Layout.VIEW_ZOOMOUT);
128
        } else if (s.compareTo("VIEW_FULL") == 0) {
129
            try {
66
	private static Logger logger = Logger.getLogger(LayoutControls.class.getName());
67
	private Layout layout = null;
68

  
69
	/**
70
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
71
	 */
72
	public void execute(String s) {
73
		layout = (Layout) PluginServices.getMDIManager().getActiveView();
74

  
75
		FLayoutZooms zooms = new FLayoutZooms(layout);
76
		logger.debug("Comand : " + s);
77

  
78
		if (s.compareTo("PAN") == 0) {
79
			layout.setTool(Layout.PAN);
80
		} else if (s.compareTo("ZOOM_IN") == 0) {
81
			layout.setTool(Layout.ZOOM_MAS);
82
		} else if (s.compareTo("ZOOM_OUT") == 0) {
83
			layout.setTool(Layout.ZOOM_MENOS);
84
		} else if (s.compareTo("RECTANGLEVIEW") == 0) {
85
			layout.setTool(Layout.RECTANGLEVIEW);
86
		} else if (s.compareTo("RECTANGLEPICTURE") == 0) {
87
			layout.setTool(Layout.RECTANGLEPICTURE);
88
		} else if (s.compareTo("RECTANGLESCALEBAR") == 0) {
89
			layout.setTool(Layout.RECTANGLESCALEBAR);
90
		} else if (s.compareTo("RECTANGLELEGEND") == 0) {
91
			layout.setTool(Layout.RECTANGLELEGEND);
92
		} else if (s.compareTo("RECTANGLETEXT") == 0) {
93
			layout.setTool(Layout.RECTANGLETEXT);
94
		} else if (s.compareTo("SELECT") == 0) {
95
			layout.setTool(Layout.SELECT);
96
		} else if (s.compareTo("POINT") == 0) {
97
			layout.setTool(Layout.POINT);
98
		} else if (s.compareTo("LINE") == 0) {
99
			layout.setTool(Layout.LINE);
100
		} else if (s.compareTo("POLYLINE") == 0) {
101
			layout.setTool(Layout.POLYLINE);
102
		} else if (s.compareTo("CIRCLE") == 0) {
103
			layout.setTool(Layout.CIRCLE);
104
		} else if (s.compareTo("RECTANGLESIMPLE") == 0) {
105
			layout.setTool(Layout.RECTANGLESIMPLE);
106
		} else if (s.compareTo("POLYGON") == 0) {
107
			layout.setTool(Layout.POLYGON);
108
		} else if (s.compareTo("CONFIG") == 0) {
109
			layout.showFConfig();
110
		} else if (s.compareTo("PROPERTIES") == 0) {
111
			layout.showFProperties();
112
		} else if (s.compareTo("FULL") == 0) {
113
			layout.fullRect();
114
		} else if (s.compareTo("REALZOOM") == 0) {
115
			zooms.realZoom();
116
		} else if (s.compareTo("ZOOMOUT") == 0) {
117
			zooms.zoomOut();
118
		} else if (s.compareTo("ZOOMIN") == 0) {
119
			zooms.zoomIn();
120
		} else if (s.compareTo("ZOOMSELECT") == 0) {
121
			zooms.zoomSelect();
122
		} else if (s.compareTo("VIEW_ZOOMIN") == 0) {
123
			layout.setTool(Layout.VIEW_ZOOMIN);
124
		} else if (s.compareTo("VIEW_ZOOMOUT") == 0) {
125
			layout.setTool(Layout.VIEW_ZOOMOUT);
126
		} else if (s.compareTo("VIEW_FULL") == 0) {
127
			try {
130 128
				layout.viewFull();
131 129
			} catch (DriverException e) {
132 130
				//TODO Enviar a Andami
133 131
				e.printStackTrace();
134 132
			}
135
        } else if (s.compareTo("VIEW_PAN") == 0) {
136
            layout.setTool(Layout.VIEW_PAN);
137
        }else if (s.compareTo("SET_TAG") == 0) {
138
            layout.setTool(Layout.SET_TAG);
139
        }
140
    }
133
		} else if (s.compareTo("VIEW_PAN") == 0) {
134
			layout.setTool(Layout.VIEW_PAN);
135
		} else if (s.compareTo("SET_TAG") == 0) {
136
			layout.setTool(Layout.SET_TAG);
137
		}
138
	}
141 139

  
142
    /**
143
     * @see com.iver.mdiApp.plugins.Extension#isVisible()
144
     */
145
    public boolean isVisible() {
146
        View f = PluginServices.getMDIManager().getActiveView();
140
	/**
141
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
142
	 */
143
	public boolean isVisible() {
144
		View f = PluginServices.getMDIManager().getActiveView();
147 145

  
148
        if (f == null) {
149
            return false;
150
        }
146
		if (f == null) {
147
			return false;
148
		}
151 149

  
152
        if (f.getClass() == Layout.class) {
153
            Layout layout = (Layout) f;
150
		if (f.getClass() == Layout.class) {
151
			Layout layout = (Layout) f;
154 152

  
155
            return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0;
156
        } else {
157
            return false;
158
        }
159
    }
153
			return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0;
154
		} else {
155
			return false;
156
		}
157
	}
160 158

  
161 159
	/**
162 160
	 * @see com.iver.andami.plugins.Extension#inicializar()
......
170 168
	public boolean isEnabled() {
171 169
		return true;
172 170
	}
173
	public Layout getLayout(){
171

  
172
	/**
173
	 * Devuelve el Layout sobre el que se opera.
174
	 *
175
	 * @return Layout.
176
	 */
177
	public Layout getLayout() {
174 178
		return layout;
175
		
176 179
	}
177 180
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ProjectExtension.java
40 40
 */
41 41
package com.iver.cit.gvsig;
42 42

  
43
import java.awt.Component;
44
import java.io.File;
45
import java.io.FileNotFoundException;
46
import java.io.FileReader;
47
import java.io.FileWriter;
48
import java.text.DateFormat;
49
import java.util.ArrayList;
50
import java.util.Date;
51

  
52
import javax.swing.JFileChooser;
53
import javax.swing.JOptionPane;
54

  
55
import org.exolab.castor.xml.MarshalException;
56
import org.exolab.castor.xml.Marshaller;
57
import org.exolab.castor.xml.ValidationException;
58

  
59 43
import com.iver.andami.PluginServices;
60 44
import com.iver.andami.messages.NotificationManager;
61 45
import com.iver.andami.plugins.Extension;
46

  
62 47
import com.iver.cit.gvsig.fmap.DriverException;
63 48
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
64 49
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
......
66 51
import com.iver.cit.gvsig.project.ProjectFactory;
67 52
import com.iver.cit.gvsig.project.ProjectWindow;
68 53
import com.iver.cit.gvsig.project.castor.Project;
54

  
69 55
import com.iver.utiles.GenericFileFilter;
70 56
import com.iver.utiles.XMLEntity;
71 57
import com.iver.utiles.xmlEntity.generate.XmlTag;
72 58

  
59
import org.exolab.castor.xml.MarshalException;
60
import org.exolab.castor.xml.Marshaller;
61
import org.exolab.castor.xml.ValidationException;
62

  
63
import java.awt.Component;
64

  
65
import java.io.File;
66
import java.io.FileNotFoundException;
67
import java.io.FileReader;
68
import java.io.FileWriter;
69

  
70
import java.text.DateFormat;
71

  
72
import java.util.ArrayList;
73
import java.util.Date;
74

  
75
import javax.swing.JFileChooser;
76
import javax.swing.JOptionPane;
77

  
78

  
73 79
/**
74 80
 * Extension que proporciona controles para crear proyectos nuevos, abrirlos y
75 81
 * guardarlos. Adem?s los tipos de tabla que soporta el proyecto son a?adidos
......
78 84
 * @author Fernando Gonz?lez Cort?s
79 85
 */
80 86
public class ProjectExtension implements Extension {
81
    private ArrayList tableExtensions = new ArrayList();
82
    private ProjectWindow projectFrame;
83
    private Project p;
87
	private ArrayList tableExtensions = new ArrayList();
88
	private ProjectWindow projectFrame;
89
	private Project p;
84 90
	private boolean modified = false;
85 91

  
86
    /**
87
     * @see com.iver.mdiApp.plugins.Extension#inicializar()
88
     */
89
    public void inicializar() {
90
        p = ProjectFactory.createProject();
91
        p.setName(PluginServices.getText(this, "untitled"));
92
        p.setModified(false);
93
        projectFrame = new ProjectWindow(this);
94
        projectFrame.setProject(p);
95
        showProjectWindow();
96
        PluginServices.getMainFrame().setTitle("gvSIG: " + PluginServices.getText(this,
97
									 "sin_titulo"));
98
        
99
        LayerFactory.setDriversPath(PluginServices.getPluginServices(this).getPluginDirectory().getAbsolutePath() + File.separator + "drivers");
100
    }
92
	/**
93
	 * @see com.iver.mdiApp.plugins.Extension#inicializar()
94
	 */
95
	public void inicializar() {
96
		p = ProjectFactory.createProject();
97
		p.setName(PluginServices.getText(this, "untitled"));
98
		p.setModified(false);
99
		projectFrame = new ProjectWindow(this);
100
		projectFrame.setProject(p);
101
		showProjectWindow();
102
		PluginServices.getMainFrame().setTitle("gvSIG: " +
103
			PluginServices.getText(this, "sin_titulo"));
101 104

  
102
	public void showProjectWindow(){
105
		LayerFactory.setDriversPath(PluginServices.getPluginServices(this)
106
												  .getPluginDirectory()
107
												  .getAbsolutePath() +
108
			File.separator + "drivers");
109
	}
110

  
111
	/**
112
	 * Muestra la ventana con el gestor de proyectos.
113
	 */
114
	public void showProjectWindow() {
103 115
		PluginServices.getMDIManager().addView(projectFrame);
104 116
	}
105 117

  
106
	private void guardar(){
118
	/**
119
	 * Guarda el proyecto actual en disco.
120
	 */
121
	private void guardar() {
107 122
		if (p.getPath() == null) {
108 123
			JFileChooser jfc = new JFileChooser();
109
			jfc.addChoosableFileFilter(new GenericFileFilter("xml", PluginServices.getText(this,"tipo_fichero_proyecto")));
110
			if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION){
124
			jfc.addChoosableFileFilter(new GenericFileFilter("xml",
125
					PluginServices.getText(this, "tipo_fichero_proyecto")));
126

  
127
			if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
111 128
				escribirProyecto(jfc.getSelectedFile(), p);
112 129
			}
113 130
		} else {
114 131
			escribirProyecto(new File(p.getPath()), p);
115 132
		}
116 133
	}
117
	
118
	private boolean modificado(){
134

  
135
	/**
136
	 * Guarda si el proyecto ha sido modificado.
137
	 *
138
	 * @return True si se ha guardado correctamente.
139
	 */
140
	private boolean modificado() {
119 141
		if (p.isModified()) {
120 142
			int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(),
121 143
					PluginServices.getText(this, "guardar_cambios"),
......
129 151
				return false;
130 152
			}
131 153
		}
132
		
154

  
133 155
		return true;
134 156
	}
135 157

  
136
    /**
137
     * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
138
     */
139
    public void execute(String actionCommand) {
140
            if (actionCommand.equals("NUEVO")) {
141
            	//Si est? modificado se pregunta si se quiere guardar el anterior
142
				if (!modificado()) return;
158
	/**
159
	 * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
160
	 */
161
	public void execute(String actionCommand) {
162
		if (actionCommand.equals("NUEVO")) {
163
			//Si est? modificado se pregunta si se quiere guardar el anterior
164
			if (!modificado()) {
165
				return;
166
			}
143 167

  
168
			PluginServices.getMDIManager().closeAllViews();
169
			p = ProjectFactory.createProject();
170
			p.setName(PluginServices.getText(this, "untitled"));
171
			p.setModified(false);
172
			projectFrame.setProject(p);
173
			showProjectWindow();
174
			PluginServices.getMainFrame().setTitle("gvSIG: " +
175
				PluginServices.getText(this, "sin_titulo"));
176
		} else if (actionCommand.equals("ABRIR")) {
177
			//Si est? modificado se pregunta si se quiere guardar el anterior
178
			if (!modificado()) {
179
				return;
180
			}
181

  
182
			JFileChooser jfc = new JFileChooser();
183
			jfc.addChoosableFileFilter(new GenericFileFilter("xml",
184
					PluginServices.getText(this, "tipo_fichero_proyecto")));
185

  
186
			if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
144 187
				PluginServices.getMDIManager().closeAllViews();
145
                p = ProjectFactory.createProject();
146
                p.setName(PluginServices.getText(this, "untitled"));
147
                p.setModified(false);
148
                projectFrame.setProject(p);
149
                showProjectWindow();
150
                PluginServices.getMainFrame().setTitle("gvSIG: " + PluginServices.getText(this,
151
				 "sin_titulo"));
152 188

  
153
            } else if (actionCommand.equals("ABRIR")) {
154
				//Si est? modificado se pregunta si se quiere guardar el anterior
155
				if (!modificado()) return;
189
				Project o = leerProyecto(jfc.getSelectedFile());
156 190

  
157
				JFileChooser jfc = new JFileChooser();
158
				jfc.addChoosableFileFilter(new GenericFileFilter("xml", PluginServices.getText(this,"tipo_fichero_proyecto")));
159
				if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION){
160
					PluginServices.getMDIManager().closeAllViews();
161
                	Project o = leerProyecto(jfc.getSelectedFile());
162
                	if (o != null){
163
						p = o; 
164
                	}
165
                	projectFrame.setProject(p);
166
                	projectFrame.refreshControls();
167
                	showProjectWindow();
191
				if (o != null) {
192
					p = o;
168 193
				}
169
            } else if (actionCommand.equals("GUARDAR")) {
170
            	guardar();
171
            }
172
    }
173 194

  
174
    private void escribirProyecto(File file, Project p){
175
            // write it out as XML
176
            try {
177
            	FileWriter writer = new FileWriter(file.getAbsolutePath());
178
            	Marshaller m = new Marshaller(writer);
179
            	m.setEncoding("ISO-8859-1");
180
            	m.marshal(p.getXMLEntity().getXmlTag());
181
                p.setPath(file.toString());
182
                p.setModificationDate(DateFormat.getDateInstance().format(new Date()));
183
                p.setModified(false);
184
                PluginServices.getMainFrame().setTitle("gvSIG: " + file.getName());
185
            } catch (Exception e) {
186
                NotificationManager.addError("Error guardando el proyecto", e);
187
            }
188
            projectFrame.refreshControls();
189
    }
195
				projectFrame.setProject(p);
196
				projectFrame.refreshControls();
197
				showProjectWindow();
198
			}
199
		} else if (actionCommand.equals("GUARDAR")) {
200
			guardar();
201
		}
202
	}
190 203

  
191
    /**
192
     * @see com.iver.mdiApp.FileExtension#writeFile(java.io.File)
193
     */
194
    public Project leerProyecto(File file) {
195
    	Project proj = null;
204
	/**
205
	 * Escribe el proyecto en XML.
206
	 *
207
	 * @param file Fichero.
208
	 * @param p Proyecto.
209
	 */
210
	private void escribirProyecto(File file, Project p) {
211
		// write it out as XML
196 212
		try {
197
        	 File xmlFile = new File(file.getAbsolutePath());
198
        	 FileReader reader;
199
				reader = new FileReader(xmlFile);
200
				XmlTag tag=(XmlTag)XmlTag.unmarshal(reader);
201
	        	p=Project.createFromXML(new XMLEntity(tag));
202
			} catch (FileNotFoundException e) {
203
				NotificationManager.addError("Al leer el proyecto",e);
204
			} catch (MarshalException e) {
205
				NotificationManager.addError("Al leer el proyecto",e);
206
			} catch (ValidationException e) {
207
				NotificationManager.addError("Al leer el proyecto",e);
208
			} catch (XMLException e) {
209
				NotificationManager.addError("Al leer el proyecto",e);
210
			} catch (DriverException e) {
211
				NotificationManager.addError("Al leer el proyecto",e);
212
			}catch (DriverIOException e2) {
213
				NotificationManager.addError("Al leer el proyecto",e2);
214
			}
215
        
216
        return proj;
217
    }
213
			FileWriter writer = new FileWriter(file.getAbsolutePath());
214
			Marshaller m = new Marshaller(writer);
215
			m.setEncoding("ISO-8859-1");
216
			m.marshal(p.getXMLEntity().getXmlTag());
217
			p.setPath(file.toString());
218
			p.setModificationDate(DateFormat.getDateInstance().format(new Date()));
219
			p.setModified(false);
220
			PluginServices.getMainFrame().setTitle("gvSIG: " + file.getName());
221
		} catch (Exception e) {
222
			NotificationManager.addError("Error guardando el proyecto", e);
223
		}
218 224

  
219
    /**
220
	 * @return
225
		projectFrame.refreshControls();
226
	}
227

  
228
	/**
229
	 * Lee del XML el proyecto.
230
	 *
231
	 * @param file Fichero.
232
	 *
233
	 * @return Proyecto.
221 234
	 */
235
	public Project leerProyecto(File file) {
236
		Project proj = null;
237

  
238
		try {
239
			File xmlFile = new File(file.getAbsolutePath());
240
			FileReader reader;
241
			reader = new FileReader(xmlFile);
242

  
243
			XmlTag tag = (XmlTag) XmlTag.unmarshal(reader);
244
			p = Project.createFromXML(new XMLEntity(tag));
245
		} catch (FileNotFoundException e) {
246
			NotificationManager.addError("Al leer el proyecto", e);
247
		} catch (MarshalException e) {
248
			NotificationManager.addError("Al leer el proyecto", e);
249
		} catch (ValidationException e) {
250
			NotificationManager.addError("Al leer el proyecto", e);
251
		} catch (XMLException e) {
252
			NotificationManager.addError("Al leer el proyecto", e);
253
		} catch (DriverException e) {
254
			NotificationManager.addError("Al leer el proyecto", e);
255
		} catch (DriverIOException e2) {
256
			NotificationManager.addError("Al leer el proyecto", e2);
257
		}
258

  
259
		return proj;
260
	}
261

  
262
	/**
263
	 * Devuelve el proyecto.
264
	 *
265
	 * @return Proyecto.
266
	 */
222 267
	public Project getProject() {
223 268
		return p;
224 269
	}
......
236 281
	public boolean isVisible() {
237 282
		return true;
238 283
	}
239

  
240 284
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/About.java
48 48

  
49 49
import com.iver.andami.PluginServices;
50 50
import com.iver.andami.plugins.Extension;
51

  
51 52
import com.iver.cit.gvsig.gui.Panels.FPanelAbout;
52 53

  
54

  
53 55
/**
54
 * DOCUMENT ME!
56
 * Extensi?n que abre una nueva ventana mostrando la informaci?n sobre el
57
 * gvSIG.
55 58
 *
56 59
 * @author Francisco Jos? Pe?arrubia
57 60
 */
58
public class About implements Extension{
59

  
61
public class About implements Extension {
60 62
	/**
61
	 * DOCUMENT ME!
62
	 *
63
	 * @return DOCUMENT ME!
63
	 * @see com.iver.andami.plugins.Extension#isEnabled()
64 64
	 */
65 65
	public boolean isEnabled() {
66

  
67 66
		return true;
68 67
	}
69 68

  
70 69
	/**
71
	 * DOCUMENT ME!
72
	 *
73
	 * @return DOCUMENT ME!
70
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
74 71
	 */
75 72
	public boolean isVisible() {
76 73
		return true;
......
86 83
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
87 84
	 */
88 85
	public void execute(String actionCommand) {
89
        FPanelAbout panelAbout = new FPanelAbout();
90
        // panelAbout.setPreferredSize(panelAbout.getSize());                
91
    	
86
		FPanelAbout panelAbout = new FPanelAbout();
87

  
88
		// panelAbout.setPreferredSize(panelAbout.getSize());                
92 89
		PluginServices.getMDIManager().addView(panelAbout);
93 90
	}
94
}
91
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/LinkControls.java
46 46
 */
47 47
package com.iver.cit.gvsig;
48 48

  
49
import org.apache.log4j.Logger;
50

  
51 49
import com.iver.andami.PluginServices;
52 50
import com.iver.andami.plugins.Extension;
51

  
53 52
import com.iver.cit.gvsig.fmap.FMap;
54 53
import com.iver.cit.gvsig.fmap.NewMapControl;
55 54
import com.iver.cit.gvsig.fmap.layers.FLayer;
56 55
import com.iver.cit.gvsig.gui.View;
57 56
import com.iver.cit.gvsig.project.castor.ProjectView;
58 57

  
58
import org.apache.log4j.Logger;
59 59

  
60

  
60 61
/**
61 62
 * Extensi?n para gestionar los hiperlinks.
62 63
 *
63 64
 * @author Vicente Caballero Navarro
64 65
 */
65 66
public class LinkControls implements Extension {
66
    private static Logger logger = Logger.getLogger(ViewControls.class.getName());
67
	private static Logger logger = Logger.getLogger(LinkControls.class.getName());
67 68

  
68
    /**
69
     * DOCUMENT ME!
70
     *
71
     * @param status DOCUMENT ME!
72
     * @param s DOCUMENT ME!
73
     */
74
    public void execute(String s) {
75
    	 View vista = (View) PluginServices.getMDIManager().getActiveView();
76
         ProjectView model=vista.getModel();
77
         FMap mapa = model.getMapContext();
78
         NewMapControl mapCtrl = vista.getMapControl();
79
        logger.debug("Comand : " + s);
80
        if (s.compareTo("LINK") == 0) {
81
        	mapCtrl.setTool("link");
82
        }
83
    }
69
	/**
70
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
71
	 */
72
	public void execute(String s) {
73
		View vista = (View) PluginServices.getMDIManager().getActiveView();
74
		ProjectView model = vista.getModel();
75
		FMap mapa = model.getMapContext();
76
		NewMapControl mapCtrl = vista.getMapControl();
77
		logger.debug("Comand : " + s);
84 78

  
85
    /**
86
     * @see com.iver.mdiApp.plugins.Extension#isVisible()
87
     */
88
    public boolean isVisible() {
89
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager().getActiveView();
90
        if (f == null) {
91
            return false;
92
        }
79
		if (s.compareTo("LINK") == 0) {
80
			mapCtrl.setTool("link");
81
		}
82
	}
93 83

  
94
        if (f.getClass() == View.class) {
95
            FMap mapa = ((View) f).getModel().getMapContext();
84
	/**
85
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
86
	 */
87
	public boolean isVisible() {
88
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
89
															 .getActiveView();
96 90

  
97
            View v = (View) f;
91
		if (f == null) {
92
			return false;
93
		}
98 94

  
99
            return mapa.getLayers().getLayersCount() > 0;
100
        } else {
101
            return false;
102
        }
103
    }
95
		if (f.getClass() == View.class) {
96
			FMap mapa = ((View) f).getModel().getMapContext();
104 97

  
105
    /**
106
     * DOCUMENT ME!
107
     *
108
     * @return DOCUMENT ME!
109
     */
110
    public boolean isEnabled() {
111
        View f = (View) PluginServices.getMDIManager().getActiveView();
98
			View v = (View) f;
112 99

  
113
        if (f == null) {
114
            return false;
115
        }
100
			return mapa.getLayers().getLayersCount() > 0;
101
		} else {
102
			return false;
103
		}
104
	}
116 105

  
117
        FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
106
	/**
107
	 * @see com.iver.andami.plugins.Extension#isEnabled()
108
	 */
109
	public boolean isEnabled() {
110
		View f = (View) PluginServices.getMDIManager().getActiveView();
118 111

  
119
        return selected.length > 0;
120
    }
112
		if (f == null) {
113
			return false;
114
		}
121 115

  
116
		FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
117

  
118
		return selected.length > 0;
119
	}
120

  
122 121
	/**
123 122
	 * @see com.iver.andami.plugins.Extension#inicializar()
124 123
	 */
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ZoomPrev.java
42 42

  
43 43
import com.iver.andami.PluginServices;
44 44
import com.iver.andami.plugins.Extension;
45

  
45 46
import com.iver.cit.gvsig.fmap.FMap;
46 47
import com.iver.cit.gvsig.fmap.ViewPort;
47 48
import com.iver.cit.gvsig.gui.View;
48 49

  
49 50

  
51
/**
52
 * Extensi?n que cambia el extent de la vista al extent anterior.
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
50 56
public class ZoomPrev implements Extension {
51

  
52 57
	/**
53 58
	 * @see com.iver.mdiApp.plugins.Extension#isEnabled()
54 59
	 */
55 60
	public boolean isEnabled() {
56 61
		View vista = (View) PluginServices.getMDIManager().getActiveView();
57 62
		ViewPort vp = vista.getModel().getMapContext().getViewPort();
63

  
58 64
		return vp.getExtents().hasPrevious();
59 65
	}
60 66

  
......
62 68
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
63 69
	 */
64 70
	public boolean isVisible() {
65
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager().getActiveView();
71
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
72
															 .getActiveView();
66 73

  
67 74
		if (f == null) {
68 75
			return false;
......
72 79
			View v = (View) f;
73 80

  
74 81
			FMap mapa = v.getModel().getMapContext();
82

  
75 83
			return mapa.getLayers().getLayersCount() > 0;
76 84
		} else {
77 85
			return false;
......
92 100
	 */
93 101
	public void inicializar() {
94 102
	}
95

  
96 103
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/Export.java
71 71

  
72 72

  
73 73
/**
74
 * DOCUMENT ME!
74
 * Extensi?n para exportar en algunos formatos raster la vista actual.
75 75
 *
76 76
 * @author Fernando Gonz?lez Cort?s
77 77
 */
78 78
public class Export implements Extension {
79 79
	/**
80
	 * DOCUMENT ME!
81
	 *
82
	 * @return DOCUMENT ME!
80
	 * @see com.iver.andami.plugins.Extension#isEnabled()
83 81
	 */
84 82
	public boolean isEnabled() {
85 83
		View f = (View) PluginServices.getMDIManager().getActiveView();
......
92 90
	}
93 91

  
94 92
	/**
95
	 * DOCUMENT ME!
96
	 *
97
	 * @return DOCUMENT ME!
93
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
98 94
	 */
99 95
	public boolean isVisible() {
100
		com.iver.andami.ui.mdiManager.View f = (com.iver.andami.ui.mdiManager.View) PluginServices.getMDIManager().getActiveView();
96
		com.iver.andami.ui.mdiManager.View f = (com.iver.andami.ui.mdiManager.View) PluginServices.getMDIManager()
97
																								  .getActiveView();
101 98

  
102 99
		if (f == null) {
103 100
			return false;
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/Tabla.java
46 46
 */
47 47
package com.iver.cit.gvsig;
48 48

  
49
import com.hardcode.driverManager.DriverLoadException;
50 49
import com.iver.andami.PluginServices;
51 50
import com.iver.andami.messages.NotificationManager;
52 51
import com.iver.andami.plugins.Extension;
......
61 60

  
62 61

  
63 62
/**
64
 * DOCUMENT ME!
63
 * Extensi?n que abre las tablas asociadas a las vistas.
65 64
 *
66
 * @author vcn To change the template for this generated type comment go to
67
 * 		   Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
68
 * 		   Comments
65
 * @author Vicente Caballero Navarro
66
 * 
69 67
 */
70 68
public class Tabla implements Extension {
71 69
	/**
72
	 * DOCUMENT ME!
73
	 *
74
	 * @return DOCUMENT ME!
70
	 * @see com.iver.andami.plugins.Extension#isEnabled()
75 71
	 */
76 72
	public boolean isEnabled() {
77 73
		View f = (View) PluginServices.getMDIManager().getActiveView();
......
99 95
	}
100 96

  
101 97
	/**
102
	 * DOCUMENT ME!
103
	 *
104
	 * @return DOCUMENT ME!
98
	 * @see com.iver.andami.plugins.Extension#isVisible()
105 99
	 */
106 100
	public boolean isVisible() {
107 101
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
......
115 109
	}
116 110

  
117 111
	/**
118
	 * DOCUMENT ME!
119
	 *
120
	 * @param status DOCUMENT ME!
121
	 * @param s DOCUMENT ME!
112
	 * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
122 113
	 */
123 114
	public void execute(String s) {
124 115
		View vista = (View) PluginServices.getMDIManager().getActiveView();
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ThemeControls.java
46 46
 */
47 47
package com.iver.cit.gvsig;
48 48

  
49
import java.awt.Component;
50
import java.awt.geom.Rectangle2D;
51
import java.util.BitSet;
52

  
53
import javax.swing.JFileChooser;
54

  
55
import org.apache.log4j.Logger;
56

  
57 49
import com.iver.andami.PluginServices;
58 50
import com.iver.andami.plugins.Extension;
51

  
59 52
import com.iver.cit.gvsig.fmap.FMap;
60 53
import com.iver.cit.gvsig.fmap.NewMapControl;
61 54
import com.iver.cit.gvsig.fmap.drivers.shp.SHP;
......
63 56
import com.iver.cit.gvsig.fmap.layers.layerOperations.Selectable;
64 57
import com.iver.cit.gvsig.gui.View;
65 58
import com.iver.cit.gvsig.project.castor.ProjectView;
59

  
66 60
import com.iver.utiles.GenericFileFilter;
67 61

  
62
import org.apache.log4j.Logger;
68 63

  
64
import java.awt.Component;
65
import java.awt.geom.Rectangle2D;
66
import java.io.File;
67

  
68
import java.util.BitSet;
69

  
70
import javax.swing.JFileChooser;
71

  
72

  
69 73
/**
70
 * Propiedades del tema.
74
 * Extensi?n de operaciones sobre el tema.
71 75
 *
72 76
 * @author Vicente Caballero Navarro
73 77
 */
74 78
public class ThemeControls implements Extension {
75
    private static Logger logger = Logger.getLogger(ViewControls.class.getName());
79
	private static Logger logger = Logger.getLogger(ThemeControls.class.getName());
76 80

  
77
    /**
78
     * DOCUMENT ME!
79
     *
80
     * @param status DOCUMENT ME!
81
     * @param s DOCUMENT ME!
82
     */
83
    public void execute(String s) {
84
        View vista = (View) PluginServices.getMDIManager().getActiveView();
85
       	ProjectView model = vista.getModel();
81
	/**
82
	 * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
83
	 */
84
	public void execute(String s) {
85
		View vista = (View) PluginServices.getMDIManager().getActiveView();
86
		ProjectView model = vista.getModel();
86 87
		FMap mapa = model.getMapContext();
87 88
		NewMapControl mapCtrl = vista.getMapControl();
88 89
		logger.debug("Comand : " + s);
89
        if (s.compareTo("PROPERTIES") == 0){
90
        	vista.openThemeProperties();
91
        }else if (s.compareTo("SHAPE_SELECTED") == 0) {
90

  
91
		if (s.compareTo("PROPERTIES") == 0) {
92
			vista.openThemeProperties();
93
		} else if (s.compareTo("SHAPE_SELECTED") == 0) {
92 94
			createShape(mapa);
93
		}else if (s.compareTo("DEL_SELECTION") == 0) {
94
			boolean refresh=false;
95
			for (int i=0; i<mapa.getLayers().getLayersCount();i++){
96
			if (mapa.getLayers().getLayer(i) instanceof Selectable){
97
				if (mapa.getLayers().getLayer(i).isActive()){
98
				BitSet bitset=((Selectable)mapa.getLayers().getLayer(i)).getSelection();
99
				if (bitset.cardinality()!=0){
100
					refresh=true;
95
		} else if (s.compareTo("DEL_SELECTION") == 0) {
96
			boolean refresh = false;
97

  
98
			for (int i = 0; i < mapa.getLayers().getLayersCount(); i++) {
99
				if (mapa.getLayers().getLayer(i) instanceof Selectable) {
100
					if (mapa.getLayers().getLayer(i).isActive()) {
101
						BitSet bitset = ((Selectable) mapa.getLayers().getLayer(i)).getSelection();
102

  
103
						if (bitset.cardinality() != 0) {
104
							refresh = true;
105
						}
106

  
107
						bitset.clear();
108
					}
101 109
				}
102
				bitset.clear();
103
				}
104 110
			}
111

  
112
			if (refresh) {
113
				mapCtrl.drawMap(false);
105 114
			}
106
			if (refresh) mapCtrl.drawMap(false);
107
			
108
		}else if (s.compareTo("ZOOM_SELECT") == 0) {
115
		} else if (s.compareTo("ZOOM_SELECT") == 0) {
109 116
			Rectangle2D selectedExtent = mapa.getSelectionBounds();
110 117

  
111 118
			if (selectedExtent != null) {
112 119
				mapa.getViewPort().setExtent(selectedExtent);
113 120
			}
114 121
		}
115
    }
116
    private void createShape(FMap map){
122
	}
123

  
124
	/**
125
	 * Crea un nuevo shape.
126
	 *
127
	 * @param map FMap de donde coger las capas a copiar.
128
	 */
129
	private void createShape(FMap map) {
117 130
		if (map.getSelectionBounds() != null) {
118 131
			JFileChooser jfc = new JFileChooser();
119
			jfc.addChoosableFileFilter(new GenericFileFilter("shp", PluginServices.getText(this,"ShapeFile")));
120
			if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION){
121
				SHP.SHPFileFromSelected(map,jfc.getSelectedFile());
132
			jfc.addChoosableFileFilter(new GenericFileFilter("shp",
133
					PluginServices.getText(this, "ShapeFile")));
134

  
135
			if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
136
				File file=jfc.getSelectedFile();
137
				if (!(file.getPath().endsWith(".shp") || file.getPath().endsWith(".SHP"))){
138
					file=new File(file.getPath()+".shp");
139
				}
140
				SHP.SHPFileFromSelected(map, file);
122 141
			}
123
		}// else {
142
		} // else {
143

  
124 144
		//}
145
	}
146

  
147
	/**
148
	 * @see com.iver.mdiApp.plugins.Extension#isVisible()
149
	 */
150
	public boolean isVisible() {
151
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
152
															 .getActiveView();
153

  
154
		if (f == null) {
155
			return false;
125 156
		}
126
    /**
127
     * @see com.iver.mdiApp.plugins.Extension#isVisible()
128
     */
129
    public boolean isVisible() {
130
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
131
                                                           .getActiveView();
132
        
133
        if (f == null) {
134
            return false;
135
        }
136 157

  
137
        if (f.getClass() == View.class) {
138
            FMap mapa = ((View) f).getModel().getMapContext();
158
		if (f.getClass() == View.class) {
159
			FMap mapa = ((View) f).getModel().getMapContext();
139 160

  
140
            View v = (View) f;
161
			View v = (View) f;
141 162

  
142
            return mapa.getLayers().getLayersCount() > 0;
143
        } else {
144
            return false;
145
        }
146
    }
163
			return mapa.getLayers().getLayersCount() > 0;
164
		} else {
165
			return false;
166
		}
167
	}
147 168

  
148
    /**
149
     * DOCUMENT ME!
150
     *
151
     * @return DOCUMENT ME!
152
     */
153
    public boolean isEnabled() {
154
        View f = (View) PluginServices.getMDIManager().getActiveView();
169
	/**
170
	 * @see com.iver.andami.plugins.Extension#isEnabled()
171
	 */
172
	public boolean isEnabled() {
173
		View f = (View) PluginServices.getMDIManager().getActiveView();
155 174

  
156
        if (f == null) {
157
            return false;
158
        }
175
		if (f == null) {
176
			return false;
177
		}
159 178

  
160
        FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
179
		FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
161 180

  
162
        return selected.length > 0;
163
    }
181
		return selected.length > 0;
182
	}
164 183

  
165 184
	/**
166 185
	 * @see com.iver.andami.plugins.Extension#inicializar()
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ViewProjectWindow.java
44 44
import com.iver.andami.plugins.Extension;
45 45

  
46 46

  
47

  
47
/**
48
 * Extensi?n que abre la ventana de gestor de proyecto.
49
 *
50
 * @author Vicente Caballero Navarro
51
 */
48 52
public class ViewProjectWindow implements Extension {
49 53
	/**
50 54
	 * @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
......
73 77
	public boolean isVisible() {
74 78
		return true;
75 79
	}
76

  
77 80
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableOperations.java
40 40
 */
41 41
package com.iver.cit.gvsig;
42 42

  
43
import java.io.IOException;
43
import com.hardcode.driverManager.DriverLoadException;
44 44

  
45
import com.hardcode.driverManager.DriverLoadException;
46 45
import com.hardcode.gdbms.engine.data.DataSource;
47 46
import com.hardcode.gdbms.engine.data.DataSourceFactory;
48 47
import com.hardcode.gdbms.engine.instruction.SemanticException;
49 48
import com.hardcode.gdbms.parser.ParseException;
49

  
50 50
import com.iver.andami.PluginServices;
51 51
import com.iver.andami.messages.NotificationManager;
52 52
import com.iver.andami.plugins.Extension;
53 53
import com.iver.andami.ui.mdiManager.View;
54

  
54 55
import com.iver.cit.gvsig.fmap.DriverException;
55 56
import com.iver.cit.gvsig.fmap.layers.FBitSet;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff