Révision 1113

tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java (revision 1113)
45 45
		super(partition);
46 46

  
47 47
		this.setVisible(false);
48
		this.persistable = true;
48
		this.internalPersistable = true;
49 49
		this.userPersistable = false;
50 50
	}
51 51
	
......
53 53
		super(parametersNodePath); // build the subcorpus part
54 54
		
55 55
		this.setVisible(false);
56
		this.persistable = true;
56
		this.internalPersistable = true;
57 57
		this.userPersistable = false;
58 58
	}
59 59
	
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 1113)
82 82
	 */
83 83
	public MainCorpus(Partition partition) {
84 84
		super(partition);
85
		this.persistable = true;
85
		this.internalPersistable = true;
86 86
		throw new IllegalArgumentException("Maincorpus parent must not be a Partition");
87 87
	}
88 88
	
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/debug/TXMResultDebugView.java (revision 1113)
132 132
		buffer.append("Selected object = " + this.currentResult + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
133 133
		buffer.append("Node visible = " + this.currentResult.isVisible() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
134 134
		buffer.append("Node weight = " + this.currentResult.getWeight() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
135
		buffer.append("Persistable = " + this.currentResult.isPersistable() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
135
		buffer.append("Persistable = " + this.currentResult.isInternalPersistable() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
136 136
		buffer.append("User persistable = " + this.currentResult.isUserPersistable() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
137 137
//		if (this.currentResult instanceof ChartResult) 	{
138 138
//			buffer.append("Chart engine = " + ((ChartResult)this.currentResult).getChartsEngine() + ", chart object = " + ((ChartResult)this.currentResult).getChart()
tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 1113)
277 277
			e.printStackTrace();
278 278
		}
279 279

  
280
		// loads and recreate the existing projects
281
		loadProjects();
280 282

  
283

  
284
		initializing = false;
285
		return checkState();
286
	}
287

  
288
	/**
289
	 * Loads and recreate the existing projects.
290
	 */
291
	// FIXME: SJ: should be done in the Workspace class
292
	public static void loadProjects()	{
293
		
294

  
281 295
		// FIXME: tmp persistence tests: Reload saved results
282 296
		//		if (TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED)) {
283
		Log.severe("*** Toolbox.initialize(): reloading projects...");
297
		Log.finest("Toolbox.initialize(): reloading projects...");
284 298
		
285 299
		IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
286 300
		IProject projects[] = rcpWorkspace.getRoot().getProjects();
......
291 305
			
292 306
			//IScopeContext projectScope = new ProjectScope(projects[i]);
293 307

  
294
			//System.out.println("*************** Toolbox.initialize(): scope = " + projectScope.getName());
295
			
296 308
			ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("project/" + projects[i].getName() + "/");
297 309
			
298 310
			Log.info("Toolbox.initialize(): loading project " + projects[i].getName() + "...");
......
314 326
					String className = TXMPreferences.preferencesRootNode.node(parametersNodePath).get("class", ""); //$NON-NLS-1$
315 327
					
316 328
					if(!className.equals(Project.class.getName()))	{
317
						Log.finest("Toolbox.initialize(): not a project, result skipped (classame = " + className + ").");
329
					//	Log.finest("Toolbox.initialize(): not a project, result skipped (classame = " + className + ").");
318 330
						continue;
319 331
					}
320 332

  
......
326 338

  
327 339
					
328 340
					Log.finest("Toolbox.initialize(): class = " + className); //$NON-NLS-1$
329
//					Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.getString(TXMPreferences.PARENT_UUID, nodeQualifier));
330 341
					Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.PARENT_UUID, "")); //$NON-NLS-1$
331 342
					String bundleId = TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.BUNDLE_ID, ""); //$NON-NLS-1$
332 343
					Log.finest("Toolbox.initialize(): bundle_id = " + bundleId); //$NON-NLS-1$
......
335 346
						Log.finest("Warning: can not restore object with bundle name " + bundleId); //$NON-NLS-1$
336 347
						continue;
337 348
					}
338

  
339 349
					
340 350
					Log.info("Toolbox.initialize(): creating project " + projects[i].getName() + ".");
341 351
					Class<?> cl = bundle.loadClass(className);
......
343 353
					TXMResult result = (TXMResult) cons.newInstance(parametersNodePath);
344 354
					
345 355
					// not an internal persistence (eg. corpus or partition)
346
					if (!result.isPersistable())	{
356
					if (!result.isInternalPersistable())	{
347 357
						result.setUserPersistable(true);	
348 358
					}
349 359
				} catch (Exception e) {
......
355 365

  
356 366
		}
357 367
		
358
		
359
		
360

  
361

  
362

  
363
		initializing = false;
364
		return checkState();
365 368
	}
366

  
369
	
367 370
	/**
368 371
	 * initialize the toolbox from a UTF-8 file
369 372
	 * 
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 1113)
1303 1303
	 */
1304 1304
	// FIXME: try to use the scope directly and not pass through the reference service
1305 1305
	public static ArrayList<String> getAllResultsNodePaths(String rootPath)	{
1306
//		ArrayList<String> resultsNodesQualifiers = new ArrayList<String>();
1307
//		try {
1308
//			IPreferencesService service = Platform.getPreferencesService();
1309
//			for (String scopeName : service.getRootNode().childrenNames()) {
1310
//				System.out.println("TXMPreferences.getAllResultsNodesQualifiers(): scope = " + scopeName);
1311
//				if(!scopeName.equals(scope.getName()))	{
1312
//					System.out.println("TXMPreferences.getAllResultsNodesQualifiersProjects(): skipping scope.");
1313
//					continue;
1314
//				}
1315
//
1316
//				String[] nodesNames = service.getRootNode().node(scopeName).node(nodePath).childrenNames();
1317
//				
1318
//				System.out.println("TXMPreferences.getAllResultsNodesQualifiers(): nodes found = " + nodesNames.length);
1319
//				
1320
//				
1321
//				Arrays.sort(nodesNames);
1322
//				for (String nodeName : nodesNames) {
1323
//					System.out.println("TXMPreferences.getAllResultsNodesQualifiers(): node name = " + nodeName);
1324
//					
1325
//					if(nodeName.startsWith(TXMResult.UUID_PREFIX))	{
1326
//						resultsNodesQualifiers.add(nodeName);
1327
//					}
1328
//				}
1329
//			}
1330
//		} catch (Exception e) {
1331
//			e.printStackTrace();
1332
//		}
1333
//		Collections.sort(resultsNodesQualifiers);
1334
//		return resultsNodesQualifiers;
1335
		
1336
		
1337 1306
		Log.finest("TXMPreferences.getAllResultsNodePaths(): looking for nodes in path \"" + preferencesRootNode.node(rootPath) + "\".");
1338 1307
		
1339 1308
		ArrayList<String> nodePaths = new ArrayList<String>();
......
1348 1317
				Log.finest("TXMPreferences.getAllResultsNodePaths(): node name = " + nodeName);
1349 1318
				
1350 1319
				if(nodeName.startsWith(TXMResult.UUID_PREFIX))	{
1351
					Log.finest("TXMPreferences.getAllResultsNodePaths(): node path = " + rootPath + nodeName);
1320
					// Debug
1321
					//Log.finest("TXMPreferences.getAllResultsNodePaths(): node path = " + rootPath + nodeName);
1352 1322
					nodePaths.add(rootPath + nodeName);
1353 1323
				}
1354 1324
			}
......
1363 1333
	}
1364 1334

  
1365 1335

  
1336
//	FIXME: became useless?
1337
//	/**
1338
//	 * Deletes all the result nodes from the preferences and files that are not set as persistable.
1339
//	 */
1340
//	public static void deleteAllNotPersistableResultsNodes(String path)	{
1341
//		
1342
//		ArrayList<String> resultsNodesQualifier = getAllResultsNodePaths(path);
1343
//		for (int i = 0; i < resultsNodesQualifier.size(); i++) {
1344
//			TXMResult result = TXMResult.getResult(resultsNodesQualifier.get(i)); 
1345
//			if(result != null && !result.isPersistable())	{
1346
//				delete(preferencesRootNode.node(path).node(resultsNodesQualifier.get(i)));
1347
//			}
1348
//		}
1349
//	}
1366 1350

  
1367
	/**
1368
	 * Deletes all the result nodes from the preferences and files that are not set as persistable.
1369
	 */
1370
	public static void deleteAllNotPersistableResultsNodes(String path)	{
1371
		
1372
		ArrayList<String> resultsNodesQualifier = getAllResultsNodePaths(path);
1373
		for (int i = 0; i < resultsNodesQualifier.size(); i++) {
1374
			TXMResult result = TXMResult.getResult(resultsNodesQualifier.get(i)); 
1375
			if(result != null && !result.isPersistable())	{
1376
				delete(preferencesRootNode.node(path).node(resultsNodesQualifier.get(i)));
1377
			}
1378
		}
1379
	}
1380

  
1381

  
1382
	/**
1383
	 * Deletes all the result nodes from the preferences and files.
1384
	 */
1385
	public static void deleteAllResultsNodes(String path)	{
1386
		
1387
		ArrayList<String> resultsNodesQualifier = getAllResultsNodePaths(path);
1388
		for (int i = 0; i < resultsNodesQualifier.size(); i++) {
1389
			delete(preferencesRootNode.node(path).node(resultsNodesQualifier.get(i)));
1390
		}
1391
	}
1351
//FIXME: became useless?
1352
//	/**
1353
//	 * Deletes all the result nodes from the preferences and files.
1354
//	 */
1355
//	public static void deleteAllResultsNodes(String path)	{
1356
//		
1357
//		ArrayList<String> resultsNodesQualifier = getAllResultsNodePaths(path);
1358
//		for (int i = 0; i < resultsNodesQualifier.size(); i++) {
1359
//			delete(preferencesRootNode.node(path).node(resultsNodesQualifier.get(i)));
1360
//		}
1361
//	}
1392 1362
	
1393 1363

  
1394 1364
	/**
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1113)
143 143
	/**
144 144
	 * Internal persistable state.
145 145
	 */
146
	protected boolean persistable;
146
	protected boolean internalPersistable;
147 147

  
148 148
	/**
149 149
	 * User persistable state.
......
224 224
		
225 225
		
226 226
		this.dirty = true;
227
		this.persistable = false;
227
		this.internalPersistable = false;
228 228
		this.userPersistable = TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED);
229 229

  
230 230

  
......
1790 1790
	 * @return
1791 1791
	 */
1792 1792
	public boolean mustBePersisted()	{
1793
		if (this.persistable
1793
		if (this.internalPersistable
1794 1794
				//|| TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED) // FIXME
1795 1795
				|| this.userPersistable)	{
1796 1796
			return true;
......
1986 1986

  
1987 1987

  
1988 1988
	/**
1989
	 * Gets the persistable state. 
1989
	 * Gets the internal persistable state. 
1990 1990
	 * @return the persistable
1991 1991
	 */
1992
	public boolean isPersistable() {
1993
		return persistable;
1992
	public boolean isInternalPersistable() {
1993
		return internalPersistable;
1994 1994
	}
1995 1995

  
1996 1996
	/**
1997
	 * Sets the persistable state. If set to false, the result will never be saved to file.
1997
	 * Sets the internal persistable state. Results internally persisted will not be deleted when quitting, event if the user set them as non persistable.
1998 1998
	 * @param persistable the persistable to set
1999 1999
	 */
2000
	public void setPersistable(boolean persistable) {
2001
		this.persistable = persistable;
2000
	public void setInternalPersistable(boolean persistable) {
2001
		this.internalPersistable = persistable;
2002 2002
	}
2003 2003

  
2004 2004
	/**
......
2027 2027
	 */
2028 2028
	public void setUserPersistable(boolean userPersistable) {
2029 2029
		this.userPersistable = userPersistable;
2030
		if (userPersistable && this.parent != null && !this.parent.isPersistable()) {
2030
		if (userPersistable && this.parent != null && !this.parent.isInternalPersistable()) {
2031 2031
			this.parent.setUserPersistable(true);
2032 2032
		}
2033 2033
		if (!userPersistable) {
......
2035 2035
				child.setUserPersistable(userPersistable);
2036 2036
			}
2037 2037
		}
2038
		Log.finest("TXMResult.setUserPersistable(): " + userPersistable);
2038
		// Debug
2039
//		Log.finest("TXMResult.setUserPersistable(): " + userPersistable);
2039 2040
	}
2040 2041

  
2041 2042
	/**
tmp/org.txm.core/src/java/org/txm/objects/Text.java (revision 1113)
64 64
	public Text(Project project) {
65 65
		super(project);
66 66
		this.setVisible(false);
67
		this.persistable = true;
67
		this.internalPersistable = true;
68 68
	}
69 69

  
70 70
	/**
......
76 76
	public Text(String parametersNodePath) {
77 77
		super(parametersNodePath);
78 78
		this.setVisible(false);
79
		this.persistable = true;
79
		this.internalPersistable = true;
80 80
	}
81 81

  
82 82
	
tmp/org.txm.core/src/java/org/txm/objects/CorpusBuild.java (revision 1113)
121 121
	 */
122 122
	public CorpusBuild(Project project) {
123 123
		super(project);
124
		this.persistable = true;
124
		this.internalPersistable = true;
125 125

  
126 126
		//		this.name = name;
127 127
		//		this.persistable = true;
......
141 141
	 */
142 142
	public CorpusBuild(CorpusBuild corpus2) {
143 143
		super(corpus2);
144
		this.persistable = true;
144
		this.internalPersistable = true;
145 145
	}
146 146
	
147 147
	/**
......
151 151
	 */
152 152
	public CorpusBuild(Partition partition) {
153 153
		super(partition);
154
		this.persistable = true;
154
		this.internalPersistable = true;
155 155
	}
156 156

  
157 157
	/**
......
160 160
	 */
161 161
	public CorpusBuild(String parametersNodePath) {
162 162
		super(parametersNodePath);
163
		this.persistable = true;
163
		this.internalPersistable = true;
164 164
	}
165 165
	
166 166
	public String getID() {
tmp/org.txm.core/src/java/org/txm/objects/Edition.java (revision 1113)
77 77
	public Edition(Text text) {
78 78
		super(text);
79 79
		this.visible = false;
80
		this.persistable = true;
80
		this.internalPersistable = true;
81 81
	}
82 82
	
83 83
	/**
......
88 88
	public Edition(String parametersNodePath) {
89 89
		super(parametersNodePath);
90 90
		this.visible = false;
91
		this.persistable = true;
91
		this.internalPersistable = true;
92 92
	}
93 93

  
94 94
	/**
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 1113)
127 127
		super("ROOT");
128 128
		
129 129
		IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
130
		this.persistable = true;
130
		this.internalPersistable = true;
131 131
		this.pName = rcpWorkspace.getRoot().getName(); // corpora
132 132
		//		this.setPath("/"+pName); 
133 133
//		this.xmlDefinitionFile = xmlfile;
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1113)
73 73
 */
74 74
public class Project extends TXMResult {
75 75

  
76
	
77
	
78
	private ArrayList<String> pEditionNames = new ArrayList<String>();
79
	private IProject rcpProject;
80
	
81
	private boolean pCleanAfterBuild;
82
	private ProjectScope preferenceScope;
83

  
84
	
85
	/**
86
	 * Name.
87
	 */
76 88
	@Parameter(key=TBXPreferences.NAME)
77 89
	String pName;
78 90

  
91
	/**
92
	 * Name of import module.
93
	 */
79 94
	@Parameter(key=TBXPreferences.IMPORT_MODULE_NAME)
80 95
	String pImportModuleName;
81 96

  
97
	/**
98
	 * 
99
	 */
82 100
	@Parameter(key=TBXPreferences.LINKS)
83 101
	private HashMap<String, Alignement> links = new HashMap<String, Alignement>();
84 102

  
103
	/**
104
	 * Default edition.
105
	 */
85 106
	@Parameter(key=TBXPreferences.DEFAULT_EDITION)
86 107
	private String pDefaultEditionName;
87 108

  
88
	/** The encoding. */
109
	/**
110
	 * Encoding.
111
	 */
89 112
	@Parameter(key=TBXPreferences.ENCODING)
90 113
	private String pEncoding;
91 114

  
92
	/** The lang. */
115
	/**
116
	 * Language.
117
	 */
93 118
	@Parameter(key=TBXPreferences.LANG)
94 119
	private String pLanguage;
95 120

  
96
	/** The srcdir. */
121
	/**
122
	 * Source directory.
123
	 */
97 124
	@Parameter(key=TBXPreferences.SOURCE)
98 125
	private File pSrcDirectory;
99 126

  
......
104 131
	//	@Parameter(key=TBXPreferences.FRONT_XSL_PARAMETERS)
105 132
	//	private HashMap<String, String> pXsltParameters;
106 133

  
107
	/** The author. */
134
	/**
135
	 * Author.
136
	 */
108 137
	@Parameter(key=TBXPreferences.AUTHOR)
109 138
	private String pAuthor;
139
	
140
	/**
141
	 * Font.
142
	 */
110 143
	@Parameter(key=TBXPreferences.FONT)
111 144
	private String pFont = "Arial";
112 145

  
113
	private ArrayList<String> pEditionNames = new ArrayList<String>();
114
	private IProject rcpProject;
146
	/**
147
	 * Description.
148
	 */
115 149
	@Parameter(key=TBXPreferences.DESCRIPTION)
116 150
	private String pDescription;
151
	
152
	/**
153
	 * 
154
	 */
117 155
	@Parameter(key=TBXPreferences.ANNOTATE)
118 156
	private boolean pAnnotate;
119
	private boolean pCleanAfterBuild;
120
	private ProjectScope preferenceScope;
121 157

  
158
	/**
159
	 * Last update date.
160
	 */
161
	@Parameter(key=TBXPreferences.UPDATE_DATE)
162
	private Date pLastUpdateDate;
163
	
164
	/**
165
	 * Creation date.
166
	 */
122 167
	@Parameter(key=TBXPreferences.CREATE_DATE)
123
	private Date pLastUpdateDate;
124
	@Parameter(key=TBXPreferences.UPDATE_DATE)
125 168
	private Date pCreationDate;
126 169

  
127 170
	/**
......
133 176
	 */
134 177
	public Project(Workspace workspace, String name) throws Exception {
135 178
		super(workspace);
136
		this.persistable = true;
179
		this.internalPersistable = true;
137 180
		this.pName = name;
138 181
		this.dirty = false;
139 182
		this.hasBeenComputedOnce = true;
......
166 209
		//		this.scope = new BasePreferenceScope(this);
167 210
		
168 211
		
169
		// loading corpus
212
		// reloading existing results
170 213
		this.loadResults();
171 214
		
172 215
	}
......
260 303
					TXMResult result = (TXMResult) cons.newInstance(parametersNodePath);
261 304
					
262 305
					// not an internal persistence (eg. corpus or partition)
263
					if (!result.isPersistable())	{
306
					if (!result.isInternalPersistable())	{
264 307
						result.setUserPersistable(true);	
265 308
					}
266 309
				} catch (Exception e) {
......
270 313
			}
271 314
	}
272 315
	
316
	
317
	
273 318

  
274 319
	//	public BasePreferenceScope getPreferenceScope() {
275 320
	//		return scope;
tmp/org.txm.core/src/java/org/txm/objects/Partition.java (revision 1113)
40 40
	 */
41 41
	public Partition(CorpusBuild parent) {
42 42
		super(parent);
43
		this.persistable = true;
43
		this.internalPersistable = true;
44 44
	}
45 45
	
46 46
	/**
......
49 49
	 */
50 50
	public Partition(String parametersNodePath) {
51 51
		super(parametersNodePath);
52
		this.persistable = true;
52
		this.internalPersistable = true;
53 53
	}
54 54
	
55 55
	/**

Formats disponibles : Unified diff