blob: 57937edc797f43acbf240db73eef17338ff4f547 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*****************************************************************************
* Copyright (c) 2013 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.papyrus.infra.nattable.manager.PasteInTableManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.utils.PasteModeEnumeration;
/**
* Paste Handler
*
* @author VL222926
*
*/
public class PasteInTableHandler extends AbstractTableHandler {
/**
* the paste manager
*/
private PasteInTableManager pasteManager;
/**
* this field is used to determine if we want open a dialog to prevent the user that the command creation and the command execution can take a
* long time
*/
private boolean useProgressMonitorDialog = true;
/**
* the paste mode
*/
private PasteModeEnumeration pasteMode;
/**
* the current table manager
*/
private INattableModelManager manager;
/**
*
* Constructor.
*
*/
public PasteInTableHandler() {
this.pasteManager = new PasteInTableManager();
}
/**
*
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
* @param event
* @return
* @throws ExecutionException
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
this.pasteManager.paste(getCurrentNattableModelManager(), pasteMode, useProgressMonitorDialog);
return null;
}
/**
* @Override
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
*
* @param evaluationContext
*/
public void setEnabled(Object evaluationContext) {
pasteMode = null;
this.manager = getCurrentNattableModelManager();
boolean isEnabled = false;
if(manager != null) {
pasteMode = this.pasteManager.getPasteMode(evaluationContext, manager);
switch(pasteMode) {
case CANT_PASTE:
isEnabled = false;
break;
default:
isEnabled = true;
}
}
setBaseEnabled(isEnabled);
}
}
|