blob: 2ac86084fbb2621def9252725e703615161ff1d3 (
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
|
/*****************************************************************************
* Copyright (c) 2015 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:
* Patrick Tessier(CEA LIST) Patrick.Tessier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.effbd;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
import org.eclipse.papyrus.effbd.command.UpdateOpaqueAction_body;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.uml2.uml.OpaqueAction;
public class OpaqueActionBodyParser implements IParser {
@Override
public String getEditString(IAdaptable element, int flags) {
EObject eObject = EMFHelper.getEObject(element);
if (eObject instanceof OpaqueAction) {
return ((OpaqueAction) eObject).getBodies().get(0);
}
return "";
}
@Override
public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
if (editString != null) {
return ParserEditStatus.EDITABLE_STATUS;
}
return ParserEditStatus.UNEDITABLE_STATUS;
}
@Override
public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
EObject eObject = EMFHelper.getEObject(element);
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(eObject);
UpdateOpaqueAction_body setCommand = new UpdateOpaqueAction_body(editingDomain, (OpaqueAction) eObject, newString);
return new EMFtoGMFCommandWrapper(setCommand);
}
@Override
public String getPrintString(IAdaptable element, int flags) {
EObject eObject = EMFHelper.getEObject(element);
if (eObject instanceof OpaqueAction) {
if (((OpaqueAction) eObject).getBodies().size() > 0) {
return ((OpaqueAction) eObject).getBodies().get(0);
}
}
return "";
}
@Override
public boolean isAffectingEvent(Object event, int flags) {
// TODO Auto-generated method stub
return false;
}
@Override
public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
// TODO Auto-generated method stub
return null;
}
}
|