Révision 3972

TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 3972)
1591 1591
	 * @return
1592 1592
	 */
1593 1593
	public List<TXMResult> getChildren() {
1594
		
1594 1595
		return this.children;
1595 1596
	}
1596 1597

  
......
1599 1600
	 * 
1600 1601
	 * @return
1601 1602
	 */
1602
	public List<TXMResult> getChildren(boolean onlyVisible) {
1603
	public final List<TXMResult> getChildren(boolean onlyVisible) {
1604
		
1603 1605
		return this.getChildren(null, onlyVisible);
1604 1606
	}
1607
	
1608
	/**
1609
	 * Gets the children resultsby name and class
1610
	 * 
1611
	 * @param name filter using c.getName()
1612
	 * @param clazz filter by c.getClass()
1613
	 * @return list of results
1614
	 */
1615
	public final List<TXMResult> getChildrenByName(String name, Class<? extends TXMResult> clazz) {
1616
		
1617
		ArrayList<TXMResult> rez = new ArrayList<TXMResult>();
1618
		for (TXMResult c : children) {
1619
			if (c.getName().equals(name) && c.getClass().equals(clazz)) rez.add(c);
1620
		}
1621
		return rez;
1622
	}
1623
	
1624
	/**
1625
	 * Gets the children results by name
1626
	 * 
1627
	 * @param name filter using c.getName()
1628
	 * @return list of results
1629
	 */
1630
	public final List<TXMResult> getChildrenByName(String name) {
1631
		
1632
		ArrayList<TXMResult> rez = new ArrayList<TXMResult>();
1633
		for (TXMResult c : children) {
1634
			if (c.getName().equals(name)) rez.add(c);
1635
		}
1636
		return rez;
1637
	}
1638
	
1639
	/**
1640
	 * Gets the children resultsby name and class
1641
	 * 
1642
	 * @param name filter using c.getSimpleName()
1643
	 * @param clazz filter by c.getClass()
1644
	 * @return list of results
1645
	 */
1646
	public final List<TXMResult> getChildrenBySimpleName(String name, Class<? extends TXMResult> clazz) {
1647
		
1648
		ArrayList<TXMResult> rez = new ArrayList<TXMResult>();
1649
		for (TXMResult c : children) {
1650
			if (c.getSimpleName().equals(name) && c.getClass().equals(clazz)) rez.add(c);
1651
		}
1652
		return rez;
1653
	}
1654
	
1655
	/**
1656
	 * Gets the children results by name
1657
	 * 
1658
	 * @param name filter using c.getSimpleName()
1659
	 * @return list of results
1660
	 */
1661
	public final List<TXMResult> getChildrenBySimpleName(String name) {
1662
		
1663
		ArrayList<TXMResult> rez = new ArrayList<TXMResult>();
1664
		for (TXMResult c : children) {
1665
			if (c.getSimpleName().equals(name)) rez.add(c);
1666
		}
1667
		return rez;
1668
	}
1605 1669

  
1606 1670
	/**
1607 1671
	 * Gets the children results specified by their class.
1608 1672
	 * 
1609
	 * @param clazz
1673
	 * @param clazz filter by c.getClass()
1610 1674
	 * @return
1611 1675
	 */
1612
	public <T extends TXMResult> List<T> getChildren(Class<T> clazz) {
1676
	public final <T extends TXMResult> List<T> getChildren(Class<T> clazz) {
1677
		
1613 1678
		return TXMResult.getNodes(this.children, clazz, false);
1614 1679
	}
1615 1680

  
......
1619 1684
	 * @param clazz
1620 1685
	 * @return
1621 1686
	 */
1622
	public <T extends TXMResult> List<T> getChildren(Class<T> clazz, boolean onlyVisible) {
1687
	public final <T extends TXMResult> List<T> getChildren(Class<T> clazz, boolean onlyVisible) {
1623 1688
		return TXMResult.getNodes(this.children, clazz, onlyVisible);
1624 1689
	}
1625 1690

  
......
1629 1694
	 * @param clazz
1630 1695
	 * @return the first child if exists otherwise null
1631 1696
	 */
1632
	public <T extends TXMResult> T getFirstChild(Class<T> clazz) {
1697
	public final <T extends TXMResult> T getFirstChild(Class<T> clazz) {
1633 1698
		List<T> children = this.getChildren(clazz, false);
1634 1699
		try {
1635 1700
			return children.get(0);
......
1643 1708
	 * Deletes all the children
1644 1709
	 * 
1645 1710
	 */
1646
	public void deleteChildren() {
1711
	public final void deleteChildren() {
1647 1712
		deleteChildren(null);
1648 1713
	}
1649 1714

  
TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java (revision 3972)
610 610
			@Override
611 611
			public void run() {
612 612
				if (concordanceEditor == null || // no editor opened
613
						concordanceEditor.getLineTableViewer().getTable().isDisposed() // editor was closed
613
						concordanceEditor.getTableViewer().getTable().isDisposed() // editor was closed
614 614
						|| !concordanceEditor.getCorpus().equals(corpus)) { // editor opened but with different corpus
615 615
					
616 616
					IEditorPart editor = ComputeConcordance.openEditor(concordance);
TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitConcordanceToolbar.java (revision 3972)
148 148
		this.annotManager = URSCorpora.getCorpus(corpus);
149 149
		this.vue = URSCorpora.getVue(corpus);
150 150
		
151
		TableViewer viewer = this.editor.getLineTableViewer();
151
		TableViewer viewer = this.editor.getTableViewer();
152 152
		
153 153
		// RESULT
154 154
		if (position < 0) {
......
327 327
			@Override
328 328
			public void keyReleased(KeyEvent e) {
329 329
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
330
					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
330
					affectAnnotationToSelection(editor.getTableViewer().getSelection());
331 331
				}
332 332
			}
333 333
			
......
344 344
			
345 345
			@Override
346 346
			public void widgetSelected(SelectionEvent e) {
347
				affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
347
				affectAnnotationToSelection(editor.getTableViewer().getSelection());
348 348
			}
349 349
			
350 350
			@Override
......
380 380
			
381 381
			@Override
382 382
			public void widgetSelected(SelectionEvent e) {
383
				deleteAnnotationValues(editor.getLineTableViewer().getSelection());
383
				deleteAnnotationValues(editor.getTableViewer().getSelection());
384 384
			}
385 385
			
386 386
			@Override
......
475 475
						}
476 476
					}
477 477
					
478
					editor.getLineTableViewer().getTable().getDisplay().syncExec(new Runnable() {
478
					editor.getTableViewer().getTable().getDisplay().syncExec(new Runnable() {
479 479
						
480 480
						@Override
481 481
						public void run() {
482
							editor.getLineTableViewer().refresh();
482
							editor.getTableViewer().refresh();
483 483
						}
484 484
					});
485 485
					
......
525 525
			}
526 526
		}
527 527
		
528
		editor.getLineTableViewer().refresh();
528
		editor.getTableViewer().refresh();
529 529
	}
530 530
	
531 531
	protected void affectAnnotationToSelection(ISelection selection) {
TXM/trunk/bundles/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ToggleShowParts.java (revision 3972)
1
// Copyright © 2010-2023 ENS de Lyon., University of Franche-Comté
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.searchengine.cqp.rcp.handlers.base;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.core.runtime.IProgressMonitor;
33
import org.eclipse.core.runtime.IStatus;
34
import org.eclipse.core.runtime.Status;
35
import org.eclipse.core.runtime.SubMonitor;
36
import org.eclipse.osgi.util.NLS;
37
import org.txm.objects.CorpusBuild;
38
import org.txm.objects.Partition;
39
import org.txm.rcp.handlers.BaseAbstractHandler;
40
import org.txm.rcp.messages.TXMUIMessages;
41
import org.txm.rcp.utils.JobHandler;
42
import org.txm.rcp.views.corpora.CorporaView;
43
import org.txm.utils.logger.Log;
44

  
45
/**
46
 * Command that toggle the visibility of a Partition parts
47
 * 
48
 * @author mdecorde
49
 */
50
public class ToggleShowParts extends BaseAbstractHandler {
51
	
52
	
53
	/*
54
	 * (non-Javadoc)
55
	 * @see
56
	 * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
57
	 * .ExecutionEvent)
58
	 */
59
	@Override
60
	public Object execute(ExecutionEvent event) throws ExecutionException {
61
		
62
		Object selection = this.getCorporaViewSelectedObject(event);
63
		
64
		if (selection instanceof Partition) {
65
			return togglePartsDisplay((Partition)selection);
66
		}
67
		return null;
68
	}
69
	
70
	/**
71
	 * 
72
	 * @param partition the partition parts to display or not
73
	 * @return
74
	 * @throws ExecutionException
75
	 */
76
	public JobHandler togglePartsDisplay(Partition partition) throws ExecutionException {
77
		
78
		try {
79
			JobHandler jobhandler = new JobHandler(NLS.bind("Toggle visibility of {0} parts", partition.getName())) {
80
				
81
				@Override
82
				protected IStatus run(IProgressMonitor monitor) {
83
					
84
					// convert the monitor into sub-monitor
85
					SubMonitor subMonitor = SubMonitor.convert(monitor, NLS.bind("Toggle visibility of {0} parts", partition.getName()), 100);
86
					
87
					this.runInit(subMonitor);
88
					
89
					try {
90
						subMonitor.subTask("Toggle parts...");
91
						for (CorpusBuild part : partition.getParts()) {
92
							part.setVisible(!part.isVisible());
93
						}
94
						
95
						subMonitor.subTask(TXMUIMessages.refreshingCorpora);
96
						syncExec(new Runnable() {
97
							
98
							@Override
99
							public void run() {
100
								CorporaView.refresh();
101
								CorporaView.expand(partition);
102
							}
103
						});
104
					}
105
					catch (ThreadDeath e) { // for user direct canceling
106
						return Status.CANCEL_STATUS;
107
					}
108
					catch (Exception e) {
109
						Log.printStackTrace(e);
110
						return Status.CANCEL_STATUS;
111
					}
112
					finally {
113
						subMonitor.done();
114
					}
115
					return Status.OK_STATUS;
116
				}
117
			};
118
			
119
			jobhandler.startJob();
120
			return jobhandler;
121
			
122
		}
123
		catch (Exception e) {
124
			Log.severe(NLS.bind(TXMUIMessages.errorWhileCreatingAPartitionColonP0, e));
125
		}
126
		return null;
127
	}
128
}
0 129

  
TXM/trunk/bundles/org.txm.searchengine.cqp.rcp/plugin.xml (revision 3972)
79 79
               optional="true">
80 80
         </commandParameter>
81 81
      </command>
82
      <command
83
            defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.ToggleShowParts"
84
            id="org.txm.searchengine.cqp.rcp.handlers.base.ToggleShowParts"
85
            name="Toggle parts visibility">
86
      </command>
82 87
   </extension>
83 88
   <extension
84 89
         point="org.eclipse.ui.preferencePages">
......
280 285
               </reference>
281 286
            </visibleWhen>
282 287
         </command>
288
         <command
289
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.ToggleShowParts"
290
               style="push">
291
            <visibleWhen
292
                  checkEnabled="false">
293
               <and>
294
                  <reference
295
                        definitionId="OnePartitionSelected">
296
                  </reference>
297
               </and>
298
            </visibleWhen>
299
         </command>
283 300
      </menuContribution>
284 301
      <menuContribution
285 302
            locationURI="menu:menu.file.export.corpus">
......
389 406
               </reference>
390 407
            </visibleWhen>
391 408
         </command>
409
         <command
410
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.ToggleShowParts"
411
               style="push">
412
            <visibleWhen
413
                  checkEnabled="false">
414
               <and>
415
                  <reference
416
                        definitionId="OnePartitionSelected">
417
                  </reference>
418
               </and>
419
            </visibleWhen>
420
         </command>
392 421
      </menuContribution>
393 422
      <menuContribution
394 423
            allPopups="true"
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/r/PrintTableRSymbolAndSelectedLinesNamesMacro.groovy (revision 3972)
25 25

  
26 26
monitor.syncExec(new Runnable() {
27 27
	public void run() {
28
		def selection = editor.getlineTableViewer().getSelection()
28
		def selection = editor.getTableViewer().getSelection()
29 29
		def names = table.getRowNames().asStringsArray()
30 30
		println "Selection: "+selection.toList()
31 31
		println "Names: "+names[selection.toList()]
TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/r/PrintTableRSymbolAndSelectedLinesNamesMacro.groovy (revision 3972)
25 25

  
26 26
monitor.syncExec(new Runnable() {
27 27
	public void run() {
28
		def selection = editor.getlineTableViewer().getSelection()
28
		def selection = editor.getTableViewer().getSelection()
29 29
		def names = table.getRowNames().asStringsArray()
30 30
		println "Selection: "+selection.toList()
31 31
		println "Names: "+names[selection.toList()]
TXM/trunk/bundles/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 3972)
638 638
		return null;
639 639
	}
640 640

  
641

  
642

  
643 641
	/**
644 642
	 * Gets the line table viewer.
645 643
	 *
646 644
	 * @return the line table viewer
647 645
	 */
648
	public TableViewer getlineTableViewer() {
646
	public TableViewer getTableViewer() {
649 647
		return viewer;
650 648
	}
651 649

  
TXM/trunk/bundles/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/CopyLines.java (revision 3972)
62 62

  
63 63
	public static void copyLines(LexicalTableEditor editor) {
64 64
		
65
		TableViewer viewer = editor.getlineTableViewer();
65
		TableViewer viewer = editor.getTableViewer();
66 66
		TableKeyListener.copyLinesToClipboard(new TableViewer[] {viewer});
67 67
	}
68 68
}
TXM/trunk/bundles/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/MergeLines.java (revision 3972)
60 60
		
61 61
		if (editor instanceof LexicalTableEditor) {
62 62
			LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
63
			int[] selection = LTeditor.getlineTableViewer().getTable().getSelectionIndices();
63
			int[] selection = LTeditor.getTableViewer().getTable().getSelectionIndices();
64 64
			
65 65
			if (selection.length == 0) {
66 66
				return null;
TXM/trunk/bundles/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/DeleteLines.java (revision 3972)
79 79
	 * @throws Exception
80 80
	 */
81 81
	public static void deleteLexicalTableLines(LexicalTableEditor editor) throws Exception {
82
		int[] selection = editor.getlineTableViewer().getTable().getSelectionIndices();
82
		int[] selection = editor.getTableViewer().getTable().getSelectionIndices();
83 83
		if (selection.length == 0)
84 84
			return;
85 85
		
TXM/trunk/bundles/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/___MergeCols.java (revision 3972)
62 62
				.getActivePage().getActivePart();
63 63
		if (editor instanceof LexicalTableEditor) {
64 64
			LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
65
			int[] selection = LTeditor.getlineTableViewer().getTable()
65
			int[] selection = LTeditor.getTableViewer().getTable()
66 66
					.getSelectionIndices();
67 67
			if (selection.length == 0)
68 68
				return null;
TXM/trunk/bundles/org.txm.progression.rcp/src/org/txm/progression/rcp/chartsengine/events/ProgressionEventCallBack.java (revision 3972)
311 311
	 */
312 312
	public void updateLinkedConcordanceEditor(final ConcordanceEditor linkedEditor, final ArrayList<Integer> selectedPointPositions, boolean loadLines) {
313 313
		
314
		final TableViewer linesTableViewer = linkedEditor.getLineTableViewer();
314
		final TableViewer linesTableViewer = linkedEditor.getTableViewer();
315 315
		final TableViewer refTableViewer = linkedEditor.getReferenceTableViewer();
316 316
		
317 317
		if (linesTableViewer.getTable().isDisposed()) {
TXM/trunk/bundles/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 3972)
2146 2146
	 *
2147 2147
	 * @return the line table viewer
2148 2148
	 */
2149
	public TableViewer getLineTableViewer() {
2149
	public TableViewer getTableViewer() {
2150 2150
		
2151 2151
		return viewerRight;
2152 2152
	}
TXM/trunk/bundles/org.txm.concordance.rcp/src/org/txm/concordance/rcp/handlers/DeleteLines.java (revision 3972)
69 69

  
70 70

  
71 71
	public static void deleteConcordanceLines(ConcordanceEditor editor) {
72
		TableViewer viewer = editor.getLineTableViewer();
72
		TableViewer viewer = editor.getTableViewer();
73 73
		Concordance concordance = editor.getConcordance();
74 74
		if (concordance == null) return;
75 75
		IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
TXM/trunk/bundles/org.txm.concordance.rcp/src/org/txm/concordance/rcp/handlers/CopyLines.java (revision 3972)
61 61

  
62 62

  
63 63
	public static void copyLines(ConcordanceEditor editor) {
64
		TableViewer viewer = editor.getLineTableViewer();
64
		TableViewer viewer = editor.getTableViewer();
65 65
		TableViewer viewer2 = editor.getReferenceTableViewer();
66 66
		
67 67
		TableKeyListener.copyLinesToClipboard(new TableViewer[] {viewer, viewer2});
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java (revision 3972)
143 143
		annotations.computeLines(this.editor.getConcordance().getLines()); // pre-compute the annotation lines ot avoid breaking the sort and co.
144 144
		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
145 145
		
146
		TableViewer viewer = this.editor.getLineTableViewer();
146
		TableViewer viewer = this.editor.getTableViewer();
147 147
		
148 148
		// RESULT
149 149
		
......
276 276
			@Override
277 277
			public void keyReleased(KeyEvent e) {
278 278
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
279
					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
279
					affectAnnotationToSelection(editor.getTableViewer().getSelection());
280 280
				}
281 281
			}
282 282
			
......
359 359
			public void widgetSelected(SelectionEvent e) {
360 360
				int isel = affectCombo.getSelectionIndex();
361 361
				if (isel == 0) { // selected line
362
					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
362
					affectAnnotationToSelection(editor.getTableViewer().getSelection());
363 363
				}
364 364
				else { // all
365 365
					try {
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 3972)
155 155
		annotations.computeLines(this.editor.getConcordance().getLines()); // pre-compute the annotation lines ot avoid breaking the sort and co.
156 156
		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
157 157
		
158
		TableViewer viewer = this.editor.getLineTableViewer();
158
		TableViewer viewer = this.editor.getTableViewer();
159 159
		
160 160
		// RESULT
161 161
		if (position < 0) {
......
486 486
			@Override
487 487
			public void keyReleased(KeyEvent e) {
488 488
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
489
					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
489
					affectAnnotationToSelection(editor.getTableViewer().getSelection());
490 490
				}
491 491
			}
492 492
			
......
572 572
			public void widgetSelected(SelectionEvent e) {
573 573
				int isel = affectCombo.getSelectionIndex();
574 574
				if (isel == 0) { // selected line
575
					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
575
					affectAnnotationToSelection(editor.getTableViewer().getSelection());
576 576
				}
577 577
				else { // all
578 578
					try {
TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 3972)
419 419
		//annotations.computeLines(this.editor.getConcordance().getLines()); // pre-compute the annotation lines ot avoid breaking the sort and co.
420 420
		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
421 421
		
422
		TableViewer viewer = this.editor.getLineTableViewer();
422
		TableViewer viewer = this.editor.getTableViewer();
423 423
		
424 424
		// RESULT
425 425
		if (position < 0) {
......
678 678
			@Override
679 679
			public void keyReleased(KeyEvent e) {
680 680
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
681
					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
681
					affectAnnotationToSelection(editor.getTableViewer().getSelection());
682 682
				}
683 683
			}
684 684
			
......
750 750
			
751 751
			@Override
752 752
			public void widgetSelected(SelectionEvent e) {
753
				affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
753
				affectAnnotationToSelection(editor.getTableViewer().getSelection());
754 754
			}
755 755
			
756 756
			@Override
......
765 765
			
766 766
			@Override
767 767
			public void widgetSelected(SelectionEvent e) {
768
				deleteAnnotationValues(editor.getLineTableViewer().getSelection());
768
				deleteAnnotationValues(editor.getTableViewer().getSelection());
769 769
			}
770 770
			
771 771
			@Override
......
806 806
			public void widgetSelected(SelectionEvent e) {
807 807
				try {
808 808
					// int position = -1;
809
					// TableColumn[] columns = editor.getLineTableViewer().getTable().getColumns();
809
					// TableColumn[] columns = editor.getTableViewer().getTable().getColumns();
810 810
					// TableColumn column = annotationColumnViewer.getColumn();
811 811
					// for (int i = 0 ; i < columns.length ; i++) {
812 812
					// if (columns[i] == column) {

Formats disponibles : Unified diff