Révision 3361

TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 3361)
824 824
		// remove previous EditionPanel
825 825
		if (reloadPanels) {
826 826
			for (EditionPanel panel : editionPanels.values()) {
827
				panel.dispose();
827
				if (!panel.isDisposed()) {
828
					panel.dispose();
829
				}
828 830
			}
829 831
			editionPanels = new LinkedHashMap<>();
830 832
			
......
890 892
			this.addHighlightWordsById(BackToText.lightred, Arrays.asList(wordIdsArray));
891 893
			this.setFocusedWordID(wordIds);
892 894
		}
895
		
896
		String url = this.editionPanels.get(editionNames.get(0)).getURL();
897
		if (url == null || url.equals("about:blank")) {
898
			setText(text,  true);
899
		}
893 900
		return true;
894 901
	}
895 902
	
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiServer.java (revision 3361)
348 348
	
349 349
	public native String corpusCharset(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError;
350 350
	
351
	public native String getOption(String name) throws UnexpectedAnswerException, IOException, CqiServerError;
352
	
353
	public native String setOption(String name, String value) throws UnexpectedAnswerException, IOException, CqiServerError;
354
	
351 355
	public native String corpusFullName(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError;
352 356
	
353 357
	public native String[] corpusInfo(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError;
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiClient.java (revision 3361)
4 4

  
5 5
import org.eclipse.osgi.util.NLS;
6 6
import org.txm.core.messages.TXMCoreMessages;
7
import org.txm.searchengine.core.messages.SearchEngineCoreMessages;
8 7
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
9 8
import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages;
10 9
import org.txm.searchengine.cqp.serverException.CqiClErrorCorpusAccess;
......
721 720
		}
722 721
		return server.load_a_system_corpus(regfilepath, entry);
723 722
	}
723

  
724
	@Override
725
	public String getOption(String name) throws UnexpectedAnswerException, IOException, CqiServerError {
726
		if (name == null) {
727
			throw new CqiServerError("getOption called with NULL name parameter.");
728
		}
729
		String rez = server.getOption(name);
730
		if (rez == null) {
731
			throwExceptionFromCqi(server.getErrorCode());
732
		}
733
		return rez;
734
	}
735

  
736
	@Override
737
	public String setOption(String name, String value) throws UnexpectedAnswerException, IOException, CqiServerError {
738
		if (name == null) {
739
			throw new CqiServerError("setOption called with NULL name parameter.");
740
		}
741
		if (value == null) {
742
			throw new CqiServerError("setOption called with NULL value parameter.");
743
		}
744
		String rez = server.setOption(name, value);
745
		if (rez == null) {
746
			throwExceptionFromCqi(server.getErrorCode());
747
		}
748
		return rez;
749
	}
724 750
}
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiClient.java (revision 3361)
1938 1938
		this.writeString(entry);
1939 1939
		return readBoolean();
1940 1940
	}
1941

  
1942
	@Override
1943
	public String getOption(String name) throws UnexpectedAnswerException, IOException, CqiServerError {
1944
		
1945
		Log.warning("NOT IMPLEMENTED: NetCqiClient.getOption");
1946
		return null;
1947
	}
1948

  
1949
	@Override
1950
	public String setOption(String name, String value) throws UnexpectedAnswerException, IOException, CqiServerError {
1951
		
1952
		Log.warning("NOT IMPLEMENTED: NetCqiClient.setOption");
1953
		return null;
1954
	}
1941 1955
}
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiClient.java (revision 3361)
351 351
	 * @return the name of the charset
352 352
	 */
353 353
	public String corpusCharset(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
354
	
355
	/**
356
	 * Get the String value of a CQP environment option 
357
	 *
358
	 * @param name the option full name
359
	 * @return the value
360
	 */
361
	public String getOption(String name) throws UnexpectedAnswerException, IOException, CqiServerError;
362
	
363
	// None
364
	/**
365
	 * set the String value of a CQP environment option 
366
	 *
367
	 * @param name the option full name
368
	 * @param value the option value to set
369
	 * @return the value
370
	 */
371
	public String setOption(String name, String value) throws UnexpectedAnswerException, IOException, CqiServerError;
354 372

  
355 373
	// None (not really implemented anyway)
356 374
	/**
TXM/trunk/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiClient.java (revision 3361)
273 273
	@Override
274 274
	public abstract String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError;
275 275
	
276

  
277
	
278
	
276 279
	// None
277 280
	/**
278 281
	 * Gives the corpus charset.
......
283 286
	@Override
284 287
	public abstract String corpusCharset(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
285 288
	
289
	
286 290
	// None (not really implemented anyway)
287 291
	/**
288 292
	 * Gives the corpus properties.
TXM/trunk/org.txm.analec.rcp/src/org/txm/macro/urs/edit/CloneUnitPropertyMacro.groovy (revision 3361)
1
package org.txm.macro.urs.edit
2

  
3
// Copyright © 2021 ENS de Lyon, CNRS, University of Franche-Comté
4
// Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses)
5
// @author sheiden
6

  
7

  
8
import org.kohsuke.args4j.*
9
import groovy.transform.Field
10
import org.txm.rcpapplication.swt.widget.parameters.*
11
import org.txm.searchengine.cqp.*
12
import org.txm.searchengine.cqp.corpus.*
13
import org.txm.searchengine.cqp.corpus.query.*
14
import org.txm.*
15
import org.txm.rcpapplication.views.*
16
import org.txm.macro.cqp.*
17
import org.txm.annotation.urs.URSCorpora
18
import org.txm.macro.urs.AnalecUtils
19
import visuAnalec.elements.Unite
20

  
21

  
22
// BEGINNING OF PARAMETERS
23

  
24
if (!(corpusViewSelection instanceof MainCorpus)) {
25
	scriptName = this.class.getSimpleName()
26
	println "** $scriptName: please select a corpus in the Corpus view or provide a corpus name (current selection is $corpusViewSelection). Aborting."
27
	return false
28
}
29
// Declare each parameter here
30
// (available widget types: Query, File, Folder, String, Text, Boolean, Integer, Float and Date)
31

  
32
@Field @Option(name="unit_type", usage="Unit Type", widget="String", required=false, def="Biblical Reference")
33
def unit_type
34

  
35
@Field @Option(name="unit_ursql", usage="TYPE or TYPE@PROP or TYPE@PROP=<regex>", widget="String", required=false, def="Biblical Reference")
36
def unit_ursql
37

  
38
@Field @Option(name="propertyToClone", usage="name of the property to clone", widget="String", required=true, def="")
39
def propertyToClone
40

  
41
@Field @Option(name="newProperty", usage="name of the new property", widget="String", required=true, def="")
42
def newProperty
43

  
44
@Field @Option(name="debug", usage="Show debug information", widget="StringArray", metaVar="OFF	ON	ALL	REALLY ALL", required=false, def="OFF")
45
def debug
46

  
47
// Open the parameters input dialog box
48
if (!ParametersDialog.open(this)) return false
49

  
50
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3
51

  
52
// check availability of the corpus
53

  
54
CQI = CQPSearchEngine.getCqiClient()
55

  
56
scriptName = this.class.getSimpleName()
57

  
58
corpus = corpusViewSelection
59
corpusName = corpus.getName()
60

  
61
// check availability of every information needed in the corpus
62

  
63
if (!URSCorpora.isAnnotationStructureReady(corpus)) {
64
	println "** URS Annotation Structure of "+corpusName+" is not ready. Aborting."
65
	return false
66
}
67

  
68
analecCorpus = URSCorpora.getCorpus(corpus)
69

  
70
if (analecCorpus == null) {
71
	println "** no URS Annotations for "+corpusName+" corpus. Aborting."
72
	return false
73
}
74

  
75
// select Units
76

  
77
selectedUnits = AnalecUtils.selectUnitsInSchema(debug, analecCorpus, corpus, null, null, null, unit_ursql, 0, null, false, 0)
78

  
79
nUnits = selectedUnits.size()
80

  
81
if (nUnits == 0) {
82
	println "No units selected, no property cloned."
83
	return
84
}
85

  
86
// check availability of every information needed in the corpus
87

  
88
corpus_units = analecCorpus.getUnites(unit_type)
89

  
90
if (corpus_units == null) {
91
	println "** no URS Annotations '"+unit_type+"' corpus unit type in corpus "+corpusName+". Aborting."
92
	return false
93
}
94

  
95
struct = analecCorpus.getStructure()
96

  
97
if (struct == null) {
98
	println "** no URS Annotations structure in corpus "+corpusName+". Aborting."
99
	return false
100
}
101

  
102
struct_units = struct.getUnites()
103

  
104
if (struct_units == null) {
105
	println "** no URS Annotations structure units in corpus "+corpusName+". Aborting."
106
	return false
107
}
108

  
109
if (debug > 0) {
110

  
111
println "unit types: "+struct_units
112
println unit_type+" properties: "+struct.getNomsProps(Unite.class, unit_type)
113

  
114
}
115

  
116
// check Unit type
117
props = struct.getNomsProps(Unite.class, unit_type)
118

  
119
// if necessary, add new property to unit type
120

  
121
if ((props == null) || (!props.contains(newProperty))) {
122
	struct.ajouterProp(Unite.class, unit_type, newProperty)
123
}
124

  
125
// verify that the property is added to unit_type unit type
126
props = struct.getNomsProps(Unite.class, unit_type)
127

  
128
if (props == null) {
129
	println "** impossible to add new property '"+newProperty+"' to '"+unit_type+"' unit type in corpus "+corpusName+". Aborting."
130
	return false
131
}
132
	
133
if (!props.contains(newProperty)) {
134
	println "** impossible to add new property '"+newProperty+"' to '"+unit_type+"' unit type in corpus "+corpusName+". Aborting."
135
	return false
136
}
137

  
138
// check Vue
139
vue = URSCorpora.getVue(corpus)
140

  
141
if (vue == null) {
142
	println "** no URS 'vue' for corpus "+corpusName+". Aborting."
143
	return false
144
}
145

  
146
vue_units = vue.getTypesUnitesAVoir()
147

  
148
if (vue_units == null) {
149
	println "** no URS Annotations vue units in corpus "+corpusName+". Aborting."
150
	return false
151
}
152

  
153
props = vue.getNomsChamps(Unite.class, unit_type)
154

  
155
if (debug > 0) {
156
	println "vue unit types: "+vue_units
157
	println unit_type+" vue fields: "+props
158
}
159

  
160
// if necessary, add the new property to unit_type unit type in vue
161

  
162
if ((props == null) || (!props.contains(newProperty))) {
163
	vue.ajouterProp(Unite.class, unit_type, newProperty)
164
}
165

  
166
// verify that the property is added to unit_type unit type in vue
167
props = vue.getNomsChamps(Unite.class, unit_type)
168

  
169
if (props == null) {
170
	println "** impossible to add properties to '"+unit_type+"' unit type in vue of corpus "+corpusName+". Aborting."
171
	return false
172
}
173

  
174
if (!props.contains(newProperty)) {
175
		println "** impossible to add property '"+newProperty+"' to '"+unit_type+"' unit type in vue of corpus "+corpusName+". Aborting."
176
		return false
177
}
178

  
179
selectedUnits.each { unit ->
180
	def val = unit.getProp(propertyToClone)
181
   	vue.setValeurChamp(unit, newProperty, val)
182
}
183

  
184
println nUnits+" properties cloned (but not saved)."
185

  
186
corpus.setIsModified(true)
187

  
188
return true
189

  
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ComputeProgressMonitorDialog.java (revision 3361)
101 101
		this.run(cancelable, runnable);
102 102
	}
103 103
	
104
	
105 104
	/**
106 105
	 * Runs the given <code>IRunnableWithProgress</code>.
107 106
	 * 
......
114 113
		this.run(true, cancelable, runnable);
115 114
	}
116 115
	
117
	
118 116
	@Override
119 117
	public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
120 118
		
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 3361)
622 622
				
623 623
				installPreferenceRestored = false; // reset and finally set true if the process ended correctly
624 624
				
625
				try {
626
					Display.getDefault().syncExec(new Runnable() {
627
						
628
						@Override
629
						public void run() {
630
							OpenWelcomePage.openWelcomePage();
631
						}
632
					});
633
				}
634
				catch (Exception e2) {
635
					try {
636
						OpenWelcomePage.openWelcomePage();
637
					} catch (Exception e3) { }
638
				}
639
				
640 625
				// set the install directory preference
641 626
				String installpath = Platform.getInstallLocation().getURL().getFile(); // the TXM.exe file path
642 627
				File installDirectory = new File(installpath);
......
1020 1005
			}
1021 1006
		});
1022 1007
		
1008
		try {
1009
			Display.getDefault().syncExec(new Runnable() {
1010
				
1011
				@Override
1012
				public void run() {
1013
					OpenWelcomePage.openWelcomePage();
1014
				}
1015
			});
1016
		}
1017
		catch (Exception e2) {
1018
			try {
1019
				Display.getCurrent().syncExec(new Runnable() {
1020
					
1021
					@Override
1022
					public void run() {
1023
						OpenWelcomePage.openWelcomePage();
1024
					}
1025
				});
1026
			}
1027
			catch (Exception e3) {
1028
				try {
1029
					OpenWelcomePage.openWelcomePage();
1030
				} catch (Exception e4) { }
1031
			}
1032
		}
1033
		
1023 1034
		monitor.setTaskName(""); //$NON-NLS-1$
1024 1035
	}
1025 1036
	
TXM/trunk/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 3361)
1465 1465
		StatusLine.setMessage(ConcordanceUIMessages.startComputingConcordance);
1466 1466
		
1467 1467
		try {
1468
			
1469 1468
			QueriesView.refresh();
1470 1469
			
1471
			this.fillDisplayArea(update);
1470
			this.fillDisplayArea(update );
1472 1471
			
1473 1472
			boolean b = concordance.getQueryResultParameter() == null;
1474 1473
			this.queryWidget.setEnabled(b); // disable the widget if a QueryResult was provided
......
2306 2305
		getResultArea().layout(true, true);
2307 2306
	}
2308 2307
	
2309
	/*
2310
	 * 
2308
	/**
2309
	 * @return the number of lines in the table
2311 2310
	 */
2312
	public void resetRightTableColumnWidths() {
2311
	public int resetRightTableColumnWidths() {
2313 2312
		
2314 2313
		float W = 1f + queryLabel.getSize().x / (float) queryLabel.getText().length();
2315 2314
		
2315
		int n = 0;
2316 2316
		TableColumn[] columns = viewerRight.getTable().getColumns();
2317 2317
		for (int i = 0; i < columns.length; i++) {
2318 2318
			TableColumn column = columns[i];
......
2321 2321
			int max = column.getText().length();
2322 2322
			if (max == 0) continue; // skip no-title columns
2323 2323
			
2324
			int n = 0;
2324
			n = 0;
2325 2325
			for (TableItem item : viewerRight.getTable().getItems()) {
2326 2326
				if (max < item.getText(i).length()) max = item.getText(i).length();
2327 2327
				if (n++ > 100) break; // stop testing after 100 lines
......
2336 2336
		
2337 2337
		viewerRight.getTable().layout(true, true);
2338 2338
		tableResizeListener.handleEvent(null); // center on keyword column
2339
		return n;
2339 2340
	}
2340 2341
	
2341 2342
	/**
......
2344 2345
	 * Use this method after recomputing a result
2345 2346
	 * 
2346 2347
	 * The characters width is estimated using the queryLabel length
2348
	 * @return the number of lines in the table
2347 2349
	 */
2348
	public void resetColumnWidths() {
2350
	public int resetColumnWidths() {
2349 2351
		resetLeftTableColumnWidths();
2350
		resetRightTableColumnWidths();
2352
		return resetRightTableColumnWidths();
2351 2353
	}
2352 2354
	
2353 2355
	public Composite getExtensionButtonComposite() {
TXM/trunk/org.txm.concordance.rcp/src/org/txm/concordance/rcp/handlers/ComputeConcordance.java (revision 3361)
81 81
		}
82 82
		
83 83
		StatusLine.setMessage(ConcordanceUIMessages.openingTheConcordanceResult);
84
		TXMEditor.openEditor(concordance, ConcordanceEditor.class.getName());
85
		return null;
84
		return TXMEditor.openEditor(concordance, ConcordanceEditor.class.getName());
86 85
	}
87 86
	
88 87
	public static TXMEditor openEditor(Concordance concordance) {

Formats disponibles : Unified diff