Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6c2c409a94202ac9b6b6022a0540a195f79fbf5a (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
/*****************************************************************************
 * 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:
 *  Fadwa TMAR (CEA LIST) fadwa.tmar@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.soaml.diagram.common.commands;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.uml.diagram.common.commands.ModelCreationCommandBase;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.UMLFactory;

public class CreateSoamlModelCommand extends ModelCreationCommandBase {

	public static final String COMMAND_ID = "soaML";


	
	public static final String PROFILES_PATHMAP = "pathmap://SoaML_PROFILES/"; //$NON-NLS-1$


	public static final String SOAML_PROFILE_URI = PROFILES_PATHMAP + "SoaMLProfile.profile.uml"; //$NON-NLS-1$

	//public static final String FCM_PROFILE_URI = "pathmap://FCM_PROFILES/FCM.profile.uml";

	//public static final String SOAML_PROFILE_URI = PROFILES_PATHMAP + "SoaML.profile.uml"; //$NON-NLS-1$


	/**
	 * @see org.eclipse.papyrus.core.extension.commands.ModelCreationCommandBase#createRootElement()
	 * 
	 * @return
	 */

	@Override
	protected EObject createRootElement() {
		return UMLFactory.eINSTANCE.createModel();
	}

	/**
	 * @see org.eclipse.papyrus.core.extension.commands.ModelCreationCommandBase#initializeModel(org.eclipse.emf.ecore.EObject)
	 * 
	 * @param owner
	 */

	@Override
	protected void initializeModel(EObject owner) {
		super.initializeModel(owner);
		((org.eclipse.uml2.uml.Package)owner).setName(getModelName());

		// Retrieve soaml profile and apply with Sub-profile
		org.eclipse.uml2.uml.Package soaml = PackageUtil.loadPackage(URI.createURI(SOAML_PROFILE_URI), owner.eResource().getResourceSet());
		//org.eclipse.uml2.uml.Package fcm = PackageUtil.loadPackage(URI.createURI(FCM_PROFILE_URI), owner.eResource().getResourceSet());
		if((soaml != null) && (soaml instanceof Profile)) {
			PackageUtil.applyProfile(((org.eclipse.uml2.uml.Package)owner), (org.eclipse.uml2.uml.Profile)soaml, true);
			//PackageUtil.applyProfile(((org.eclipse.uml2.uml.Package)owner), (org.eclipse.uml2.uml.Profile) fcm, true);
		}
	}

	/**
	 * Gets the model name.
	 * 
	 * @return the model name
	 */
	protected String getModelName() {
		return "SoaMLModel";
	}


}

Back to the top