Révision 3367

TXM/trunk/org.txm.concordance.rcp/plugin.xml (revision 3367)
103 103
               icon="platform:/plugin/org.txm.rcp/icons/cross.png"
104 104
               style="push">
105 105
         </command>
106
         <command
107
               commandId="org.txm.concordance.rcp.handlers.CopyLines"
108
               icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/copy_edit.png"
109
               label="Copy"
110
               style="push">
111
         </command>
106 112
      </menuContribution>
107 113
      <menuContribution
108 114
            locationURI="toolbar:org.txm.concordance.rcp.editors.ConcordanceEditor">
......
190 196
            id="org.txm.concordance.rcp.handlers.DeleteLines"
191 197
            name="%command.name.37">
192 198
      </command>
199
      <command
200
            defaultHandler="org.txm.concordance.rcp.handlers.CopyLines"
201
            id="org.txm.concordance.rcp.handlers.CopyLines"
202
            name="Copy">
203
      </command>
193 204
   </extension>
194 205
   <extension
195 206
         point="org.eclipse.ui.preferencePages">
TXM/trunk/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 3367)
2102 2102
	}
2103 2103
	
2104 2104
	/**
2105
	 * Gets the line table viewer.
2106
	 *
2107
	 * @return the line table viewer
2108
	 */
2109
	public TableViewer getReferenceTableViewer() {
2110
		
2111
		return viewerLeft;
2112
	}
2113
	
2114
	/**
2105 2115
	 * Reset sorted column.
2106 2116
	 *
2107 2117
	 * @param col the col
TXM/trunk/org.txm.concordance.rcp/src/org/txm/concordance/rcp/handlers/CopyLines.java (revision 3367)
1
// Copyright © 2010-2020 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.concordance.rcp.handlers;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.TableViewer;
34
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.ui.IWorkbenchPart;
36
import org.eclipse.ui.handlers.HandlerUtil;
37
import org.txm.concordance.rcp.editors.ConcordanceEditor;
38
import org.txm.rcp.editors.TableKeyListener;
39

  
40
/**
41
 * Allow the user to delete lines in a Concordance table.
42
 * @author mdecorde
43
 * @author sjacquot
44
 */
45
public class CopyLines extends AbstractHandler {
46

  
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
49
	 */
50
	@Override
51
	public Object execute(ExecutionEvent event) throws ExecutionException {
52
		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
53
		// ISelection selection =
54
		// HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
55

  
56
		IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event)
57
				.getActivePage().getActivePart();
58
		if (editor instanceof ConcordanceEditor) {
59
			ConcordanceEditor ceditor = (ConcordanceEditor) editor;
60
			deleteConcordanceLines(ceditor);
61
		}
62

  
63
		return null;
64
	}
65

  
66

  
67
	public static void deleteConcordanceLines(ConcordanceEditor editor) {
68
		TableViewer viewer = editor.getLineTableViewer();
69
		TableViewer viewer2 = editor.getReferenceTableViewer();
70
		
71
		TableKeyListener.copyLinesToClipboard(new TableViewer[] {viewer, viewer2});
72
	}
73
}
0 74

  
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/TableKeyListener.java (revision 3367)
33 33
	public void keyPressed(KeyEvent e) {
34 34
		// System.out.println("key code: "+e.keyCode);
35 35
		if ((e.stateMask & SWT.CTRL) != 0 && e.keyCode == 99) { // CTRL + C
36
			copyLinesToClipboard(e);
36
			copyLinesToClipboard(viewers);
37 37
		}
38 38
		else if ((e.stateMask & SWT.CTRL) != 0 && e.keyCode == 102) { // CTRL + F
39
			searchInLines(e);
39
			searchInLines(viewers);
40 40
		}
41 41
		else if ((e.stateMask & SWT.COMMAND) != 0 && e.keyCode == 99) { // CMD + C
42
			copyLinesToClipboard(e);
42
			copyLinesToClipboard(viewers);
43 43
		}
44 44
		else if ((e.stateMask & SWT.COMMAND) != 0 && e.keyCode == 102) { // CMD + F
45
			searchInLines(e);
45
			searchInLines(viewers);
46 46
		}
47 47
	}
48 48
	
49 49
	/**
50 50
	 * Opens a dialog box to enter a REGEX that selects lines in the table.
51
	 * 
52
	 * uses the viewers shell to open the dialog
51 53
	 */
52
	public void searchInLines(KeyEvent e) {
54
	public static void searchInLines(TableViewer[] viewers) {
53 55
		
54 56
		InputDialog dialog = new InputDialog(viewers[0].getTable().getShell(), "Compute", TXMUIMessages.common_enterRegularExpressionOfYourSearch, "", null);  //$NON-NLS-1$
55 57
		if (dialog.open() == Window.OK) {
56 58
			for (TableViewer viewer : viewers) {
59
				
57 60
				TableItem[] items = viewer.getTable().getItems();
58 61
				// System.out.println("search in tablein items: "+Arrays.toString(items));
59 62
				
......
116 119
	/**
117 120
	 * Copies the current lines selection to the clipboard.
118 121
	 */
119
	public void copyLinesToClipboard(KeyEvent e) {
122
	public static void copyLinesToClipboard(TableViewer[] viewers) {
120 123
		
121 124
		StringBuffer str = new StringBuffer();
122 125
		
......
125 128
			if (l > 0) str.append("\n"); //$NON-NLS-1$
126 129
			
127 130
			for (TableViewer viewer : viewers) {
131
				
128 132
				TableColumn[] cols = viewer.getTable().getColumns();
129 133
				TableItem[] items = viewer.getTable().getSelection();
130 134
				TableItem item = items[l];
131 135
				
132 136
				for (int i = 0; i < cols.length; i++) {
137
					
133 138
					if (cols[i].getText().trim().length() > 0) {
139
						
134 140
						if (i > 0) str.append("\t"); //$NON-NLS-1$
135 141
						str.append(item.getText(i));
136 142
					}
137 143
				}
138 144
			}
139
			
140 145
		}
146
		
141 147
		String strr = str.toString();
142 148
		org.txm.rcp.utils.IOClipboard.write(strr);
143 149
		Log.info(TXMCoreMessages.bind(TXMUIMessages.copiedLinesColon, strr));
TXM/trunk/org.txm.index.rcp/plugin.xml (revision 3367)
162 162
                     </visibleWhen>
163 163
                  </command>
164 164
               </menuContribution>
165
               <menuContribution
166
                     locationURI="popup:org.txm.index.rcp.editors.IndexEditor">
167
                  <command
168
                        commandId="org.txm.index.rcp.handlers.CopyLines"
169
                        icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/copy_edit.png"
170
                        label="Copy"
171
                        style="push">
172
                  </command>
173
               </menuContribution>
165 174
      
166 175
   </extension>
167 176
   <extension
......
251 260
            name="%command.name"
252 261
            returnTypeId="org.txm.index.core.functions.PartitionIndex">
253 262
      </command>
263
      <command
264
            defaultHandler="org.txm.index.rcp.handlers.CopyLines"
265
            id="org.txm.index.rcp.handlers.CopyLines"
266
            name="Copy">
267
      </command>
254 268
      
255 269
      
256 270
   </extension>
TXM/trunk/org.txm.index.rcp/src/org/txm/index/rcp/handlers/CopyLines.java (revision 3367)
1
// Copyright © 2010-2020 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.index.rcp.handlers;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.TableViewer;
34
import org.eclipse.ui.IWorkbenchPart;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.index.rcp.editors.IndexEditor;
37
import org.txm.rcp.editors.TableKeyListener;
38

  
39
/**
40
 * Allow the user to delete lines in a Concordance table.
41
 * @author mdecorde
42
 * @author sjacquot
43
 */
44
public class CopyLines extends AbstractHandler {
45

  
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
48
	 */
49
	@Override
50
	public Object execute(ExecutionEvent event) throws ExecutionException {
51
		// Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
52
		// ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
53

  
54
		IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActivePart();
55
		
56
		if (editor instanceof IndexEditor) {
57
			IndexEditor ceditor = (IndexEditor) editor;
58
			deleteConcordanceLines(ceditor);
59
		}
60

  
61
		return null;
62
	}
63

  
64

  
65
	public static void deleteConcordanceLines(IndexEditor editor) {
66
		TableViewer viewer = editor.getTableViewer();
67
				
68
		TableKeyListener.copyLinesToClipboard(new TableViewer[] {viewer});
69
	}
70
}
0 71

  
TXM/trunk/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 3367)
533 533
	public IQuery getQuery() {
534 534
		return queryWidget.getQuery();
535 535
	}
536

  
537

  
538

  
539

  
540
	public TableViewer getTableViewer() {
541
		
542
		return viewer;
543
	}
536 544
}

Formats disponibles : Unified diff