|
1 " |
|
2 COPYRIGHT (c) 2006 by eXept Software AG |
|
3 All Rights Reserved |
|
4 |
|
5 This software is furnished under a license and may be used |
|
6 only in accordance with the terms of that license and with the |
|
7 inclusion of the above copyright notice. This software may not |
|
8 be provided or otherwise made available to, or used by, any |
|
9 other person. No title to or ownership of the software is |
|
10 hereby transferred. |
|
11 " |
|
12 "{ Package: 'stx:libtool' }" |
|
13 |
|
14 "{ NameSpace: Tools }" |
|
15 |
|
16 TextDiffTool subclass:#TextDiff2Tool |
|
17 instanceVariableNames:'showDiffHolder diffSpecHolder codeView' |
|
18 classVariableNames:'' |
|
19 poolDictionaries:'' |
|
20 category:'Interface-Diff' |
|
21 ! |
|
22 |
|
23 !TextDiff2Tool class methodsFor:'documentation'! |
|
24 |
|
25 copyright |
|
26 " |
|
27 COPYRIGHT (c) 2006 by eXept Software AG |
|
28 All Rights Reserved |
|
29 |
|
30 This software is furnished under a license and may be used |
|
31 only in accordance with the terms of that license and with the |
|
32 inclusion of the above copyright notice. This software may not |
|
33 be provided or otherwise made available to, or used by, any |
|
34 other person. No title to or ownership of the software is |
|
35 hereby transferred. |
|
36 " |
|
37 ! |
|
38 |
|
39 documentation |
|
40 " |
|
41 documentation to be added. |
|
42 |
|
43 [author:] |
|
44 Jan Vrany <jan.vrany@fit.cvut.cz> |
|
45 |
|
46 [instance variables:] |
|
47 |
|
48 [class variables:] |
|
49 |
|
50 [see also:] |
|
51 |
|
52 " |
|
53 ! |
|
54 |
|
55 examples |
|
56 " |
|
57 [exBegin] |
|
58 |text1 text2| |
|
59 |
|
60 text1 := 'hello world |
|
61 here is some difference |
|
62 more text |
|
63 this line has been removed |
|
64 more text |
|
65 more text |
|
66 '. |
|
67 |
|
68 text2 := 'hello world |
|
69 where is the difference ? |
|
70 more text |
|
71 more text |
|
72 more text |
|
73 this line has been added |
|
74 '. |
|
75 |
|
76 TextDiff2Tool openOn:text1 label:'text1' |
|
77 and:text2 label:'text2' |
|
78 [exEnd] |
|
79 " |
|
80 ! ! |
|
81 |
|
82 !TextDiff2Tool class methodsFor:'interface opening'! |
|
83 |
|
84 openOn:textA label:labelA and: textB label: labelB |
|
85 | app | |
|
86 |
|
87 app := self new. |
|
88 app labelA: labelA; textA: textA. |
|
89 app labelB: labelB; textB: textB. |
|
90 app open |
|
91 |
|
92 "Created: / 16-03-2012 / 13:15:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
93 ! ! |
|
94 |
|
95 !TextDiff2Tool class methodsFor:'interface specs'! |
|
96 |
|
97 diffSpec |
|
98 "This resource specification was automatically generated |
|
99 by the UIPainter of ST/X." |
|
100 |
|
101 "Do not manually edit this!! If it is corrupted, |
|
102 the UIPainter may not be able to read the specification." |
|
103 |
|
104 " |
|
105 UIPainter new openOnClass:Tools::TextDiff2Tool andSelector:#diffSpec |
|
106 Tools::TextDiff2Tool new openInterface:#diffSpec |
|
107 " |
|
108 |
|
109 <resource: #canvas> |
|
110 |
|
111 ^ |
|
112 #(FullSpec |
|
113 name: diffSpec |
|
114 window: |
|
115 (WindowSpec |
|
116 label: 'Text Diff Tool (for embedding)' |
|
117 name: 'Text Diff Tool (for embedding)' |
|
118 min: (Point 10 10) |
|
119 bounds: (Rectangle 0 0 782 506) |
|
120 ) |
|
121 component: |
|
122 (SpecCollection |
|
123 collection: ( |
|
124 (ViewSpec |
|
125 name: '2Labels' |
|
126 layout: (LayoutFrame 0 0 0 0 -16 1 30 0) |
|
127 component: |
|
128 (SpecCollection |
|
129 collection: ( |
|
130 (UISubSpecification |
|
131 name: 'VersionA' |
|
132 layout: (LayoutFrame 0 0 0 0 0 0.5 30 0) |
|
133 minorKey: versionALabelSpec |
|
134 ) |
|
135 (UISubSpecification |
|
136 name: 'VersionB' |
|
137 layout: (LayoutFrame 5 0.5 0 0 0 1 30 0) |
|
138 minorKey: versionBLabelSpec |
|
139 ) |
|
140 ) |
|
141 |
|
142 ) |
|
143 ) |
|
144 (ArbitraryComponentSpec |
|
145 name: 'Diff2TextView' |
|
146 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
|
147 hasHorizontalScrollBar: false |
|
148 hasVerticalScrollBar: false |
|
149 autoHideScrollBars: false |
|
150 hasBorder: false |
|
151 component: diffView |
|
152 postBuildCallback: postBuildDiffView: |
|
153 ) |
|
154 ) |
|
155 |
|
156 ) |
|
157 ) |
|
158 ! |
|
159 |
|
160 nothingSpec |
|
161 "This resource specification was automatically generated |
|
162 by the UIPainter of ST/X." |
|
163 |
|
164 "Do not manually edit this!! If it is corrupted, |
|
165 the UIPainter may not be able to read the specification." |
|
166 |
|
167 " |
|
168 UIPainter new openOnClass:Tools::TextDiffTool andSelector:#nothingSpec |
|
169 Tools::TextDiffTool new openInterface:#nothingSpec |
|
170 " |
|
171 |
|
172 <resource: #canvas> |
|
173 |
|
174 ^ |
|
175 #(FullSpec |
|
176 name: nothingSpec |
|
177 window: |
|
178 (WindowSpec |
|
179 label: 'NewApplication' |
|
180 name: 'NewApplication' |
|
181 bounds: (Rectangle 0 0 300 300) |
|
182 ) |
|
183 component: |
|
184 (SpecCollection |
|
185 collection: ( |
|
186 (LabelSpec |
|
187 label: 'Nothing selected...' |
|
188 name: 'Label1' |
|
189 layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
190 translateLabel: true |
|
191 ) |
|
192 ) |
|
193 |
|
194 ) |
|
195 ) |
|
196 ! |
|
197 |
|
198 textAViewSpec |
|
199 "This resource specification was automatically generated |
|
200 by the UIPainter of ST/X." |
|
201 |
|
202 "Do not manually edit this!! If it is corrupted, |
|
203 the UIPainter may not be able to read the specification." |
|
204 |
|
205 " |
|
206 UIPainter new openOnClass:Tools::TextDiffTool andSelector:#textViewSpec |
|
207 Tools::TextDiffTool new openInterface:#textViewSpec |
|
208 " |
|
209 |
|
210 <resource: #canvas> |
|
211 |
|
212 ^ |
|
213 #(FullSpec |
|
214 name: 'textAViewSpec' |
|
215 window: |
|
216 (WindowSpec |
|
217 label: 'Text Only' |
|
218 name: 'Text Only' |
|
219 min: (Point 10 10) |
|
220 bounds: (Rectangle 0 0 782 506) |
|
221 ) |
|
222 component: |
|
223 (SpecCollection |
|
224 collection: ( |
|
225 (ArbitraryComponentSpec |
|
226 name: 'CodeView' |
|
227 layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
228 model: textAHolder |
|
229 hasHorizontalScrollBar: false |
|
230 hasVerticalScrollBar: false |
|
231 autoHideScrollBars: false |
|
232 hasBorder: false |
|
233 component: #'Tools::CodeView2' |
|
234 postBuildCallback: postBuildCodeView: |
|
235 ) |
|
236 ) |
|
237 |
|
238 ) |
|
239 ) |
|
240 |
|
241 "Created: / 18-04-2012 / 18:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
242 ! |
|
243 |
|
244 textBViewSpec |
|
245 "This resource specification was automatically generated |
|
246 by the UIPainter of ST/X." |
|
247 |
|
248 "Do not manually edit this!! If it is corrupted, |
|
249 the UIPainter may not be able to read the specification." |
|
250 |
|
251 " |
|
252 UIPainter new openOnClass:Tools::TextDiffTool andSelector:#textViewSpec |
|
253 Tools::TextDiffTool new openInterface:#textViewSpec |
|
254 " |
|
255 |
|
256 <resource: #canvas> |
|
257 |
|
258 ^ |
|
259 #(FullSpec |
|
260 name: 'textAViewSpec' |
|
261 window: |
|
262 (WindowSpec |
|
263 label: 'Text Only' |
|
264 name: 'Text Only' |
|
265 min: (Point 10 10) |
|
266 bounds: (Rectangle 0 0 782 506) |
|
267 ) |
|
268 component: |
|
269 (SpecCollection |
|
270 collection: ( |
|
271 (ArbitraryComponentSpec |
|
272 name: 'CodeView' |
|
273 layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
274 model: textBHolder |
|
275 hasHorizontalScrollBar: false |
|
276 hasVerticalScrollBar: false |
|
277 autoHideScrollBars: false |
|
278 hasBorder: false |
|
279 component: #'Tools::CodeView2' |
|
280 postBuildCallback: postBuildCodeView: |
|
281 ) |
|
282 ) |
|
283 |
|
284 ) |
|
285 ) |
|
286 |
|
287 "Created: / 18-04-2012 / 18:43:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
288 ! |
|
289 |
|
290 versionAOnlySpec |
|
291 "This resource specification was automatically generated |
|
292 by the UIPainter of ST/X." |
|
293 |
|
294 "Do not manually edit this!! If it is corrupted, |
|
295 the UIPainter may not be able to read the specification." |
|
296 |
|
297 " |
|
298 UIPainter new openOnClass:Tools::TextDiffTool andSelector:#versionAOnlySpec |
|
299 Tools::TextDiffTool new openInterface:#versionAOnlySpec |
|
300 " |
|
301 |
|
302 <resource: #canvas> |
|
303 |
|
304 ^ |
|
305 #(FullSpec |
|
306 name: versionAOnlySpec |
|
307 window: |
|
308 (WindowSpec |
|
309 label: 'Version A Only' |
|
310 name: 'Version A Only' |
|
311 min: (Point 10 10) |
|
312 bounds: (Rectangle 0 0 782 506) |
|
313 ) |
|
314 component: |
|
315 (SpecCollection |
|
316 collection: ( |
|
317 (UISubSpecification |
|
318 name: 'VersionA' |
|
319 layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
|
320 minorKey: versionALabelSpec |
|
321 ) |
|
322 (UISubSpecification |
|
323 name: 'Text' |
|
324 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
|
325 minorKey: textAViewSpec |
|
326 ) |
|
327 ) |
|
328 |
|
329 ) |
|
330 ) |
|
331 |
|
332 "Modified: / 18-04-2012 / 18:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
333 ! |
|
334 |
|
335 versionBOnlySpec |
|
336 "This resource specification was automatically generated |
|
337 by the UIPainter of ST/X." |
|
338 |
|
339 "Do not manually edit this!! If it is corrupted, |
|
340 the UIPainter may not be able to read the specification." |
|
341 |
|
342 " |
|
343 UIPainter new openOnClass:Tools::TextDiffTool andSelector:#versionBOnlySpec |
|
344 Tools::TextDiffTool new openInterface:#versionBOnlySpec |
|
345 " |
|
346 |
|
347 <resource: #canvas> |
|
348 |
|
349 ^ |
|
350 #(FullSpec |
|
351 name: 'versionBOnlySpec' |
|
352 window: |
|
353 (WindowSpec |
|
354 label: 'Version B Only' |
|
355 name: 'Version B Only' |
|
356 min: (Point 10 10) |
|
357 bounds: (Rectangle 0 0 782 506) |
|
358 ) |
|
359 component: |
|
360 (SpecCollection |
|
361 collection: ( |
|
362 (UISubSpecification |
|
363 name: 'VersionB' |
|
364 layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
|
365 minorKey: versionBLabelSpec |
|
366 ) |
|
367 (UISubSpecification |
|
368 name: 'Text' |
|
369 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
|
370 minorKey: textBViewSpec |
|
371 ) |
|
372 ) |
|
373 |
|
374 ) |
|
375 ) |
|
376 |
|
377 "Created: / 19-07-2011 / 10:06:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
378 ! ! |
|
379 |
|
380 !TextDiff2Tool class methodsFor:'plugIn spec'! |
|
381 |
|
382 aspectSelectors |
|
383 "This resource specification was automatically generated |
|
384 by the UIPainter of ST/X." |
|
385 |
|
386 "Do not manually edit this. If it is corrupted, |
|
387 the UIPainter may not be able to read the specification." |
|
388 |
|
389 "Return a description of exported aspects; |
|
390 these can be connected to aspects of an embedding application |
|
391 (if this app is embedded in a subCanvas)." |
|
392 |
|
393 ^ #( |
|
394 #classHolder |
|
395 #codeAspectHolder |
|
396 #labelAHolder |
|
397 #labelBHolde |
|
398 #labelCHolder |
|
399 #labelHolder |
|
400 #languageHolder |
|
401 #showDiffHolder |
|
402 #textAHolder |
|
403 #textBHolder |
|
404 #textCHolder |
|
405 ). |
|
406 |
|
407 ! ! |
|
408 |
|
409 !TextDiff2Tool methodsFor:'accessing'! |
|
410 |
|
411 title: aString |
|
412 |
|
413 ^self label: aString |
|
414 |
|
415 "Created: / 30-08-2011 / 09:45:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
416 ! ! |
|
417 |
|
418 !TextDiff2Tool methodsFor:'aspects'! |
|
419 |
|
420 showDiffHolder |
|
421 "return/create the 'showDiffHolder' value holder (automatically generated)" |
|
422 |
|
423 showDiffHolder isNil ifTrue:[ |
|
424 showDiffHolder := ValueHolder with: true. |
|
425 showDiffHolder addDependent:self. |
|
426 ]. |
|
427 ^ showDiffHolder |
|
428 |
|
429 "Modified: / 30-06-2011 / 20:59:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
430 ! |
|
431 |
|
432 showDiffHolder:something |
|
433 "set the 'showDiffHolder' value holder (automatically generated)" |
|
434 |
|
435 |oldValue newValue| |
|
436 |
|
437 showDiffHolder notNil ifTrue:[ |
|
438 oldValue := showDiffHolder value. |
|
439 showDiffHolder removeDependent:self. |
|
440 ]. |
|
441 showDiffHolder := something. |
|
442 showDiffHolder notNil ifTrue:[ |
|
443 showDiffHolder addDependent:self. |
|
444 ]. |
|
445 newValue := showDiffHolder value. |
|
446 oldValue ~~ newValue ifTrue:[ |
|
447 self update:#value with:newValue from:showDiffHolder. |
|
448 ]. |
|
449 ! ! |
|
450 |
|
451 !TextDiff2Tool methodsFor:'change & update'! |
|
452 |
|
453 codeAspect |
|
454 |
|
455 ^self codeAspectHolder value |
|
456 |
|
457 "Created: / 19-07-2011 / 19:07:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
458 ! |
|
459 |
|
460 update:something with:aParameter from:changedObject |
|
461 "Invoked when an object that I depend upon sends a change notification." |
|
462 |
|
463 (changedObject == showDiffHolder) ifTrue:[ |
|
464 self updateViews. |
|
465 ^self. |
|
466 ]. |
|
467 super update:something with:aParameter from:changedObject |
|
468 |
|
469 "Modified: / 16-03-2012 / 12:36:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
470 ! |
|
471 |
|
472 updateAfterAorBorCChanged |
|
473 |
|
474 (textAChanged & textBChanged) ifTrue:[ |
|
475 textAChanged := textBChanged := false. |
|
476 self updateViews |
|
477 ]. |
|
478 |
|
479 "Created: / 16-03-2012 / 12:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
480 ! |
|
481 |
|
482 updateViews |
|
483 |
|
484 | a b | |
|
485 a := self textAHolder value. |
|
486 b := self textBHolder value. |
|
487 |
|
488 self showDiffHolder value ifFalse:[ |
|
489 self showTextOnly. |
|
490 ^ self |
|
491 ]. |
|
492 |
|
493 (a notNil and:[b notNil]) ifTrue:[ |
|
494 self showDiff. |
|
495 ^self |
|
496 ]. |
|
497 a notNil ifTrue:[ |
|
498 self showVersionA. |
|
499 ^self |
|
500 ]. |
|
501 b notNil ifTrue:[ |
|
502 self showVersionB. |
|
503 ^self |
|
504 ]. |
|
505 |
|
506 self showNothing. |
|
507 |
|
508 "Created: / 19-07-2011 / 11:29:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
509 ! ! |
|
510 |
|
511 !TextDiff2Tool methodsFor:'hooks'! |
|
512 |
|
513 postBuildCodeView:aScrollableView |
|
514 |
|
515 codeView := aScrollableView. |
|
516 codeView notNil ifTrue:[codeView languageHolder: self languageHolder]. |
|
517 codeView notNil ifTrue:[codeView classHolder: self classHolder]. |
|
518 |
|
519 "Created: / 19-07-2011 / 10:17:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
520 ! |
|
521 |
|
522 postBuildDiffView:aScrollableView |
|
523 |
|
524 super postBuildDiffView:aScrollableView. |
|
525 diffView notNil ifTrue:[ |
|
526 (self textAHolder value notNil and:[self textBHolder value notNil]) ifTrue:[ |
|
527 diffView scrolledView |
|
528 text1: self textAHolder value |
|
529 text2: self textBHolder value |
|
530 ] |
|
531 |
|
532 ]. |
|
533 |
|
534 "Created: / 16-03-2012 / 13:30:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
535 ! ! |
|
536 |
|
537 !TextDiff2Tool methodsFor:'initialization'! |
|
538 |
|
539 initializeDiffView |
|
540 "superclass Tools::TextDiffTool says that I am responsible to implement this method" |
|
541 |
|
542 ^ Tools::Diff2CodeView2 new |
|
543 |
|
544 "Modified: / 16-01-2013 / 11:58:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
545 ! ! |
|
546 |
|
547 !TextDiff2Tool methodsFor:'private'! |
|
548 |
|
549 showDiff |
|
550 |scrolledView| |
|
551 |
|
552 self contentSpecHolder value: #diffSpec. |
|
553 |
|
554 diffView isNil ifTrue:[^self]. |
|
555 (scrolledView := diffView scrolledView) isNil ifTrue:[^self]. |
|
556 scrolledView |
|
557 text1: self textAHolder value |
|
558 text2: self textBHolder value |
|
559 |
|
560 "Created: / 19-07-2011 / 10:22:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
561 "Modified: / 18-11-2011 / 15:01:12 / cg" |
|
562 "Modified: / 16-03-2012 / 13:21:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
563 ! |
|
564 |
|
565 showNothing |
|
566 |
|
567 self contentSpecHolder value: #nothingSpec |
|
568 |
|
569 "Created: / 19-07-2011 / 19:34:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
570 ! |
|
571 |
|
572 showTextOnly |
|
573 |
|
574 self contentSpecHolder value: #textViewSpec |
|
575 |
|
576 "Created: / 19-07-2011 / 11:39:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
577 ! |
|
578 |
|
579 showVersionA |
|
580 |
|
581 self contentSpecHolder value: #versionAOnlySpec |
|
582 |
|
583 "Created: / 19-07-2011 / 10:22:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
584 ! |
|
585 |
|
586 showVersionB |
|
587 |
|
588 self contentSpecHolder value: #versionBOnlySpec |
|
589 |
|
590 "Created: / 19-07-2011 / 10:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
591 ! ! |
|
592 |
|
593 !TextDiff2Tool methodsFor:'testing'! |
|
594 |
|
595 isDiff2 |
|
596 ^true |
|
597 |
|
598 "Created: / 16-03-2012 / 15:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
599 ! ! |
|
600 |
|
601 !TextDiff2Tool class methodsFor:'documentation'! |
|
602 |
|
603 version |
|
604 ^ '$Id: Tools__TextDiff2Tool.st,v 1.1 2014-02-05 19:00:35 vrany Exp $' |
|
605 ! |
|
606 |
|
607 version_CVS |
|
608 ^ '§Header: /cvs/stx/stx/libtool/Tools__TextDiffTool.st,v 1.6 2011/11/18 14:05:39 cg Exp §' |
|
609 ! |
|
610 |
|
611 version_HG |
|
612 |
|
613 ^ '$Changeset: <not expanded> $' |
|
614 ! |
|
615 |
|
616 version_SVN |
|
617 ^ '$Id: Tools__TextDiff2Tool.st,v 1.1 2014-02-05 19:00:35 vrany Exp $' |
|
618 ! ! |
|
619 |