Revision 1142

tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorExtension.java (revision 1142)
78 78
	 * Save something when the doSave method is called
79 79
	 * @throws Exception
80 80
	 */
81
	public abstract void notifydoSave() throws Exception;
81
	public abstract void notifyDoSave() throws Exception;
82 82
	
83 83
	/**
84 84
	 * Do something when the editor is closing
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/Load079BinaryCorpus.java (revision 1142)
63 63
		corporaDir.mkdir();
64 64
		
65 65
		String basedirname = Zip.getRoot(zipFile);
66
		
66 67
		if (!Zip.hasEntries(zipFile, "import.xml", "data")) {
67 68
			return null;
68 69
		}
......
111 112
		
112 113
		MainCorpus c = new MainCorpus(project);
113 114
		BaseOldParameters params = new BaseOldParameters(new File(project.getProjectDirectory(), "import.xml"));
114
		c._load(params.corporaElement);
115
		c.compute();
115
		params.load();
116
		if (c._load(params.getCorpusElement())) {
117
			project.compute();
118
		} else {
119
			project.delete();
120
		}
121
		
116 122

  
117
		Toolbox.workspace.save();
123
		//Toolbox.workspace.save();
118 124
		return project;
119 125
	}
120 126
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 1142)
51 51
import org.txm.rcp.swt.dialog.LastOpened;
52 52
import org.txm.rcp.utils.JobHandler;
53 53
import org.txm.rcp.views.corpora.CorporaView;
54
import org.txm.searchengine.core.SearchEngine;
55
import org.txm.searchengine.core.SearchEnginesManager;
54 56
import org.txm.searchengine.cqp.corpus.MainCorpus;
55 57
import org.txm.utils.DeleteDir;
56 58
import org.txm.utils.logger.Log;
......
141 143
			System.out.println(NLS.bind(TXMUIMessages.AddBase_17, zipFile));
142 144
			return false;
143 145
		}
146
		
147
		SearchEngine engine = SearchEnginesManager.getCQPSearchEngine();
148
		if (engine.isRunning()) {
149
			try {
150
				engine.stop();
151
			} catch (Exception e) {
152
				// TODO Auto-generated catch block
153
				e.printStackTrace();
154
			}
155
		}
144 156

  
145 157
		//build binary dir path			
146 158
		basedirname = Zip.getRoot(zipFile);
......
161 173
//					System.out.println(Messages.LoadBinaryCorpus_2+backup);
162 174
//					return false;
163 175
//				}
164
				DeleteDir.deleteDirectory(corpusdir);
176
				
177
				Project p = Toolbox.workspace.getProject(basedirname);
178
				if (p != null) {
179
					p.clean();
180
				} else {
181
					DeleteDir.deleteDirectory(corpusdir);
182
				}
183
				
165 184
				if (corpusdir.exists()) {
166 185
					System.out.println("Error: previous binary corpus directory was not deleted: "+corpusdir);
167 186
					return false;
......
175 194
		JobHandler jobhandler = new JobHandler(
176 195
				NLS.bind(TXMUIMessages.AddBase_1, corpusdir.getName())) {
177 196
			@Override
178
			protected IStatus run(IProgressMonitor monitor) {
197
			protected IStatus run(final IProgressMonitor monitor) {
179 198
				this.runInit(monitor);
180 199
				try {
181 200
					//CHECK ZIPPED FILE
......
192 211
					syncExec(new Runnable() {
193 212
						@Override
194 213
						public void run() {
214
							
215
							SearchEngine engine = SearchEnginesManager.getCQPSearchEngine();
216
							if (!engine.isRunning()) {
217
								try {
218
									engine.start(monitor);
219
								} catch (Exception e) {
220
									// TODO Auto-generated catch block
221
									e.printStackTrace();
222
								}
223
							}
224
							
195 225
							RestartTXM.reloadViews();
196 226
							//System.out.println("Select newly loaded corpus: "+base2.getCorpora().values());
197 227
							CorporaView.select(newProject2.getChildren(MainCorpus.class));
......
204 234
				} catch (Exception e2) {
205 235
					org.txm.rcp.utils.Logger.printStackTrace(e2);
206 236
				} finally {
237
					SearchEngine engine = SearchEnginesManager.getCQPSearchEngine();
238
					if (!engine.isRunning()) {
239
						try {
240
							engine.start(monitor);
241
						} catch (Exception e) {
242
							// TODO Auto-generated catch block
243
							e.printStackTrace();
244
						}
245
					}
207 246
					monitor.done();
208 247
				}
209 248
				return Status.OK_STATUS;
tmp/org.txm.internalview.core/src/org/txm/internalview/core/functions/InternalView.java (revision 1142)
103 103
	@Override
104 104
	protected boolean _compute() throws Exception {
105 105

  
106
		if(this.hasParameterChanged(InternalViewPreferences.STRUCTURAL_UNIT))	{
106
		//if(this.hasParameterChanged(InternalViewPreferences.STRUCTURAL_UNIT))	{
107 107
			this.pCurrentPage = 0;
108 108
			//find struct start-end
109 109
			CQLQuery query = new CQLQuery("<" + pStructuralUnit.getName() + "> [] expand to " + pStructuralUnit); //$NON-NLS-1$ //$NON-NLS-2$
......
117 117
			//System.out.println(matches);
118 118
			dirty = false;
119 119
			return (nmatches > 0);
120
		}
120
		//}
121 121
		
122
		return true;
123 122
	}
124 123
	
125 124
	
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 1142)
354 354
	 */
355 355
	@Override
356 356
	public String toString() {
357
		return this.pName;
357
		return this.pID;
358 358
	}
359 359

  
360 360
	/* (non-Javadoc)
tmp/org.txm.core/src/java/org/txm/objects/CorpusBuild.java (revision 1142)
293 293
	protected boolean _load(Element e) {
294 294
		if (e == null) return false;
295 295

  
296
		this.pName = e.getAttribute(NAME); 
296
		this.pName = e.getAttribute(NAME);
297
		this.pID = e.getAttribute(NAME); 
297 298
//		this.pLanguage = e.getAttribute(LANG);
298 299
		// System.out.println("LOAD BASE "+this.name);
299 300
		loadImportInfos(e);
tmp/org.txm.core/src/java/org/txm/objects/Edition.java (revision 1142)
120 120
		// System.out.println("  build edition "+name);
121 121
		NodeList pagesList = e.getElementsByTagName("page"); //$NON-NLS-1$
122 122
		int numpages = pagesList.getLength();
123
		pages = new ArrayList<>();
123 124
		for (int i = 0; i < numpages; i++) {
124 125
			Element p = (Element) pagesList.item(i);
125 126
			Page page = new Page(this, "", "");
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 1142)
280 280
			//				return null;
281 281
			//			}
282 282

  
283
			Project p = getProject(parameters.name);
284
			if (p != null) {
285
				p.delete();
286
			}
287

  
288 283
			//System.out.println(parameters.toString());
289
			Project b = new Project(this, parameters.name);
290
			b._load(parameters);
291
			b._compute();
284
			Project project = new Project(this, parameters.name);
285
			project._load(parameters);
286
			//b._compute();
292 287
			//System.out.println("CREATE CORPORA? "+b.corpora.values());
293 288
			for (Element c : parameters.corpora.values()) {
294 289
				String corpusname = c.getAttribute(NAME);
......
307 302
				}
308 303
			}
309 304
			
310
			return b;
305
			return project;
311 306
		} else {
312 307
			System.out.println(TXMCoreMessages.bind(TXMCoreMessages.Project_26, binCorpusDir));
313 308
			System.out.println(TXMCoreMessages.Project_28+HTMLs+", "+DATAs+", "+REGISTRY+TXMCoreMessages.Project_31+PARAMS); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1142)
75 75
 */
76 76
public class Project extends TXMResult {
77 77

  
78

  
79

  
80 78
	private ArrayList<String> pEditionNames = new ArrayList<String>();
81 79
	private IProject rcpProject;
82 80

  
......
814 812
		}
815 813

  
816 814
		ImportEngines engines = Toolbox.getImportEngines();
817
		System.out.println("RUNNING IMPORT MODULE WITH NAME="+getImportModuleName());
815
		
818 816
		//File scriptfile = new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/org/txm/scripts/importer/"+importName+"/"+importName+"Loader.groovy"); //$NON-NLS-1$
819 817
		ImportEngine engine = engines.getEngine(getImportModuleName());
820 818
		if (engine == null) {
......
826 824
			//					return false;
827 825
			//				}
828 826
			//			};
829
			Log.severe("Project._compute(): Import engine not found.");
830
			return false;
827
			//Log.severe("Project._compute(): Import engine not found.");
828
			
829
			// no import set
830
			return true;
831 831
		}
832 832

  
833 833
		if (monitor == null) {
834 834
			monitor = new ConsoleProgressBar(10);
835 835
		}
836
		
837
		System.out.println("RUNNING IMPORT MODULE WITH NAME="+getImportModuleName());
836 838
		return engine.build(this, monitor).isOK();
837 839
	}
838 840

  
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 1142)
222 222
	}
223 223

  
224 224
	@Override
225
	public void notifydoSave() throws Exception {
225
	public void notifyDoSave() throws Exception {
226 226
		for (AnnotationArea aa : annotationAreas) {
227 227
			aa.save();
228 228
		}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 1142)
299 299
		String[] names;
300 300
		try {
301 301
			IEclipsePreferences node = base.getPreferencesScope().getNode("KnowledgeRepository");
302
			if (!node.nodeExists("DEFAULT")) {
302
			if (!node.nodeExists(corpus.getID())) {
303 303
				// create the "DEFAULT" KR configuration
304
				Preferences krconf = node.node("DEFAULT");
305
				krconf.put("name", "DEFAULT");
304
				Preferences krconf = node.node(corpus.getID());
305
				krconf.put("name", corpus.getID());
306 306
				//
307 307
			}
308 308
			names = node.childrenNames();
tmp/org.txm.tigersearch.rcp/src/org/txm/tigersearch/editors/IndexExtension.java (revision 1142)
53 53
	}
54 54

  
55 55
	@Override
56
	public void notifydoSave() throws Exception {
56
	public void notifyDoSave() throws Exception {
57 57
		// TODO Auto-generated method stub
58 58
		
59 59
	}
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1142)
287 287

  
288 288
		annotationTypesCombo.getCombo().setLayoutData(gdata);
289 289
		annotationTypesCombo.setInput(typesList);
290
		annotationTypesCombo.getCombo().select(0);
291
		annotations.setViewAnnotation(typesList.get(0));
290
		if (typesList.size() > 0) {
291
			annotationTypesCombo.getCombo().select(0);
292
			annotations.setViewAnnotation(typesList.get(0));
293
		}
292 294
		
293 295
		annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
294 296
			@Override
tmp/org.txm.analec.rcp/src/org/txm/analec/AnalecCorpora.java (revision 1142)
127 127

  
128 128
	public static boolean saveCorpus(Corpus corpus) {
129 129
		for (MainCorpus mcorpus : corpora.keySet()) {
130
			if (corpora.get(mcorpus) == corpus) return saveCorpus(corpus);
130
			if (corpora.get(mcorpus) == corpus) return saveCorpus(mcorpus);
131 131
		}
132 132
		return false;
133 133
	}

Also available in: Unified diff