Revision 237 branches/modelio3.7.x/src/main/java/org/modelio/togaf/profile/businessarchitecture/commande/explorer/diagram/wizard/TogafOrganizationDecompositionDiagramWizardContributor.java

View differences:

TogafOrganizationDecompositionDiagramWizardContributor.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.businessarchitecture.commande.explorer.diagram.wizard;
26 26

  
......
46 46

  
47 47
public class TogafOrganizationDecompositionDiagramWizardContributor extends TogafDiagramWizardContributor {
48 48

  
49
    @Override
50
    public boolean accept(MObject ielement) {
49
	@Override
50
	public boolean accept(MObject ielement) {
51 51

  
52
        ModelElement element = (ModelElement) ielement;
53
        if (element.isStereotyped("TogafArchitect", "BusinessArchitecture")) {
54
            return true;
55
        } else if (element.isStereotyped("TogafArchitect", "TogafActor") || element.isStereotyped("TogafArchitect", "TogafRole")) {
56
            return true;
57
        }
58
        return false;
59
    }
52
		ModelElement element = (ModelElement) ielement;
53
		if (element.isStereotyped("TogafArchitect", "BusinessArchitecture")) {
54
			return true;
55
		} else if (element.isStereotyped("TogafArchitect", "TogafActor") || element.isStereotyped("TogafArchitect", "TogafRole")) {
56
			return true;
57
		}
58
		return false;
59
	}
60 60

  
61
    @Override
62
    public AbstractDiagram actionPerformed(ModelElement diagramOwner, String diagramName, String diagramDescription) {
61
	@Override
62
	public AbstractDiagram actionPerformed(ModelElement diagramOwner, String diagramName, String diagramDescription) {
63 63

  
64
        IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
65
        IDiagramService diagramService = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
66
        try (ITransaction transaction = session.createTransaction("");) {
67
        	IStyleHandle style = diagramService.getStyle(getStyle());  
68
        	TogafOrganizationDecompositionDiagram proxy = new TogafOrganizationDecompositionDiagram(diagramOwner,style);
69
            proxy.getElement().setName(diagramName);
70
            proxy.getElement().putNoteContent("ModelerModule", "description", diagramDescription);
64
		IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
65
		IDiagramService diagramService = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
66
		try (ITransaction transaction = session.createTransaction("");) {
67
			IStyleHandle style = diagramService.getStyle(getStyle());
68
			TogafOrganizationDecompositionDiagram proxy = new TogafOrganizationDecompositionDiagram(diagramOwner,style);
69
			proxy.getElement().setName(diagramName);
70
			proxy.getElement().putNoteContent("ModelerModule", "description", diagramDescription);
71 71

  
72
            if (diagramOwner.isStereotyped("TogafArchitect", "OrganizationParticipant")) {
73
                IDiagramHandle rep = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(proxy.getElement());
72
			if (diagramOwner.isStereotyped("TogafArchitect", "OrganizationParticipant")) {
73
				try (IDiagramHandle rep = TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(proxy.getElement())) {
74
					rep.unmask(diagramOwner, 0, 0);
75
					rep.save();
76
					rep.close();
77
				}
78
			}
79
			TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(proxy.getElement());
80
			transaction.commit();
81
			return proxy.getElement();
82
		} catch (Exception e) {
83
			e.printStackTrace();
84
		}
74 85

  
75
                rep.unmask(diagramOwner, 0, 0);
76
                rep.save();
77
                rep.close();
78
            }
79
            TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(proxy.getElement());
80
            transaction.commit();
81
            return proxy.getElement();
82
        } catch (Exception e) {
83
            e.printStackTrace();
84
        }
86
		return null;
87
	}
85 88

  
86
        return null;
87
    }
89
	@Override
90
	public ElementDescriptor getCreatedElementType() {
91
		IModuleContext moduleContext = getModule().getModuleContext();
92
		MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
93
		MClass mClass = metamodel.getMClass(StaticDiagram.class);
94
		IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
95
		Stereotype stereotype = extensions.getStereotype(ITogafArchitectPeerModule.MODULE_NAME, "TogafOrganizationDecompositionDiagram", mClass);
96
		return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
97
	}
88 98

  
89
    @Override
90
    public ElementDescriptor getCreatedElementType() {
91
        IModuleContext moduleContext = getModule().getModuleContext();
92
        MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
93
        MClass mClass = metamodel.getMClass(StaticDiagram.class);
94
        IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
95
        Stereotype stereotype = extensions.getStereotype(ITogafArchitectPeerModule.MODULE_NAME, "TogafOrganizationDecompositionDiagram", mClass);
96
        return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
97
    }
98

  
99 99
}

Also available in: Unified diff