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
|
/*****************************************************************************
* Copyright (c) 2011 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.factory;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.papyrus.eclipse.project.editors.interfaces.IPluginEditor;
import org.eclipse.papyrus.toolsmiths.messages.Messages;
import org.eclipse.papyrus.toolsmiths.model.customizationplugin.CustomizableElement;
import org.eclipse.papyrus.toolsmiths.model.customizationplugin.CustomizationPluginPackage;
import org.eclipse.papyrus.toolsmiths.model.customizationplugin.FileBasedCustomizableElement;
import org.eclipse.papyrus.toolsmiths.model.customizationplugin.UMLModel;
import org.w3c.dom.Element;
public class UMLModelExtensionFactory extends FileBasedExtensionFactory {
public UMLModelExtensionFactory() {
super(Messages.UMLModelExtensionFactory_UMLModel, "org.eclipse.papyrus.uml.extensionpoints.UMLLibrary", "path", "library", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
public void addElement(CustomizableElement element, IPluginEditor editor) {
super.addElement(element, editor);
editor.addDependency("org.eclipse.papyrus.uml.extensionpoints"); //$NON-NLS-1$
}
@Override
protected Element createExtension(FileBasedCustomizableElement element, IPluginEditor editor) {
Element extension = super.createExtension(element, editor);
UMLModel model = (UMLModel) element;
if (model.getDescription() != null) {
extension.setAttribute("description", model.getDescription()); //$NON-NLS-1$
}
if (model.getIconpath() != null) {
extension.setAttribute("iconpath", model.getIconpath()); //$NON-NLS-1$
}
if (model.getName() != null) {
extension.setAttribute("name", model.getName()); //$NON-NLS-1$
}
if (model.getProvider() != null) {
extension.setAttribute("provider", model.getProvider()); //$NON-NLS-1$
}
return extension;
}
@Override
protected String getTargetPath(FileBasedCustomizableElement element) {
return "/umlLibrary/" + getFileName(element); //$NON-NLS-1$
}
public EClass getCustomizableElementClass() {
return CustomizationPluginPackage.eINSTANCE.getUMLModel();
}
}
|