Revision 6888

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/Project.java
45 45
import java.beans.PropertyChangeListener;
46 46
import java.beans.PropertyChangeSupport;
47 47
import java.io.Serializable;
48
import java.lang.reflect.Field;
49
import java.lang.reflect.Modifier;
48 50
import java.text.DateFormat;
49 51
import java.util.ArrayList;
50 52
import java.util.Date;
......
84 86
import com.iver.cit.gvsig.gui.project.SaveException;
85 87
import com.iver.utiles.PostProcessSupport;
86 88
import com.iver.utiles.StringUtilities;
89
import com.iver.utiles.Utils;
87 90
import com.iver.utiles.XMLEntity;
88 91

  
89 92

  
......
99 102
	private PropertyChangeSupport change;
100 103
	boolean modified = false;
101 104
	private String name;
102
	private String path;
105
	//private String path;
103 106
	private String creationDate;
104 107
	private String modificationDate;
105 108
	private String owner;
......
109 112
	private ArrayList tables = new ArrayList();
110 113
	private ArrayList maps = new ArrayList();
111 114
	private ArrayList extents = new ArrayList();
115
	private int signatureAtStartup;
112 116
	// used to restore the position of the Project Manager window when loading a project from file
113 117
	private static WindowInfo seedProjectWindow = null;
114 118

  
119

  
115 120
	/**
116 121
	 * Creates a new Project object.
117 122
	 */
......
121 126
		//        change.addPropertyChangeListener(this);
122 127
		creationDate = DateFormat.getDateInstance().format(new Date());
123 128
		modificationDate = creationDate;
129
//		signatureAtStartup = computeSignature();
124 130

  
125 131
		/*                LayerFactory.setDriversPath(PluginServices.getPluginServices(this)
126 132
		   .getPluginDirectory()
......
147 153
		return name;
148 154
	}
149 155

  
150
	/**
151
	 * Obtiene la ruta completa del fichero donde se guardo por ?ltima vez el
152
	 * proyecto
153
	 *
154
	 * @return
155
	 */
156
	public String getPath() {
157
		return path;
158
	}
156
//	/**
157
//	 * Obtiene la ruta completa del fichero donde se guardo por ?ltima vez el
158
//	 * proyecto
159
//	 *
160
//	 * @return
161
//	 */
162
//	public String getPath() {
163
//		return path;
164
//	}
159 165

  
160 166
	/**
161 167
	 * Asigna la fecha de creaci?n del proyecto. Este m?todo tiene sentido s?lo
......
206 212
		change.firePropertyChange("", null, null);
207 213
	}
208 214

  
209
	/**
210
	 * establece la ruta completa de donde se encuentra guardado el proyecto
211
	 *
212
	 * @param string
213
	 */
214
	public void setPath(String string) {
215
		path = string;
216
		modified = true;
217
		change.firePropertyChange("", null, null);
218
	}
215
//	/**
216
//	 * establece la ruta completa de donde se encuentra guardado el proyecto
217
//	 *
218
//	 * @param string
219
//	 */
220
//	public void setPath(String string) {
221
//		path = string;
222
//		modified = true;
223
//		change.firePropertyChange("", null, null);
224
//	}
219 225

  
220 226
	/**
221 227
	 * DOCUMENT ME!
......
610 616
		xml.putProperty("modified", modified);
611 617
		xml.putProperty("name", name);
612 618
		xml.putProperty("owner", owner);
613
		xml.putProperty("path", path);
619
		//xml.putProperty("path", path);
614 620
		xml.putProperty("selectionColor",
615 621
			StringUtilities.color2String(selectionColor));
616 622

  
......
635 641
				ProjectWindow pw = (ProjectWindow) andamiViews[i];
636 642
				try {
637 643
					XMLEntity xmlchild = null;
638
					xmlchild = getViewInfoXMLEntity(pw);
644
					xmlchild = getWindowInfoXMLEntity(pw);
639 645
					if (xmlchild!=null) {
640 646
						xml.addChild(xmlchild);
641 647
					}
......
693 699
		p.modified = xml.getBooleanProperty("modified");
694 700
		p.name = xml.getStringProperty("name");
695 701
		p.owner = xml.getStringProperty("owner");
696
		p.path = xml.getStringProperty("path");
702
//		p.path = xml.getStringProperty("path");
697 703
		p.selectionColor = StringUtilities.string2Color(xml.getStringProperty(
698 704
					"selectionColor"));
699 705

  
......
822 828
		p.modified = xml.getBooleanProperty("modified");
823 829
		p.name = xml.getStringProperty("name");
824 830
		p.owner = xml.getStringProperty("owner");
825
		p.path = xml.getStringProperty("path");
831
//		p.path = xml.getStringProperty("path");
826 832
		p.selectionColor = StringUtilities.string2Color(xml.getStringProperty(
827 833
					"selectionColor"));
828 834

  
......
866 872
		}catch (Exception e) {
867 873
			throw new OpenException(e,p.getClass().getName());
868 874
		}
875
//		p.setSignature( p.hashCode());
869 876
		return p;
870 877

  
871 878
	}
872 879

  
880
//	private void setSignature(int signature) {
881
//		this.signatureAtStartup = computeSignature();
882
//	}
883

  
873 884
	/**
874 885
	 * Reestablece los link que ten?a cada tabla con las dem?s.
875 886
	 */
......
927 938

  
928 939
		throw new RuntimeException("The layer is not in a view");
929 940
	}
930
	public boolean isView(FLayers layers,FLayer layer) {
931
			for (int i = 0; i < layers.getLayersCount(); i++) {
932
				if (layers.getLayer(i) instanceof FLayers){
933
					return isView((FLayers)layers.getLayer(i),layer);
934
				}else{
941

  
942
	public boolean isView(FLayers layers, FLayer layer) {
943
		for (int i = 0; i < layers.getLayersCount(); i++) {
944
			if (layers.getLayer(i) instanceof FLayers){
945
				return isView((FLayers)layers.getLayer(i),layer);
946
			}else{
935 947
				if (layers.getLayer(i) == layer) {
936 948
					return true;
937 949
				}
938
				}
939 950
			}
940
			return false;
951
		}
952
		return false;
941 953
	}
954

  
942 955
	/**
943 956
	 * Devuelve la vista cuyo nombre coincide (sensible a mayusculas) con el
944 957
	 * que se pasa como par?metro. Devuelve null si no hay ninguna vista con
......
1164 1177
	 * @throws XMLException
1165 1178
	 * @throws SaveException
1166 1179
	 */
1167
	public XMLEntity getViewInfoXMLEntity(com.iver.andami.ui.mdiManager.IWindow view) throws SaveException {
1168
		if (view!=null && PluginServices.getMDIManager().getWindowInfo(view)!=null) {
1169
			WindowInfo vi = PluginServices.getMDIManager().getWindowInfo(view);
1180
	public XMLEntity getWindowInfoXMLEntity(IWindow window) throws SaveException {
1181
		if (window!=null && PluginServices.getMDIManager().getWindowInfo(window)!=null) {
1182
			WindowInfo vi = PluginServices.getMDIManager().getWindowInfo(window);
1170 1183
			XMLEntity xml = new XMLEntity();
1171 1184
			//xml.putProperty("nameClass", this.getClass().getName());
1172 1185
			try{
......
1198 1211
			return null;
1199 1212
	}
1200 1213

  
1201
	public static WindowInfo createViewInfoFromXMLEntity(XMLEntity xml)
1214
	public static WindowInfo createWindowInfoFromXMLEntity(XMLEntity xml)
1202 1215
	{
1203 1216
		WindowInfo result = new WindowInfo();
1204 1217
		result.setX(xml.getIntProperty("X"));
......
1254 1267

  
1255 1268
		return child;
1256 1269
	}
1270

  
1271
//	public boolean hasChanged() {
1272
//		return signatureAtStartup != computeSignature();
1273
//	}
1274

  
1275
//	public int computeSignature() {
1276
//
1277
////		/* TODO method also present in ProjectMap, ProjectTable,
1278
////		 *  ProjectView and ProjectExtent
1279
////		 */
1280
//		int result = 17;
1281
////
1282
////		Class clazz = getClass();
1283
////		Field[] fields = clazz.getDeclaredFields();
1284
////		for (int i = 0; i < fields.length; i++) {
1285
////			try {
1286
////				// don't compute following fields
1287
////				if (fields[i].getName().equals("modificationDate")
1288
////						|| fields[i].getName().equals("creationDate")
1289
////						|| fields[i].getName().equals("signatureAtStartup")
1290
////						|| fields[i].getName().equals("change")
1291
////						|| Modifier.isStatic(fields[i].getModifiers()))
1292
////					continue;
1293
////
1294
////
1295
////				String type = fields[i].getType().getName();
1296
////				if (type.equals("boolean")) {
1297
////					result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
1298
////				} else if (type.equals("java.lang.String")) {
1299
////					Object v = fields[i].get(this);
1300
////					if (v == null) {
1301
////						result += 37;
1302
////						continue;
1303
////					}
1304
////					char[] chars = ((String) v).toCharArray();
1305
////					for (int j = 0; j < chars.length; j++) {
1306
////						result += 37 + (int) chars[i];
1307
////					}
1308
////				} else if (type.equals("byte")) {
1309
////					result += 37 + (int) fields[i].getByte(this);
1310
////				} else if (type.equals("char")) {
1311
////					result += 37 + (int) fields[i].getChar(this);
1312
////				} else if (type.equals("short")) {
1313
////					result += 37 + (int) fields[i].getShort(this);
1314
////				} else if (type.equals("int")) {
1315
////					result += 37 + fields[i].getInt(this);
1316
////				} else if (type.equals("long")) {
1317
////					long f = fields[i].getLong(this) ;
1318
////					result += 37 + (f ^ (f >>> 32));
1319
////				} else if (type.equals("float")) {
1320
////					result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
1321
////				} else if (type.equals("double")) {
1322
////					long f = Double.doubleToLongBits(fields[i].getDouble(this));
1323
////					result += 37 + (f ^ (f >>> 32));
1324
////				} else {
1325
//////					Object obj = fields[i].get(this);
1326
//////					result += 37 + ((obj != null)? obj.hashCode() : 0);
1327
////				}
1328
////			} catch (Exception e) { e.printStackTrace(); }
1329
////
1330
////		}
1331
////
1332
////		for (int i = 0; i < views.size(); i++) {
1333
////			ProjectView e = (ProjectView) views.get(i);
1334
////			result += 37 + e.computeSignature();
1335
////		}
1336
////
1337
////		for (int i = 0; i < tables.size(); i++) {
1338
////			ProjectTable e = (ProjectTable) tables.get(i);
1339
////			result += 37 + e.computeSignature();
1340
////		}
1341
////
1342
////		for (int i = 0; i < maps.size(); i++) {
1343
////			ProjectMap e = (ProjectMap) maps.get(i);
1344
////			result += 37 + e.computeSignature();
1345
////		}
1346
////
1347
////		for (int i = 0; i < extents.size(); i++) {
1348
////			ProjectExtent e = (ProjectExtent) extents.get(i);
1349
////			result += 37 + e.computeSignature();
1350
////		}
1351
//
1352
//
1353
//		return result;
1354
//	}
1355

  
1257 1356
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectExtent.java
43 43
import com.iver.utiles.XMLEntity;
44 44

  
45 45
import java.awt.geom.Rectangle2D;
46
import java.lang.reflect.Field;
46 47

  
47 48

  
48 49
/**
......
169 170

  
170 171
        return pe;
171 172
    }
173

  
174
//	public int computeSignature() {
175
//		int result = 17;
176
//
177
//		Class clazz = getClass();
178
//		Field[] fields = clazz.getDeclaredFields();
179
//		for (int i = 0; i < fields.length; i++) {
180
//			try {
181
//				String type = fields[i].getType().getName();
182
//				if (type.equals("boolean")) {
183
//					result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
184
//				} else if (type.equals("java.lang.String")) {
185
//					Object v = fields[i].get(this);
186
//					if (v == null) {
187
//						result += 37;
188
//						continue;
189
//					}
190
//					char[] chars = ((String) v).toCharArray();
191
//					for (int j = 0; j < chars.length; j++) {
192
//						result += 37 + (int) chars[i];
193
//					}
194
//				} else if (type.equals("byte")) {
195
//					result += 37 + (int) fields[i].getByte(this);
196
//				} else if (type.equals("char")) {
197
//					result += 37 + (int) fields[i].getChar(this);
198
//				} else if (type.equals("short")) {
199
//					result += 37 + (int) fields[i].getShort(this);
200
//				} else if (type.equals("int")) {
201
//					result += 37 + fields[i].getInt(this);
202
//				} else if (type.equals("long")) {
203
//					long f = fields[i].getLong(this) ;
204
//					result += 37 + (f ^ (f >>> 32));
205
//				} else if (type.equals("float")) {
206
//					result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
207
//				} else if (type.equals("double")) {
208
//					long f = Double.doubleToLongBits(fields[i].getDouble(this));
209
//					result += 37 + (f ^ (f >>> 32));
210
//				} else {
211
//					Object obj = fields[i].get(this);
212
//					result += 37 + ((obj != null)? obj.hashCode() : 0);
213
//				}
214
//			} catch (Exception e) { e.printStackTrace(); }
215
//
216
//		}
217
//		return result;
218
//	}
172 219
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectTable.java
41 41
package com.iver.cit.gvsig.project;
42 42

  
43 43
import java.io.IOException;
44
import java.lang.reflect.Field;
44 45
import java.text.DateFormat;
45 46
import java.util.ArrayList;
46 47
import java.util.Date;
......
799 800
	public int getColumnCount() {
800 801
		return columns.size();
801 802
	}
803

  
804
//	public int computeSignature() {
805
//		int result = 17;
806
//
807
//		Class clazz = getClass();
808
//		Field[] fields = clazz.getDeclaredFields();
809
//		for (int i = 0; i < fields.length; i++) {
810
//			try {
811
//				String type = fields[i].getType().getName();
812
//				if (type.equals("boolean")) {
813
//					result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
814
//				} else if (type.equals("java.lang.String")) {
815
//					Object v = fields[i].get(this);
816
//					if (v == null) {
817
//						result += 37;
818
//						continue;
819
//					}
820
//					char[] chars = ((String) v).toCharArray();
821
//					for (int j = 0; j < chars.length; j++) {
822
//						result += 37 + (int) chars[i];
823
//					}
824
//				} else if (type.equals("byte")) {
825
//					result += 37 + (int) fields[i].getByte(this);
826
//				} else if (type.equals("char")) {
827
//					result += 37 + (int) fields[i].getChar(this);
828
//				} else if (type.equals("short")) {
829
//					result += 37 + (int) fields[i].getShort(this);
830
//				} else if (type.equals("int")) {
831
//					result += 37 + fields[i].getInt(this);
832
//				} else if (type.equals("long")) {
833
//					long f = fields[i].getLong(this) ;
834
//					result += 37 + (f ^ (f >>> 32));
835
//				} else if (type.equals("float")) {
836
//					result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
837
//				} else if (type.equals("double")) {
838
//					long f = Double.doubleToLongBits(fields[i].getDouble(this));
839
//					result += 37 + (f ^ (f >>> 32));
840
//				} else {
841
//					Object obj = fields[i].get(this);
842
//					result += 37 + ((obj != null)? obj.hashCode() : 0);
843
//				}
844
//			} catch (Exception e) { e.printStackTrace(); }
845
//
846
//		}
847
//		return result;
848
//	}
802 849
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectElement.java
410 410
	
411 411
	public static WindowInfo createViewInfoFromXMLEntity(XMLEntity xml)
412 412
	{
413
		return Project.createViewInfoFromXMLEntity(xml);
413
		return Project.createWindowInfoFromXMLEntity(xml);
414 414
	}
415 415
	
416 416
	public WindowInfo getSeedViewInfo() {
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectView.java
42 42

  
43 43
import java.awt.Color;
44 44
import java.awt.Component;
45
import java.lang.reflect.Field;
45 46
import java.text.DateFormat;
46 47
import java.util.Date;
47 48

  
......
364 365
					e.getMessage());
365 366

  
366 367
	}
368

  
369
//	public int computeSignature() {
370
//		int result = 17;
371
//
372
//		Class clazz = getClass();
373
//		Field[] fields = clazz.getDeclaredFields();
374
//		for (int i = 0; i < fields.length; i++) {
375
//			try {
376
//				String type = fields[i].getType().getName();
377
//				if (type.equals("boolean")) {
378
//					result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
379
//				} else if (type.equals("java.lang.String")) {
380
//					Object v = fields[i].get(this);
381
//					if (v == null) {
382
//						result += 37;
383
//						continue;
384
//					}
385
//					char[] chars = ((String) v).toCharArray();
386
//					for (int j = 0; j < chars.length; j++) {
387
//						result += 37 + (int) chars[i];
388
//					}
389
//				} else if (type.equals("byte")) {
390
//					result += 37 + (int) fields[i].getByte(this);
391
//				} else if (type.equals("char")) {
392
//					result += 37 + (int) fields[i].getChar(this);
393
//				} else if (type.equals("short")) {
394
//					result += 37 + (int) fields[i].getShort(this);
395
//				} else if (type.equals("int")) {
396
//					result += 37 + fields[i].getInt(this);
397
//				} else if (type.equals("long")) {
398
//					long f = fields[i].getLong(this) ;
399
//					result += 37 + (f ^ (f >>> 32));
400
//				} else if (type.equals("float")) {
401
//					result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
402
//				} else if (type.equals("double")) {
403
//					long f = Double.doubleToLongBits(fields[i].getDouble(this));
404
//					result += 37 + (f ^ (f >>> 32));
405
//				} else {
406
//					Object obj = fields[i].get(this);
407
//					result += 37 + ((obj != null)? obj.hashCode() : 0);
408
//				}
409
//			} catch (Exception e) { e.printStackTrace(); }
410
//
411
//		}
412
//		return result;
413
//	}
367 414
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectMap.java
49 49

  
50 50
import com.iver.utiles.XMLEntity;
51 51

  
52
import java.lang.reflect.Field;
52 53
import java.text.DateFormat;
53 54

  
54 55
import java.util.Date;
......
167 168
		numMaps = xml.getIntProperty("numMaps");
168 169
		model = Layout.createLayout03(xml.getChild(0), p);
169 170
	}
171

  
172
//	public int computeSignature() {
173
//		int result = 17;
174
//
175
//		Class clazz = getClass();
176
//		Field[] fields = clazz.getDeclaredFields();
177
//		for (int i = 0; i < fields.length; i++) {
178
//			try {
179
//				String type = fields[i].getType().getName();
180
//				if (type.equals("boolean")) {
181
//					result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
182
//				} else if (type.equals("java.lang.String")) {
183
//					Object v = fields[i].get(this);
184
//					if (v == null) {
185
//						result += 37;
186
//						continue;
187
//					}
188
//					char[] chars = ((String) v).toCharArray();
189
//					for (int j = 0; j < chars.length; j++) {
190
//						result += 37 + (int) chars[i];
191
//					}
192
//				} else if (type.equals("byte")) {
193
//					result += 37 + (int) fields[i].getByte(this);
194
//				} else if (type.equals("char")) {
195
//					result += 37 + (int) fields[i].getChar(this);
196
//				} else if (type.equals("short")) {
197
//					result += 37 + (int) fields[i].getShort(this);
198
//				} else if (type.equals("int")) {
199
//					result += 37 + fields[i].getInt(this);
200
//				} else if (type.equals("long")) {
201
//					long f = fields[i].getLong(this) ;
202
//					result += 37 + (f ^ (f >>> 32));
203
//				} else if (type.equals("float")) {
204
//					result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
205
//				} else if (type.equals("double")) {
206
//					long f = Double.doubleToLongBits(fields[i].getDouble(this));
207
//					result += 37 + (f ^ (f >>> 32));
208
//				} else {
209
//					Object obj = fields[i].get(this);
210
//					result += 37 + ((obj != null)? obj.hashCode() : 0);
211
//				}
212
//			} catch (Exception e) { e.printStackTrace(); }
213
//
214
//		}
215
//		return result;
216
//	}
170 217
}

Also available in: Unified diff