Statistics
| Revision:

root / branches / modelio3.7.x / src / main / java / org / modelio / togaf / profile / technologyarchitecture / model / TogafPlatformDecompositionDiagram.java @ 237

History | View | Annotate | Download (3.89 KB)

1
/**
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *        http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 *        Unless required by applicable law or agreed to in writing,
13
 *        software distributed under the License is distributed on an
14
 *        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 *        KIND, either express or implied.  See the License for the
16
 *        specific language governing permissions and limitations
17
 *        under the License.
18
 *
19
 *
20
 * @package    org.modelio.togaf.
21
 * @author     Modelio
22
 * @license    http://www.apache.org/licenses/LICENSE-2.0
23
 * @version  1.0.00
24
 **/
25
package org.modelio.togaf.profile.technologyarchitecture.model;
26

    
27
import org.eclipse.draw2d.geometry.Rectangle;
28
import org.modelio.api.modelio.diagram.IDiagramHandle;
29
import org.modelio.api.modelio.diagram.IDiagramNode;
30
import org.modelio.api.modelio.diagram.style.IStyleHandle;
31
import org.modelio.api.modelio.model.IModelingSession;
32
import org.modelio.api.module.IPeerModule;
33
import org.modelio.metamodel.diagrams.StaticDiagram;
34
import org.modelio.metamodel.uml.infrastructure.ModelElement;
35
import org.modelio.metamodel.uml.infrastructure.Note;
36
import org.modelio.metamodel.uml.statik.Package;
37
import org.modelio.togaf.impl.TogafArchitectModule;
38
import org.modelio.togaf.profile.structure.model.TechnologyArchitecture;
39
import org.modelio.togaf.profile.structure.model.TogafDiagram;
40
import org.modelio.togaf.profile.utils.Module;
41
import org.modelio.togaf.profile.utils.ResourceManager;
42

    
43
public class TogafPlatformDecompositionDiagram extends TogafDiagram {
44

    
45
        public TogafPlatformDecompositionDiagram(ModelElement owner, IStyleHandle style) throws Exception {
46
                super(TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getModel().createStaticDiagram(owner.getName() + " " + ResourceManager.getName("TogafPlatformDecompositionDiagram"), owner, TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getMetamodelExtensions().getStereotype("TogafArchitect","TogafPlatformDecompositionDiagram", TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getMetamodelService().getMetamodel().getMClass(StaticDiagram.class))));
47

    
48
                try (IDiagramHandle diagramHandler = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(getElement())) {
49
                        diagramHandler.getDiagramNode().setStyle(style);
50
                        diagramHandler.save();
51
                }
52

    
53
                IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
54
                IPeerModule peer = Module.getPeer();
55
                if (peer.getConfiguration().getParameterValue("DisplayNote").equals("TRUE")) {
56
                        Note note = session.getModel().createNote(TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getMetamodelExtensions().getNoteType("TogafArchitect","TOGAFModelingGuide", getElement().getMClass()), getElement(), org.modelio.togaf.i18n.Messages.getString("TogafPlatformDecompositionDiagram_NOTE"));
57
                        try (IDiagramHandle rep = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(getElement())) {
58
                                IDiagramNode node = (IDiagramNode) rep.unmask(note, 0, 0).get(0);
59
                                node.setBounds(new Rectangle(0, 0, 500, 300));
60
                                rep.save();
61
                        }
62
                }
63
        }
64

    
65
        public TogafPlatformDecompositionDiagram(StaticDiagram element) {
66
                super(element);
67
        }
68

    
69
        public TechnologyArchitecture getTechnologyArchitecture() {
70
                return new TechnologyArchitecture((Package) this.element.getOrigin());
71
        }
72

    
73
        public void addTechnologyArchitecture(TechnologyArchitecture model) {
74
                this.element.setOrigin(model.getElement());
75
        }
76

    
77
}