Statistics
| Revision:

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

History | View | Annotate | Download (3.7 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.togaf.impl.TogafArchitectModule;
37
import org.modelio.togaf.profile.utils.Module;
38
import org.modelio.togaf.profile.utils.ResourceManager;
39

    
40
public class TogafSolutionConceptDiagram {
41
        protected StaticDiagram element;
42

    
43
        public TogafSolutionConceptDiagram(ModelElement owner, IStyleHandle style) {
44
                try {
45
                        this.element = TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getModel().createStaticDiagram(owner.getName() + " " + ResourceManager.getName("TogafSolutionConceptDiagram"), owner, TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getMetamodelExtensions().getStereotype("TogafArchitect","TogafSolutionConceptDiagram", TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getMetamodelService().getMetamodel().getMClass(StaticDiagram.class)));
46

    
47
                        try (IDiagramHandle diagramHandler = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(getElement())) {
48
                                diagramHandler.getDiagramNode().setStyle(style);
49
                                diagramHandler.save();
50
                                diagramHandler.close();
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("TogafSolutionConceptDiagram_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
                                        rep.close();
62
                                }
63
                        }
64

    
65
                } catch (Exception e) {
66
                        e.printStackTrace();
67
                }
68
        }
69

    
70
        public TogafSolutionConceptDiagram(StaticDiagram element) {
71
                this.element = element;
72
        }
73

    
74
        public StaticDiagram getElement() {
75
                return this.element;
76
        }
77

    
78
        public void setParent(ModelElement parent) {
79
                this.element.setOrigin(parent);
80
        }
81

    
82
}