Revision 6888 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/Project.java

View differences:

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
}

Also available in: Unified diff