Révision 3560

TXM/trunk/org.txm.searchengine.cqp.rcp/plugin.xml (revision 3560)
54 54
            id="org.txm.searchengine.cqp.rcp.handlers.base.Intersection"
55 55
            name="%command.name.3">
56 56
      </command>
57
      <command
58
            defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.EditPartition"
59
            id="org.txm.searchengine.cqp.rcp.handlers.base.EditPartition"
60
            name="Edit">
61
         <commandParameter
62
               id="CorpusParameter"
63
               name="%commandParameter.name.0"
64
               optional="true">
65
         </commandParameter>
66
      </command>
67
      <command
68
            defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.EditSubCorpus"
69
            id="org.txm.searchengine.cqp.rcp.handlers.base.EditSubCorpus"
70
            name="Edit">
71
         <commandParameter
72
               id="CorpusParameter"
73
               name="%commandParameter.name.0"
74
               optional="true">
75
         </commandParameter>
76
         <commandParameter
77
               id="edit"
78
               name="%commandParameter.name"
79
               optional="true">
80
         </commandParameter>
81
      </command>
57 82
   </extension>
58 83
   <extension
59 84
         point="org.eclipse.ui.preferencePages">
......
163 188
      <menuContribution
164 189
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView?after=org.txm.rcp.corporaview.corpus.manage">
165 190
         <command
191
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.EditSubCorpus"
192
               icon="platform:/plugin/org.txm.rcp/icons/functions/pencil.png"
193
               style="push">
194
            <visibleWhen
195
                  checkEnabled="false">
196
               <and>
197
                  <reference
198
                        definitionId="OneSubCorpusSelected">
199
                  </reference>
200
                  <reference
201
                        definitionId="ExpertEnabled">
202
                  </reference>
203
               </and>
204
            </visibleWhen>
205
         </command>
206
         <command
207
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.EditPartition"
208
               icon="platform:/plugin/org.txm.rcp/icons/functions/pencil.png"
209
               style="push">
210
            <visibleWhen
211
                  checkEnabled="false">
212
               <and>
213
                  <reference
214
                        definitionId="OnePartitionSelected">
215
                  </reference>
216
                  <reference
217
                        definitionId="ExpertEnabled">
218
                  </reference>
219
               </and>
220
            </visibleWhen>
221
         </command>
222
         <command
166 223
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
167 224
               icon="icons/functions/subcorpus.png"
168 225
               style="push">
......
239 296
      <menuContribution
240 297
            locationURI="menu:menu.corpus?after=menu.corpus.build">
241 298
         <command
299
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.EditSubCorpus"
300
               icon="platform:/plugin/org.txm.rcp/icons/functions/pencil.png"
301
               style="push">
302
            <visibleWhen
303
                  checkEnabled="false">
304
               <and>
305
                  <reference
306
                        definitionId="OneSubCorpusSelected">
307
                  </reference>
308
                  <reference
309
                        definitionId="ExpertEnabled">
310
                  </reference>
311
               </and>
312
            </visibleWhen>
313
         </command>
314
         <command
315
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.EditPartition"
316
               icon="platform:/plugin/org.txm.rcp/icons/functions/pencil.png"
317
               style="push">
318
            <visibleWhen
319
                  checkEnabled="false">
320
               <and>
321
                  <reference
322
                        definitionId="OnePartitionSelected">
323
                  </reference>
324
                  <reference
325
                        definitionId="ExpertEnabled">
326
                  </reference>
327
               </and>
328
            </visibleWhen>
329
         </command>
330
         <command
242 331
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
243 332
               icon="icons/functions/subcorpus.png"
244 333
               style="push">
......
314 403
      <menuContribution
315 404
            locationURI="toolbar:org.txm.rcp.toolbarcorpus?after=org.txm.rcp.toolbarcorpus.corpus">
316 405
         <command
406
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.EditSubCorpus"
407
               icon="platform:/plugin/org.txm.rcp/icons/functions/pencil.png"
408
               style="push">
409
            <visibleWhen
410
                  checkEnabled="false">
411
               <and>
412
                  <reference
413
                        definitionId="OneSubCorpusSelected">
414
                  </reference>
415
                  <reference
416
                        definitionId="ExpertEnabled">
417
                  </reference>
418
               </and>
419
            </visibleWhen>
420
         </command>
421
         <command
422
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.EditPartition"
423
               icon="platform:/plugin/org.txm.rcp/icons/functions/pencil.png"
424
               style="push">
425
            <visibleWhen
426
                  checkEnabled="false">
427
               <and>
428
                  <reference
429
                        definitionId="OnePartitionSelected">
430
                  </reference>
431
                  <reference
432
                        definitionId="ExpertEnabled">
433
                  </reference>
434
               </and>
435
            </visibleWhen>
436
         </command>
437
         <command
317 438
               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
318 439
               icon="icons/functions/subcorpus.png"
319 440
               style="push">
TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/EditSubCorpus.java (revision 3560)
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.searchengine.cqp.rcp.handlers.base;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.handlers.HandlerUtil;
34
import org.txm.rcp.editors.TXMEditor;
35
import org.txm.rcp.handlers.BaseAbstractHandler;
36
import org.txm.rcp.messages.TXMUIMessages;
37
import org.txm.searchengine.cqp.corpus.Subcorpus;
38
import org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor;
39

  
40
/**
41
 * Command which creates a subcorpus from a Corpus
42
 * 
43
 * @author mdecorde
44
 * @author sjacquot
45
 * 
46
 */
47
public class EditSubCorpus extends BaseAbstractHandler {
48
	
49
	/*
50
	 * (non-Javadoc)
51
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
52
	 */
53
	@Override
54
	public Object execute(ExecutionEvent event) throws ExecutionException {
55
		
56
		if (!this.checkCorpusEngine()) {
57
			return false;
58
		}
59
		
60
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
61
		if (selection == null) {
62
			System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
63
			return null;
64
		}
65
		
66
		if (selection.getFirstElement() instanceof Subcorpus) {
67
			return edit((Subcorpus) selection.getFirstElement());
68
		} else {
69
			return null;
70
		}
71
	}
72
	
73
	public static Object edit(Subcorpus sub) throws ExecutionException {
74
		
75
		return TXMEditor.openEditor(sub, SubcorpusEditor.class.getName());
76
	}	
77
}
0 78

  
TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/EditPartition.java (revision 3560)
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.searchengine.cqp.rcp.handlers.base;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.handlers.HandlerUtil;
34
import org.txm.rcp.editors.TXMEditor;
35
import org.txm.rcp.handlers.BaseAbstractHandler;
36
import org.txm.rcp.messages.TXMUIMessages;
37
import org.txm.searchengine.cqp.corpus.Partition;
38
import org.txm.searchengine.cqp.rcp.editor.PartitionEditor;
39

  
40
/**
41
 * Command that creates a Partition from a Corpus.
42
 * 
43
 * @author mdecorde
44
 * @author sjacquot
45
 */
46
public class EditPartition extends BaseAbstractHandler {
47
		
48
	/*
49
	 * (non-Javadoc)
50
	 * @see
51
	 * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
52
	 * .ExecutionEvent)
53
	 */
54
	@Override
55
	public Object execute(ExecutionEvent event) throws ExecutionException {
56
		
57
		if (!this.checkCorpusEngine()) {
58
			return false;
59
		}
60

  
61
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
62
		if (selection == null) {
63
			System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
64
			return null;
65
		}
66
		
67
		if (selection.getFirstElement() instanceof Partition) {
68
			return edit((Partition) selection.getFirstElement());
69
		} else {
70
			return null;
71
		}
72
	}
73
	
74
	/**
75
	 * 
76
	 * @param event
77
	 * @return
78
	 * @throws ExecutionException
79
	 */
80
	public static Object edit(Partition part) throws ExecutionException {
81
		
82
		return TXMEditor.openEditor(part, PartitionEditor.class.getName());
83
	}
84
}
0 85

  

Formats disponibles : Unified diff