Revision 237 branches/modelio3.7.x/src/main/java/org/modelio/togaf/profile/applicationarchitecture/model/TogafBenefitsDiagram.java

View differences:

TogafBenefitsDiagram.java
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 
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 24
 **/
25 25
package org.modelio.togaf.profile.applicationarchitecture.model;
26 26

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

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

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

  

Also available in: Unified diff