Révision 861

tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 861)
498 498
		try {
499 499
			
500 500
			
501
			// remove result local nodes if persistence preference is disabled
501
			// FIXME: tmp solution before IProject: remove all not persistable result nodes
502
			TXMPreferences.deleteAllNotPersistableResultsNodes();
503
			
504
			// FIXME: tmp solution before IProject: remove result local nodes if persistence preference is disabled
502 505
			if (!TBXPreferences.getBoolean(TBXPreferences.AUTO_SAVE_RESULTS, TBXPreferences.PREFERENCES_NODE)) {
503 506
				TXMPreferences.deleteAllResultsNodes();
504 507
			}
......
520 523
			//			}
521 524
			//		}
522 525
		} catch(Exception e) {
523
			Log.severe("Error while saving preferences.");
526
			Log.severe("Error while saving preferences and session results.");
524 527
			e.printStackTrace();
525 528
		}
526 529
	}
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 861)
989 989
			String[] keys = preferences.keys();
990 990
			Arrays.sort(keys);
991 991
			for(int i = 0; i < keys.length; i++) {
992
				str.put(keys[i],preferences.get(keys[i], ""));
992
				str.put(keys[i],preferences.get(keys[i], "")); //$NON-NLS-1$
993 993
			}
994 994
		}
995 995
		catch(BackingStoreException e) {
......
1006 1006
		
1007 1007
		IEclipsePreferences preferences = scope.getNode(nodeQualifier);
1008 1008
		
1009
		str.append("Path = " +  preferences.absolutePath() + "\n");
1009
		str.append("Path = " +  preferences.absolutePath() + "\n"); //$NON-NLS-1$  //$NON-NLS-2$
1010 1010
		
1011 1011
		try {
1012 1012
			String[] keys = preferences.keys();
1013 1013
			Arrays.sort(keys);
1014 1014
			for(int i = 0; i < keys.length; i++) {
1015
				str.append(keys[i] + " = " + preferences.get(keys[i], "") + "\n");
1015
				str.append(keys[i] + " = " + preferences.get(keys[i], "") + "\n"); //$NON-NLS-1$  //$NON-NLS-2$
1016 1016
			}
1017 1017
		}
1018 1018
		catch(BackingStoreException e) {
......
1036 1036
		// result scope node
1037 1037
		if(result != null)	{
1038 1038
			if(resultScopeNodeExists(result))	{
1039
				System.out.println("TXMPreferences.dump(): Result scope preferences for node " + result.getUUID() + ":");
1039
				Log.finest("TXMPreferences.dump(): Result scope preferences for node " + result.getUUID() + ":");
1040 1040
				dump(result.getUUID());
1041 1041
			}
1042 1042
			else	{
1043
				System.out.println("TXMPreferences.dump(): No result scope preferences was found for node" + result.getUUID() + ".");
1043
				Log.severe("TXMPreferences.dump(): No result scope preferences was found for node" + result.getUUID() + ".");
1044 1044
			}
1045 1045
		}
1046 1046
		// command scope node
1047 1047
		if(nodeQualifier != null)	{
1048
			System.out.println("TXMPreferences.dump(): Command scope preferences for node " + nodeQualifier + ":");
1048
			Log.finest("TXMPreferences.dump(): Command scope preferences for node " + nodeQualifier + ":");
1049 1049
			dump(nodeQualifier);
1050 1050
		}
1051 1051
		else	{
1052
			System.out.println("TXMPreferences.dump(): No Command scope was asked to dump.");
1052
			Log.finest("TXMPreferences.dump(): No Command scope was asked to dump.");
1053 1053
		}
1054 1054

  
1055 1055
		// alternative global scope nodes
1056 1056
		for(int i = 0; i < alternativeNodesQualifiers.size(); i++) {
1057
			System.out.println("TXMPreferences.dump(): Alternative global scope preferences for node " + alternativeNodesQualifiers.get(i) + ":");
1057
			Log.finest("TXMPreferences.dump(): Alternative global scope preferences for node " + alternativeNodesQualifiers.get(i) + ":");
1058 1058
			dump(alternativeNodesQualifiers.get(i));
1059 1059
		}
1060 1060
	}
......
1066 1066
	 */
1067 1067
	public static void flush(TXMResult result)	{
1068 1068
		try {
1069
			System.err.println("TXMPreferences.flush(): Local preferences for object " + result.getUUID() + " saved to file.");
1069
			Log.finest("TXMPreferences.flush(): Local preferences for object " + result.getUUID() + " saved to file.");
1070 1070
			// FIXME: useless?
1071 1071
			//scope.getNode(result.getUUID()).sync();
1072 1072
			scope.getNode(result.getUUID()).flush();
......
1102 1102
			e.printStackTrace();
1103 1103
		}
1104 1104
	}
1105

  
1105 1106
	
1106 1107
	/**
1108
	 * Deletes all the result nodes from the preferences and files that are not set as persistable.
1109
	 */
1110
	public static void deleteAllNotPersistableResultsNodes()	{
1111
		ArrayList<String> resultsNodesQualifier = getAllResultsNodesQualifiers();
1112
		for (int i = 0; i < resultsNodesQualifier.size(); i++) {
1113
			if(!TXMResult.getResult(resultsNodesQualifier.get(i)).isPersistable())	{
1114
				delete(scope.getNode(resultsNodesQualifier.get(i)));
1115
			}
1116
		}
1117
	}
1118

  
1119
	
1120
	/**
1107 1121
	 * Deletes all the result nodes from the preferences and files.
1108 1122
	 */
1109 1123
	public static void deleteAllResultsNodes()	{
1110 1124
		ArrayList<String> resultsNodesQualifier = getAllResultsNodesQualifiers();
1111 1125
		for (int i = 0; i < resultsNodesQualifier.size(); i++) {
1126
			TXMResult.getResult(resultsNodesQualifier.get(i)).isPersistable();
1112 1127
			delete(scope.getNode(resultsNodesQualifier.get(i)));
1113 1128
		}
1114 1129
	}
1115 1130
	
1116 1131
	
1117 1132
	/**
1118
	 * Gets all the result nodes qualifiers (from *.prefs file starting with TXMResult.UUID_PREFIX, eg.: "txm_res_").
1133
	 * Gets all the result nodes qualifiers (from scope or *.prefs files starting with TXMResult.UUID_PREFIX, eg.: "txm_res_").
1119 1134
	 * @return
1120 1135
	 */
1121 1136
	public static ArrayList<String> getAllResultsNodesQualifiers()	{
......
1243 1258
//			scope.getNode(nodeQualifier).putByteArray(key, (byte[]) value);
1244 1259
//		}
1245 1260
		else if(value != null) {
1261
			scope.getNode(nodeQualifier).put(key, value.toString());
1262
			
1263
			
1246 1264
		// FIXME: to do if needed
1247 1265
			//FIXME: Debug
1248
			System.err.println("TXMPreferences.putLocal(): error, can't find a put method that matches the value type: " + value.getClass() + "=" + value + ".");
1266
			//System.err.println("TXMPreferences.put(): error, can't find a put method that matches the value type: " + value.getClass() + "=" + value + ".");
1249 1267
		}
1250 1268
	}
1251 1269

  
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 861)
129 129
	protected HashMap<String, Object> lastParameters = new HashMap<String, Object>();
130 130

  
131 131

  
132
	/**
133
	 * Persistable state.
134
	 */
135
	protected boolean persistable;
136
	
132 137

  
133 138
	/**
134 139
	 * Creates a new TXMResult, child of the specified parent.
......
188 193
		// + this.preferencesNodeQualifier + ", class = " + getClass());
189 194

  
190 195
		this.dirty = true;
196
		this.persistable = true;
197
		
191 198

  
192

  
193 199
		// retrieving parent from UUID
194 200
		if(parent == null && uuid != null && !this.getStringParameterValue(TXMPreferences.PARENT_UUID).isEmpty())	{
201
			Log.warning("Searching parent with UUID: " + this.getStringParameterValue(TXMPreferences.PARENT_UUID) + "...");
195 202
			TXMResult retrievedParent = TXMResult.getResult(this.getStringParameterValue(TXMPreferences.PARENT_UUID));
196 203
			if (retrievedParent != null) {
197 204
				Log.warning("Parent retrieved from UUID: " + retrievedParent + ".");
198 205
				retrievedParent.addChild(this);
199 206
			}
207
			else	{
208
				Log.severe("No parent found in workspace.");
209
			}
200 210
		}
201 211

  
202 212
		// retrieving user name
......
710 720
		System.out.println("TXMResult.autoSaveParametersFromAnnotations(): " + this.getClass().getSimpleName() + ": saving parameters to local node...");
711 721

  
712 722
		// internal data to save for unserialization
713
		this.saveParameter("class", this.getClass().getName());
723
		this.saveParameter("class", this.getClass().getName()); //$NON-NLS-1$
714 724
		// store the user name if exists otherwise the simple name
715 725
		if(this.userName != null)	{
716 726
			this.saveParameter(TXMPreferences.NAME, this.userName);
......
827 837
				f.set(this, value);
828 838

  
829 839
				// FIXME: Debug
830
				System.err.println("TXMResult.autoLoadParametersFromAnnotations(): setting parameter " + key + " = " + value + " for " + this.getClass());
840
				Log.finest("TXMResult.autoLoadParametersFromAnnotations(): setting parameter " + key + " = " + value + " for " + this.getClass());
831 841

  
832 842
			} catch (Exception e) {
833 843
				e.printStackTrace();
......
1615 1625
		}
1616 1626

  
1617 1627
		// FIXME: file persistence flush tests
1618
		if (TBXPreferences.getBoolean(TBXPreferences.AUTO_SAVE_RESULTS, TBXPreferences.PREFERENCES_NODE)) {
1628
		if (this.persistable && TBXPreferences.getBoolean(TBXPreferences.AUTO_SAVE_RESULTS, TBXPreferences.PREFERENCES_NODE)) {
1619 1629
			Log.finest("TXMResult.compute(): flushing local preferences node in file for persistence tests.");
1620 1630
			TXMPreferences.flush(this);
1621 1631
		}
......
1796 1806
	public void setHasBeenComputedOnce(boolean hasBeenComputedOnce) {
1797 1807
		this.hasBeenComputedOnce = hasBeenComputedOnce;
1798 1808
	}
1809

  
1810
	/**
1811
	 * Gets the persistable state. 
1812
	 * @return the persistable
1813
	 */
1814
	public boolean isPersistable() {
1815
		return persistable;
1816
	}
1817

  
1818
	/**
1819
	 * Sets the persistable state. If set to false, the result will never be saved to file.
1820
	 * @param persistable the persistable to set
1821
	 */
1822
	public void setPersistable(boolean persistable) {
1823
		this.persistable = persistable;
1824
	}
1799 1825
}
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 861)
48 48
	/**
49 49
	 * The property.
50 50
	 */
51
	@Parameter(key=LexicalTablePreferences.UNIT_PROPERTY)
51
	@Parameter(key=TBXPreferences.UNIT_PROPERTY)
52 52
	private Property property;
53 53
	
54 54
	/**
55 55
	 * Minimum frequency.
56 56
	 */
57
	@Parameter(key=LexicalTablePreferences.F_MIN)
57
	@Parameter(key=TBXPreferences.F_MIN)
58 58
	private int fMinFilter;
59 59

  
60 60
	/**
61 61
	 * Maximum number of lines.
62 62
	 */
63
	@Parameter(key=LexicalTablePreferences.V_MAX)
63
	@Parameter(key=TBXPreferences.V_MAX)
64 64
	private int vMaxFilter;
65 65
	
66 66
	/**
......
170 170
	@Override
171 171
	public boolean loadParameters() {
172 172
		try {
173
			this.property = this.getCorpus().getProperty(this.getStringParameterValue(LexicalTablePreferences.UNIT_PROPERTY));
173
			// FIXME: debug
174
			System.err.println("LexicalTable.loadParameters(): loading unit property...");
175
			this.property = this.getCorpus().getProperty(this.getStringParameterValue(TBXPreferences.UNIT_PROPERTY));
176
			System.err.println("LexicalTable.loadParameters(): property = " + this.property);
174 177
		}
175 178
		catch (CqiClientException e) {
176 179
			// TODO Auto-generated catch block
......
182 185
	
183 186
	@Override
184 187
	public boolean saveParameters() {
185
		if(this.property != null)	{
186
			this.saveParameter(TBXPreferences.UNIT_PROPERTY, this.property.getName());
187
		}
188
		this.saveParameter(TBXPreferences.UNIT_PROPERTY, this.property);
188 189
		return true;
189 190
	}
190 191

  
tmp/org.txm.index.core/src/org/txm/index/core/messages/messages.properties (revision 861)
13 13

  
14 14
LexiconDetailsFromPartition = Lexicon:\n\	Partition {0}\n\	query {1}\n\	properties {2}\n\	Fmin {3}\n\	Fmax {4}
15 15

  
16
Lexicon_0                   = Forms and frequencies tables must be of the same length.
17
Lexicon_3                   = Lexicon : 
16
Lexicon_0                   = Forms and frequencies tables must have the same size.
17
Lexicon_3                   = Lexicon: 
18 18

  
19 19
RESULT_TYPE = Index
tmp/org.txm.index.core/src/org/txm/index/core/messages/IndexCoreMessages.java (revision 861)
3 3
import org.eclipse.osgi.util.NLS;
4 4
import org.txm.utils.messages.Utf8NLS;
5 5

  
6
/**
7
 * 
8
 * @author sjacquot
9
 *
10
 */
6 11
public class IndexCoreMessages extends NLS {
7 12

  
13
	private static final String BUNDLE_NAME = "org.txm.index.core.messages.messages"; //$NON-NLS-1$
14
	
8 15
	public static String DetailsFromPartition;
9 16
	public static String DetailsFromCorpus;
10 17
	
......
24 31
	
25 32
	static {
26 33
		// initialize resource bundle
27
		Utf8NLS.initializeMessages(IndexCoreMessages.class);
34
		Utf8NLS.initializeMessages(BUNDLE_NAME, IndexCoreMessages.class);
28 35
	}
29 36

  
30 37
	private IndexCoreMessages() {
tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 861)
39 39

  
40 40
import org.eclipse.core.runtime.IProgressMonitor;
41 41
import org.txm.core.messages.TXMCoreMessages;
42
import org.txm.core.preferences.TBXPreferences;
43
import org.txm.core.results.Parameter;
42 44
import org.txm.core.results.TXMParameters;
43 45
import org.txm.core.results.TXMResult;
44 46
import org.txm.index.core.messages.IndexCoreMessages;
......
83 85
	/** The number of tokens. */
84 86
	int numberOfTokens = -1;
85 87

  
86
	/** The property. */
87
	private Property pProperty;
88

  
89 88
	/** The symbol. */
90 89
	private String symbol;
91 90

  
......
95 94
	private Corpus corpus;
96 95

  
97 96
	
97

  
98
	/**
99
	 * The property.
100
	 */
101
	@Parameter(key=TBXPreferences.UNIT_PROPERTY)
102
	protected Property pProperty;
103

  
98 104
	
99 105
	
100 106
	
......
109 115
	public Lexicon(String uuid, Corpus corpus)	{
110 116
		super(uuid, corpus);
111 117
		this.corpus = (Corpus) this.parent;
118
		this.persistable = false; // FIXME: remove that later
112 119
	}
113 120

  
114 121
	
122

  
115 123
	@Override
116
	public boolean saveParameters() throws Exception {
117
		// TODO Auto-generated method stub
124
	public boolean loadParameters() throws Exception {
125
		try {
126
			this.pProperty = this.getCorpus().getProperty(this.getStringParameterValue(TBXPreferences.UNIT_PROPERTY));
127
		}
128
		catch (CqiClientException e) {
129
			// TODO Auto-generated catch block
130
			e.printStackTrace();
131
			return false;
132
		}
118 133
		return true;
119 134
	}
120 135

  
136
	
121 137
	@Override
122
	public boolean loadParameters() throws Exception {
123
		// TODO Auto-generated method stub
138
	public boolean saveParameters() throws Exception {
139
		this.saveParameter(TBXPreferences.UNIT_PROPERTY, this.pProperty);
124 140
		return true;
125 141
	}
126 142

  
143
	
127 144
	@Override
128 145
	public void clean() {
129 146
		// TODO Auto-generated method stub
......
144 161
			return computewithSubCorpus((Subcorpus)corpus, pProperty, monitor);
145 162
		}
146 163
		else {
147
			System.out.println("Error: Lexicon parent is neither a Maincorpus nor a Subcorpus.");
164
			Log.severe("Error: Lexicon parent is neither a Maincorpus nor a Subcorpus.");
148 165
			return false;
149 166
		}
150 167
	}
......
164 181
		// System.out.println("in "+this.getCqpId()+" look for cached lexicon "+property);
165 182
		// System.out.println("not found");
166 183
		this.subTask("Computing lexicon size...");
167
		Log.finest(TXMCoreMessages.LEXICON + corpus.getName());
184
		Log.finest(IndexCoreMessages.LEXICON_RESULT_TYPE + corpus.getName());
168 185
		int lexiconSize;
169 186
		try {
170 187
			lexiconSize = CorpusManager.getCorpusManager().getCqiClient().lexiconSize(property.getQualifiedName());
......
185 202
			throw new CqiClientException(e);
186 203
		}
187 204

  
188
		init(corpus, property, freqs, ids);
205
		this.init(corpus, property, freqs, ids);
189 206
		return true;
190 207
	}
191 208

  
......
418 435
		return ids;
419 436
	}
420 437

  
438
	@Override
421 439
	public String getName() {
422 440
		try {
423 441
			return IndexCoreMessages.LEXICON_RESULT_TYPE + ": " + this.corpus.getSimpleName() + ": " + this.getSimpleName();	
......
436 454
		return pProperty;
437 455
	}
438 456

  
457
	@Override
439 458
	public String getSimpleName() {
440 459
		try {
441 460
			return this.getProperty().getName();
tmp/org.txm.links.rcp/src/org/txm/links/rcp/handlers/SendSelectionToQueryable.java (revision 861)
30 30
import org.eclipse.core.commands.ExecutionEvent;
31 31
import org.eclipse.core.commands.ExecutionException;
32 32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.contexts.IContextActivation;
36
import org.eclipse.ui.contexts.IContextService;
37 33
import org.eclipse.ui.handlers.HandlerUtil;
38 34
import org.txm.core.preferences.TXMPreferences;
39 35
import org.txm.core.results.TXMResult;
......
73 69
	@Override
74 70
	public Object execute(ExecutionEvent event) throws ExecutionException {
75 71
		
76
		System.err.println("SendSelectionToQueryable.execute()");
77
		
78 72
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
79
		//String commandId = event.getParameter("sendToTargetCommandId"); //$NON-NLS-1$
80
		
81
		String commandId = event.getCommand().getId();
82
		
83
		
84
		
85
		if (
86
				selection != null
87
				//&& 
88
				//commandId != null && !commandId.isEmpty()
89
				) {
73
		if (selection != null) {
90 74
			
91 75
			String query = this.createQuery(event, selection);
92 76
			String queries = this.createQueries(event, selection);
......
102 86
			TXMPreferences.put(uuid, TXMPreferences.QUERY, query);
103 87
			TXMPreferences.put(uuid, TXMPreferences.QUERIES, queries);
104 88
			
89
			BaseAbstractHandler.executeSendToCommand(event.getCommand().getId(), uuid);
105 90
			
106
			//this.getActiveEditor(event).close();
107

  
108
//			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
109
//			IContextService contextService = (IContextService)window.getService(IContextService.class);
110
			
111
			
112
//			IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
113
//			IContextActivation activationToken = contextService.activateContext(SEND_SELECTION_TO_COMMAND_CONTEXT_ID);
114
//			
115
//			
116
////			ICommandService commandManager = (ICommandService) window.getService(ICommandService.class);
117
////			IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
118
////			handlerService.activateHandler(commandId, handler)
119
//			//event.getCommand().getHandler().dispose();
120
//			//event.getCommand().setHandler(handler)
121
//			
122
//			BaseAbstractHandler.executeCommand(commandId, uuid);
123
//			
124
//			
125
//			contextService.deactivateContext(activationToken);
126

  
127

  
128
			BaseAbstractHandler.executeSendToCommand(commandId, uuid);
129
			
130 91
		}
131 92
		else	{
132 93
			this.logCanNotCompute(selection);
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 861)
133 133
	
134 134
	
135 135
	
136
	/**
137
	 * Creates a not computed Specificities.
138
	 * @param parent
139
	 */
140
	public Specificities(LexicalTable parent) {
141
		super(parent);
142
	}
143

  
144

  
136 145
	
146
	/**
147
	 * Creates a not computed Specificities.
148
	 * @param uuid
149
	 */
150
	public Specificities(String uuid)	{
151
		this(uuid, null);
152
	}
137 153
	
138
	
139
	
140 154
	/**
141
	 * Specificities.
155
	 * Creates a not computed Specificities.
142 156
	 *
143
	 * @param lexicalTable the table
157
	 * @param parent the table
144 158
	 * @return the specificities result
145 159
	 * @throws CqiClientException the cqi client exception
146 160
	 * @throws StatException the stat exception
147 161
	 */
148
	public Specificities(LexicalTable lexicalTable)	throws CqiClientException, StatException {
149
		super(lexicalTable);
150
		this.lexicalTable = lexicalTable;
162
	public Specificities(String uuid, LexicalTable parent) {
163
		super(uuid, parent);
164
	}
165
	
166
	
167
	
168
	@Override
169
	public boolean loadParameters() {
170
		this.lexicalTable = (LexicalTable) this.parent;
151 171
		this.unitProperty = this.lexicalTable.getProperty();
152 172
		this.lexicalTable.setVMaxFilter(Integer.MAX_VALUE);
173
		return true;
153 174
	}
175

  
176
	@Override
177
	public boolean saveParameters() {
178
		// nothing to do
179
		return true;
180
	}
154 181
	
155 182

  
183
	
184

  
156 185
	@Override
157 186
	protected boolean _compute() throws Exception {
158 187
		
......
696 725
		return true;
697 726
	}
698 727

  
699
	@Override
700
	public boolean loadParameters() {
701
		// nothing to do
702
		return true;
703
	}
704

  
705
	@Override
706
	public boolean saveParameters() {
707
		// nothing to do
708
		return true;
709
	}
710 728
	
711
	
712 729
	/**
713 730
	 * @return the maxScore
714 731
	 */
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitiesSelection.java (revision 861)
9 9
import org.txm.chartsengine.core.results.ChartResult;
10 10
import org.txm.core.results.Parameter;
11 11
import org.txm.core.results.TXMParameters;
12
import org.txm.core.results.TXMResult;
12 13
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
13 14

  
14 15
/**
......
63 64

  
64 65
	
65 66
	
67

  
66 68
	
67 69
	/**
68 70
	 * Creates an empty SpecificitiesSelection.
......
72 74
		super(parent);
73 75
	}
74 76

  
77

  
75 78
	
79
	public SpecificitiesSelection(String uuid)	{
80
		this(uuid, null);
81
	}
82
	
83
	public SpecificitiesSelection(String uuid, Specificities parent)	{
84
		super(uuid, parent);
85
	}
76 86

  
87
	
88
	
89
	
90

  
77 91
	@Override
78 92
	public boolean loadParameters() {
79 93
		// nothing to do

Formats disponibles : Unified diff