Revision 506

View differences:

branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/SysMLDiagramWizardContributor.java
33 33

  
34 34
	private IModule module;
35 35

  
36
	@Override
36 37
	public String getLabel() {
37
		return label;
38
		return this.label;
38 39
	}
39 40

  
41
	@Override
40 42
	public void setLabel(String label) {
41 43
		this.label = label;
42 44
	}
43 45

  
46
	@Override
44 47
	public String getInformation() {
45
		return information;
48
		return this.information;
46 49
	}
47 50

  
51
	@Override
48 52
	public void setInformation(String information) {
49 53
		this.information = information;
50 54
	}
......
79 83
	}
80 84

  
81 85

  
86
	@Override
82 87
	public String getHelpUrl() {
83
		return helpUrl;
88
		return this.helpUrl;
84 89
	}
85 90

  
91
	@Override
86 92
	public void setHelpUrl(String helpUrl) {
87 93
		this.helpUrl = helpUrl;
88 94
	}
89 95

  
96
	@Override
90 97
	public String getDetails() {
91
		return details;
98
		return this.details;
92 99
	}
93 100

  
101
	@Override
94 102
	public void setDetails(String details) {
95 103
		this.details = details;
96 104
	}
97 105

  
106
	@Override
98 107
	public Image getIcon() {
99
		return icon;
108
		return this.icon;
100 109
	}
101 110

  
111
	@Override
102 112
	public void setIcon(Image icon) {
103 113
		this.icon = icon;
104 114
	}
105 115

  
106
	 public ImageDescriptor getPreviewImage() {
116
	 @Override
117
	public ImageDescriptor getPreviewImage() {
107 118
		 return null;
108 119
	 };
109 120

  
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/SysMLActivityDiagramWizard.java
30 30

  
31 31
import org.eclipse.swt.graphics.Image;
32 32
import org.eclipse.swt.widgets.Display;
33
import org.modelio.api.modelio.model.IMetamodelExtensions;
33 34
import org.modelio.api.modelio.model.IModelingSession;
34 35
import org.modelio.api.modelio.model.ITransaction;
36
import org.modelio.api.module.context.IModuleContext;
35 37
import org.modelio.api.module.contributor.AbstractWizardContributor;
38
import org.modelio.api.module.contributor.ElementDescriptor;
36 39
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
37 40
import org.modelio.metamodel.diagrams.AbstractDiagram;
41
import org.modelio.metamodel.diagrams.ActivityDiagram;
38 42
import org.modelio.metamodel.uml.behavior.activityModel.Activity;
39 43
import org.modelio.metamodel.uml.behavior.commonBehaviors.Signal;
40 44
import org.modelio.metamodel.uml.behavior.usecaseModel.Actor;
41 45
import org.modelio.metamodel.uml.behavior.usecaseModel.UseCase;
42 46
import org.modelio.metamodel.uml.infrastructure.ModelElement;
43 47
import org.modelio.metamodel.uml.infrastructure.Profile;
48
import org.modelio.metamodel.uml.infrastructure.Stereotype;
44 49
import org.modelio.metamodel.uml.statik.Class;
45 50
import org.modelio.metamodel.uml.statik.Collaboration;
46 51
import org.modelio.metamodel.uml.statik.Component;
......
48 53
import org.modelio.metamodel.uml.statik.Node;
49 54
import org.modelio.metamodel.uml.statik.Operation;
50 55
import org.modelio.metamodel.uml.statik.Package;
56
import org.modelio.vcore.smkernel.mapi.MClass;
57
import org.modelio.vcore.smkernel.mapi.MMetamodel;
51 58
import org.modelio.vcore.smkernel.mapi.MObject;
52 59

  
60
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
61
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
53 62
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
54 63
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
55 64
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
122 131
                        || (selectedElt instanceof Activity)));
123 132
    }
124 133

  
134
    @Override
135
    public ElementDescriptor getCreatedElementType() {
136
        IModuleContext moduleContext = getModule().getModuleContext();
137
        MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
138
        MClass mClass = metamodel.getMClass(ActivityDiagram.class);
139
        IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
140
        Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.SYSMLACTIVITYDIAGRAM, mClass);
141
        return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
142
    }
125 143
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/InternalBlockDiagramWizard.java
39 39
import org.modelio.api.modelio.diagram.IDiagramService;
40 40
import org.modelio.api.modelio.diagram.dg.IDiagramDG;
41 41
import org.modelio.api.modelio.diagram.style.IStyleHandle;
42
import org.modelio.api.modelio.model.IMetamodelExtensions;
42 43
import org.modelio.api.modelio.model.IModelingSession;
43 44
import org.modelio.api.modelio.model.ITransaction;
45
import org.modelio.api.module.context.IModuleContext;
44 46
import org.modelio.api.module.contributor.AbstractWizardContributor;
47
import org.modelio.api.module.contributor.ElementDescriptor;
45 48
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
46 49
import org.modelio.metamodel.diagrams.AbstractDiagram;
50
import org.modelio.metamodel.diagrams.StaticDiagram;
47 51
import org.modelio.metamodel.uml.infrastructure.ModelElement;
52
import org.modelio.metamodel.uml.infrastructure.Stereotype;
53
import org.modelio.vcore.smkernel.mapi.MClass;
54
import org.modelio.vcore.smkernel.mapi.MMetamodel;
48 55
import org.modelio.vcore.smkernel.mapi.MObject;
49 56

  
57
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
58
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
50 59
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
51 60
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
52 61
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
61 70
 */
62 71
public class InternalBlockDiagramWizard extends AbstractWizardContributor implements IDiagramWizardContributor {
63 72

  
64
    @Override
65
    public AbstractDiagram actionPerformed(ModelElement element, String diagramName, String description) {
66
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
67
        AbstractDiagram diagram = null;
68
        try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
73
	@Override
74
	public AbstractDiagram actionPerformed(ModelElement element, String diagramName, String description) {
75
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
76
		AbstractDiagram diagram = null;
77
		try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
69 78

  
70
            diagram = SysMLFactory.createAndAddInternalBlockDiagram(element, diagramName, description);
79
			diagram = SysMLFactory.createAndAddInternalBlockDiagram(element, diagramName, description);
71 80

  
72
            if (diagram != null) {
73
                // Unmask the block in the diagram
81
			if (diagram != null) {
82
				// Unmask the block in the diagram
74 83

  
75
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
76
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
77
                IDiagramDG dg = handler.getDiagramNode();
78
                for (IStyleHandle style : ds.listStyles()) {
79
                    if (style.getName().equals("sysmlinternal")) {
80
                        dg.setStyle(style);
81
                        break;
82
                    }
83
                }
84
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
85
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
86
					IDiagramDG dg = handler.getDiagramNode();
87
					for (IStyleHandle style : ds.listStyles()) {
88
						if (style.getName().equals("sysmlinternal")) {
89
							dg.setStyle(style);
90
							break;
91
						}
92
					}
84 93

  
85
                List<IDiagramGraphic> dgs = handler.unmask(element, 0, 0);
86
                for (IDiagramGraphic dg2 : dgs) {
87
                    if (dg2 instanceof IDiagramNode)
88
                        ((IDiagramNode) dg2).setBounds(new Rectangle(100, 100, 300, 250));
89
                }
94
					List<IDiagramGraphic> dgs = handler.unmask(element, 0, 0);
95
					for (IDiagramGraphic dg2 : dgs) {
96
						if (dg2 instanceof IDiagramNode) {
97
							((IDiagramNode) dg2).setBounds(new Rectangle(100, 100, 300, 250));
98
						}
99
					}
90 100

  
91
                handler.save();
92
                handler.close();
101
					handler.save();
102
					handler.close();
103
				}
93 104

  
94
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
95
            }
105
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
106
			}
96 107

  
97
            transaction.commit();
98
        }
108
			transaction.commit();
109
		}
99 110

  
100
        return diagram;
101
    }
111
		return diagram;
112
	}
102 113

  
103
    @Override
104
    public String getLabel() {
105
        return I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Label");
106
    }
114
	@Override
115
	public String getLabel() {
116
		return I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Label");
117
	}
107 118

  
108
    @Override
109
    public String getDetails() {
110
        return I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Details");
111
    }
119
	@Override
120
	public String getDetails() {
121
		return I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Details");
122
	}
112 123

  
113
    @Override
114
    public String getHelpUrl() {
115
        return null;
116
    }
124
	@Override
125
	public String getHelpUrl() {
126
		return null;
127
	}
117 128

  
118
    @Override
119
    public Image getIcon() {
120
        return new Image(Display.getDefault(), SysMLResourcesManager.getInstance().getImage("internalblockdiagram.png"));
121
    }
129
	@Override
130
	public Image getIcon() {
131
		return new Image(Display.getDefault(), SysMLResourcesManager.getInstance().getImage("internalblockdiagram.png"));
132
	}
122 133

  
123
    @Override
124
    public String getInformation() {
125
        return I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Information");
126
    }
134
	@Override
135
	public String getInformation() {
136
		return I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Information");
137
	}
127 138

  
128
    @Override
129
    public boolean accept(MObject element) {
139
	@Override
140
	public boolean accept(MObject element) {
130 141

  
131
        return ((element != null) && (Utils.isABlock(element)));
132
    }
142
		return ((element != null) && (Utils.isABlock(element)));
143
	}
133 144

  
145
	@Override
146
	public ElementDescriptor getCreatedElementType() {
147
		IModuleContext moduleContext = getModule().getModuleContext();
148
		MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
149
		MClass mClass = metamodel.getMClass(StaticDiagram.class);
150
		IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
151
		Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.INTERNALBLOCKDIAGRAM, mClass);
152
		return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
153
	}
134 154
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/ParametricDiagramWizard.java
39 39
import org.modelio.api.modelio.diagram.IDiagramService;
40 40
import org.modelio.api.modelio.diagram.dg.IDiagramDG;
41 41
import org.modelio.api.modelio.diagram.style.IStyleHandle;
42
import org.modelio.api.modelio.model.IMetamodelExtensions;
42 43
import org.modelio.api.modelio.model.IModelingSession;
43 44
import org.modelio.api.modelio.model.ITransaction;
45
import org.modelio.api.module.context.IModuleContext;
44 46
import org.modelio.api.module.contributor.AbstractWizardContributor;
47
import org.modelio.api.module.contributor.ElementDescriptor;
45 48
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
46 49
import org.modelio.metamodel.diagrams.AbstractDiagram;
50
import org.modelio.metamodel.diagrams.StaticDiagram;
47 51
import org.modelio.metamodel.uml.infrastructure.ModelElement;
52
import org.modelio.metamodel.uml.infrastructure.Stereotype;
53
import org.modelio.vcore.smkernel.mapi.MClass;
54
import org.modelio.vcore.smkernel.mapi.MMetamodel;
48 55
import org.modelio.vcore.smkernel.mapi.MObject;
49 56

  
57
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
58
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
50 59
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
51 60
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
52 61
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
61 70
public class ParametricDiagramWizard extends AbstractWizardContributor implements IDiagramWizardContributor {
62 71

  
63 72

  
64
    @Override
65
    public AbstractDiagram actionPerformed(ModelElement element, String diagramName,
66
            String description) {
67
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
73
	@Override
74
	public AbstractDiagram actionPerformed(ModelElement element, String diagramName,
75
			String description) {
76
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
68 77

  
69
        AbstractDiagram diagram = null;
70
        try( ITransaction transaction = session.createTransaction (I18nMessageService.getString ("Info.Session.Create","Activity"))){
78
		AbstractDiagram diagram = null;
79
		try( ITransaction transaction = session.createTransaction (I18nMessageService.getString ("Info.Session.Create","Activity"))){
71 80

  
72
            diagram = SysMLFactory.createAndAddParametricDiagram (element, diagramName, description);
81
			diagram = SysMLFactory.createAndAddParametricDiagram (element, diagramName, description);
73 82

  
74
            if (diagram != null) {
75
                // Unmask the block in the diagram
76
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
77
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
78
                IDiagramDG dg = handler.getDiagramNode();
79
                for (IStyleHandle style : ds.listStyles()){
80
                	if (style.getName().equals("sysmlinternal")){
81
                        dg.setStyle(style);
82
                        break;
83
                    }
84
                }
83
			if (diagram != null) {
84
				// Unmask the block in the diagram
85
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
86
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
87
					IDiagramDG dg = handler.getDiagramNode();
88
					for (IStyleHandle style : ds.listStyles()){
89
						if (style.getName().equals("sysmlinternal")){
90
							dg.setStyle(style);
91
							break;
92
						}
93
					}
85 94

  
86
                List<IDiagramGraphic> dgs = handler.unmask(element, 0, 0);
87
                for (IDiagramGraphic dg2 : dgs){
88
                    if (dg2 instanceof IDiagramNode)
89
                        ((IDiagramNode) dg2).setBounds(new Rectangle (100, 100, 300, 250));
90
                }
95
					List<IDiagramGraphic> dgs = handler.unmask(element, 0, 0);
96
					for (IDiagramGraphic dg2 : dgs){
97
						if (dg2 instanceof IDiagramNode) {
98
							((IDiagramNode) dg2).setBounds(new Rectangle (100, 100, 300, 250));
99
						}
100
					}
91 101

  
92
                // Open the diagram
102
					// Open the diagram
93 103

  
94
                handler.save();
95
                handler.close();
104
					handler.save();
105
					handler.close();
106
				}
96 107

  
97
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
98
            }
108
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
109
			}
99 110

  
100 111

  
101
            transaction.commit ();
102
        }
112
			transaction.commit ();
113
		}
103 114

  
104
        return diagram;
105
    }
115
		return diagram;
116
	}
106 117

  
107
    @Override
108
    public String getLabel() {
109
        return I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Label");
110
    }
118
	@Override
119
	public String getLabel() {
120
		return I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Label");
121
	}
111 122

  
112
    @Override
113
    public String getDetails() {
114
        return I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Details");
115
    }
123
	@Override
124
	public String getDetails() {
125
		return I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Details");
126
	}
116 127

  
117
    @Override
118
    public String getHelpUrl() {
119
        return null;
120
    }
128
	@Override
129
	public String getHelpUrl() {
130
		return null;
131
	}
121 132

  
122
    @Override
123
    public Image getIcon() {
124
        return new Image(Display.getDefault(),SysMLResourcesManager.getInstance().getImage("parametricdiagram.png"));
125
    }
133
	@Override
134
	public Image getIcon() {
135
		return new Image(Display.getDefault(),SysMLResourcesManager.getInstance().getImage("parametricdiagram.png"));
136
	}
126 137

  
127
    @Override
128
    public String getInformation() {
129
        return I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Information");
130
    }
138
	@Override
139
	public String getInformation() {
140
		return I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Information");
141
	}
131 142

  
132
    @Override
133
    public boolean accept(MObject element) {
143
	@Override
144
	public boolean accept(MObject element) {
134 145

  
135
        return ((element != null) &&
136
                ((Utils.isABlock (element)
137
                        || Utils.isAConstraintBlock (element))));
146
		return ((element != null) &&
147
				((Utils.isABlock (element)
148
						|| Utils.isAConstraintBlock (element))));
138 149

  
139
    }
150
	}
140 151

  
152
	@Override
153
	public ElementDescriptor getCreatedElementType() {
154
		IModuleContext moduleContext = getModule().getModuleContext();
155
		MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
156
		MClass mClass = metamodel.getMClass(StaticDiagram.class);
157
		IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
158
		Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.PARAMETRICDIAGRAM, mClass);
159
		return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
160
	}
141 161
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/BlockDiagramWizard.java
34 34
import org.modelio.api.modelio.diagram.IDiagramService;
35 35
import org.modelio.api.modelio.diagram.dg.IDiagramDG;
36 36
import org.modelio.api.modelio.diagram.style.IStyleHandle;
37
import org.modelio.api.modelio.model.IMetamodelExtensions;
37 38
import org.modelio.api.modelio.model.IModelingSession;
38 39
import org.modelio.api.modelio.model.ITransaction;
40
import org.modelio.api.module.context.IModuleContext;
39 41
import org.modelio.api.module.contributor.AbstractWizardContributor;
42
import org.modelio.api.module.contributor.ElementDescriptor;
40 43
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
41 44
import org.modelio.metamodel.diagrams.AbstractDiagram;
45
import org.modelio.metamodel.diagrams.StaticDiagram;
42 46
import org.modelio.metamodel.uml.infrastructure.ModelElement;
43 47
import org.modelio.metamodel.uml.infrastructure.Profile;
48
import org.modelio.metamodel.uml.infrastructure.Stereotype;
44 49
import org.modelio.metamodel.uml.statik.Class;
45 50
import org.modelio.metamodel.uml.statik.Package;
51
import org.modelio.vcore.smkernel.mapi.MClass;
52
import org.modelio.vcore.smkernel.mapi.MMetamodel;
46 53
import org.modelio.vcore.smkernel.mapi.MObject;
47 54

  
48 55
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
......
67 74

  
68 75
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
69 76
		AbstractDiagram diagram = null;
70
        try( ITransaction transaction = session.createTransaction (I18nMessageService.getString ("Info.Session.Create","Activity"))){
77
		try( ITransaction transaction = session.createTransaction (I18nMessageService.getString ("Info.Session.Create","Activity"))){
71 78

  
72 79

  
73 80
			diagram = SysMLFactory.createAndAddBlockDiagram(element, diagramName, description);
74 81

  
75 82
			if (diagram != null) {
76 83
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
77
				IDiagramHandle handler = ds.getDiagramHandle(diagram);
78
				IDiagramDG dg = handler.getDiagramNode();
84
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
85
					IDiagramDG dg = handler.getDiagramNode();
79 86

  
80
				for (IStyleHandle style : ds.listStyles()){
81
					if (style.getName().equals("sysml")){
82
						dg.setStyle(style);
83
						break;
87
					for (IStyleHandle style : ds.listStyles()){
88
						if (style.getName().equals("sysml")){
89
							dg.setStyle(style);
90
							break;
91
						}
84 92
					}
93

  
94
					handler.save();
95
					handler.close();
85 96
				}
86 97

  
87
				handler.save();
88
				handler.close();
89

  
90 98
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
91 99
			}
92 100

  
......
127 135

  
128 136
		return ((selectedElt != null) &&
129 137
				(((selectedElt instanceof Package) && !(selectedElt instanceof Profile)
130
				        || ((selectedElt instanceof Class) && (((Class)selectedElt).isStereotyped(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCK) )))
138
						|| ((selectedElt instanceof Class) && (((Class)selectedElt).isStereotyped(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCK) )))
131 139
						&& selectedElt.getStatus().isModifiable()));
132 140
	}
133 141

  
142
	@Override
143
	public ElementDescriptor getCreatedElementType() {
144
		IModuleContext moduleContext = getModule().getModuleContext();
145
		MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
146
		MClass mClass = metamodel.getMClass(StaticDiagram.class);
147
		IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
148
		Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCKDIAGRAM, mClass);
149
		return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
150
	}
134 151

  
135

  
136 152
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/PackageDiagramWizard.java
34 34
import org.modelio.api.modelio.diagram.IDiagramService;
35 35
import org.modelio.api.modelio.diagram.dg.IDiagramDG;
36 36
import org.modelio.api.modelio.diagram.style.IStyleHandle;
37
import org.modelio.api.modelio.model.IMetamodelExtensions;
37 38
import org.modelio.api.modelio.model.IModelingSession;
38 39
import org.modelio.api.modelio.model.ITransaction;
40
import org.modelio.api.module.context.IModuleContext;
39 41
import org.modelio.api.module.contributor.AbstractWizardContributor;
42
import org.modelio.api.module.contributor.ElementDescriptor;
40 43
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
41 44
import org.modelio.metamodel.diagrams.AbstractDiagram;
45
import org.modelio.metamodel.diagrams.StaticDiagram;
42 46
import org.modelio.metamodel.uml.infrastructure.ModelElement;
47
import org.modelio.metamodel.uml.infrastructure.Stereotype;
43 48
import org.modelio.metamodel.uml.statik.Package;
49
import org.modelio.vcore.smkernel.mapi.MClass;
50
import org.modelio.vcore.smkernel.mapi.MMetamodel;
44 51
import org.modelio.vcore.smkernel.mapi.MObject;
45 52

  
53
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
54
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
46 55
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
47 56
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
48 57
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
56 65
 */
57 66
public class PackageDiagramWizard extends AbstractWizardContributor implements IDiagramWizardContributor {
58 67

  
59
    @Override
60
    public AbstractDiagram actionPerformed(ModelElement element, String diagramName, String description) {
61
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
68
	@Override
69
	public AbstractDiagram actionPerformed(ModelElement element, String diagramName, String description) {
70
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
62 71

  
63
        AbstractDiagram diagram = null;
64
        try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
72
		AbstractDiagram diagram = null;
73
		try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
65 74

  
66
            diagram = SysMLFactory.createAndAddPackageDiagram(element, diagramName, description);
75
			diagram = SysMLFactory.createAndAddPackageDiagram(element, diagramName, description);
67 76

  
68
            if (diagram != null) {
77
			if (diagram != null) {
69 78

  
70
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
71
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
72
                IDiagramDG dg = handler.getDiagramNode();
73
                for (IStyleHandle style : ds.listStyles()) {
74
                    if (style.getName().equals("sysmlpackage")) {
75
                        dg.setStyle(style);
76
                        break;
77
                    }
78
                }
79
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
80
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
81
					IDiagramDG dg = handler.getDiagramNode();
82
					for (IStyleHandle style : ds.listStyles()) {
83
						if (style.getName().equals("sysmlpackage")) {
84
							dg.setStyle(style);
85
							break;
86
						}
87
					}
79 88

  
80
                handler.save();
81
                handler.close();
89
					handler.save();
90
					handler.close();
91
				}
82 92

  
83
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
93
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
84 94

  
85
            }
86
            transaction.commit();
87
        }
95
			}
96
			transaction.commit();
97
		}
88 98

  
89
        return diagram;
99
		return diagram;
90 100

  
91
    }
101
	}
92 102

  
93
    @Override
94
    public String getLabel() {
95
        return I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Label");
96
    }
103
	@Override
104
	public String getLabel() {
105
		return I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Label");
106
	}
97 107

  
98
    @Override
99
    public String getDetails() {
100
        return I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Details");
101
    }
108
	@Override
109
	public String getDetails() {
110
		return I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Details");
111
	}
102 112

  
103
    @Override
104
    public String getHelpUrl() {
105
        return null;
106
    }
113
	@Override
114
	public String getHelpUrl() {
115
		return null;
116
	}
107 117

  
108
    @Override
109
    public Image getIcon() {
110
        return new Image(Display.getDefault(), SysMLResourcesManager.getInstance().getImage("packagediagram.png"));
111
    }
118
	@Override
119
	public Image getIcon() {
120
		return new Image(Display.getDefault(), SysMLResourcesManager.getInstance().getImage("packagediagram.png"));
121
	}
112 122

  
113
    @Override
114
    public String getInformation() {
115
        return I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Information");
116
    }
123
	@Override
124
	public String getInformation() {
125
		return I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Information");
126
	}
117 127

  
118
    @Override
119
    public boolean accept(MObject element) {
120
        return ((element != null) && (element instanceof Package));
121
    }
128
	@Override
129
	public boolean accept(MObject element) {
130
		return ((element != null) && (element instanceof Package));
131
	}
122 132

  
133
	@Override
134
	public ElementDescriptor getCreatedElementType() {
135
		IModuleContext moduleContext = getModule().getModuleContext();
136
		MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
137
		MClass mClass = metamodel.getMClass(StaticDiagram.class);
138
		IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
139
		Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.PACKAGEDIAGRAM, mClass);
140
		return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
141
	}
142

  
123 143
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/SysMLStateMachineDiagramWizard.java
30 30

  
31 31
import org.eclipse.swt.graphics.Image;
32 32
import org.eclipse.swt.widgets.Display;
33
import org.modelio.api.modelio.model.IMetamodelExtensions;
33 34
import org.modelio.api.modelio.model.IModelingSession;
34 35
import org.modelio.api.modelio.model.ITransaction;
36
import org.modelio.api.module.context.IModuleContext;
35 37
import org.modelio.api.module.contributor.AbstractWizardContributor;
38
import org.modelio.api.module.contributor.ElementDescriptor;
36 39
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
37 40
import org.modelio.metamodel.diagrams.AbstractDiagram;
41
import org.modelio.metamodel.diagrams.StateMachineDiagram;
38 42
import org.modelio.metamodel.uml.behavior.stateMachineModel.StateMachine;
39 43
import org.modelio.metamodel.uml.behavior.usecaseModel.Actor;
40 44
import org.modelio.metamodel.uml.behavior.usecaseModel.UseCase;
41 45
import org.modelio.metamodel.uml.infrastructure.ModelElement;
42 46
import org.modelio.metamodel.uml.infrastructure.Profile;
47
import org.modelio.metamodel.uml.infrastructure.Stereotype;
43 48
import org.modelio.metamodel.uml.statik.Class;
44 49
import org.modelio.metamodel.uml.statik.Collaboration;
45 50
import org.modelio.metamodel.uml.statik.Component;
......
47 52
import org.modelio.metamodel.uml.statik.Node;
48 53
import org.modelio.metamodel.uml.statik.Operation;
49 54
import org.modelio.metamodel.uml.statik.Package;
55
import org.modelio.vcore.smkernel.mapi.MClass;
56
import org.modelio.vcore.smkernel.mapi.MMetamodel;
50 57
import org.modelio.vcore.smkernel.mapi.MObject;
51 58

  
59
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
60
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
52 61
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
53 62
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
54 63
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
117 126
                || (selectedElt instanceof Operation) || (selectedElt instanceof StateMachine)));
118 127
    }
119 128

  
129
    @Override
130
    public ElementDescriptor getCreatedElementType() {
131
        IModuleContext moduleContext = getModule().getModuleContext();
132
        MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
133
        MClass mClass = metamodel.getMClass(StateMachineDiagram.class);
134
        IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
135
        Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.SYSMLSTATEMACHINEDIAGRAM, mClass);
136
        return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
137
    }
120 138
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/SysMLSequenceDiagramWizard.java
30 30

  
31 31
import org.eclipse.swt.graphics.Image;
32 32
import org.eclipse.swt.widgets.Display;
33
import org.modelio.api.modelio.model.IMetamodelExtensions;
33 34
import org.modelio.api.modelio.model.IModelingSession;
34 35
import org.modelio.api.modelio.model.ITransaction;
36
import org.modelio.api.module.context.IModuleContext;
35 37
import org.modelio.api.module.contributor.AbstractWizardContributor;
38
import org.modelio.api.module.contributor.ElementDescriptor;
36 39
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
37 40
import org.modelio.metamodel.diagrams.AbstractDiagram;
41
import org.modelio.metamodel.diagrams.SequenceDiagram;
38 42
import org.modelio.metamodel.uml.behavior.interactionModel.Interaction;
39 43
import org.modelio.metamodel.uml.behavior.usecaseModel.Actor;
40 44
import org.modelio.metamodel.uml.behavior.usecaseModel.UseCase;
41 45
import org.modelio.metamodel.uml.infrastructure.ModelElement;
42 46
import org.modelio.metamodel.uml.infrastructure.Profile;
47
import org.modelio.metamodel.uml.infrastructure.Stereotype;
43 48
import org.modelio.metamodel.uml.statik.Class;
44 49
import org.modelio.metamodel.uml.statik.Collaboration;
45 50
import org.modelio.metamodel.uml.statik.Component;
......
47 52
import org.modelio.metamodel.uml.statik.Node;
48 53
import org.modelio.metamodel.uml.statik.Operation;
49 54
import org.modelio.metamodel.uml.statik.Package;
55
import org.modelio.vcore.smkernel.mapi.MClass;
56
import org.modelio.vcore.smkernel.mapi.MMetamodel;
50 57
import org.modelio.vcore.smkernel.mapi.MObject;
51 58

  
59
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
60
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
52 61
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
53 62
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
54 63
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
114 123
                || (selectedElt instanceof Operation) || (selectedElt instanceof Interaction)));
115 124
    }
116 125

  
126
    @Override
127
    public ElementDescriptor getCreatedElementType() {
128
        IModuleContext moduleContext = getModule().getModuleContext();
129
        MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
130
        MClass mClass = metamodel.getMClass(SequenceDiagram.class);
131
        IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
132
        Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.SYSMLSEQUENCEDIAGRAM, mClass);
133
        return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
134
    }
117 135
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/wizard/SysMLUseCaseDiagramWizard.java
30 30

  
31 31
import org.eclipse.swt.graphics.Image;
32 32
import org.eclipse.swt.widgets.Display;
33
import org.modelio.api.modelio.model.IMetamodelExtensions;
33 34
import org.modelio.api.modelio.model.IModelingSession;
34 35
import org.modelio.api.modelio.model.ITransaction;
36
import org.modelio.api.module.context.IModuleContext;
35 37
import org.modelio.api.module.contributor.AbstractWizardContributor;
38
import org.modelio.api.module.contributor.ElementDescriptor;
36 39
import org.modelio.api.module.contributor.diagramcreation.IDiagramWizardContributor;
37 40
import org.modelio.metamodel.diagrams.AbstractDiagram;
41
import org.modelio.metamodel.diagrams.UseCaseDiagram;
38 42
import org.modelio.metamodel.uml.behavior.usecaseModel.UseCase;
39 43
import org.modelio.metamodel.uml.infrastructure.ModelElement;
40 44
import org.modelio.metamodel.uml.infrastructure.Profile;
45
import org.modelio.metamodel.uml.infrastructure.Stereotype;
41 46
import org.modelio.metamodel.uml.statik.Class;
42 47
import org.modelio.metamodel.uml.statik.Component;
43 48
import org.modelio.metamodel.uml.statik.Interface;
44 49
import org.modelio.metamodel.uml.statik.Package;
50
import org.modelio.vcore.smkernel.mapi.MClass;
51
import org.modelio.vcore.smkernel.mapi.MMetamodel;
45 52
import org.modelio.vcore.smkernel.mapi.MObject;
46 53

  
54
import com.modeliosoft.modelio.sysml.api.ISysMLPeerModule;
55
import com.modeliosoft.modelio.sysml.api.SysMLStereotypes;
47 56
import com.modeliosoft.modelio.sysml.i18n.I18nMessageService;
48 57
import com.modeliosoft.modelio.sysml.impl.SysMLModule;
49 58
import com.modeliosoft.modelio.sysml.utils.SysMLFactory;
......
106 115
                || (selectedElt instanceof Component) || (selectedElt instanceof UseCase)));
107 116
    }
108 117

  
118
    @Override
119
    public ElementDescriptor getCreatedElementType() {
120
        IModuleContext moduleContext = getModule().getModuleContext();
121
        MMetamodel metamodel = moduleContext.getModelioServices().getMetamodelService().getMetamodel();
122
        MClass mClass = metamodel.getMClass(UseCaseDiagram.class);
123
        IMetamodelExtensions extensions = moduleContext.getModelingSession().getMetamodelExtensions();
124
        Stereotype stereotype = extensions.getStereotype(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.SYSMLUSECASEDIAGRAM, mClass);
125
        return stereotype != null ? new ElementDescriptor(mClass, stereotype) : null;
126
    }
109 127
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/command/InternalBlockDiagramCommand.java
54 54

  
55 55
/**
56 56
 * This class handles the creation of SysML internal block diagram
57
 * 
57
 *
58 58
 * @author ebrosse
59
 * 
59
 *
60 60
 */
61 61
public class InternalBlockDiagramCommand extends DefaultModuleCommandHandler {
62 62

  
63
    @Override
64
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
65
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
66
        AbstractDiagram diagram = null;
67
        
68
        String name = I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Label");
69
       
70
        try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
71
            ModelElement element = (ModelElement) selectedElements.get(0);
72
            diagram = session.getModel().createStaticDiagram (name, element, ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.INTERNALBLOCKDIAGRAM);
73
            Utils.setUMLFreeName(diagram, name);
63
	@Override
64
	public void actionPerformed(List<MObject> selectedElements, IModule module) {
65
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
66
		AbstractDiagram diagram = null;
74 67

  
75
            if (diagram != null) {
76
                // Unmask the block in the diagram
68
		String name = I18nMessageService.getString("Ui.Command.InternalBlockDiagramExplorerCommand.Label");
77 69

  
78
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
79
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
80
                IDiagramDG dg = handler.getDiagramNode();
81
                for (IStyleHandle style : ds.listStyles()) {
82
                    if (style.getName().equals("sysmlinternal")) {
83
                        dg.setStyle(style);
84
                        break;
85
                    }
86
                }
70
		try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
71
			ModelElement element = (ModelElement) selectedElements.get(0);
72
			diagram = session.getModel().createStaticDiagram (name, element, ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.INTERNALBLOCKDIAGRAM);
73
			Utils.setUMLFreeName(diagram, name);
87 74

  
88
                List<IDiagramGraphic> dgs = handler.unmask(element, 0, 0);
89
                for (IDiagramGraphic dg2 : dgs) {
90
                    if (dg2 instanceof IDiagramNode)
91
                        ((IDiagramNode) dg2).setBounds(new Rectangle(100, 100, 300, 250));
92
                }
75
			if (diagram != null) {
76
				// Unmask the block in the diagram
93 77

  
94
                handler.save();
95
                handler.close();
78
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
79
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
80
					IDiagramDG dg = handler.getDiagramNode();
81
					for (IStyleHandle style : ds.listStyles()) {
82
						if (style.getName().equals("sysmlinternal")) {
83
							dg.setStyle(style);
84
							break;
85
						}
86
					}
96 87

  
97
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
98
            }
88
					List<IDiagramGraphic> dgs = handler.unmask(element, 0, 0);
89
					for (IDiagramGraphic dg2 : dgs) {
90
						if (dg2 instanceof IDiagramNode) {
91
							((IDiagramNode) dg2).setBounds(new Rectangle(100, 100, 300, 250));
92
						}
93
					}
99 94

  
100
            transaction.commit();
101
        } catch (ExtensionNotFoundException e) {
102
            // TODO Auto-generated catch block
103
            e.printStackTrace();
104
        }
95
					handler.save();
96
					handler.close();
97
				}
105 98

  
106
       
107
    }
99
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
100
			}
108 101

  
109
   
110
    @Override
111
    public boolean accept(List<MObject> selectedElements, IModule module) {
102
			transaction.commit();
103
		} catch (ExtensionNotFoundException e) {
104
			// TODO Auto-generated catch block
105
			e.printStackTrace();
106
		}
112 107

  
113
        if ((selectedElements != null) && (selectedElements.size() == 1)){
114
            MObject selectedElement = selectedElements.get(0);
115
            return ((selectedElement != null) && (Utils.isABlock(selectedElement)));
116
        }
117
        return false; 
118
    }
119
   
120 108

  
109
	}
110

  
111

  
112
	@Override
113
	public boolean accept(List<MObject> selectedElements, IModule module) {
114

  
115
		if ((selectedElements != null) && (selectedElements.size() == 1)){
116
			MObject selectedElement = selectedElements.get(0);
117
			return ((selectedElement != null) && (Utils.isABlock(selectedElement)));
118
		}
119
		return false;
120
	}
121

  
122

  
121 123
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/command/ParametricDiagramCommand.java
60 60
public class ParametricDiagramCommand extends DefaultModuleCommandHandler {
61 61

  
62 62

  
63
    @Override
64
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
65
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
66
        
67
        String name = I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Label");
68
       
69
        ModelElement owner = (ModelElement) selectedElements.get(0);
70
        
71
        StaticDiagram diagram = null;
72
        try( ITransaction transaction = session.createTransaction (I18nMessageService.getString ("Info.Session.Create","Activity"))){
63
	@Override
64
	public void actionPerformed(List<MObject> selectedElements, IModule module) {
65
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
73 66

  
74
            diagram = session.getModel ().createStaticDiagram (name, owner, ISysMLPeerModule.MODULE_NAME,SysMLStereotypes.PARAMETRICDIAGRAM);
75
            
76
            Utils.setUMLFreeName(diagram,name);
67
		String name = I18nMessageService.getString ("Ui.Command.ParametricDiagramExplorerCommand.Label");
77 68

  
78
            if (diagram != null) {
79
                // Unmask the block in the diagram
80
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
81
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
82
                IDiagramDG dg = handler.getDiagramNode();
83
                for (IStyleHandle style : ds.listStyles()){
84
                	if (style.getName().equals("sysmlinternal")){
85
                        dg.setStyle(style);
86
                        break;
87
                    }
88
                }
69
		ModelElement owner = (ModelElement) selectedElements.get(0);
89 70

  
90
                List<IDiagramGraphic> dgs = handler.unmask(owner, 0, 0);
91
                for (IDiagramGraphic dg2 : dgs){
92
                    if (dg2 instanceof IDiagramNode)
93
                        ((IDiagramNode) dg2).setBounds(new Rectangle (100, 100, 300, 250));
94
                }
71
		StaticDiagram diagram = null;
72
		try( ITransaction transaction = session.createTransaction (I18nMessageService.getString ("Info.Session.Create","Activity"))){
95 73

  
96
                // Open the diagram
97
               
98
                handler.save();
99
                handler.close();   
100
                
101
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
102
            }
74
			diagram = session.getModel ().createStaticDiagram (name, owner, ISysMLPeerModule.MODULE_NAME,SysMLStereotypes.PARAMETRICDIAGRAM);
103 75

  
76
			Utils.setUMLFreeName(diagram,name);
104 77

  
105
            transaction.commit ();
106
        } catch (ExtensionNotFoundException e) {
107
            // TODO Auto-generated catch block
108
            e.printStackTrace();
109
        } 
78
			if (diagram != null) {
79
				// Unmask the block in the diagram
80
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
81
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
82
					IDiagramDG dg = handler.getDiagramNode();
83
					for (IStyleHandle style : ds.listStyles()){
84
						if (style.getName().equals("sysmlinternal")){
85
							dg.setStyle(style);
86
							break;
87
						}
88
					}
110 89

  
111
    }
90
					List<IDiagramGraphic> dgs = handler.unmask(owner, 0, 0);
91
					for (IDiagramGraphic dg2 : dgs){
92
						if (dg2 instanceof IDiagramNode) {
93
							((IDiagramNode) dg2).setBounds(new Rectangle (100, 100, 300, 250));
94
						}
95
					}
112 96

  
113
    
114
    @Override
115
    public boolean accept(List<MObject> selectedElements, IModule module) {
97
					// Open the diagram
116 98

  
117
        if ((selectedElements != null) && (selectedElements.size() == 1)){
118
            MObject selectedElement = selectedElements.get(0);
119
            return ((selectedElement != null) && 
120
                    ((Utils.isABlock (selectedElement) 
121
                            || Utils.isAConstraintBlock (selectedElement))));
122
        }
123
        return false; 
124
    }
99
					handler.save();
100
					handler.close();
101
				}
125 102

  
103
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
104
			}
126 105

  
106

  
107
			transaction.commit ();
108
		} catch (ExtensionNotFoundException e) {
109
			// TODO Auto-generated catch block
110
			e.printStackTrace();
111
		}
112

  
113
	}
114

  
115

  
116
	@Override
117
	public boolean accept(List<MObject> selectedElements, IModule module) {
118

  
119
		if ((selectedElements != null) && (selectedElements.size() == 1)){
120
			MObject selectedElement = selectedElements.get(0);
121
			return ((selectedElement != null) &&
122
					((Utils.isABlock (selectedElement)
123
							|| Utils.isAConstraintBlock (selectedElement))));
124
		}
125
		return false;
126
	}
127

  
128

  
127 129
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/command/BlockDiagramCommand.java
61 61
public class BlockDiagramCommand extends DefaultModuleCommandHandler {
62 62

  
63 63

  
64
    @Override
65
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
66
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
67
        StaticDiagram diagram = null;
68
        String name = I18nMessageService.getString ("Ui.Command.BlockDiagramExplorerCommand.Label");
69
        try( ITransaction transaction = session.createTransaction(I18nMessageService.getString ("Info.Session.Create","Activity"))){
64
	@Override
65
	public void actionPerformed(List<MObject> selectedElements, IModule module) {
66
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
67
		StaticDiagram diagram = null;
68
		String name = I18nMessageService.getString ("Ui.Command.BlockDiagramExplorerCommand.Label");
69
		try( ITransaction transaction = session.createTransaction(I18nMessageService.getString ("Info.Session.Create","Activity"))){
70 70

  
71
            diagram = session.getModel().createStaticDiagram (name, (ModelElement) selectedElements.get(0),ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCKDIAGRAM);
72
            Utils.setUMLFreeName(diagram, name);
71
			diagram = session.getModel().createStaticDiagram (name, (ModelElement) selectedElements.get(0),ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCKDIAGRAM);
72
			Utils.setUMLFreeName(diagram, name);
73 73

  
74
            if (diagram != null) {
75
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
76
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
77
                IDiagramDG dg = handler.getDiagramNode();
74
			if (diagram != null) {
75
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
76
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
77
					IDiagramDG dg = handler.getDiagramNode();
78 78

  
79
                for (IStyleHandle style : ds.listStyles()){
80
                    if (style.getName().equals("sysml")){
81
                        dg.setStyle(style);
82
                        break;
83
                    }
84
                }
79
					for (IStyleHandle style : ds.listStyles()){
80
						if (style.getName().equals("sysml")){
81
							dg.setStyle(style);
82
							break;
83
						}
84
					}
85 85

  
86
                handler.save();
87
                handler.close();
86
					handler.save();
87
					handler.close();
88
				}
88 89

  
89
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
90
            }
90
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
91
			}
91 92

  
92
            transaction.commit ();
93
        } catch (ExtensionNotFoundException e) {
94
            // TODO Auto-generated catch block
95
            e.printStackTrace();
96
        } 
93
			transaction.commit ();
94
		} catch (ExtensionNotFoundException e) {
95
			// TODO Auto-generated catch block
96
			e.printStackTrace();
97
		}
97 98

  
98
        
99
    }
100 99

  
100
	}
101 101

  
102 102

  
103 103

  
104
    @Override
105
    public boolean accept(List<MObject> selectedElements, IModule module) {
106 104

  
107
        if ((selectedElements != null) && (selectedElements.size() == 1)){
108
            MObject selectedElt = selectedElements.get(0);
109
            return ((selectedElt != null) &&
110
                    (((selectedElt instanceof Package) && !(selectedElt instanceof Profile)
111
                            || ((selectedElt instanceof Class) && (((Class)selectedElt).isStereotyped(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCK) )))
112
                            && selectedElt.getStatus().isModifiable()));
113
        }
114
        return false; 
115
    }
105
	@Override
106
	public boolean accept(List<MObject> selectedElements, IModule module) {
116 107

  
108
		if ((selectedElements != null) && (selectedElements.size() == 1)){
109
			MObject selectedElt = selectedElements.get(0);
110
			return ((selectedElt != null) &&
111
					(((selectedElt instanceof Package) && !(selectedElt instanceof Profile)
112
							|| ((selectedElt instanceof Class) && (((Class)selectedElt).isStereotyped(ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.BLOCK) )))
113
							&& selectedElt.getStatus().isModifiable()));
114
		}
115
		return false;
116
	}
117 117

  
118 118

  
119

  
119 120
}
branches/modelio3.7.x/src/main/java/com/modeliosoft/modelio/sysml/commands/explorer/diagram/command/PackageDiagramCommand.java
52 52

  
53 53
/**
54 54
 * This class handles the creation of SysML package diagram
55
 * 
55
 *
56 56
 * @author ebrosse
57
 * 
57
 *
58 58
 */
59 59
public class PackageDiagramCommand extends DefaultModuleCommandHandler {
60 60

  
61
    @Override
62
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
61
	@Override
62
	public void actionPerformed(List<MObject> selectedElements, IModule module) {
63 63

  
64
        IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
65
        
66
        String name = I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Label");
67
        
68
        AbstractDiagram diagram = null;
69
        try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
64
		IModelingSession session = SysMLModule.getInstance().getModuleContext().getModelingSession();
70 65

  
71
            diagram = session.getModel ().createStaticDiagram(name, (ModelElement) selectedElements.get(0),ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.PACKAGEDIAGRAM);
72
            Utils.setUMLFreeName(diagram, name);
73
           
66
		String name = I18nMessageService.getString("Ui.Command.PackageDiagramExplorerCommand.Label");
74 67

  
75
            if (diagram != null) {
68
		AbstractDiagram diagram = null;
69
		try (ITransaction transaction = session.createTransaction(I18nMessageService.getString("Info.Session.Create", "Activity"))) {
76 70

  
77
                IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
78
                IDiagramHandle handler = ds.getDiagramHandle(diagram);
79
                IDiagramDG dg = handler.getDiagramNode();
80
                for (IStyleHandle style : ds.listStyles()) {
81
                    if (style.getName().equals("sysmlpackage")) {
82
                        dg.setStyle(style);
83
                        break;
84
                    }
85
                }
71
			diagram = session.getModel ().createStaticDiagram(name, (ModelElement) selectedElements.get(0),ISysMLPeerModule.MODULE_NAME, SysMLStereotypes.PACKAGEDIAGRAM);
72
			Utils.setUMLFreeName(diagram, name);
86 73

  
87
                handler.save();
88
                handler.close();
89 74

  
90
                SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
75
			if (diagram != null) {
91 76

  
92
            }
93
            transaction.commit();
94
        } catch (ExtensionNotFoundException e) {
95
            // TODO Auto-generated catch block
96
            e.printStackTrace();
97
        }
77
				IDiagramService ds = SysMLModule.getInstance().getModuleContext().getModelioServices().getDiagramService();
78
				try (IDiagramHandle handler = ds.getDiagramHandle(diagram)) {
79
					IDiagramDG dg = handler.getDiagramNode();
80
					for (IStyleHandle style : ds.listStyles()) {
81
						if (style.getName().equals("sysmlpackage")) {
82
							dg.setStyle(style);
83
							break;
84
						}
85
					}
98 86

  
87
					handler.save();
88
					handler.close();
89
				}
99 90

  
100
    }
101
    
102
    @Override
103
    public boolean accept(List<MObject> selectedElements, IModule module) {
91
				SysMLModule.getInstance().getModuleContext().getModelioServices().getEditionService().openEditor(diagram);
104 92

  
105
        if ((selectedElements != null) && (selectedElements.size() == 1)){
106
            MObject selectedElement = selectedElements.get(0);
107
            return ((selectedElement != null) && (selectedElement instanceof Package));
108
        }
109
        return false; 
110
    }
93
			}
94
			transaction.commit();
95
		} catch (ExtensionNotFoundException e) {
96
			// TODO Auto-generated catch block
97
			e.printStackTrace();
98
		}
111 99

  
112 100

  
101
	}
102

  
103
	@Override
104
	public boolean accept(List<MObject> selectedElements, IModule module) {
105

  
106
		if ((selectedElements != null) && (selectedElements.size() == 1)){
107
			MObject selectedElement = selectedElements.get(0);
108
			return ((selectedElement != null) && (selectedElement instanceof Package));
109
		}
110
		return false;
111
	}
112

  
113

  
113 114
}

Also available in: Unified diff