Revision 1404

tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1404)
103 103
	 * if frozen, the result is not updated when computed
104 104
	 */
105 105
	protected boolean frozen = false;
106
	
107
	/**
108
	 * if a method changed the internal data without **recomputing** the result, the result must be marked "altered"
109
	 */
110
	protected boolean altered = false;
106 111

  
107 112
	/**
108 113
	 * The result parent. Should not be null except for roots TXMResult
......
143 148
	// But this stack is also the start for an UNDO command on TXMResult.
144 149
	protected ArrayList<HashMap<String, Object>> parametersHistory = new ArrayList<HashMap<String, Object>>();
145 150

  
146

  
151
	
147 152
	/**
148 153
	 * Internal persistable state.
149 154
	 */
......
294 299
	}
295 300

  
296 301
	/**
302
	 * @return true is the internal data has been modified
303
	 */
304
	public boolean isAltered() {
305
		return altered;
306
	}
307
	
308
	/**
309
	 * Mark the result as altered -> modifications are lost after a re-compute
310
	 */
311
	public void setAltered() {
312
		this.altered = true;
313
	}
314
	
315
	/**
297 316
	 * Freezes the result -> cannot be recomputed.
298 317
	 */
299 318
	public void freeze() {
......
1934 1953

  
1935 1954
		// no changes to do
1936 1955
		// FIXME: SJ: we need to do do some actions even if the object is frozen, eg. updating parameters, saving parameters, etc.
1956
		// FIXME MD: nope the parameters must not move and will be saved in the current state
1937 1957
		if (hasBeenComputedOnce && frozen) {
1938 1958
			return true;
1939 1959
		}
......
2010 2030
				}
2011 2031

  
2012 2032
				this.dirty = false; // the computing was successful, the result is no more dirty
2013
				this.hasBeenComputedOnce = true; 
2014

  
2033
				this.hasBeenComputedOnce = true;
2034
				if (altered) {
2035
					System.out.println(NLS.bind("Warning {0} modifications have been lost.", this.getSimpleName()));
2036
				}
2037
				this.altered = false;
2015 2038
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done.");
2016 2039

  
2017 2040
				// set the children as dirty since the result has changed
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPLexicon.java (revision 1404)
166 166
		String tmp = "TMP" + CQPCorpus.getNextSubcorpusCounter();
167 167
		String qtmp = corpus.getMainCorpus().getQualifiedCqpId()+":"+tmp;
168 168
		try {
169
			System.out.println("subcorpus: "+corpus.getQualifiedCqpId());
170
			System.out.println("query subcorpus: "+qtmp);
169
//			System.out.println("subcorpus: "+corpus.getQualifiedCqpId());
170
//			System.out.println("query subcorpus: "+qtmp);
171 171
			cqi.cqpQuery(corpus.getQualifiedCqpId(), tmp, "[]");
172 172
			fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(qtmp, 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
173 173
			//System.out.println("nb lines: "+fdist.length);
......
546 546
			lexicon.setProperty(property);
547 547
			lexicon._compute();
548 548
		}
549
		System.out.println("Lexicon="+lexicon+" "+lexicon.hashCode());
549
		//System.out.println("Lexicon="+lexicon+" "+lexicon.hashCode());
550 550
		return lexicon;
551 551
	}
552 552
	
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/DeleteLines.java (revision 1404)
93 93
		}
94 94

  
95 95
		LTeditor.getLexicalTable().getData().removeRows(selection);
96

  
96
		LTeditor.getLexicalTable().setAltered();
97 97
		LTeditor.refreshTable();
98 98
		LTeditor.getlineTableViewer().getTable().deselectAll();
99 99
		try {
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/___MergeCols.java (revision 1404)
106 106
			System.arraycopy(selectedCols, 1, coltodelete, 0,
107 107
					selectedCols.length - 1);
108 108
			table.getData().removeCols(coltodelete);
109

  
109
			table.setAltered();
110 110
			// reset col name
111 111
			table.getColNames().setString(selectedCols[0], newname);
112 112
			try {
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/MergeLines.java (revision 1404)
113 113
		System.arraycopy(selection, 1, lineToDelete, 0, selection.length - 1);
114 114
		//System.out.println("Lines to delete : "+Arrays.toString(lineToDelete));
115 115
		table.getData().removeRows(lineToDelete);
116

  
116
		table.setAltered();
117 117
		// reset line name
118 118
		try {
119 119
			table.getRowNames().setString(selection[0], newname);
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 1404)
293 293
							// keep only the first col
294 294
							List<Integer> coltodelete = colindices.subList(1, colindices.size());
295 295
							lexicalTable.getData().removeCols(coltodelete);
296

  
296
							lexicalTable.setAltered();
297 297
							// refresh stuff
298 298
							collist = new ArrayList<Object>();// update col name
299 299
							// list
......
370 370
							MergeLines.mergeLines(LexicalTableEditor.this, d.getMergeName(), rowindices);
371 371
						} else {
372 372
							lexicalTable.getData().removeRows(rowindices);
373
							lexicalTable.setAltered();
373 374
							refreshTable(true);
374 375
							viewer.getTable().deselectAll();
375 376
						}
......
667 668
	public void importData(File file) {
668 669
		try {
669 670
			if (lexicalTable.getData().importData(file)) {
671
				lexicalTable.setAltered();
670 672
				// fix col names
671 673
				String[] colnames = lexicalTable.getColNames().asStringsArray();
672 674
				TableColumn[] cols = viewer.getTable().getColumns();
......
691 693
		}
692 694
	}
693 695

  
694
	 
695

  
696 696
		/**
697 697
		 * Sort.
698 698
		 *
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/MergeDeleteDialog.java (revision 1404)
93 93

  
94 94
		mergeRadio = new Button(mainArea, SWT.RADIO);
95 95
		mergeRadio.setText(TXMUIMessages.merge);
96
		mergeRadio.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
97
				2, 1));
96
		mergeRadio.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
98 97
		mergeRadio.setSelection(true);
99 98
		
100 99
		deleteRadio = new Button(mainArea, SWT.RADIO);
101 100
		deleteRadio.setText(TXMCoreMessages.common_delete);
102
		deleteRadio.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
103
				2, 1));
101
		deleteRadio.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
104 102
		
105 103
		newname = new Text(mainArea, SWT.SINGLE | SWT.BORDER);
106 104
		newname.setText(TXMUIMessages.mergeResultName);
107
		newname.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4,
108
				1));
105
		newname.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
109 106

  
110 107
		return mainArea;
111 108
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1404)
19 19
import org.eclipse.core.runtime.Status;
20 20
import org.eclipse.core.runtime.jobs.Job;
21 21
import org.eclipse.jface.action.MenuManager;
22
import org.eclipse.jface.dialogs.MessageDialog;
22 23
import org.eclipse.jface.viewers.ISelectionProvider;
23 24
import org.eclipse.jface.viewers.IStructuredSelection;
24 25
import org.eclipse.jface.viewers.StructuredSelection;
......
621 622

  
622 623
		StatusLine.setMessage(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName()));
623 624

  
625
		
624 626
		JobHandler job = new JobHandler(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName())) {
625 627

  
626 628
			@Override
......
630 632

  
631 633
				try {
632 634
					JobsTimer.start();
633

  
634 635
					this.syncExec(new Runnable() {
635 636
						@Override
636 637
						public void run() {
637 638
							if(update)	{
639
								
640
								if (TXMEditor.this.getResult().isAltered()) {
641
									if (!MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Warning", "The result have been edited. Changes will be lost. Do you want to continue?")) {
642
										setCanceled(true);
643
									}
644
								}
645
								
638 646
								// FIXME: DEbug
639 647
								Log.finest("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": manually updating result from editor."); //$NON-NLS-1$
640 648
								updateResultFromEditor(); // subclasses manual result updating from editor fields
......
649 657
						}
650 658
					});
651 659

  
652

  
660
					if (this.isCanceled()) {
661
						return Status.CANCEL_STATUS;
662
					}
663
					
653 664
					// computing result
654 665
					monitor.beginTask(TXMUIMessages.computing_3, 100);
655 666

  
656
					notifyExtensions("notifyStartOfCompute"); //$NON-NLS-1$
667
					notifyExtensions("notifyStartOfCompute"); //$NON-NLS-1$	
668
					
657 669
					//if (!update || RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR)) {
658 670
						if (!TXMEditor.this.getResult().compute(monitor)) {
659 671
							Log.severe("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed.");
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 1404)
1130 1130
			}
1131 1131

  
1132 1132
			this.nLines = queryResult.getNMatch();
1133
			this.setAltered();
1133 1134
			return c > 0;
1134 1135
		}
1135 1136
		return false;

Also available in: Unified diff