Statistics
| Revision:

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

History | View | Annotate | Download (3.96 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.applicationarchitecture.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.ApplicationArchitecture;
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 TogafApplicationCommunicationDiagram extends TogafDiagram {
44

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

    
48
                IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
49
                IPeerModule peer = Module.getPeer();
50
                try (IDiagramHandle diagramHandler = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(getElement())) {
51
                        diagramHandler.getDiagramNode().setStyle(style);
52
                        diagramHandler.save();
53
                        diagramHandler.close();
54
                }
55

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

    
67
        public TogafApplicationCommunicationDiagram(StaticDiagram element) {
68
                super(element);
69
        }
70

    
71
        public ApplicationArchitecture getApplicationArchitecture() {
72
                return new ApplicationArchitecture((Package) this.element.getOrigin());
73
        }
74

    
75
        public void addApplicationArchitecture(ApplicationArchitecture model) {
76
                this.element.setOrigin(model.getElement());
77
        }
78

    
79
}