Revision d9b8df42
Added by Patrick Plitzner almost 4 years ago
eu.etaxonomy.taxeditor.bulkeditor/fragment.e4xmi | ||
---|---|---|
16 | 16 |
<elements xsi:type="commands:Command" xmi:id="_tLGKgJcOEeeM745tzuPNCQ" elementId="taxeditor-bulkeditor.dynamicdeleteobjectcommand" commandName="%command.name.3"/> |
17 | 17 |
<elements xsi:type="commands:Command" xmi:id="_Svo9oKK6EeeZb4PEjoRsuw" elementId="taxeditor-bulkeditor.command.setMarkerFlag" commandName="%command.name.6"/> |
18 | 18 |
<elements xsi:type="commands:Command" xmi:id="_hh5p4K9kEeejfdQ69MxTUA" elementId="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity" commandName="%command.commandname.1"/> |
19 |
<elements xsi:type="commands:Command" xmi:id="_FSL3YGQEEeiuIMJ7WBlkCA" elementId="eu.etaxonomy.taxeditor.bulkeditor.command.copy" commandName="Copy"/> |
|
19 | 20 |
</fragments> |
20 | 21 |
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_l_8NMCQUEeelPNxAg-e3TA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.workbench.menu.admin"> |
21 | 22 |
<elements xsi:type="menu:MenuSeparator" xmi:id="_zph3kDF2Eee-JvlKXQGppA" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.0"/> |
... | ... | |
72 | 73 |
<handlers xmi:id="_a-U4EJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeTargetHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeTargetHandlerE4" command="_GAm9cJcNEeeM745tzuPNCQ"/> |
73 | 74 |
<handlers xmi:id="_qPOPQJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.NewObjectHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.NewObjectHandlerE4" command="_jWkVYJcOEeeM745tzuPNCQ"/> |
74 | 75 |
<handlers xmi:id="_c9ppwKK6EeeZb4PEjoRsuw" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMarkerFlagHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMarkerFlagHandlerE4" command="_Svo9oKK6EeeZb4PEjoRsuw"/> |
76 |
<handlers xmi:id="_I8Q8cGQEEeiuIMJ7WBlkCA" elementId="eu.etaxonomy.taxeditor.bulkeditor.handler.0" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.CopyHandler" command="_FSL3YGQEEeiuIMJ7WBlkCA"/> |
|
75 | 77 |
<menus xsi:type="menu:PopupMenu" xmi:id="_B6IFsJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"> |
76 | 78 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_H83EMJcMEeeM745tzuPNCQ" coreExpressionId="isCdmStoreConnected"/> |
77 | 79 |
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_Y49vAJfHEeeUB5KN7hGpYQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicNewObjectMenuE4"/> |
... | ... | |
88 | 90 |
<children xsi:type="menu:MenuSeparator" xmi:id="_p-7bYJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.3"/> |
89 | 91 |
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_MughoKK6EeeZb4PEjoRsuw" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.command.DynamicMarkerTypeEditingMenuE4"/> |
90 | 92 |
<children xsi:type="menu:MenuSeparator" xmi:id="_x3rgUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.menuseparator.4"/> |
93 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_-LVJcGQDEeiuIMJ7WBlkCA" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.copy" label="Copy" command="_FSL3YGQEEeiuIMJ7WBlkCA"/> |
|
91 | 94 |
<children xsi:type="menu:HandledMenuItem" xmi:id="_yt2TUJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.handledmenuitem.delete" label="%command.label.4" command="_S8xR4JcNEeeM745tzuPNCQ"/> |
92 | 95 |
</menus> |
93 | 96 |
</elements> |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java | ||
---|---|---|
59 | 59 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction; |
60 | 60 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder; |
61 | 61 |
import org.eclipse.swt.SWT; |
62 |
import org.eclipse.swt.dnd.Clipboard; |
|
63 |
import org.eclipse.swt.dnd.TextTransfer; |
|
64 |
import org.eclipse.swt.dnd.Transfer; |
|
62 | 65 |
import org.eclipse.swt.layout.GridData; |
63 | 66 |
import org.eclipse.swt.layout.GridLayout; |
64 | 67 |
import org.eclipse.swt.widgets.Composite; |
68 |
import org.eclipse.swt.widgets.Display; |
|
65 | 69 |
import org.eclipse.swt.widgets.Menu; |
66 | 70 |
|
67 | 71 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
... | ... | |
273 | 277 |
menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$ |
274 | 278 |
// get the menu registered by EMenuService |
275 | 279 |
final Menu e4Menu = natTable.getMenu(); |
276 |
|
|
277 | 280 |
// remove the menu reference from NatTable instance |
278 | 281 |
natTable.setMenu(null); |
279 |
|
|
280 |
//add default configuration because autoconfigure is set to false in constructor |
|
281 |
natTable.addConfiguration(new DefaultNatTableStyleConfiguration()); |
|
282 | 282 |
natTable.addConfiguration( |
283 | 283 |
new AbstractUiBindingConfiguration() { |
284 | 284 |
|
... | ... | |
297 | 297 |
GridRegion.BODY, |
298 | 298 |
MouseEventMatcher.RIGHT_BUTTON), |
299 | 299 |
new PopupMenuAction(e4Menu)); |
300 |
// register the UI binding |
|
301 |
uiBindingRegistry.registerMouseDownBinding( |
|
302 |
new MouseEventMatcher( |
|
303 |
SWT.NONE, |
|
304 |
GridRegion.COLUMN_HEADER, |
|
305 |
MouseEventMatcher.RIGHT_BUTTON), |
|
306 |
new PopupMenuAction(e4Menu)); |
|
300 | 307 |
} |
301 | 308 |
}); |
302 | 309 |
|
310 |
//add default configuration because autoconfigure is set to false in constructor |
|
311 |
natTable.addConfiguration(new DefaultNatTableStyleConfiguration()); |
|
303 | 312 |
natTable.configure(); |
304 | 313 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable); |
305 | 314 |
|
... | ... | |
467 | 476 |
return input; |
468 | 477 |
} |
469 | 478 |
|
479 |
public void copyDataToClipboard() { |
|
480 |
String textData = ""; |
|
481 |
IStructuredSelection selection = getSelection(); |
|
482 |
Object[] objects = selection.toArray(); |
|
483 |
for (Object object : objects) { |
|
484 |
if(object instanceof CdmBase){ |
|
485 |
textData += getEditorInput().getText((CdmBase)object); |
|
486 |
} |
|
487 |
} |
|
488 |
final TextTransfer textTransfer = TextTransfer.getInstance(); |
|
489 |
final Clipboard clipboard = new Clipboard(Display.getDefault()); |
|
490 |
try { |
|
491 |
clipboard.setContents(new Object[] { textData.toString() }, |
|
492 |
new Transfer[] { textTransfer }); |
|
493 |
} finally { |
|
494 |
clipboard.dispose(); |
|
495 |
} |
|
496 |
} |
|
497 |
|
|
470 | 498 |
/** |
471 | 499 |
* {@inheritDoc} |
472 | 500 |
*/ |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/CopyHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
|
10 |
|
|
11 |
import javax.inject.Named; |
|
12 |
|
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
14 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
19 |
|
|
20 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
21 |
|
|
22 |
/** |
|
23 |
* |
|
24 |
* @author pplitzner |
|
25 |
* @date 12.09.2017 |
|
26 |
* |
|
27 |
*/ |
|
28 |
public class CopyHandler { |
|
29 |
|
|
30 |
@Execute |
|
31 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
|
32 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
33 |
editor.copyDataToClipboard(); |
|
34 |
} |
|
35 |
|
|
36 |
@CanExecute |
|
37 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
38 |
MHandledMenuItem menuItem) { |
|
39 |
boolean canExecute = false; |
|
40 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
41 |
IStructuredSelection selection = editor.getSelection(); |
|
42 |
canExecute = selection.size()==1; |
|
43 |
menuItem.setVisible(canExecute); |
|
44 |
return canExecute; |
|
45 |
} |
|
46 |
} |
Also available in: Unified diff
ref #7439 Add "Copy" to context menu