Skip to content

Commit 6d098e5

Browse files
Tosca Designer Factory template added
1 parent 4d3d751 commit 6d098e5

20 files changed

+11282
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Java Class : IPropertyContent.java
3+
*
4+
* Description :
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one
7+
* or more contributor license agreements. See the NOTICE file
8+
* distributed with this work for additional information
9+
* regarding copyright ownership. The ASF licenses this file
10+
* to you under the Apache License, Version 2.0 (the
11+
* "License"); you may not use this file except in compliance
12+
* with the License. You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing,
17+
* software distributed under the License is distributed on an
18+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19+
* KIND, either express or implied. See the License for the
20+
* specific language governing permissions and limitations
21+
* under the License.
22+
*
23+
* @category Util
24+
* @package com.modeliosoft.modelio.sysml.utils
25+
* @author Modelio
26+
* @license http://www.apache.org/licenses/LICENSE-2.0
27+
* @version 2.0.08
28+
**/
29+
package fr.softeam.toscadesigner.handlers.propertypages;
30+
31+
import com.modeliosoft.modelio.javadesigner.annotations.objid;
32+
import org.modelio.api.module.propertiesPage.IModulePropertyTable;
33+
34+
/**
35+
* This interface defines the contract of all property pages
36+
*/
37+
public interface IPropertyContent {
38+
/**
39+
* This method handles the changes of the given property, identified by its row index, of a selected element
40+
* to a new value.
41+
*
42+
* @param row : the row of the changed property
43+
* @param value : the new value of the property
44+
*/
45+
void changeProperty(int row, String value);
46+
47+
/**
48+
* This method handles the construction of the property table of a selected element
49+
*
50+
* @param table : the property table to fulfill
51+
*/
52+
void update(IModulePropertyTable table);
53+
54+
}
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
/*
2+
* WARNING: GENERATED FILE - DO NOT EDIT
3+
* Module: CamelDesigner v0.1.06
4+
5+
* This file was generated on 11/30/20 8:06 PM by Modelio Studio.
6+
*/
7+
package fr.softeam.toscadesigner.handlers.propertypages;
8+
9+
10+
import com.modeliosoft.modelio.javadesigner.annotations.objid;
11+
12+
import fr.softeam.toscadesigner.api.IToscaDesignerPeerModule;
13+
14+
import org.modelio.metamodel.diagrams.ClassDiagram;
15+
import org.modelio.metamodel.mda.ModuleComponent;
16+
import org.modelio.metamodel.uml.infrastructure.Dependency;
17+
import org.modelio.metamodel.uml.infrastructure.Element;
18+
import org.modelio.metamodel.uml.infrastructure.ModelElement;
19+
import org.modelio.metamodel.uml.infrastructure.Stereotype;
20+
import org.modelio.metamodel.uml.statik.Artifact;
21+
import org.modelio.metamodel.uml.statik.Attribute;
22+
import org.modelio.metamodel.uml.statik.AttributeLink;
23+
import org.modelio.metamodel.uml.statik.Class;
24+
import org.modelio.metamodel.uml.statik.Component;
25+
import org.modelio.metamodel.uml.statik.Connector;
26+
import org.modelio.metamodel.uml.statik.DataType;
27+
import org.modelio.metamodel.uml.statik.Enumeration;
28+
import org.modelio.metamodel.uml.statik.GeneralClass;
29+
import org.modelio.metamodel.uml.statik.Instance;
30+
import org.modelio.metamodel.uml.statik.Package;
31+
import org.modelio.metamodel.uml.statik.Port;
32+
import org.modelio.metamodel.visitors.IDefaultInfrastructureVisitor;
33+
import org.modelio.metamodel.visitors.IDefaultModelVisitor;
34+
import org.modelio.metamodel.visitors.IInfrastructureVisitor;
35+
36+
37+
public class ToscaDesignerPropertyPageFactory {
38+
private static final PropertyPageVisitor propertyVisitor = new PropertyPageVisitor();
39+
40+
/**
41+
* Instantiates the right proxy class the given element.
42+
* <br/>The model element must be stereotyped by a 'CamelDesigner' module stereotype.
43+
* <br/>In the other case the method will return <i>null</i>.
44+
*
45+
* @param e A model element
46+
* @return the right proxy or <i>null</i>.
47+
*/
48+
@objid ("421d5784-c31b-41f2-8e84-fb05df25016b")
49+
public static final Object instantiatePropertyPage(final ModelElement e) {
50+
for (Stereotype s : e.getExtension()) {
51+
ModuleComponent module = s.getModule();
52+
if (module != null && module.getName().equals(IToscaDesignerPeerModule.MODULE_NAME)) {
53+
return instantiatePropertyPage(e, s.getName());
54+
}
55+
}
56+
return null;
57+
}
58+
59+
/**
60+
* Instantiates the right proxy class the given element with a stereotype name.
61+
* The stereotype must be one of the 'CamelDesigner' module stereotypes.
62+
* In the other case the method will return <i>null</i>.
63+
*
64+
* @param e A model element.
65+
* @param stName A stereotype name.
66+
* @return the right proxy or <i>null</i>.
67+
*/
68+
@objid ("33aeb9ea-d643-4b55-8c5b-11c7df82eec4")
69+
public static final Object instantiatePropertyPage(final Element e, final String stName) {
70+
propertyVisitor.setStereotype(stName);
71+
return e.accept(propertyVisitor);
72+
}
73+
74+
@objid ("18563f46-96b0-4137-bf2c-f82a64e467d9")
75+
private static class PropertyPageVisitor implements IDefaultModelVisitor, IDefaultInfrastructureVisitor {
76+
@objid ("8bbd6a2f-ed17-4779-a468-d61617ab0386")
77+
private String stName;
78+
79+
@objid ("978eac80-3ce0-45b6-ae6f-e6916b1cd570")
80+
@Override
81+
public final Object visitGeneralClass(GeneralClass obj) {
82+
switch (this.stName) {
83+
default:
84+
break;
85+
}
86+
return IDefaultModelVisitor.super.visitGeneralClass(obj);
87+
}
88+
89+
@Override
90+
public final Object visitDependency(Dependency obj) {
91+
switch (this.stName) {
92+
default:
93+
break;
94+
}
95+
return IDefaultInfrastructureVisitor.super.visitDependency(obj);
96+
}
97+
98+
@Override
99+
public final Object visitComponent(Component obj) {
100+
switch (this.stName) {
101+
default:
102+
break;
103+
}
104+
return IDefaultModelVisitor.super.visitComponent(obj);
105+
}
106+
107+
@Override
108+
public final Object visitInstance(Instance obj) {
109+
switch (this.stName) {
110+
default:
111+
break;
112+
}
113+
return IDefaultModelVisitor.super.visitInstance(obj);
114+
}
115+
116+
@Override
117+
public final Object visitClass(Class obj) {
118+
switch (this.stName) {
119+
default:
120+
break;
121+
}
122+
return IDefaultModelVisitor.super.visitClass(obj);
123+
}
124+
125+
@Override
126+
public final Object visitEnumeration(Enumeration obj) {
127+
switch (this.stName) {
128+
default:
129+
break;
130+
}
131+
return IDefaultModelVisitor.super.visitEnumeration(obj);
132+
}
133+
134+
@Override
135+
public final Object visitModelElement(ModelElement obj) {
136+
switch (this.stName) {
137+
default:
138+
break;
139+
}
140+
return IDefaultInfrastructureVisitor.super.visitModelElement(obj);
141+
}
142+
143+
@Override
144+
public final Object visitArtifact(Artifact obj) {
145+
switch (this.stName) {
146+
default:
147+
break;
148+
}
149+
return IDefaultModelVisitor.super.visitArtifact(obj);
150+
}
151+
152+
@Override
153+
public final Object visitAttribute(Attribute obj) {
154+
switch (this.stName) {
155+
default:
156+
break;
157+
}
158+
return IDefaultModelVisitor.super.visitAttribute(obj);
159+
}
160+
161+
@Override
162+
public final Object visitAttributeLink(AttributeLink obj) {
163+
switch (this.stName) {
164+
default:
165+
break;
166+
}
167+
return IDefaultModelVisitor.super.visitAttributeLink(obj);
168+
}
169+
170+
@Override
171+
public final Object visitClassDiagram(ClassDiagram obj) {
172+
switch (this.stName) {
173+
default:
174+
break;
175+
}
176+
return IDefaultModelVisitor.super.visitClassDiagram(obj);
177+
}
178+
179+
@Override
180+
public final Object visitPackage(Package obj) {
181+
switch (this.stName) {
182+
default:
183+
break;
184+
}
185+
return IDefaultModelVisitor.super.visitPackage(obj);
186+
}
187+
188+
@Override
189+
public final Object visitConnector(Connector obj) {
190+
switch (this.stName) {
191+
default:
192+
break;
193+
}
194+
return IDefaultModelVisitor.super.visitConnector(obj);
195+
}
196+
197+
@Override
198+
public final Object visitDataType(DataType obj) {
199+
switch (this.stName) {
200+
default:
201+
break;
202+
}
203+
return IDefaultModelVisitor.super.visitDataType(obj);
204+
}
205+
206+
@Override
207+
public final Object visitPort(Port obj) {
208+
switch (this.stName) {
209+
default:
210+
break;
211+
}
212+
return IDefaultModelVisitor.super.visitPort(obj);
213+
}
214+
215+
/**
216+
* Get the visitor to delegate to when a {@link IInfrastructureVisitor} is needed.
217+
* <p>If null is returned the caller will return null.
218+
*
219+
* @return the {@link IInfrastructureVisitor} visitor or <i>null</i>.
220+
*/
221+
@objid ("65ba04d7-dcfb-43d5-8619-e88870f03f28")
222+
@Override
223+
public IInfrastructureVisitor getInfrastructureVisitor() {
224+
return this;
225+
}
226+
227+
@objid ("1dcbce9d-01c0-42b6-89e6-797da0dadd2c")
228+
public final void setStereotype(final String stName) {
229+
this.stName = stName;
230+
}
231+
232+
}
233+
234+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package fr.softeam.toscadesigner.handlers.propertypages;
2+
3+
import java.util.List;
4+
import com.modeliosoft.modelio.javadesigner.annotations.objid;
5+
import org.modelio.api.module.IModule;
6+
import org.modelio.api.module.propertiesPage.AbstractModulePropertyPage;
7+
import org.modelio.api.module.propertiesPage.IModulePropertyTable;
8+
import org.modelio.metamodel.uml.infrastructure.ModelElement;
9+
import org.modelio.vcore.smkernel.mapi.MObject;
10+
11+
public class ToscaPropertyPageHandler extends AbstractModulePropertyPage {
12+
public ToscaPropertyPageHandler(final IModule module, final String name, final String label, final String bitmap) {
13+
super(module, name, label, bitmap);
14+
}
15+
16+
@Override
17+
public void update(final List<MObject> selectedElements, final IModulePropertyTable table) {
18+
if ((selectedElements != null) && (selectedElements.size() > 0)
19+
&& (selectedElements.get(0) != null)
20+
&& (selectedElements.get(0) instanceof ModelElement)){
21+
22+
ModelElement selectedElement = ((ModelElement) selectedElements.get(0));
23+
24+
IPropertyContent propertyPage = getPropertyPage(selectedElement);
25+
26+
if (propertyPage != null) {
27+
propertyPage.update(table);
28+
}
29+
}
30+
}
31+
32+
@Override
33+
public void changeProperty(final List<MObject> selectedElements, final int row, final String value) {
34+
if ((selectedElements != null) && (selectedElements.size() > 0) && (selectedElements.get(0) instanceof ModelElement)){
35+
ModelElement selectedElement = ((ModelElement) selectedElements.get(0));
36+
37+
IPropertyContent propertyPage = getPropertyPage(selectedElement);
38+
39+
if (propertyPage != null) {
40+
propertyPage.changeProperty(row, value);
41+
}
42+
}
43+
}
44+
45+
@objid ("c48bcc8b-54c2-4cec-ae04-cdde28640a1e")
46+
private IPropertyContent getPropertyPage(ModelElement elt) {
47+
Object result = ToscaDesignerPropertyPageFactory.instantiatePropertyPage(elt);
48+
if (result instanceof IPropertyContent) {
49+
return (IPropertyContent) result;
50+
}
51+
return null;
52+
}
53+
54+
}
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)