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

View differences:

Project.java
136 136

  
137 137
	private boolean modified = false;
138 138

  
139
	private String name;
139
	private String name = PluginServices.getText(this, "untitled");
140 140

  
141 141
	// private String path;
142
	private String creationDate;
142
	private String creationDate = new Date().toGMTString();
143 143

  
144
	private String modificationDate;
144
	private String modificationDate = new Date().toGMTString();
145 145

  
146
	private String owner;
146
	private String owner = "";
147 147

  
148
	private String comments;
148
	private String comments = "";
149 149

  
150 150
	private Color selectionColor = null;
151 151

  
......
160 160
	// del usuario haciendo uso de los marcadores
161 161
	private List cameras = new ArrayList();
162 162

  
163
	// private int signatureAtStartup;
163
	/**
164
	 * this is a runtime-calculated value, do NOT persist it!
165
	 */
166
	private long signatureAtStartup;
164 167
	private IProjection projection;
165 168

  
166 169
	/**
......
257 260
		change.firePropertyChange("", null, null);
258 261
	}
259 262

  
260
	// /**
261
	// * establece la ruta completa de donde se encuentra guardado el proyecto
262
	// *
263
	// * @param string
264
	// */
265
	// public void setPath(String string) {
266
	// path = string;
267
	// modified = true;
268
	// change.firePropertyChange("", null, null);
269
	// }
270

  
271 263
	/**
272 264
	 * Devuelve a partir de la capa la tabla asociada.
273 265
	 *
......
323 315
		}
324 316
		return false;
325 317
	}
326
	/**
327
	 * Devuelve true si el proyecto (o alguna tabla, vista o mapa que contiene)
328
	 * fue modificado
329
	 *
330
	 * @return
331
	 */
332
	public boolean isModified() {
333
		if ((this.getDocuments().size() == 0) && !modified && !isModifiedDocuments()) {
334
			return false;
335
		}
336
		return true;
337
		// /return modified; TODO El atributo modified solo detecta cuando se
338
		// elimina o a?ade una vista,
339
		// /mapa o tabla pero no cuando se modifican.
340
	}
318
//	/**
319
//	 * Devuelve true si el proyecto (o alguna tabla, vista o mapa que contiene)
320
//	 * fue modificado
321
//	 *
322
//	 * @return
323
//	 */
324
//	public boolean isModified() {
325
//		if ((this.getDocuments().size() == 0) && !modified && !isModifiedDocuments()) {
326
//			return false;
327
//		}
328
//		return true;
329
//		// /return modified; TODO El atributo modified solo detecta cuando se
330
//		// elimina o a?ade una vista,
331
//		// /mapa o tabla pero no cuando se modifican.
332
//	}
341 333

  
342 334
	/**
343 335
	 * Obtiene los comentarios
......
657 649
		XMLEntity xml = new XMLEntity();
658 650
		xml.putProperty("className", this.getClass().getName());
659 651
		xml.putProperty("VERSION", VERSION);
660
		xml.putProperty("comments", comments);
652
		xml.putProperty("comments", getComments());
661 653
		xml.putProperty("creationDate", creationDate);
662 654

  
663 655
		int numExtents = extents.size();
......
713 705
		 * e.showError(); } } xml.putProperty("numMaps", numMaps);
714 706
		 */
715 707
		xml.putProperty("modificationDate", modificationDate);
716
		//xml.putProperty("modified", modified);
717 708
		xml.putProperty("name", name);
718 709
		xml.putProperty("owner", owner);
719
		// xml.putProperty("path", path);
720 710
		xml.putProperty("selectionColor", StringUtilities
721 711
				.color2String(selectionColor));
722 712
		/*
......
1118 1108

  
1119 1109
		int childNumber = 0;
1120 1110
		Project p = new Project();
1111

  
1121 1112
		try {
1122 1113
			p.comments = xml.getStringProperty("comments");
1123 1114
			p.creationDate = xml.getStringProperty("creationDate");
......
1233 1224
		} catch (Exception e) {
1234 1225
			throw new OpenException(e, p.getClass().getName());
1235 1226
		}
1236
		// p.setSignature( p.hashCode());
1227

  
1237 1228
		return p;
1238 1229

  
1239 1230
	}
1240 1231

  
1241
	// private void setSignature(int signature) {
1242
	// this.signatureAtStartup = computeSignature();
1243
	// }
1244

  
1245 1232
	/**
1246 1233
	 * Reestablece los link que ten?a cada tabla con las dem?s.
1247 1234
	 */
......
1259 1246
				try {
1260 1247
					if ((((ProjectTable) tables.get(i)).getLinkTable() != null)
1261 1248
							&& ((ProjectTable) tables.get(i)).getLinkTable()
1262
									.equals(
1263
											((ProjectTable) tables.get(j))
1264
													.getModelo().getRecordset()
1265
													.getName())) {
1249
							.equals(
1250
									((ProjectTable) tables.get(j))
1251
									.getModelo().getRecordset()
1252
									.getName())) {
1266 1253
						LinkSelectionListener lsl;
1267 1254

  
1268 1255
						lsl = new LinkSelectionListener(((ProjectTable) tables
1269 1256
								.get(i)).getModelo().getRecordset(),
1270 1257
								((ProjectTable) tables.get(j)).getModelo()
1271
										.getRecordset(), ((ProjectTable) tables
1258
								.getRecordset(), ((ProjectTable) tables
1272 1259
										.get(i)).getField1(),
1273
								((ProjectTable) tables.get(i)).getField2());
1260
										((ProjectTable) tables.get(i)).getField2());
1274 1261

  
1275 1262
						(((ProjectTable) tables.get(i)).getModelo()
1276 1263
								.getRecordset()).addSelectionListener(lsl);
......
1578 1565
					xml.putProperty("normalY", vi.getNormalY());
1579 1566
					xml.putProperty("normalWidth", vi.getNormalWidth());
1580 1567
					xml.putProperty("normalHeight", vi.getNormalHeight());
1581
				}
1568
}
1582 1569
			} catch (Exception e) {
1583 1570
				throw new SaveException(e, this.getClass().getName());
1584 1571
			}
......
2077 2064
		return pde;
2078 2065
	}
2079 2066

  
2080
	// public boolean hasChanged() {
2081
	// return signatureAtStartup != computeSignature();
2082
	// }
2067
	 public boolean hasChanged() {
2083 2068

  
2084
	// public int computeSignature() {
2085
	//
2086
	// // /* TODO method also present in ProjectMap, ProjectTable,
2087
	// // * ProjectView and ProjectExtent
2088
	// // */
2089
	// int result = 17;
2090
	// //
2091
	// // Class clazz = getClass();
2092
	// // Field[] fields = clazz.getDeclaredFields();
2093
	// // for (int i = 0; i < fields.length; i++) {
2094
	// // try {
2095
	// // // don't compute following fields
2096
	// // if (fields[i].getName().equals("modificationDate")
2097
	// // || fields[i].getName().equals("creationDate")
2098
	// // || fields[i].getName().equals("signatureAtStartup")
2099
	// // || fields[i].getName().equals("change")
2100
	// // || Modifier.isStatic(fields[i].getModifiers()))
2101
	// // continue;
2102
	// //
2103
	// //
2104
	// // String type = fields[i].getType().getName();
2105
	// // if (type.equals("boolean")) {
2106
	// // result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
2107
	// // } else if (type.equals("java.lang.String")) {
2108
	// // Object v = fields[i].get(this);
2109
	// // if (v == null) {
2110
	// // result += 37;
2111
	// // continue;
2112
	// // }
2113
	// // char[] chars = ((String) v).toCharArray();
2114
	// // for (int j = 0; j < chars.length; j++) {
2115
	// // result += 37 + (int) chars[i];
2116
	// // }
2117
	// // } else if (type.equals("byte")) {
2118
	// // result += 37 + (int) fields[i].getByte(this);
2119
	// // } else if (type.equals("char")) {
2120
	// // result += 37 + (int) fields[i].getChar(this);
2121
	// // } else if (type.equals("short")) {
2122
	// // result += 37 + (int) fields[i].getShort(this);
2123
	// // } else if (type.equals("int")) {
2124
	// // result += 37 + fields[i].getInt(this);
2125
	// // } else if (type.equals("long")) {
2126
	// // long f = fields[i].getLong(this) ;
2127
	// // result += 37 + (f ^ (f >>> 32));
2128
	// // } else if (type.equals("float")) {
2129
	// // result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
2130
	// // } else if (type.equals("double")) {
2131
	// // long f = Double.doubleToLongBits(fields[i].getDouble(this));
2132
	// // result += 37 + (f ^ (f >>> 32));
2133
	// // } else {
2134
	// //// Object obj = fields[i].get(this);
2135
	// //// result += 37 + ((obj != null)? obj.hashCode() : 0);
2136
	// // }
2137
	// // } catch (Exception e) { e.printStackTrace(); }
2138
	// //
2139
	// // }
2140
	// //
2141
	// // for (int i = 0; i < views.size(); i++) {
2142
	// // ProjectView e = (ProjectView) views.get(i);
2143
	// // result += 37 + e.computeSignature();
2144
	// // }
2145
	// //
2146
	// // for (int i = 0; i < tables.size(); i++) {
2147
	// // ProjectTable e = (ProjectTable) tables.get(i);
2148
	// // result += 37 + e.computeSignature();
2149
	// // }
2150
	// //
2151
	// // for (int i = 0; i < maps.size(); i++) {
2152
	// // ProjectMap e = (ProjectMap) maps.get(i);
2153
	// // result += 37 + e.computeSignature();
2154
	// // }
2155
	// //
2156
	// // for (int i = 0; i < extents.size(); i++) {
2157
	// // ProjectExtent e = (ProjectExtent) extents.get(i);
2158
	// // result += 37 + e.computeSignature();
2159
	// // }
2160
	//
2161
	//
2162
	// return result;
2163
	// }
2069
//		 System.out.println(getXMLEntity().toString());
2070
//		 System.err.println("old hash = " +signatureAtStartup+", new hash "+getXMLEntity().hash());
2071
		 return signatureAtStartup != getXMLEntity().hash();
2164 2072

  
2073
	 }
2074

  
2075
	public void setSignature(long hash) {
2076
		signatureAtStartup = hash;
2077
//		System.err.println("\n\nHASH = " +hash+"\n\n");
2078
//		System.out.println(getXMLEntity().toString());
2079
	}
2165 2080
}

Also available in: Unified diff