Révision 742

tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 742)
169 169
			TableColumn separatorColumn = new TableColumn(specificitesTable, SWT.NONE);
170 170
			separatorColumn.setResizable(false);
171 171

  
172

  
173

  
174 172
			specificitesTable.setHeaderVisible(true);
175 173

  
176 174
			// Horizontal bar on second table takes up a little extra space.
......
245 243

  
246 244
			
247 245
			// units
248
			String[] typeNames = getResult().getTypeNames();
246
			String[] typeNames = this.getResult().getTypeNames();
249 247
			// units' total freq
250
			int[] typeFreq = getResult().getFormFrequencies();
248
			int[] typeFreq = this.getResult().getFormFrequencies();
251 249
			// units' index fr each part
252
			double[][] specIndex = getResult().getSpecificitesIndex();
253
			int[][] specFreqs = getResult().getFrequency();
250
			double[][] specIndex = this.getResult().getSpecificitesIndex();
251
			int[][] specFreqs = this.getResult().getFrequency();
254 252
			
255 253
			// units' total in parts
256 254
			//final int[] sortedPartIndexes = specificitesResult.getSortedPartIndexes();
tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 742)
33 33
import java.io.IOException;
34 34
import java.io.OutputStreamWriter;
35 35
import java.io.UnsupportedEncodingException;
36
import java.util.ArrayList;
36 37
import java.util.Arrays;
37 38
import java.util.Map;
38 39

  
......
189 190
	 * @return
190 191
	 * @throws CqiClientException
191 192
	 */
193
	// FIXME: why this method needs to create and delete some new subcorpus???? the computing can't be done directly on the corpus argument???
194
	// eg. dist = CorpusManager.getCorpusManager().getCqiClient().fdist1(corpus.getQualifiedCqpId(), 0,	ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
192 195
	protected boolean computewithSubCorpus(Subcorpus corpus, Property property, IProgressMonitor monitor) throws CqiClientException {
193 196

  
194 197
		//System.out.println("not found");
......
200 203
			this.subTask("Computing lexicon frequencies...");
201 204
			tmp = corpus.createSubcorpus(new Query("[]"), "S"+corpus.getNextSubcorpusCounter(), true); //$NON-NLS-1$
202 205
			if (tmp != null) {
203
				fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(
204
						tmp.getQualifiedCqpId(), 0,
205
						ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
206
				fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(tmp.getQualifiedCqpId(), 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
206 207

  
207
				corpus.dropSubcorpus(tmp); // drop the subcorpus only if correctly created
208
				corpus.dropSubcorpus(tmp);
209
				tmp.delete();
208 210
			}
209 211
			//System.out.println("nb lines: "+fdist.length);
210 212
		} catch (Exception e) {
211 213
			throw new CqiClientException(e);
212 214
		} finally {
213 215
			if (tmp != null) {
214
				try {corpus.dropSubcorpus(tmp);}
215
				catch (Exception e2) {}
216
				try {
217
					corpus.dropSubcorpus(tmp);
218
					tmp.delete();
219
				}
220
				catch (Exception e2) {
221
				}
216 222
			}
217 223
		}
218 224
		int lexiconSize = fdist.length;
......
579 585
		this.pProperty = property;
580 586
	}
581 587

  
588

  
589
	/**
590
	 * Gets a Lexicon from the specified corpus.
591
	 * If a Lexicon child exists in the Corpus fro the specified property, returns it otherwise creates and computes a new Lexicon.
592
	 * @param corpus
593
	 * @param property
594
	 * @return
595
	 * @throws Exception
596
	 */
597
	public static Lexicon getLexicon(Corpus corpus, Property property, IProgressMonitor monitor) throws Exception {
598
		Lexicon lexicon = null;
599
		
600
		// recycling parent Lexicon if exists 
601
		ArrayList<Lexicon> partLexicons = (ArrayList<Lexicon>)corpus.getChildren(Lexicon.class);
602
		for (int i = 0; i < partLexicons.size(); i++) {
603
			if(partLexicons.get(i).getProperty() == property)	{
604
				lexicon = partLexicons.get(i);
605
				break;
606
			}
607
		}
608
		
609
		// creating new Lexicon
610
		if(lexicon == null || lexicon.getProperty() != property)	{
611
			lexicon = new Lexicon(corpus);
612
			lexicon.setProperty(property);
613
			lexicon.compute(monitor);
614
		}
615
		return lexicon;
616
	}
582 617
	
618
	
583 619
//	/**
584 620
//	 * Find or build a lexicon given a Corpus (MainCorpus or SubCorpus).
585 621
//	 * 
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 742)
223 223

  
224 224
		this.filterLines();
225 225

  
226
		Log.info("Sorting...");
226
		this.subTask("Sorting...");
227
		
227 228
		this.sortLines(SortMode.FREQUNIT, true);
228 229

  
229 230
		this.cut();
230 231

  
231 232
		this.dirty = false;
232 233
		this.pTopIndex = 0;
233
		Log.info("Index done.");
234
		
235
		this.subTask("Index done.");
236
		
234 237
		return true;
235 238
	}
236 239
	
......
416 419
				lexicon.setProperty(property);
417 420
				lexicon.compute(null);
418 421
			} else {
419
				lexicon.setParameters(this.pProperties.get(0));
422
				lexicon.setProperty(this.pProperties.get(0));
420 423
				lexicon.compute(monitor);
421 424
			}
422 425

  
......
527 530
	}
528 531

  
529 532
	/**
530
	 * return all the lines of the index.
531
	 *
532
	 * @return the all lines
533
	 */
534
	public List<Line> getAllLines() {
535
		return getLines(0, lines.size());
536
	}
537

  
538
	/**
539 533
	 * Gets the corpus.
540 534
	 *
541 535
	 * @return the corpus
......
693 687
		return selectedLines;
694 688
	}
695 689

  
690
	
691
	/**
692
	 * return all the lines of the index.
693
	 *
694
	 * @return the all lines
695
	 */
696
	public List<Line> getAllLines() {
697
		return getLines(0, lines.size());
698
	}
699

  
700
	/**
701
	 * update the lines counts.
702
	 */
703
	protected void setLineCounts() {
704
		for (Line line : lines) {// for each Line set its count
705
			int[] c = new int[partnames.size()];
706
			for (int i = 0; i < partnames.size(); i++) {
707
				if (counts.get(line.getSignature()).size() <= i) {
708
					c[i] = 0;
709
				}
710
				else {
711
					c[i] = counts.get(line.getSignature()).get(i);
712
				}
713
			}
714
			line.setCounts(c, -1);
715
		}
716
	}
717
	
718

  
719
	
720
	
696 721
	@Override
697 722
	public String getName() {
698 723
		try {
......
963 988
		this.lexiconMode = mode;
964 989
	}
965 990

  
966
	/**
967
	 * update the lines counts.
968
	 */
969
	protected void setLineCounts() {
970
		for (Line line : lines) {// for each Line set its count
971
			int[] c = new int[partnames.size()];
972
			for (int i = 0; i < partnames.size(); i++) {
973
				if (counts.get(line.getSignature()).size() <= i) {
974
					c[i] = 0;
975
				}
976
				else {
977
					c[i] = counts.get(line.getSignature()).get(i);
978
				}
979
			}
980
			line.setCounts(c, -1);
981
		}
982
	}
983 991

  
992

  
984 993
	public void setNLinesPerPage(int nLinesPerPage) {
985 994
		this.pNLinesPerPage = Math.max(nLinesPerPage, 1);
986 995
	}
......
1180 1189
	public void toTxt(File outfile, int from, int to, String encoding, String colseparator, String txtseparator)
1181 1190
			throws CqiClientException, IOException {
1182 1191
		// NK: writer declared as class attribute to perform a clean if the operation is interrupted
1183
		this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile),
1184
				encoding)); 
1192
		this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile), encoding)); 
1185 1193
		// if ("UTF-8".equals(encoding)) writer.write('\ufeff'); // UTF-8 BOM
1186 1194
		String header = ""; //$NON-NLS-1$
1187
		for (Property p : pProperties)
1195
		for (Property p : pProperties) {
1188 1196
			header += (p + pPropertiesSeparator);
1197
		}
1189 1198
		header = txtseparator+ header.substring(0, header.length() - 1) +txtseparator;
1190 1199
		header += colseparator+ txtseparator+ "F" + txtseparator; //$NON-NLS-1$
1191
		if (partnames.size() > 1)
1192
			for (int j = 0; j < partnames.size(); j++)
1193
				header += colseparator + txtseparator+ partnames.get(j).replace(txtseparator, txtseparator+txtseparator)+txtseparator; 
1200
		if (partnames.size() > 1) {
1201
			for (int j = 0; j < partnames.size(); j++) {
1202
				header += colseparator + txtseparator+ partnames.get(j).replace(txtseparator, txtseparator+txtseparator)+txtseparator;
1203
			}
1204
		}
1194 1205
		header += "\n"; //$NON-NLS-1$
1195 1206
		writer.write(header);
1196 1207

  
......
1198 1209
		for (int i = from; i < to; i++) {
1199 1210
			Line ligne = lines.get(i);
1200 1211
			writer.write(txtseparator+ ligne.toString().replace(txtseparator, txtseparator+txtseparator)+ txtseparator + colseparator + ligne.getFrequency()); 
1201
			if (partnames.size() > 1)
1202
				for (int j = 0; j < partnames.size(); j++)
1203
					writer.write(colseparator + ligne.getFrequency(j)); 
1212
			if (partnames.size() > 1) {
1213
				for (int j = 0; j < partnames.size(); j++) {
1214
					writer.write(colseparator + ligne.getFrequency(j));
1215
				}
1216
			}
1204 1217
			writer.write("\n"); //$NON-NLS-1$
1205 1218
		}
1206 1219
		writer.flush();
......
1235 1248
		for (int i = 0; i < lines.size(); i++) {
1236 1249
			Line line = lines.get(i);
1237 1250
			int f = line.getFrequency();
1238
			if (f < Fmin)
1251
			if (f < Fmin) {
1239 1252
				Fmin = f;
1240
			if (f > Fmax)
1253
			}
1254
			if (f > Fmax) {
1241 1255
				Fmax = f;
1256
			}
1242 1257
		}
1243 1258
	}
1244 1259
}
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 742)
34 34
import java.util.Comparator;
35 35
import java.util.List;
36 36

  
37
import org.eclipse.jface.action.MenuManager;
38 37
import org.eclipse.jface.viewers.CellLabelProvider;
39 38
import org.eclipse.jface.viewers.TableViewer;
40 39
import org.eclipse.jface.viewers.TableViewerColumn;
......
48 47
import org.eclipse.swt.layout.FormData;
49 48
import org.eclipse.swt.layout.FormLayout;
50 49
import org.eclipse.swt.layout.GridData;
51
import org.eclipse.swt.layout.GridLayout;
52 50
import org.eclipse.swt.widgets.Button;
53 51
import org.eclipse.swt.widgets.Composite;
54 52
import org.eclipse.swt.widgets.Label;
55
import org.eclipse.swt.widgets.Menu;
56 53
import org.eclipse.swt.widgets.MessageBox;
57 54
import org.eclipse.swt.widgets.Spinner;
58 55
import org.eclipse.swt.widgets.TableColumn;
......
60 57
import org.txm.core.results.Parameter;
61 58
import org.txm.lexicaltable.core.functions.LexicalTable;
62 59
import org.txm.lexicaltable.core.preferences.LexicalTablePreferences;
63
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
64 60
import org.txm.lexicaltable.rcp.handlers.MergeLines;
65 61
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages;
66 62
import org.txm.rcp.StatusLine;
67 63
import org.txm.rcp.editors.TXMEditor;
68 64
import org.txm.rcp.editors.TableKeyListener;
69 65
import org.txm.rcp.messages.TXMUIMessages;
66
import org.txm.rcp.swt.widget.structures.PropertiesComboViewer;
70 67
import org.txm.rcp.views.QueriesView;
71 68
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
72 69
import org.txm.searchengine.cqp.corpus.Corpus;
......
79 76
 * 
80 77
 * @author mdecorde
81 78
 */
82
public class LexicalTableEditor extends TXMEditor	{
79
public class LexicalTableEditor extends TXMEditor<LexicalTable>	{
83 80

  
84 81
	
85 82
	public static final String ID = LexicalTableEditor.class.getName();
......
118 115

  
119 116

  
120 117
	
118
	/**
119
	 * Unit property.
120
	 */
121
	@Parameter(key=LexicalTablePreferences.UNIT_PROPERTY)
122
	protected PropertiesComboViewer unitPropertyComboViewer;
123

  
124
	
121 125
	/** The minfreqspinner. */
122 126
//	@Parameter(key=LexicalTablePreferences.F_MIN)
123 127
	protected Spinner fMin;
......
139 143
	@Override
140 144
	public void _createPartControl(final Composite parent) {
141 145
		
142
		lexicalTable = (LexicalTable) this.getResult();
143
		
144
		Composite paramArea = this.getCommandParametersGroup();
145
		
146
		// Apply button
147
		Button keepTop = new Button(paramArea, SWT.PUSH);
148
		keepTop.setText(LexicalTableUIMessages.LexicalTableEditor_4);
149
		keepTop.addSelectionListener(new SelectionListener() {
150
			@Override
151
			public void widgetSelected(SelectionEvent e) {
152
				StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_16);
153
				System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_5, vMax.getSelection(), fMin.getSelection()));
146
		try {
147
			lexicalTable = (LexicalTable) this.getResult();
148
			
149
			Composite parametersArea = this.getCommandParametersGroup();
150
			
151
			// Apply button
152
			Button keepTop = new Button(parametersArea, SWT.PUSH);
153
			keepTop.setText(LexicalTableUIMessages.LexicalTableEditor_4);
154
			keepTop.addSelectionListener(new SelectionListener() {
155
				@Override
156
				public void widgetSelected(SelectionEvent e) {
157
					StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_16);
158
					System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_5, vMax.getSelection(), fMin.getSelection()));
154 159

  
155
				MessageBox messageBox = new MessageBox(e.display.getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
156
				messageBox.setMessage(TXMUIMessages.common_areYouSure);
157
				int response = messageBox.open();
158
				if (response != SWT.YES) {
159
					return;
160
					MessageBox messageBox = new MessageBox(e.display.getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
161
					messageBox.setMessage(TXMUIMessages.common_areYouSure);
162
					int response = messageBox.open();
163
					if (response != SWT.YES) {
164
						return;
165
					}
166

  
167
					try {
168
						updateResultFromEditor();
169
						refresh(false);
170
					} catch (Exception e1) {
171
						// TODO Auto-generated catch block
172
						org.txm.rcp.utils.Logger.printStackTrace(e1);
173
						StatusLine.setMessage("LexicalTable: sorting error."); //$NON-NLS-1$
174
					}
160 175
				}
161 176

  
162
				try {
163
					updateResultFromEditor();
164
					refresh(false);
165
				} catch (Exception e1) {
166
					// TODO Auto-generated catch block
167
					org.txm.rcp.utils.Logger.printStackTrace(e1);
168
					StatusLine.setMessage("LexicalTable: sorting error."); //$NON-NLS-1$
177
				@Override
178
				public void widgetDefaultSelected(SelectionEvent e) {
169 179
				}
170
			}
180
			});
181
			
182
			// Number of lines
183
			Label nLines = new Label(parametersArea, SWT.NONE);
184
			nLines.setText(TXMCoreMessages.common_numberOfLines);
185
			vMax = new Spinner(parametersArea, SWT.BORDER);
171 186

  
172
			@Override
173
			public void widgetDefaultSelected(SelectionEvent e) {
174
			}
175
		});
176
		
177
		// Number of lines
178
		Label nLines = new Label(paramArea, SWT.NONE);
179
		nLines.setText(TXMCoreMessages.common_numberOfLines);
180
		vMax = new Spinner(paramArea, SWT.BORDER);
187
			// Fmin
188
			Label fmin = new Label(parametersArea, SWT.NONE);
189
			fmin.setText(TXMCoreMessages.common_fMin);
190
			fMin = new Spinner(parametersArea, SWT.BORDER);
181 191

  
182
		// Fmin
183
		Label fmin = new Label(paramArea, SWT.NONE);
184
		fmin.setText(TXMCoreMessages.common_fMin);
185
		fMin = new Spinner(paramArea, SWT.BORDER);
192
			// unit property
193
			new Label(parametersArea, SWT.NONE).setText(TXMCoreMessages.common_property);
194
			this.unitPropertyComboViewer = new PropertiesComboViewer(parametersArea, this, true,
195
					Corpus.getFirstParentCorpus(this.getResult()).getOrderedProperties(),
196
					this.getResult().getProperty(), false);
186 197

  
187
		// Merge or delete columns button
188
		Button fusionCol = new Button(paramArea, SWT.PUSH);
189
		fusionCol.setText(LexicalTableUIMessages.LexicalTableEditor_10);
190
		fusionCol.addSelectionListener(new SelectionListener() {
191
			@Override
192
			public void widgetSelected(SelectionEvent e) {
193
				StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_18);
194
				ArrayList<Object> selection = new ArrayList<Object>();
195
				MergeDeleteDialog d = new MergeDeleteDialog(e.display
196
						.getActiveShell(), new ArrayList<Object>(collist),
197
						selection, -1);
198
			
199
			
200
			// Merge or delete columns button
201
			Button fusionCol = new Button(parametersArea, SWT.PUSH);
202
			fusionCol.setText(LexicalTableUIMessages.LexicalTableEditor_10);
203
			fusionCol.addSelectionListener(new SelectionListener() {
204
				@Override
205
				public void widgetSelected(SelectionEvent e) {
206
					StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_18);
207
					ArrayList<Object> selection = new ArrayList<Object>();
208
					MergeDeleteDialog d = new MergeDeleteDialog(e.display.getActiveShell(), new ArrayList<Object>(collist), selection, -1);
198 209

  
199
				if (d.open() == Window.OK) {
200
					List<Integer> colindices = new ArrayList<Integer>();
201
					for (int i = 0; i < collist.size(); i++) {
202
						if (selection.contains(collist.get(i)))
203
							colindices.add(i);
204
					}
210
					if (d.open() == Window.OK) {
211
						List<Integer> colindices = new ArrayList<Integer>();
212
						for (int i = 0; i < collist.size(); i++) {
213
							if (selection.contains(collist.get(i)))
214
								colindices.add(i);
215
						}
205 216

  
206
					if (d.doMerge()) {
207
						String newname = d.getMergeName();
217
						if (d.doMerge()) {
218
							String newname = d.getMergeName();
208 219

  
209
						System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_11, colindices));
210
						double[] firstcol = cols.get(colindices.get(0));
220
							System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_11, colindices));
221
							double[] firstcol = cols.get(colindices.get(0));
211 222

  
212
						// merge selected cols into the first one
213
						for (int i = 1; i < colindices.size(); i++) {
223
							// merge selected cols into the first one
224
							for (int i = 1; i < colindices.size(); i++) {
225
								for (int j = 0; j < lexicalTable.getNRows(); j++) {
226
									firstcol[j] += cols.get(colindices.get(i))[j];
227
								}
228
							}
229

  
230
							// update first col of the Lexical table
214 231
							for (int j = 0; j < lexicalTable.getNRows(); j++) {
215
								firstcol[j] += cols.get(colindices.get(i))[j];
232
								lexicalTable.getData().set(j, colindices.get(0), firstcol[j]);
216 233
							}
217
						}
218 234

  
219
						// update first col of the Lexical table
220
						for (int j = 0; j < lexicalTable.getNRows(); j++) {
221
							lexicalTable.getData().set(j, colindices.get(0), firstcol[j]);
222
						}
235
							// and its name
236
							lexicalTable.getColNames().setString(colindices.get(0), newname);
223 237

  
224
						// and its name
225
						lexicalTable.getColNames().setString(colindices.get(0), newname);
238
							// keep only the first col
239
							List<Integer> coltodelete = colindices.subList(1, colindices.size());
240
							lexicalTable.getData().removeCols(coltodelete);
226 241

  
227
						// keep only the first col
228
						List<Integer> coltodelete = colindices.subList(1, colindices.size());
229
						lexicalTable.getData().removeCols(coltodelete);
242
							// refresh stuff
243
							collist = new ArrayList<Object>();// update col name
244
							// list
245
							try {
246
								for (String colname : lexicalTable.getColNames().asStringsArray()) {
247
									collist.add(colname);
248
								}
249
							} catch (StatException e1) {
250
								org.txm.rcp.utils.Logger.printStackTrace(e1);
251
								return;
252
							}
230 253

  
231
						// refresh stuff
232
						collist = new ArrayList<Object>();// update col name
233
						// list
234
						try {
235
							for (String colname : lexicalTable.getColNames().asStringsArray()) {
236
								collist.add(colname);
254
							Collections.sort(colindices);// update table viewer cols
255
							for (int i = colindices.size() - 1; i >= 1; i--) {
256
								viewer.getTable().getColumns()[colindices.get(i) + 3].dispose();// +3 = separator,
257
								// form, freq
237 258
							}
238
						} catch (StatException e1) {
239
							org.txm.rcp.utils.Logger.printStackTrace(e1);
240
							return;
241
						}
259
							viewer.getTable().getColumns()[colindices.get(0) + 3].setText(newname);
260
							refreshTable(true);
261
						} else// delete
262
						{
263
							System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_12, colindices));
264
							lexicalTable.getData().removeCols(colindices);
242 265

  
243
						Collections.sort(colindices);// update table viewer cols
244
						for (int i = colindices.size() - 1; i >= 1; i--) {
245
							viewer.getTable().getColumns()[colindices.get(i) + 3].dispose();// +3 = separator,
246
							// form, freq
247
						}
248
						viewer.getTable().getColumns()[colindices.get(0) + 3].setText(newname);
249
						refreshTable();
250
					} else// delete
251
					{
252
						System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_12, colindices));
253
						lexicalTable.getData().removeCols(colindices);
266
							collist = new ArrayList<Object>();
267
							Vector colnames = lexicalTable.getColNames();
268
							try {
269
								for (String colname : colnames.asStringsArray()) {
270
									collist.add(colname);
271
								}
272
							} catch (StatException e1) {
273
								org.txm.rcp.utils.Logger.printStackTrace(e1);
274
								return;
275
							}
254 276

  
255
						collist = new ArrayList<Object>();
256
						Vector colnames = lexicalTable.getColNames();
257
						try {
258
							for (String colname : colnames.asStringsArray()) {
259
								collist.add(colname);
277
							Collections.sort(colindices);
278
							for (int i = colindices.size() - 1; i >= 0; i--) {
279
								viewer.getTable().getColumns()[colindices
280
								                                        .get(i) + 3].dispose();
260 281
							}
261
						} catch (StatException e1) {
262
							org.txm.rcp.utils.Logger.printStackTrace(e1);
263
							return;
282
							refreshTable(true);
264 283
						}
265

  
266
						Collections.sort(colindices);
267
						for (int i = colindices.size() - 1; i >= 0; i--) {
268
							viewer.getTable().getColumns()[colindices
269
							                                        .get(i) + 3].dispose();
270
						}
271
						refreshTable();
272 284
					}
285
					StatusLine.setMessage(""); //$NON-NLS-1$
273 286
				}
274
				StatusLine.setMessage(""); //$NON-NLS-1$
275
			}
276 287

  
277
			@Override
278
			public void widgetDefaultSelected(SelectionEvent e) {
279
			}
280
		});
288
				@Override
289
				public void widgetDefaultSelected(SelectionEvent e) {
290
				}
291
			});
281 292

  
282
		// Merge or delete lines button
283
		Button mergeDeleteRows = new Button(paramArea, SWT.PUSH);
284
		mergeDeleteRows.setText(LexicalTableUIMessages.LexicalTableEditor_13);
285
		mergeDeleteRows.addSelectionListener(new SelectionListener() {
286
			@Override
287
			public void widgetSelected(SelectionEvent e) {
293
			// Merge or delete lines button
294
			Button mergeDeleteRows = new Button(parametersArea, SWT.PUSH);
295
			mergeDeleteRows.setText(LexicalTableUIMessages.LexicalTableEditor_13);
296
			mergeDeleteRows.addSelectionListener(new SelectionListener() {
297
				@Override
298
				public void widgetSelected(SelectionEvent e) {
288 299

  
289
				ArrayList<Object> selection = new ArrayList<Object>();
290
				MergeDeleteDialog d = new MergeDeleteDialog(e.display
291
						.getActiveShell(), new ArrayList<Object>(rows),
292
						selection, -1);
293
				int count = 0;
294
				if (d.open() == Window.OK) {
295
					int[] rowindices = new int[selection.size()];
296
					for (int i = 0; i < rows.size(); i++) {
297
						if (selection.contains(rows.get(i))) {
298
							rowindices[count] = i;
299
							count++;
300
					ArrayList<Object> selection = new ArrayList<Object>();
301
					MergeDeleteDialog d = new MergeDeleteDialog(e.display
302
							.getActiveShell(), new ArrayList<Object>(rows),
303
							selection, -1);
304
					int count = 0;
305
					if (d.open() == Window.OK) {
306
						int[] rowindices = new int[selection.size()];
307
						for (int i = 0; i < rows.size(); i++) {
308
							if (selection.contains(rows.get(i))) {
309
								rowindices[count] = i;
310
								count++;
311
							}
300 312
						}
301
					}
302 313

  
303
					if (d.doMerge()) {
304
						MergeLines.mergeLines(LexicalTableEditor.this, d
305
								.getMergeName(), rowindices);
306
					} else {
307
						lexicalTable.getData().removeRows(rowindices);
308
						refreshTable();
309
						viewer.getTable().deselectAll();
314
						if (d.doMerge()) {
315
							MergeLines.mergeLines(LexicalTableEditor.this, d
316
									.getMergeName(), rowindices);
317
						} else {
318
							lexicalTable.getData().removeRows(rowindices);
319
							refreshTable(true);
320
							viewer.getTable().deselectAll();
321
						}
310 322
					}
311 323
				}
312
			}
313 324

  
314
			@Override
315
			public void widgetDefaultSelected(SelectionEvent e) {
316
			}
317
		});
325
				@Override
326
				public void widgetDefaultSelected(SelectionEvent e) {
327
				}
328
			});
318 329

  
319
		Composite resultArea = this.getResultArea();
320
		
321
		
322
		GridData gd = new GridData(GridData.FILL_BOTH);
323
		gd.grabExcessVerticalSpace = true;
324
		gd.grabExcessHorizontalSpace = true;
325
		//gd.horizontalSpan = 2;
326
		resultArea.setLayoutData(gd);
327
		
328
		FormLayout resultLayout = new FormLayout();
329
		resultArea.setLayout(resultLayout);
330
			Composite resultArea = this.getResultArea();
331
			
332
			
333
			GridData gd = new GridData(GridData.FILL_BOTH);
334
			gd.grabExcessVerticalSpace = true;
335
			gd.grabExcessHorizontalSpace = true;
336
			//gd.horizontalSpan = 2;
337
			resultArea.setLayoutData(gd);
338
			
339
			FormLayout resultLayout = new FormLayout();
340
			resultArea.setLayout(resultLayout);
330 341

  
331
		viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
332
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
333
		viewer.getTable().setLinesVisible(true);
334
		viewer.getTable().setHeaderVisible(true);
342
			viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
343
			viewer.getTable().addKeyListener(new TableKeyListener(viewer));
344
			viewer.getTable().setLinesVisible(true);
345
			viewer.getTable().setHeaderVisible(true);
335 346

  
336
		FormData tableLayoutData = new FormData();
337
		tableLayoutData.top = new FormAttachment(0);
338
		tableLayoutData.bottom = new FormAttachment(100);
339
		tableLayoutData.left = new FormAttachment(0);
340
		tableLayoutData.right = new FormAttachment(100);
341
		viewer.getTable().setLayoutData(tableLayoutData);
342
		CellLabelProvider clp = new CellLabelProvider() {
343
			@Override
344
			public void update(ViewerCell cell) { }
345
		};
346
		TableViewerColumn nColumn = new TableViewerColumn(viewer, SWT.RIGHT);
347
		nColumn.getColumn().setText(" "); //$NON-NLS-1$
348
		nColumn.getColumn().pack();
349
		nColumn.setLabelProvider(clp);
350
		
351
		formColumn = new TableViewerColumn(viewer, SWT.LEFT);
352
		formColumn.getColumn().setText(this.lexicalTable.getProperty().getName()); 
353
		formColumn.getColumn().setWidth(200);
354
		formColumn.getColumn().addSelectionListener(new ColumnSelectionListener(this, formColumn, -2));
355
		formColumn.setLabelProvider(clp);
356
		
357
		freqColumn = new TableViewerColumn(viewer, SWT.LEFT);
358
		freqColumn.getColumn().setText(TXMCoreMessages.common_frequency); 
359
		freqColumn.getColumn().setWidth(200);
360
		freqColumn.getColumn().addSelectionListener(new ColumnSelectionListener(this, freqColumn, -1));
361
		freqColumn.setLabelProvider(clp);
362
		
363
		collist = new ArrayList<Object>();
364
		Vector colnames = lexicalTable.getColNames();
365
		
366
		try {
367
			int[] colmargins = lexicalTable.getColMarginsVector().asIntArray();
368
			int i = 0;
369
			for (String colname : colnames.asStringsArray()) {
370
				// partColumn = new TableColumn(lineTableViewer.getTable(),
371
				// SWT.RIGHT);
347
			FormData tableLayoutData = new FormData();
348
			tableLayoutData.top = new FormAttachment(0);
349
			tableLayoutData.bottom = new FormAttachment(100);
350
			tableLayoutData.left = new FormAttachment(0);
351
			tableLayoutData.right = new FormAttachment(100);
352
			viewer.getTable().setLayoutData(tableLayoutData);
353
			CellLabelProvider clp = new CellLabelProvider() {
354
				@Override
355
				public void update(ViewerCell cell) { }
356
			};
357
			TableViewerColumn nColumn = new TableViewerColumn(viewer, SWT.RIGHT);
358
			nColumn.getColumn().setText(" "); //$NON-NLS-1$
359
			nColumn.getColumn().pack();
360
			nColumn.setLabelProvider(clp);
361
			
362
			formColumn = new TableViewerColumn(viewer, SWT.LEFT);
363
			formColumn.getColumn().setWidth(200);
364
			formColumn.getColumn().addSelectionListener(new ColumnSelectionListener(this, formColumn, -2));
365
			formColumn.setLabelProvider(clp);
366
			
367
			freqColumn = new TableViewerColumn(viewer, SWT.LEFT);
368
			freqColumn.getColumn().setText(TXMCoreMessages.common_frequency); 
369
			freqColumn.getColumn().setWidth(200);
370
			freqColumn.getColumn().addSelectionListener(new ColumnSelectionListener(this, freqColumn, -1));
371
			freqColumn.setLabelProvider(clp);
372
			
373
			// creating the part columns
374
			for (int i = 0; i < this.getResult().getPartition().getParts().size(); i++) {
372 375
				TableViewerColumn partColumn = new TableViewerColumn(viewer, SWT.RIGHT);
373
				partColumn.getColumn().setText(colname+" t="+colmargins[i]); //$NON-NLS-1$
374
				partColumn.getColumn().setToolTipText(colname); 
375
				collist.add(colname);
376 376
				partColumn.getColumn().setWidth(200);
377 377
				partColumn.getColumn().addSelectionListener(new ColumnSelectionListener(this, partColumn, i));
378 378
				partColumn.setLabelProvider(clp);
379
				i++;
380 379
			}
381
		} catch (StatException e1) {
382
			org.txm.rcp.utils.Logger.printStackTrace(e1);
383
			return;
384
		}
380
				
385 381

  
386
//		nColumn = new TableViewerColumn(viewer, SWT.RIGHT);
387
//		nColumn.getColumn().setText(""); //$NON-NLS-1$
388
//		nColumn.getColumn().pack();
382
			viewer.setContentProvider(new LineContentProvider());
389 383

  
390
		viewer.setContentProvider(new LineContentProvider());
391
		viewer.setInput(lexicalTable);
392
		parent.layout();
384
			viewer.getTable().setSortColumn(formColumn.getColumn());
385
			viewer.getTable().setSortDirection(SWT.UP);
393 386

  
394
		viewer.refresh();
395
		viewer.getTable().setSortColumn(formColumn.getColumn());
396
		viewer.getTable().setSortDirection(SWT.UP);
387
			// Register the context menu
388
			TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); // $NON-NLS-1$
397 389

  
398
		this.updateEditorFromResult(false);
399
		
400
		// Register the context menu
401
		TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); // $NON-NLS-1$
402

  
403
		
404
		//this.commandParametersGroup.pack();
390
		}
391
		catch (CqiClientException e) {
392
			// TODO Auto-generated catch block
393
			e.printStackTrace();
394
		}
405 395
	}
406 396

  
407 397

  
......
432 422
		}
433 423
	}
434 424

  
425
	public void refreshTable() {
426
		this.refreshTable(false);
427
	}
428
	
435 429
	/**
436 430
	 * Refresh table.
437 431
	 */
438
	public void refreshTable() {
432
	public void refreshTable(boolean update) {
433

  
434
//		if(!update)	{
435
			
436
			formColumn.getColumn().setText(this.lexicalTable.getProperty().getName()); 
437

  
438
			collist = new ArrayList<Object>();
439
			Vector colnames = lexicalTable.getColNames();
440
			
441
			try {
442
				int[] colmargins = lexicalTable.getColMarginsVector().asIntArray();
443
				
444
				int i = 3;
445
				for (String colname : colnames.asStringsArray()) {
446
					TableColumn partColumn = viewer.getTable().getColumn(i);
447
					partColumn.setText(colname+" t="+colmargins[i - 3]); //$NON-NLS-1$
448
					partColumn.setToolTipText(colname); 
449
					collist.add(colname);
450
					i++;
451
				}
452
				
453
				viewer.setInput(lexicalTable);
454

  
455
				
456
			} catch (StatException e1) {
457
				org.txm.rcp.utils.Logger.printStackTrace(e1);
458
				return;
459
			}
460
//		}
461

  
439 462
		
440 463
		LineLabelProvider labelprovider = new LineLabelProvider(this.lexicalTable);
441 464
		this.viewer.setLabelProvider(labelprovider);
......
545 568
				viewer.refresh();
546 569
				viewer.setInput(lexicalTable);
547 570
				viewer.getTable().getParent().layout();
548
				refreshTable();
571
				refreshTable(false);
549 572
			} else {
550 573
				System.out.println(LexicalTableUIMessages.LexicalTableEditor_14);
551 574
			}
......
585 608
			}
586 609

  
587 610
			previousSortedCol = index;
588
			refreshTable();
611
			refreshTable(true);
589 612

  
590 613
			viewer.getTable().setSortColumn(col.getColumn());
591 614
			if (reverse) {
......
606 629
		fMin.setMinimum(lexicalTable.getData().getFMin());
607 630
		fMin.setMaximum(lexicalTable.getData().getFMax());
608 631
		
609
		this.refreshTable();
632
		this.refreshTable(update);
610 633
		this.refreshInfos();
611 634
		
612 635
		QueriesView.refresh();
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeLexicon.java (revision 742)
38 38
			index = new Index(corpus);
39 39
			index.setLexiconMode(true);
40 40
			try {
41
				index.setQuery(new Query("[]"));
41
				index.setQuery(new Query("[]")); //$NON-NLS-1$
42 42
				index.setProperties(Arrays.asList(corpus.getWordProperty()));
43 43
			} catch (CqiClientException e) {
44 44
				// TODO Auto-generated catch block
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 742)
558 558
				if (viewer.getTable().getSortColumn() != keywordColumn) {
559 559
					viewer.getTable().setSortColumn(keywordColumn);
560 560
					viewer.getTable().setSortDirection(SWT.UP);
561
				} else if (viewer.getTable().getSortDirection() == SWT.UP) {
561
				}
562
				else if (viewer.getTable().getSortDirection() == SWT.UP) {
562 563
					viewer.getTable().setSortDirection(SWT.DOWN);
563 564
					comparator = new ReverseComparator(comparator);
564
				} else
565
				}
566
				else {
565 567
					viewer.getTable().setSortDirection(SWT.UP);
568
				}
566 569
				comparator.initialize(concordance.getCorpus());
567 570
				currentComparator = comparator;
568 571
				complexsorter.setKey(1);//set ref key
......
596 599

  
597 600
				if (viewer.getTable().getSortColumn() != rightContextColumn) {
598 601
					viewer.getTable().setSortColumn(rightContextColumn);
599
				} else if (viewer.getTable().getSortDirection() == SWT.UP) {
602
				}
603
				else if (viewer.getTable().getSortDirection() == SWT.UP) {
600 604
					viewer.getTable().setSortDirection(SWT.DOWN);
601 605
					comparator = new ReverseComparator(comparator);
602
				} else {
606
				}
607
				else {
603 608
					viewer.getTable().setSortDirection(SWT.UP);
604 609
				}
605 610
				comparator.initialize(concordance.getCorpus());
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java (revision 742)
559 559
	public void dropAllPartitions() throws CqiClientException {
560 560
		List<Partition> _partitions = new ArrayList<Partition>();
561 561
		_partitions.addAll(partitions);
562
		for (Partition partition : _partitions)
562
		for (Partition partition : _partitions) {
563 563
			this.dropPartition(partition);
564
		}
564 565
		_partitions = null;
565 566
	}
566 567

  
......
572 573
	 */
573 574
	public void dropAllSubcorpora() throws CqiClientException {
574 575
		//System.out.println("!! drop all subcorpora: "+subcorpora.size());
575
		while(subcorpora.size() > 0)
576
		while(subcorpora.size() > 0) {
576 577
			this.dropSubcorpus(subcorpora.get(0));
578
		}
577 579
	}
578 580

  
579 581
	/**
......
586 588
	 *             the cqi client exception
587 589
	 */
588 590
	public void dropPartition(Partition partition) throws CqiClientException {
589
		Log.finest(TXMCoreMessages.DROP_PARTITION + partition.getName());
591
		Log.finest(TXMCoreMessages.info_deletingPartition + partition.getName());
590 592
		for (Part part : partition.getParts())
591 593
			try {
592 594
				CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(part.getQualifiedCqpId());
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 742)
197 197
	 */
198 198
	protected void _computeFromPartition(Partition partition) throws Exception {
199 199
		
200
		//long time = System.currentTimeMillis();
201
		List<Lexicon> lexicons = new ArrayList<Lexicon>();
202
		// Set<String> allLexiconEntry = new HashSet<String>();
200
		// parts lexicons
201
		List<Lexicon> partsLexicons = new ArrayList<Lexicon>();
203 202
		for (int i = 0; i < partition.getNPart(); i++) {
204
			Lexicon l = new Lexicon(partition.getParts().get(i));
205
			l.setProperty(this.property);
206
			l.compute(this.monitor);
207
			lexicons.add(l);
203
			partsLexicons.add(Lexicon.getLexicon(partition.getParts().get(i), this.property, this.monitor));
208 204
		}
209
		//System.out.println("time lexicon build "+(System.currentTimeMillis()-time));
210
		//time = System.currentTimeMillis();
211
		// String[] entries = allLexiconEntry.toArray(new String[]{});
212
		Lexicon ll = new Lexicon(partition.getCorpus());
213
		ll.setProperty(this.property);
214
		ll.compute(this.monitor);
205
		
206
		// Corpus global lexicon
207
		Lexicon corpusLexicon = Lexicon.getLexicon(partition.getCorpus(), this.property, this.monitor);
215 208

  
216 209
		ArrayList<String> filteredForms = new ArrayList<String>();
217 210
		//create a copy and filter line with Fmin;
218
		for (int i = 0 ; i < ll.getFreq().length ; i++) {
219
			if (ll.getFreq()[i] >= this.fMinFilter) {
220
				filteredForms.add(ll.getForms()[i]);
211
		for (int i = 0 ; i < corpusLexicon.getFreq().length ; i++) {
212
			if (corpusLexicon.getFreq()[i] >= this.fMinFilter) {
213
				filteredForms.add(corpusLexicon.getForms()[i]);
221 214
			}
222 215
		}
223
		//System.out.println("remove freq too low "+(System.currentTimeMillis()-time));
224
		//time = System.currentTimeMillis();
225 216
		Map<String, Integer> entries2index = new HashMap<String, Integer>();
226 217
		for (int i = 0; i < filteredForms.size(); i++) {
227 218
			entries2index.put(filteredForms.get(i), i);
228 219
		}
229 220

  
230
		//System.out.println("entries2index "+(System.currentTimeMillis()-time));
231
		//time = System.currentTimeMillis();
232
		int[][] mat = new int[filteredForms.size()][lexicons.size()];//DoubleFactory2D.sparse.make(filteredForms.size(), lexicons.size(), 0);
221
		int[][] mat = new int[filteredForms.size()][partsLexicons.size()];
233 222

  
234 223

  
235 224
		Integer id = null;
236
		for (int i = 0; i < lexicons.size(); i++) {
237
			Lexicon l = lexicons.get(i);
225
		for (int i = 0; i < partsLexicons.size(); i++) {
226
			Lexicon l = partsLexicons.get(i);
238 227
			String[] ents = l.getForms();
239 228
			int[] freqs = l.getFreq();
240 229
			for (int j = 0; j < freqs.length; j++) {
241 230
				id = entries2index.get(ents[j]);
242
				// if (entriesFreqs[id] >= 2)
243 231
				if (id != null) {
244
					mat[id][i] = freqs[j]; //mat.setQuick(id, i, freqs[j]);
232
					mat[id][i] = freqs[j];
245 233
				}
246 234
			}
247 235
		}
248
		//System.out.println("time build matrix "+(System.currentTimeMillis()-time));
249
		//time = System.currentTimeMillis();
250
		//System.out.println("Entries size " + filteredForms.size());
251
		//System.out.println("mat size " + mat.rows());
252
		//System.out.println("mat columns " + mat.columns());
253

  
254 236
		this.statsData = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames().toArray(new String[] {}));
255 237

  
256 238
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 742)
30 30

  
31 31
	@Override
32 32
	public String getLabel(Object result) {
33
		return ((TXMResult) result).getSimpleName(); 
33
		if(((TXMResult) result).getUserName() != null)	{
34
			return ((TXMResult) result).getUserName();
35
		}
36
		else	{
37
			return ((TXMResult) result).getSimpleName();	
38
		}
34 39
	}
35 40

  
36 41
	@Override
tmp/org.txm.core/src/java/org/txm/core/messages/messages.properties (revision 742)
3 3

  
4 4
AbstractCqiClient_2 = No error.
5 5

  
6
ApplicationWorkbenchAdvisor_13          = ** Could not create TXMHOME directory: {0}
6
ApplicationWorkbenchAdvisor_13 = ** Could not create TXMHOME directory: {0}
7 7
ApplicationWorkbenchAdvisor_14 = \ evaluating extension:
8 8
ApplicationWorkbenchAdvisor_15 = Loading extensions...
9
ApplicationWorkbenchAdvisor_39          = Missing folder in TXM install dir: {0}
10
ApplicationWorkbenchAdvisor_40          = Failed to copy TXM files from TXMINSTALL DIR to TXMHOME: {0}
9
ApplicationWorkbenchAdvisor_39 = Missing folder in TXM install dir: {0}
10
ApplicationWorkbenchAdvisor_40 = Failed to copy TXM files from TXMINSTALL DIR to TXMHOME: {0}
11 11
ApplicationWorkbenchAdvisor_6  = Exception:
12 12

  
13 13
Base_0  = Binary directory 
......
77 77
CwbProcess_4 = Process stoped: 
78 78
CwbProcess_5 = ** Can't find CQP location : 
79 79

  
80
DROP_PARTITION   = Deleting partition {0}
81 80
DROP_QUERYRESULT = Deleting query results {0}
82 81
DROP_SUBCORPUS   = Deleting subcorpus {0}
83 82

  
......
313 312
common_units           = Units
314 313

  
315 314
error_error = ** Error: {0}.
315

  
316
info_deletingPartition = Deleting partition {0}.
tmp/org.txm.core/src/java/org/txm/core/messages/TXMCoreMessages.java (revision 742)
107 107
	public static String CwbProcess_3;
108 108
	public static String CwbProcess_4;
109 109
	public static String CwbProcess_5;
110
	public static String DROP_PARTITION;
110
	public static String info_deletingPartition;
111 111
	public static String DROP_QUERYRESULT;
112 112
	public static String DROP_SUBCORPUS;
113 113
	public static String END_SUBCORPUS_SIZE;
tmp/org.txm.core/src/java/org/txm/core/messages/messages_fr.properties (revision 742)
3 3

  
4 4
AbstractCqiClient_2 = Pas d'erreur à notifier.
5 5

  
6
ApplicationWorkbenchAdvisor_13 = ** Échec de la création du dossier TXMHOME : {0}
7
ApplicationWorkbenchAdvisor_39 = Dossier manquant dans le dossier d''installation de TXM : {0}
8
ApplicationWorkbenchAdvisor_40 = ** Échec de la copie des fichiers TXM du dossier TXMINSTALL vers TXMHOME : {0}
9

  
6 10
Base_0  = Dossier binaire 
7 11
Base_22 = L'élément 'corpora' est absent de l'élément 'base'
8 12
Base_3  = \ n'existe pas ?
......
70 74
CwbProcess_4 = Processus arrêté : 
71 75
CwbProcess_5 = ** Echec de localisation de CQP : 
72 76

  
73
DROP_PARTITION   = Suppression de la partition {0}
74 77
DROP_QUERYRESULT = Suppression du résultat de requête {0}
75 78
DROP_SUBCORPUS   = Suppression du sous-corpus {0}
76 79

  
......
298 301

  
299 302
error_error = ** Erreur : {0}.
300 303

  
301
ApplicationWorkbenchAdvisor_13          = ** Échec de la création du dossier TXMHOME : {0}
302
ApplicationWorkbenchAdvisor_39          = Dossier manquant dans le dossier d''installation de TXM : {0}
303
ApplicationWorkbenchAdvisor_40          = ** Échec de la copie des fichiers TXM du dossier TXMINSTALL vers TXMHOME : {0}
304
info_deletingPartition = Suppression de la partition {0}.
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 742)
72 72
	public final static String RESULT_UUID = "result_uuid"; //$NON-NLS-1$
73 73
	public final static String PARENT_UUID = "parent_uuid"; //$NON-NLS-1$
74 74
	public final static String BUNDLE_ID = "bundle_id"; //$NON-NLS-1$
75
	public final static String NAME = "name"; //$NON-NLS-1$
75 76

  
76 77
	// to shared strings in some preferences
77 78
	/**
......
1064 1065
	}
1065 1066

  
1066 1067
	/**
1067
	 * Deletes the local node if exists.
1068
	 * Deletes the local node if exists and the associated .prefs persistence file.
1068 1069
	 * @param result
1069 1070
	 */
1070 1071
	public static void delete(TXMResult result)	{
1071 1072
		try {
1072 1073
			System.err.println("TXMPreferences.delete(): Local preferences for object " + result.getUUID() + " deleted.");
1074
			scope.getNode(result.getUUID()).clear();
1075
			scope.getNode(result.getUUID()).flush();
1073 1076
			scope.getNode(result.getUUID()).removeNode();
1074 1077
		}
1075 1078
		catch(BackingStoreException e) {
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 742)
61 61
public abstract class TXMResult implements Cloneable, IProgressMonitor {
62 62

  
63 63

  
64
	public static final DateFormat ID_TIME_FORMAT = new SimpleDateFormat("YYYYMMDD");
64
	public static final DateFormat ID_TIME_FORMAT = new SimpleDateFormat("YYYYMMdd");
65 65
	public static final Pattern FILE_NAME_PATTERN = Pattern.compile("[^a-zA-Z0-9\\.-]+"); //$NON-NLS-1$
66 66
	public static final String UNDERSCORE = "_";
67 67

  
......
103 103
	protected boolean visible;
104 104

  
105 105
	/**
106
	 * The user name. To rename a result but also to store the simple name for unserialization and lazy loading.
107
	 */
108
	protected String userName;
109
	
110
	/**
106 111
	 * The command preferences node qualifier.
107 112
	 */
108 113
	protected String preferencesNodeQualifier;
......
194 199
				Log.warning("Parent retrieved from UUID: " + retrievedParent + ".");
195 200
				retrievedParent.addChild(this);
196 201
			}
202
			
203
			// retrieving user name
204
			if (!this.getStringParameterValue(TXMPreferences.NAME).isEmpty()) {
205
				this.userName = this.getStringParameterValue(TXMPreferences.NAME);
206
			}
197 207
		}
198 208

  
199 209
		
210
		
200 211
		// loads parameters from local result node, current command preferences or default command preferences
201 212
		try {
202 213
			this.autoLoadParametersFromAnnotations(); // auto fill from Parameter annotations
......
676 687
	 */
677 688
	public void saveParameter(String key, Object value)	{
678 689
		// FIXME: debug
679
		System.err.println("TXMResult.saveParameter(): saving parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ") to node.");
690
		Log.info("TXMResult.saveParameter(): saving parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ") to node.");
680 691

  
681 692
		TXMPreferences.putLocal(this, key, value);
682 693
	}
......
694 705

  
695 706
		// internal data to save for unserialization
696 707
		this.saveParameter("class", this.getClass().getName());
708
		// store the user name if exists otherwise the simple name
709
		if(this.userName != null)	{
710
			this.saveParameter(TXMPreferences.NAME, this.userName);
711
		}
712
		else	{
713
			this.saveParameter(TXMPreferences.NAME, this.getSimpleName());
714
		}
697 715
		this.saveParameter(TXMPreferences.RESULT_UUID, this.uniqueID);
698 716
		this.saveParameter(TXMPreferences.BUNDLE_ID, this.preferencesNodeQualifier);
699 717
		if(this.parent != null)	{
......
870 888

  
871 889
			// FIXME: debug
872 890
			if(value != null)	{
873
				System.err.println("TXMResult.setParameter(): setting parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ")");
891
				Log.info("TXMResult.setParameter(): setting parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ")");
874 892
			}
875 893

  
876 894
			targetField.set(this, value);
......
1028 1046
	 * @param type
1029 1047
	 * @return
1030 1048
	 */
1031
	synchronized public ArrayList<TXMResult> getChildren(Class type) {
1049
	synchronized public ArrayList<? extends TXMResult> getChildren(Class type) {
1032 1050
		return TXMResult.getNodes(this.children, type, false);
1033 1051
	}
1034 1052

  
......
1043 1061
	}
1044 1062

  
1045 1063
	/**
1064
	 * Gets the first child result specified by their class.
1065
	 * @param type
1066
	 * @return the first child if exists otherwise null
1067
	 */
1068
	synchronized public TXMResult getFirstChild(Class type) {
1069
		 ArrayList<TXMResult> children = this.getChildren(type, false);
1070
		 try {
1071
			return children.get(0);
1072
		}
1073
		catch (Exception e) {
1074
			return null;
1075
		}
1076
	}
1077

  
1078
	
1079
	/**
1046 1080
	 * Gets the first child.
1047 1081
	 * @param classSimpleName
1048 1082
	 * @return
......
1171 1205
		return node;
1172 1206
	}
1173 1207

  
1208
	
1174 1209
	/**
1175 1210
	 * Gets the first parent of the specified class, eg. this.getFirstParent(Partition.class);
1176 1211
	 * Returns the object itself if it is of the specified class.
......
1678 1713
		Log.info(name);
1679 1714
	}
1680 1715

  
1716
	/**
1717
	 * @return the userName
1718
	 */
1719
	public String getUserName() {
1720
		return userName;
1721
	}
1722

  
1681 1723
}

Formats disponibles : Unified diff