Révision 1916

tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 1916)
134 134

  
135 135
			@Override
136 136
			public void widgetSelected(SelectionEvent e) {
137
				boolean saveSuccessful = true;
138 137
				boolean needToUpdateIndexes = false;
139 138
				//System.out.println("Saving annotations...");
140 139
				if (annotationAreas != null && annotationAreas.size() > 0) {
141 140
					for (AnnotationArea aa : annotationAreas) {
142
						saveSuccessful = saveSuccessful && aa.save();
143
						needToUpdateIndexes = needToUpdateIndexes || aa.needToUpdateIndexes();
141
						needToUpdateIndexes = needToUpdateIndexes || (aa.save() &&  aa.needToUpdateIndexes());
144 142
					}
145 143
					CorporaView.refresh();
146 144
				}
147 145

  
148
				if (saveSuccessful && needToUpdateIndexes) {
146
				// there is something to save AND
147
				if (needToUpdateIndexes) {
149 148
					JobHandler job = new JobHandler("Updating corpus editions and indexes", true) {
150 149

  
151 150
						@Override
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationArea.java (revision 1916)
61 61
	/**
62 62
	 * use this to save the annotations. Save must end when the files are updated
63 63
	 * 
64
	 * @return
64
	 * @return true if something was saved
65 65
	 */
66 66
	public abstract boolean save();
67 67
	
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java (revision 1916)
661 661
					// update editor corpus
662 662
					System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
663 663
					return false;
664
				} else {
665
					if (annotationColumn != null && !annotationColumn.isDisposed()) {
666
						annotationColumn.setText(annotations.getViewAnnotation().getName());
667
					}
668
					return true; // something was saved
664 669
				}
665 670
			} else {
666 671
				return false;
......
669 674
			ex.printStackTrace();
670 675
			return false;
671 676
		}
672
		return true;
673 677
	}
674 678

  
675 679
	@Override
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1916)
872 872
					// update editor corpus
873 873
					System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
874 874
					return false;
875
				} else {
876
					if (annotationColumn != null && !annotationColumn.isDisposed()) {
877
						annotationColumn.setText(annotations.getViewAnnotation().getName());
878
					}
879
					return true; // something was saved
875 880
				}
876 881
			} else {
877 882
				return false;
......
880 885
			ex.printStackTrace();
881 886
			return false;
882 887
		}
883
		return true;
884 888
	}
885 889

  
886 890
	@Override
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1916)
706 706
					// update editor corpus
707 707
					System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
708 708
					return false;
709
				} else {
710
					if (annotationColumn != null && !annotationColumn.isDisposed()) {
711
						annotationColumn.setText(annotations.getViewAnnotation().getName());
712
					}
713
					return true; // something was saved
709 714
				}
710 715
			} else {
711 716
				return false;
......
714 719
			ex.printStackTrace();
715 720
			return false;
716 721
		}
717
		if (annotationColumn != null && !annotationColumn.isDisposed()) {
718
			annotationColumn.setText(typesList.get(0).getName());
719
		}
720
		return true;
721 722
	}
722 723

  
723 724
	@Override
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/debug/ExecJSLine.groovy (revision 1916)
1
import org.txm.edition.rcp.editors.*
2

  
3
@Field @Option(name="script", usage="an example string", widget="Text", required=false, def="alert('hello world!');")
4
script
5

  
6

  
7
if (!(editor.getClass().getName().equals("org.txm.edition.rcp.editors.SynopticEditionEditor"))) {
8
	println "Editor is not an edition: "+editor+". Use the F12 key binding to run the macro."
9
	return
10
}
11
monitor.syncExec(new Runnable() {
12
	public void run() {
13
		panel = editor.editionPanels["default"]
14
		
15
		println "Execute result: "+panel.execute(script)
16
}});
17

  
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/debug/ExecJS.groovy (revision 1916)
1
import org.txm.edition.rcp.editors.*
2
/*
3
script = """sheet.insertRule("#w_a01_390 {background-color:rgba(249,208,208,1.0);}", 1);
4
sheet.insertRule("#w_a01_470 {background-color:rgba(249,208,208,1.0);}", 1);
5
sheet.insertRule("#w_a01_262 {background-color:rgba(249,208,208,1.0);}", 1);
6
sheet.insertRule("#w_a01_289 {background-color:rgba(249,208,208,1.0);}", 1);
7
sheet.insertRule("#w_a01_421 {background-color:rgba(249,208,208,1.0);}", 1);
8
sheet.insertRule("#w_a01_213 {background-color:rgba(249,208,208,1.0);}", 1);
9
sheet.insertRule("#w_a01_166 {background-color:rgba(249,208,208,1.0);}", 1);
10
sheet.insertRule("#w_a01_342 {background-color:rgba(249,208,208,1.0);}", 1);
11
sheet.insertRule("#w_a01_546 {background-color:rgba(249,208,208,1.0);}", 1);
12
sheet.insertRule("#w_a01_589 {background-color:rgba(249,208,208,1.0);}", 1);
13
sheet.insertRule("#w_a01_504 {background-color:rgba(249,160,160,1.0);}", 1);
14
sheet.insertRule("#w_a01_637 {background-color:rgba(249,208,208,1.0);}", 1);
15
*/
16
script = """
17

  
18
//alert(sheet.cssRules[0].selectorText);
19
//alert(sheet.cssRules[0].style.cssText);
20
//alert(sheet.cssRules[0].style.length);
21
//alert(sheet.cssRules[0].style.parentRule);
22

  
23
for (var i=0; i < document.styleSheets.length; i++){
24
	var styleSheet = document.styleSheets[i];
25
	alert(styleSheet.cssRules.length)
26
/*	for (var j=0; j < styleSheet.cssRules.length; j++){
27
		alert(styleSheet.cssRules[j].style.cssText)
28
	}
29
*/
30
}
31
//alert("SHEET="+sheet.cssRules.length)
32
//document.head.appendChild(style);
33
"""
34
/*
35

  
36
 */
37
if (!(editor.getClass().getName().equals("org.txm.edition.rcp.editors.SynopticEditionEditor"))) {
38
	println "Editor is not an edition: "+editor+". Use the F12 key binding to run the macro."
39
	return
40
}
41
monitor.syncExec(new Runnable() {
42
	public void run() {
43
		panel = editor.editionPanels["default"]
44
		
45
		println "Execute result: "+panel.execute(script)
46
}});
47

  
tmp/org.txm.edition.rcp/res/js/functions.js (revision 1916)
130 130
	return detailedObject;
131 131
}
132 132

  
133
var sheet = null;
134 133
try {
135 134
	var style = document.createElement("style");
136 135
	try { style.appendChild(document.createTextNode("")); } catch (e) {};
......
141 140
}
142 141

  
143 142
//try {
144
//
145
//	if (!Element.prototype.scrollIntoViewIfNeeded) {
146
//		Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView;
147
////		Element.prototype.scrollIntoViewIfNeeded = function(centerIfNeeded) {
148
////			centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
149
////			var parent = this.parentNode, parentComputedStyle = window
150
////					.getComputedStyle(parent, null), parentBorderTopWidth = parseInt(parentComputedStyle
151
////					.getPropertyValue('border-top-width')), parentBorderLeftWidth = parseInt(parentComputedStyle
152
////					.getPropertyValue('border-left-width')), overTop = this.offsetTop
153
////					- parent.offsetTop < parent.scrollTop, overBottom = (this.offsetTop
154
////					- parent.offsetTop + this.clientHeight - parentBorderTopWidth) > (parent.scrollTop + parent.clientHeight), overLeft = this.offsetLeft
155
////					- parent.offsetLeft < parent.scrollLeft, overRight = (this.offsetLeft
156
////					- parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth), alignWithTop = overTop
157
////					&& !overBottom;
158
////			if ((overTop || overBottom) && centerIfNeeded) {
159
////				parent.scrollTop = this.offsetTop - parent.offsetTop
160
////						- parent.clientHeight / 2 - parentBorderTopWidth
161
////						+ this.clientHeight / 2;
162
////			}
163
////			if ((overLeft || overRight) && centerIfNeeded) {
164
////				parent.scrollLeft = this.offsetLeft - parent.offsetLeft
165
////						- parent.clientWidth / 2 - parentBorderLeftWidth
166
////						+ this.clientWidth / 2;
167
////			}
168
////			if ((overTop || overBottom || overLeft || overRight)
169
////					&& !centerIfNeeded) {
170
////				this.scrollIntoView(alignWithTop);
171
////			}
172
////		};
173
//	}
143

  
144
//if (!Element.prototype.scrollIntoViewIfNeeded) {
145
//Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView;
146
////Element.prototype.scrollIntoViewIfNeeded = function(centerIfNeeded) {
147
////centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
148
////var parent = this.parentNode, parentComputedStyle = window
149
////.getComputedStyle(parent, null), parentBorderTopWidth = parseInt(parentComputedStyle
150
////.getPropertyValue('border-top-width')), parentBorderLeftWidth = parseInt(parentComputedStyle
151
////.getPropertyValue('border-left-width')), overTop = this.offsetTop
152
////- parent.offsetTop < parent.scrollTop, overBottom = (this.offsetTop
153
////- parent.offsetTop + this.clientHeight - parentBorderTopWidth) > (parent.scrollTop + parent.clientHeight), overLeft = this.offsetLeft
154
////- parent.offsetLeft < parent.scrollLeft, overRight = (this.offsetLeft
155
////- parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth), alignWithTop = overTop
156
////&& !overBottom;
157
////if ((overTop || overBottom) && centerIfNeeded) {
158
////parent.scrollTop = this.offsetTop - parent.offsetTop
159
////- parent.clientHeight / 2 - parentBorderTopWidth
160
////+ this.clientHeight / 2;
161
////}
162
////if ((overLeft || overRight) && centerIfNeeded) {
163
////parent.scrollLeft = this.offsetLeft - parent.offsetLeft
164
////- parent.clientWidth / 2 - parentBorderLeftWidth
165
////+ this.clientWidth / 2;
166
////}
167
////if ((overTop || overBottom || overLeft || overRight)
168
////&& !centerIfNeeded) {
169
////this.scrollIntoView(alignWithTop);
170
////}
171
////};
172
//}
174 173
//} catch (e) {
175
//	Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView
174
//Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView
176 175
//}
177 176

  
178 177
function showElementIfNeeded(el) {
......
186 185
function isAnyPartOfElementInViewport(el) {
187 186
	try { 
188 187
		const rect = el.getBoundingClientRect();
189
    // 	DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
188
		// 	DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
190 189
		const windowHeight = (window.innerHeight || document.documentElement.clientHeight);
191 190
		const windowWidth = (window.innerWidth || document.documentElement.clientWidth);
192 191

  
193
    // http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap
192
		// http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap
194 193
		const vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0);
195 194
		const horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);
196 195

  

Formats disponibles : Unified diff