Revision 1907

tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/BaseAbstractHandler.java (revision 1907)
63 63
	 */
64 64
	public boolean checkStatsEngine()	{
65 65
		if(!Toolbox.getEngineManager(EngineType.STATS).isCurrentEngineAvailable())	{
66
			Log.severe(StatsEngineCoreMessages.error_statsEngineNotReadyCancelingCommand);
66
			Log.warning(StatsEngineCoreMessages.error_statsEngineNotReadyCancelingCommand);
67 67
		}
68 68
		return true;
69 69
	}
......
75 75
	 */
76 76
	public boolean checkCorpusEngine()	{
77 77
		if (!CQPSearchEngine.isInitialized())	{
78
			Log.severe("Corpus Engine is not ready, canceling command.");
78
			Log.warning("Corpus Engine is not ready, canceling command.");
79 79
			return false;
80 80
		}
81 81
		return true;
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 1907)
39 39
import org.eclipse.core.resources.IFile;
40 40
import org.eclipse.core.resources.IFolder;
41 41
import org.eclipse.core.resources.IProject;
42
import org.eclipse.core.resources.IProjectDescription;
42 43
import org.eclipse.core.resources.IWorkspace;
43 44
import org.eclipse.core.resources.IWorkspaceRoot;
44 45
import org.eclipse.core.resources.ResourcesPlugin;
......
72 73
public class Workspace extends TXMResult {
73 74

  
74 75
	private static final String NAME = "name";
75
	
76

  
76 77
	IWorkspace rcpWorkspace;
77 78
	IWorkspaceRoot root;
78 79
	IProject corporaProject;
79
//	/** The xmlfile. */
80
//	File xmlDefinitionFile;
81
//
82
//	/** The doc. */
83
//	Document doc;
84
//
85
//	/** The projs. */
86
//	Element projs;
80
	//	/** The xmlfile. */
81
	//	File xmlDefinitionFile;
82
	//
83
	//	/** The doc. */
84
	//	Document doc;
85
	//
86
	//	/** The projs. */
87
	//	Element projs;
87 88

  
88 89

  
89
//	/**
90
//	 * Creates the empty workspace.
91
//	 *
92
//	 * @param xmlfile the xmlfile
93
//	 * @return the workspace
94
//	 */
95
//	public static Workspace createEmptyWorkspaceDefinition(File xmlfile) {
96
//		writeEmptyWorkspaceFile(xmlfile);
97
//		return new Workspace(xmlfile);
98
//	}
99
//
100
//	/**
101
//	 * Write empty workspace file.
102
//	 *
103
//	 * @param xmlfile the xmlfile
104
//	 * @return true, if successful
105
//	 */
106
//	protected static boolean writeEmptyWorkspaceFile(File xmlfile) {
107
//		xmlfile.getParentFile().mkdirs();
108
//		try {
109
//			OutputStreamWriter writer = new OutputStreamWriter(
110
//					new FileOutputStream(xmlfile), TXMPreferences.DEFAULT_ENCODING);
111
//			writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$
112
//			writer.write("<workspace>\n"); //$NON-NLS-1$
113
//			writer.write("<projects>\n"); //$NON-NLS-1$
114
//			writer.write("<project name=\"default\">\n"); //$NON-NLS-1$
115
//			writer.write("<bases/>\n"); //$NON-NLS-1$
116
//			writer.write("</project>\n"); //$NON-NLS-1$
117
//			writer.write("</projects>\n"); //$NON-NLS-1$
118
//			writer.write("</workspace>\n"); //$NON-NLS-1$
119
//			writer.close();
120
//		} catch (IOException e) {
121
//			System.out.println(TXMCoreMessages.Workspace_6+xmlfile.getAbsolutePath());
122
//			Log.severe(TXMCoreMessages.Workspace_6+xmlfile.getAbsolutePath()+" : "+e.getMessage()); //$NON-NLS-1$
123
//			return false;
124
//		}
125
//		return true;
126
//	}
90
	//	/**
91
	//	 * Creates the empty workspace.
92
	//	 *
93
	//	 * @param xmlfile the xmlfile
94
	//	 * @return the workspace
95
	//	 */
96
	//	public static Workspace createEmptyWorkspaceDefinition(File xmlfile) {
97
	//		writeEmptyWorkspaceFile(xmlfile);
98
	//		return new Workspace(xmlfile);
99
	//	}
100
	//
101
	//	/**
102
	//	 * Write empty workspace file.
103
	//	 *
104
	//	 * @param xmlfile the xmlfile
105
	//	 * @return true, if successful
106
	//	 */
107
	//	protected static boolean writeEmptyWorkspaceFile(File xmlfile) {
108
	//		xmlfile.getParentFile().mkdirs();
109
	//		try {
110
	//			OutputStreamWriter writer = new OutputStreamWriter(
111
	//					new FileOutputStream(xmlfile), TXMPreferences.DEFAULT_ENCODING);
112
	//			writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$
113
	//			writer.write("<workspace>\n"); //$NON-NLS-1$
114
	//			writer.write("<projects>\n"); //$NON-NLS-1$
115
	//			writer.write("<project name=\"default\">\n"); //$NON-NLS-1$
116
	//			writer.write("<bases/>\n"); //$NON-NLS-1$
117
	//			writer.write("</project>\n"); //$NON-NLS-1$
118
	//			writer.write("</projects>\n"); //$NON-NLS-1$
119
	//			writer.write("</workspace>\n"); //$NON-NLS-1$
120
	//			writer.close();
121
	//		} catch (IOException e) {
122
	//			System.out.println(TXMCoreMessages.Workspace_6+xmlfile.getAbsolutePath());
123
	//			Log.severe(TXMCoreMessages.Workspace_6+xmlfile.getAbsolutePath()+" : "+e.getMessage()); //$NON-NLS-1$
124
	//			return false;
125
	//		}
126
	//		return true;
127
	//	}
127 128

  
128 129
	/**
129 130
	 * Instantiates a new workspace.
......
132 133
	 */
133 134
	private Workspace() {
134 135
		super("ROOT");
135
		
136

  
136 137
		rcpWorkspace = ResourcesPlugin.getWorkspace();
137 138
		root = rcpWorkspace.getRoot();
138 139
		corporaProject = root.getProject("corpora");
139
		
140

  
140 141
		if (!corporaProject.exists()) {
141 142
			try {
142 143
				corporaProject.create(null);
......
145 146
				e.printStackTrace();
146 147
			}
147 148
		}
148
		
149

  
149 150
		this.internalPersistable = true;
150 151
		this.userName = corporaProject.getName(); // corpora
151 152
		//		this.setPath("/"+pName); 
152
//		this.xmlDefinitionFile = xmlfile;
153
		//		this.xmlDefinitionFile = xmlfile;
153 154
	}
154
	
155

  
155 156
	public static Workspace getInstance() {
156 157
		if (Toolbox.workspace == null) {
157 158
			Toolbox.workspace = new Workspace();
158 159
		}
159
		
160

  
160 161
		return Toolbox.workspace;
161 162
	}
162 163

  
......
234 235
		if (binCorpusDir.exists() && HTMLs.exists() && DATAs.exists()
235 236
				&& REGISTRY.exists() && PARAMS.exists() && PROJECT.exists())// && correspfile.exists())
236 237
		{// minimal base data
237
		
238

  
238 239
			File[] maincorpusNames = DATAs.listFiles();
239 240
			String maincorpusName = "";
240 241
			if (maincorpusNames.length == 0) { // no CQP corpus
......
243 244
			} else {
244 245
				maincorpusName = maincorpusNames[0].getName();
245 246
			}
246
			
247

  
247 248
			Project p = getProject(binCorpusDir.getName());
248 249
			if (p != null) {
249 250
				p.delete(); // a project with the same name already exists
......
254 255
			}
255 256

  
256 257
			//System.out.println(parameters.toString());
257
			
258

  
258 259
			// load the project from the project .settings directory
259 260
			IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
261
			
260 262
			//rcpWorkspace.getRoot().refreshLocal(1, new LogMonitor());
261
			IProject rcpProject = rcpWorkspace.getRoot().getProject(binCorpusDir.getName());
263
			
264
			IProjectDescription description = rcpWorkspace.loadProjectDescription(new Path(binCorpusDir.getAbsolutePath()+"/.project"));
265
			description.setLocation(new Path(binCorpusDir.getAbsolutePath()));
266
			IProject rcpProject = rcpWorkspace.getRoot().getProject(description.getName());
267
			
262 268
			if (!rcpProject.exists()) {
263
				rcpProject.create(new LogMonitor());
269
				rcpProject.create(description, new LogMonitor());
264 270
			}
265 271
			if (!rcpProject.isOpen()) {
266 272
				rcpProject.open(new LogMonitor());
267 273
			}
268
			
269
			Project.loadProjectFromProjectScope(rcpProject);
270
			
271
			Project b = this.getProject(binCorpusDir.getName());
272
			
273
			return b;
274

  
275
			if (Project.loadProjectFromProjectScope(rcpProject)) {
276
				Project b = this.getProject(binCorpusDir.getName());
277
				return b;
278
			} else {
279
				Log.warning(NLS.bind("No TXM project found in {0}", binCorpusDir));
280
				return null;
281
			}
274 282
		} else {
275 283
			System.out.println(TXMCoreMessages.bind(TXMCoreMessages.errorColonP0CorpusDirectoryIsNotConformantToTXMCorpusBinaryFormatColonCorpusSkipped, binCorpusDir));
276 284
			System.out.println(TXMCoreMessages.bind(TXMCoreMessages.tXMNeedsFoldersColonP0P1P2AndP3, HTMLs, DATAs, REGISTRY, PARAMS));
277 285
		}
278 286
		return null;
279 287
	}
280
	
288

  
281 289
	/**
282 290
	 * Scan directory: 
283 291
	 * 1- check the binary corpus format
......
318 326
			//System.out.println(parameters.toString());
319 327

  
320 328
			// Creates a new project that doesn't need to build
321
			
329

  
322 330
			//FIXME: SJ: old version where there is a bug if the name or path are not in same case
323 331
			//Project project = new Project(this, parameters.name, false);
324 332
			//FIXME: SJ: new version that fix the bug but whe may want to not modify the case of the name? 
325 333
			Project project = new Project(this, parameters.name.toUpperCase(), false);
326
			
334

  
327 335
			project._load(parameters);
328
			
336

  
329 337
			//b._compute();
330 338
			//System.out.println("CREATE CORPORA? "+b.corpora.values());
331 339
			for (Element c : parameters.corpora.values()) {
......
334 342
				File HTMLc = new File(HTMLs, corpusname);
335 343
				File REGISTRYc = new File(REGISTRY, corpusname.toLowerCase());
336 344
				File DATAc = new File(DATAs, corpusname);
337
				
345

  
338 346
				if (!(PARAMS.exists() && HTMLc.exists() && REGISTRYc.exists() && DATAc.exists())) {
339 347
					System.out.println(NLS.bind(TXMCoreMessages.errorColonSkippingTheLoadingOfTheP0Corpus, corpusname));
340 348
					System.out.println(NLS.bind(TXMCoreMessages.pARAMSColonP0, PARAMS));
......
344 352
					continue;
345 353
				}
346 354
			}
347
			
355

  
348 356
			return project;
349 357
		} else {
350 358
			System.out.println(TXMCoreMessages.bind(TXMCoreMessages.errorColonP0CorpusDirectoryIsNotConformantToTXM079CorpusBinaryFormatColonCorpusSkipped, binCorpusDir));
......
397 405
	public void loadProjectsFromProjectScopes() throws CoreException	{
398 406

  
399 407
		Log.fine("Toolbox.initialize(): reloading projects...");
400
		
408

  
401 409
		IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
402 410
		IProject corporaDirectory = rcpWorkspace.getRoot().getProject("corpora");
403
		
411

  
404 412
		if (!corporaDirectory.exists()) {
405 413
			Log.severe("Can't load corpora projects: 'corpora' not found in workspace.");
406 414
			return;
407 415
		}
408 416
		IProject projects[] = rcpWorkspace.getRoot().getProjects();
409
		
417

  
410 418
		Log.fine("Toolbox.initialize(): " + projects.length + " project(s) found in workspace.");
411 419
		LogMonitor monitor = new LogMonitor("Workspace projects initialization.");
412
		
420

  
413 421
		for (IProject project : projects) {
414
			
422

  
415 423
			if (project.getLocation() == null || !project.getLocation().toFile().exists()) {
416 424
				project.delete(true, null);
417 425
				continue;
......
420 428
				project.open(monitor);
421 429
				String[] natures = project.getDescription().getNatureIds();
422 430
				if (Arrays.binarySearch(natures, Project.TXMCORPUSNATURE) < 0) continue;
423
				
431

  
424 432
				Project.loadProjectFromProjectScope(project);
425 433
			} catch (CoreException e) {
426 434
				// TODO Auto-generated catch block
427 435
				e.printStackTrace();
428 436
			}
429 437
		}
430
		
438

  
431 439
		for (TXMResult corpus : this.getDeepChildren(CorpusBuild.class)) {
432 440
			CorpusBuild cb = (CorpusBuild)corpus;
433 441
			if (!cb.compute(false)) {
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1907)
1227 1227
	/**
1228 1228
	 * 
1229 1229
	 * @param rcpProject
1230
	 * @return true if a Project has been found
1230 1231
	 */
1231
	public static void loadProjectFromProjectScope(IProject rcpProject) {
1232
	public static boolean loadProjectFromProjectScope(IProject rcpProject) {
1232 1233

  
1233 1234
		ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("/project/" + rcpProject.getName() + "/"); //$NON-NLS-1$ //$NON-NLS-2$
1234 1235

  
......
1283 1284
					result.setUserPersistable(true);	
1284 1285
				}
1285 1286

  
1286
				return; // only one Project.class loaded per RCP project
1287
				return true; // only one Project.class loaded per RCP project
1287 1288
			} catch (Exception e) {
1288 1289
				// TODO Auto-generated catch block
1289 1290
				e.printStackTrace();
1290 1291
			}
1291 1292
		}
1293
		return false;
1292 1294
	}
1293 1295

  
1294 1296
	/**
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/chartcreators/JFCCAChartCreator.java (revision 1907)
85 85
		
86 86
		renderer.setSeriesVisible(0, ca.isShowVariables());
87 87
		renderer.setSeriesVisible(1, ca.isShowIndividuals());
88
		chart.setTitle(Utils.createCAFactorialMapChartTitle(ca)); 
88 89
		
89 90
		// Create the limits border
90 91
		this.createCAFactorialMapChartLimitsBorder(chart);

Also available in: Unified diff