Révision 1918

tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java (revision 1918)
1191 1191
	public boolean needToUpdateIndexes() {
1192 1192
		return false;
1193 1193
	}
1194
	
1195
	@Override
1196
	public boolean hasChanges() {
1197
		return analecCorpus.isModifie();
1198
	}
1194 1199
}
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/SchemaToolbar.java (revision 1918)
1004 1004
	public boolean needToUpdateIndexes() {
1005 1005
		return false;
1006 1006
	}
1007
	
1008
	@Override
1009
	public boolean hasChanges() {
1010
		return analecCorpus.isModifie();
1011
	}
1007 1012
}
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/ConcordanceAnnotations.java (revision 1918)
34 34
	
35 35
	private boolean overlapAnnotation;
36 36

  
37
	private ArrayList<AnnotationLine> lines;
37
	private HashMap<Line, AnnotationLine> lines;
38 38

  
39 39
	private List<Line> concordanceLines;
40 40
	public void setAnnotationOverlap(boolean overlap) {
......
44 44
		return overlapAnnotation;
45 45
	}
46 46
	
47
	public List<AnnotationLine> getLines(List<Line> concordanceLines) throws Exception {
47
	public HashMap<Line, AnnotationLine> computeLines(List<Line> concordanceLines) throws Exception {
48 48

  
49 49
		this.concordanceLines = concordanceLines;
50 50
		
51 51
		ArrayList<Match> matches = new ArrayList<Match>();
52
		for (Line line : concordanceLines) matches.add(line.getMatch());
52
		for (Line line : concordanceLines) {
53
			matches.add(line.getMatch());
54
		}
53 55
		
54 56
		List<Annotation> ann = getAnnotationForMatches(matches, overlapAnnotation);
55 57
		
56
		lines = new ArrayList<AnnotationLine>();
58
		lines = new HashMap<Line, AnnotationLine>();
57 59
		
58
		for (Annotation a : ann) {
60
		for (int i = 0 ; i < ann.size() ; i++) {
61
			Annotation a = ann.get(i);
59 62
			AnnotationLine aline = new AnnotationLine(a, getAnnotationTypedValue(a));
60
			lines.add(aline);
63
			lines.put(concordanceLines.get(i), aline);
61 64
		}
62 65
		
63 66
		return lines; // TODO find a way to add with lazy method
......
212 215
	 * @return the AnnotationLine pointed by 'i'. May return null if i is wrong.
213 216
	 */
214 217
	public AnnotationLine getAnnotationLine(Line line) {
215
		if (concordanceLines == null) return null;
216
		int i = concordanceLines.indexOf(line);
217
		if (i < 0) return null;
218
		return getAnnotationLine(i);
218
		if (lines == null) return null;
219
		if (!lines.containsKey(line)) return null;
220
		return lines.get(line);
219 221
	}
220 222
	
221 223
	/**
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java (revision 1918)
647 647

  
648 648
	public void notifyStartOfRefresh() throws Exception {
649 649
		List<Line> lines = concordance.getLines(concordance.getTopIndex(), concordance.getTopIndex()+concordance.getNLinePerPage());
650
		annotations.getLines(lines);
650
		annotations.computeLines(lines);
651 651
	}
652 652

  
653 653
	@Override
......
684 684
	}
685 685

  
686 686
	@Override
687
	public boolean hasChanges() {
688
		AnnotationManager am;
689
		try {
690
			am = KRAnnotationEngine.getAnnotationManager(corpus);
691
			if (am != null && am.hasChanges()) {
692
				return am.hasChanges();
693
			} else {
694
				return false;
695
			}
696
		} catch (Exception e) {
697
			// TODO Auto-generated catch block
698
			e.printStackTrace();
699
			return false;
700
		}
701
	}
702
	@Override
687 703
	public void notifyEndOfRefresh() throws Exception {
688 704
		// TODO Auto-generated method stub
689 705
	}
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1918)
42 42
import org.txm.annotation.kr.core.Annotation;
43 43
import org.txm.annotation.kr.core.AnnotationManager;
44 44
import org.txm.annotation.kr.core.KRAnnotationEngine;
45
import org.txm.annotation.kr.core.repository.AnnotationEffect;
45 46
import org.txm.annotation.kr.core.repository.AnnotationType;
46 47
import org.txm.annotation.kr.core.repository.KnowledgeRepository;
47 48
import org.txm.annotation.kr.core.repository.KnowledgeRepositoryManager;
......
214 215
			currentKnowledgeRepository = kr;
215 216
			Log.fine(" KR: "+kr); //$NON-NLS-1$
216 217
			List<AnnotationType> krtypes = kr.getAllAnnotationTypes();
218
			for (AnnotationType type : krtypes) {
219
				 if (type.getEffect().equals(AnnotationEffect.SEGMENT)) {
220
					 typesList.add(type);
221
				 }
222
			}
217 223

  
218
			typesList.addAll(krtypes);
219

  
220 224
			Log.fine(NLS.bind(KRAnnotationUIMessages.availableAnnotationTypesColonP0, typesList));
221 225
			break;
222 226
		}
......
578 582
		return true;
579 583
	}
580 584

  
585
	@Override
586
	public boolean hasChanges() {
587
		AnnotationManager am;
588
		try {
589
			am = KRAnnotationEngine.getAnnotationManager(corpus);
590
			if (am != null && am.hasChanges()) {
591
				return am.hasChanges();
592
			} else {
593
				return false;
594
			}
595
		} catch (Exception e) {
596
			// TODO Auto-generated catch block
597
			e.printStackTrace();
598
			return false;
599
		}
600
	}
601
	
581 602
	protected void affectAnnotationToSelection(ISelection selection) {
582 603

  
583 604
		final IStructuredSelection lineSelection = (IStructuredSelection) selection;
......
911 932
	@Override
912 933
	public void notifyStartOfRefresh() throws Exception {
913 934
		List<Line> lines = concordance.getLines(concordance.getTopIndex(), concordance.getTopIndex()+concordance.getNLinePerPage());
914
		annotations.getLines(lines);
935
		annotations.computeLines(lines);
915 936
	}
916 937

  
917 938
	@Override
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1918)
435 435

  
436 436
		Log.fine("KR: "+currentKnowledgeRepository); //$NON-NLS-1$
437 437
		List<AnnotationType> krtypes = currentKnowledgeRepository.getAllAnnotationTypes();
438
		for (AnnotationType type : krtypes) {
439
			if(type.getEffect().equals(AnnotationEffect.TOKEN)) {
440
				typesList.add(type);
441
			}
442
		}
438 443

  
439
		typesList.addAll(krtypes);
440

  
441 444
		Log.fine(NLS.bind(KRAnnotationUIMessages.availableAnnotationTypesColonP0, typesList));
442 445

  
443 446
		annotationArea = new GLComposite(parent, SWT.NONE, KRAnnotationUIMessages.concordanceAnnotationArea);
......
720 723
			return false;
721 724
		}
722 725
	}
726
	
727
	@Override
728
	public boolean hasChanges() {
729
		AnnotationManager am;
730
		try {
731
			am = KRAnnotationEngine.getAnnotationManager(corpus);
732
			if (am != null && am.hasChanges()) {
733
				return am.hasChanges();
734
			} else {
735
				return false;
736
			}
737
		} catch (Exception e) {
738
			// TODO Auto-generated catch block
739
			e.printStackTrace();
740
			return false;
741
		}
742
	}
723 743

  
724 744
	@Override
725 745
	public boolean notifyStartOfCompute() throws Exception {
......
745 765
	@Override
746 766
	public void notifyStartOfRefresh() throws Exception {
747 767
		List<Line> lines = concordance.getLines(concordance.getTopIndex(), concordance.getTopIndex()+concordance.getNLinePerPage());
748
		annotations.getLines(lines);
768
		annotations.computeLines(lines);
749 769
		
750 770
		updateAnnotationWidgetStates();
751 771

  
tmp/org.txm.edition.rcp/plugin.xml (revision 1918)
113 113
            commandId="org.txm.edition.rcp.handlers.BackToText"
114 114
            contextId="org.eclipse.ui.contexts.window"
115 115
            schemeId="org.txm.rcp.scheme"
116
            sequence="Enter">
116
            sequence="M1+e">
117 117
      </key>
118 118
   </extension>
119 119
   <extension
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationArea.java (revision 1918)
122 122
	 * @return true if the corpus indexes & editions needs to be updated after saving annotation
123 123
	 */
124 124
	public abstract boolean needToUpdateIndexes();
125

  
126
	public abstract boolean hasChanges();
125 127
}

Formats disponibles : Unified diff