[438074] Creation of a Wizard for VSM Initializer.

An initilizer action has been added in the contextual menu of the VSM Editor when a Viewpoint is selected. It launches a wizard which allow to select and configure a pattern. 

The Class Diagram pattern is currently the only available pattern. Its configuration page allows to specify the base id used as prefix for all IdentifiedElement of the created Class Diagram skeleton. The specifier also has the possibility to configure between a single or many delete and direct edit tools.

The Wizard is in a DRAFT state. It still has to be moed in the proper plugin, an extension point or an API has to be written to provide the patterns.

Bug: 438074
Change-Id: I22d1a585323d9d8e8c292d830310d1b08e540265
Signed-off-by: João Martins <joaomartins27396@gmail.com>
diff --git a/plugins/org.eclipse.sirius.editor.diagram/images/classDiagramPattern.png b/plugins/org.eclipse.sirius.editor.diagram/images/classDiagramPattern.png
new file mode 100644
index 0000000..bd881b2
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/images/classDiagramPattern.png
Binary files differ
diff --git a/plugins/org.eclipse.sirius.editor.diagram/plugin.xml b/plugins/org.eclipse.sirius.editor.diagram/plugin.xml
index f1b3a14..cf9d99e 100644
--- a/plugins/org.eclipse.sirius.editor.diagram/plugin.xml
+++ b/plugins/org.eclipse.sirius.editor.diagram/plugin.xml
@@ -23,7 +23,7 @@
            class="org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.DiagramRefactoringMenu">
      </builder>
      <builder
-           class="org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer.DiagramInitializerMenu">
+           class="org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer.InitializerMenu">
      </builder>
      <builder
            class="org.eclipse.sirius.diagram.editor.tools.internal.menu.child.ElementCreationMenuBuilder">
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramPattern.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramPattern.java
new file mode 100644
index 0000000..fc489ab
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramPattern.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.viewpoint.description.Viewpoint;
+
+/**
+ * This is a abstract class to provide a implementation to pattern provider.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class ClassDiagramPattern implements IPatternProvider {
+
+    /**
+     * Id.
+     */
+    private static final String DEFAUT_BASE_ID = "pattern.class.diagram";
+
+    /**
+     * Label.
+     */
+    private static final String LABEL = "ClassDiagramPatternProvider";
+
+    /**
+     * Description.
+     */
+    private static final String DESCRIPTION = "This pattern produces a Class Diagram skeleton to represent the following concepts: Package, Class, Attribute, Reference and Inheritance. Each concept has its mapping and creation tool. The delete and direct edit tools creation can be configured. The relations mappings and tools or other mappings are set.";
+
+    /**
+     * ImagePath.
+     */
+    private static final String IMAGEPATH = "images/classDiagramPattern.png";
+
+    private boolean globalEditTool;
+
+    private boolean globalDeleteTool;
+    
+    private String baseId = DEFAUT_BASE_ID;
+
+    /**
+     * Default Constructor.
+     */
+    public ClassDiagramPattern() {
+        globalEditTool = false;
+        globalDeleteTool = false;
+    }
+
+    /**
+     * set pattern configuration.
+     * 
+     * @param gEditTool
+     *            to single or multiple edit tool.
+     * @param gDeleteTool
+     *            to single or multiple delete tool.
+     */
+    public void setPatternConfiguration(boolean gEditTool, boolean gDeleteTool) {
+        this.globalEditTool = gEditTool;
+        this.globalDeleteTool = gDeleteTool;
+    }
+
+    @Override
+    public Command getPatternCreationCommand(ResourceSet resourceSet, Viewpoint viewpoint) {
+        return new ClassDiagramSkeleteonCreationCommand(resourceSet, viewpoint, globalEditTool, globalDeleteTool, baseId);
+    }
+    
+    @Override
+    public String getId() {
+        return DEFAUT_BASE_ID;
+    }
+    public String getBaseId() {
+        return baseId;
+    }
+    
+    public void setBaseId(String id) {
+        baseId = id;
+    }
+
+    @Override
+    public String getLabel() {
+        return LABEL;
+    }
+
+    @Override
+    public String getDescription() {
+        return DESCRIPTION;
+    }
+
+    @Override
+    public String getImagePath() {
+        return IMAGEPATH;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramPatternConfigurationPage.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramPatternConfigurationPage.java
new file mode 100644
index 0000000..8def71f
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramPatternConfigurationPage.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Configuration page.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class ClassDiagramPatternConfigurationPage extends WizardPage {
+
+    private Composite container;
+
+    private ClassDiagramPattern selectedPattern;
+
+    private Text text;
+
+    private boolean globalDirectEdit = true;
+
+    private boolean globalDelete = true;
+
+    private Button singleDET;
+
+    private Button manyDET;
+
+    private Button singleDT;
+
+    private Button manyDT;
+
+    /**
+     * Constructor.
+     */
+    public ClassDiagramPatternConfigurationPage() {
+        super("PatternSelection");
+        setTitle("Pattern Creation");
+        setDescription("Configure the creation of your Class Diagram skeleton.");
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        setComposite(parent);
+        setControl(container);
+    }
+
+    private void setComposite(Composite parent) {
+        container = new Composite(parent, SWT.NONE);
+        container.addListener(SWT.Show, new Listener() {
+            @Override
+            public void handleEvent(Event event) {
+                text.setText(selectedPattern.getBaseId());
+                getContainer().updateButtons();
+
+            }
+        });
+
+        Group grpTools = new Group(container, SWT.NONE);
+        grpTools.setText("Tools");
+        grpTools.setBounds(10, 121, 480, 169);
+
+        singleDET = new Button(grpTools, SWT.RADIO);
+        singleDET.setSelection(globalDirectEdit);
+        singleDET.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                setRadioButtons(manyDET, singleDET);
+                globalDirectEdit = false;
+                getContainer().updateButtons();
+                selectedPattern.setPatternConfiguration(globalDirectEdit, globalDelete);
+            }
+        });
+        singleDET.setBounds(235, 109, 53, 16);
+        singleDET.setText("Single");
+
+        manyDET = new Button(grpTools, SWT.RADIO);
+        manyDET.setBounds(290, 109, 53, 16);
+        manyDET.setText("Many");
+        manyDET.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                setRadioButtons(singleDET, manyDET);
+                globalDirectEdit = true;
+                getContainer().updateButtons();
+                selectedPattern.setPatternConfiguration(globalDirectEdit, globalDelete);
+            }
+        });
+
+        Label lblDirectEditTool = new Label(grpTools, SWT.NONE);
+        lblDirectEditTool.setBounds(140, 109, 90, 15);
+        lblDirectEditTool.setText("Direct Edit Tool:");
+        lblDirectEditTool.setToolTipText("Single Direct Edit Tool will create one tool for all mappings.\nMany Direct Edit Tools will create one tool for mapping.");
+
+        singleDT = new Button(grpTools, SWT.RADIO);
+        singleDT.setBounds(235, 71, 53, 16);
+        singleDT.setText("Single");
+        singleDT.setSelection(globalDelete);
+        singleDT.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                setRadioButtons(manyDT, singleDT);
+                globalDelete = false;
+                getContainer().updateButtons();
+                selectedPattern.setPatternConfiguration(globalDirectEdit, globalDelete);
+            }
+        });
+
+        manyDT = new Button(grpTools, SWT.RADIO);
+        manyDT.setBounds(290, 71, 53, 16);
+        manyDT.setText("Many");
+        manyDT.setCapture(true);
+        manyDT.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                setRadioButtons(singleDT, manyDT);
+                globalDelete = true;
+                getContainer().updateButtons();
+                selectedPattern.setPatternConfiguration(globalDirectEdit, globalDelete);
+            }
+        });
+
+        Label lblDeleteTool = new Label(grpTools, SWT.NONE);
+        lblDeleteTool.setBounds(140, 71, 63, 15);
+        lblDeleteTool.setText("Delete Tool:");
+        lblDeleteTool.setToolTipText("Single Delete Tool will create one tool for all mappings.\nMany Delete Tools will create one tool for mapping.");
+
+        Group grpId = new Group(container, SWT.NONE);
+        grpId.setText("ID");
+        grpId.setBounds(10, 10, 480, 55);
+
+        text = new Text(grpId, SWT.BORDER);
+        text.setBounds(61, 21, 359, 21);
+        text.addListener(SWT.Modify, new Listener() {
+            @Override
+            public void handleEvent(Event event) {
+                getContainer().updateButtons();
+                selectedPattern.setBaseId(text.getText());
+
+            }
+        });
+
+        Label lblPrefixId = new Label(grpId, SWT.NONE);
+        lblPrefixId.setText("Prefix ID:");
+        lblPrefixId.setBounds(10, 24, 45, 15);
+    }
+
+    private void setRadioButtons(Button buttonToFalse, Button buttonToTrue) {
+        buttonToFalse.setSelection(false);
+        buttonToTrue.setSelection(true);
+    }
+
+    public void setSelectedPattern(ClassDiagramPattern classDiagramPattern) {
+        this.selectedPattern = classDiagramPattern;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerCommand.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramSkeleteonCreationCommand.java
similarity index 70%
rename from plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerCommand.java
rename to plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramSkeleteonCreationCommand.java
index b130911..13350b6 100644
--- a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerCommand.java
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/ClassDiagramSkeleteonCreationCommand.java
@@ -12,9 +12,6 @@
 
 package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
 
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.ResourceSet;
 import org.eclipse.sirius.diagram.ContainerLayout;
 import org.eclipse.sirius.diagram.description.ContainerMapping;
@@ -42,42 +39,54 @@
  * @author Joao Martins
  * 
  */
-public class InitializerCommand extends AbstractUndoRecordingCommand {
+public class ClassDiagramSkeleteonCreationCommand extends AbstractUndoRecordingCommand {
 
     /**
      * Command Label.
      */
     public static final String TEXT = "Class diagram skeleton creation command";
 
-    /**
-     * Default ID.
-     */
-    private static final String BASE_ID = "pattern.class.diagram";
+    private String baseId;
 
     private final Viewpoint viewpoint;
 
+    private boolean globalEditTool;
+
+    private boolean globalDeleteTool;
+
     /**
      * Constructor.
      * 
      * @param set
      *            set.
-     * @param selection
+     * @param viewpoint
      *            selection.
+     * @param globalDeleteTool
+     *            To know if we Will initializer a single or multiple delete
+     *            Tool.
+     * @param globalEditTool
+     *            To know if we Will initializer a single or multiple edit Tool.
+     * @param baseid
+     *            Id of the pattern.
      */
-    public InitializerCommand(ResourceSet set, final Collection<EObject> selection) {
+    public ClassDiagramSkeleteonCreationCommand(ResourceSet set, final Viewpoint viewpoint, boolean globalEditTool, boolean globalDeleteTool, String baseid) {
         super(set);
-        this.viewpoint = (Viewpoint) selection.iterator().next();
+        this.viewpoint = viewpoint;
         this.setLabel(TEXT);
+        this.globalDeleteTool = globalDeleteTool;
+        this.globalEditTool = globalEditTool;
+        this.baseId = baseid;
     }
 
     @Override
     protected void doExecute() {
         // Create the Pattern Elements
         DiagramDescription diagramdesc = DescriptionFactory.eINSTANCE.createDiagramDescription();
-        diagramdesc.setName(BASE_ID + ".default.layer");
+        diagramdesc.setName(baseId);
         viewpoint.getOwnedRepresentations().add(diagramdesc);
 
         Layer layer = DescriptionFactory.eINSTANCE.createLayer();
+        layer.setName(baseId + ".default.layer");
         diagramdesc.setDefaultLayer(layer);
         ToolSection toolSection = createToolSection(layer);
 
@@ -95,14 +104,14 @@
 
     private ContainerMapping createPackageMapping(Layer layer, ToolSection toolSection) {
         ContainerMapping packageMapping = DescriptionFactory.eINSTANCE.createContainerMapping();
-        packageMapping.setLabel("packageMapping");
-        packageMapping.setName(BASE_ID + ".package.container");
+        packageMapping.setLabel("Package Mapping");
+        packageMapping.setName(baseId + ".package.container");
         packageMapping.setStyle(StyleFactory.eINSTANCE.createFlatContainerStyleDescription());
         layer.getContainerMappings().add(packageMapping);
         packageMapping.setSemanticCandidatesExpression("feature:eContents");
 
         ContainerCreationDescription containerPackageMapping = ToolFactory.eINSTANCE.createContainerCreationDescription();
-        containerPackageMapping.setName(BASE_ID + ".package.container.creation");
+        containerPackageMapping.setName(baseId + ".package.container.creation");
         containerPackageMapping.setLabel("Package");
         toolSection.getOwnedTools().add(containerPackageMapping);
         containerPackageMapping.getContainerMappings().add(packageMapping);
@@ -113,10 +122,10 @@
     private NodeMapping createAttribute(ContainerMapping classMapping, ToolSection toolSection) {
         NodeMapping attribute = DescriptionFactory.eINSTANCE.createNodeMapping();
         attribute.setLabel("Attribute");
-        attribute.setName(BASE_ID + "class.list.attribute");
+        attribute.setName(baseId + "class.list.attribute");
 
         NodeCreationDescription nodeCreation = ToolFactory.eINSTANCE.createNodeCreationDescription();
-        nodeCreation.setName(BASE_ID + ".class.list.attribute.creation");
+        nodeCreation.setName(baseId + ".class.list.attribute.creation");
         nodeCreation.setLabel("Attribute");
         toolSection.getOwnedTools().add(nodeCreation);
         nodeCreation.getNodeMappings().add(attribute);
@@ -130,12 +139,12 @@
         classMapping.setChildrenPresentation(ContainerLayout.LIST);
 
         classMapping.setLabel("classMapping");
-        classMapping.setName(BASE_ID + ".class.list");
+        classMapping.setName(baseId + ".class.list");
         layer.getContainerMappings().add(classMapping);
         classMapping.setSemanticCandidatesExpression("feature:eContents");
 
         ContainerCreationDescription containerClassMapping = ToolFactory.eINSTANCE.createContainerCreationDescription();
-        containerClassMapping.setName(BASE_ID + ".class.list.creation");
+        containerClassMapping.setName(baseId + ".class.list.creation");
         containerClassMapping.setLabel("Class");
         toolSection.getOwnedTools().add(containerClassMapping);
         containerClassMapping.getContainerMappings().add(classMapping);
@@ -146,7 +155,7 @@
         EdgeMapping edgeMappingInheritance = DescriptionFactory.eINSTANCE.createEdgeMapping();
         EdgeStyleDescription edgeStyleI = StyleFactory.eINSTANCE.createEdgeStyleDescription();
 
-        edgeMappingInheritance.setName(BASE_ID + ".edge.inheritance");
+        edgeMappingInheritance.setName(baseId + ".edge.inheritance");
         edgeMappingInheritance.setLabel("Inheritance");
 
         edgeStyleI.setCenterLabelStyleDescription(StyleFactory.eINSTANCE.createCenterLabelStyleDescription());
@@ -159,9 +168,9 @@
         layer.getEdgeMappings().add(edgeMappingInheritance);
 
         EdgeCreationDescription edgeCreationDescription = ToolFactory.eINSTANCE.createEdgeCreationDescription();
-        edgeCreationDescription.setName(BASE_ID + ".edge.inheritance.creation");
+        edgeCreationDescription.setName(baseId + ".edge.inheritance.creation");
         edgeCreationDescription.setLabel("Inheritance");
-        
+
         edgeCreationDescription.getEdgeMappings().add(edgeMappingInheritance);
         toolSection.getOwnedTools().add(edgeCreationDescription);
 
@@ -172,7 +181,7 @@
         EdgeMapping edgeMappingReference = DescriptionFactory.eINSTANCE.createEdgeMapping();
         EdgeStyleDescription edgeStyleR = StyleFactory.eINSTANCE.createEdgeStyleDescription();
 
-        edgeMappingReference.setName(BASE_ID + ".edge.reference");
+        edgeMappingReference.setName(baseId + ".edge.reference");
         edgeMappingReference.setLabel("Reference");
 
         edgeMappingReference.setUseDomainElement(true);
@@ -187,9 +196,9 @@
         layer.getEdgeMappings().add(edgeMappingReference);
 
         EdgeCreationDescription edgeCreationDescription = ToolFactory.eINSTANCE.createEdgeCreationDescription();
-        edgeCreationDescription.setName(BASE_ID + ".edge.reference.creation");
+        edgeCreationDescription.setName(baseId + ".edge.reference.creation");
         edgeCreationDescription.setLabel("Reference");
-        
+
         edgeCreationDescription.getEdgeMappings().add(edgeMappingReference);
         toolSection.getOwnedTools().add(edgeCreationDescription);
 
@@ -199,30 +208,55 @@
     private ToolSection createToolSection(Layer layer) {
         ToolSection toolSection = ToolFactory.eINSTANCE.createToolSection();
         toolSection.setLabel("Tool Section");
-        toolSection.setName(BASE_ID + ".package.toolsection");
+        toolSection.setName(baseId + ".package.toolsection");
         layer.getToolSections().add(toolSection);
         return toolSection;
     }
 
     private void createDeleteTool(ToolSection toolSection, DiagramElementMapping... mappings) {
-        DeleteElementDescription deleteElement = ToolFactory.eINSTANCE.createDeleteElementDescription();
-        deleteElement.setName(BASE_ID + "global.delete");
-        deleteElement.setLabel("Delete Tool");
-        toolSection.getOwnedTools().add(deleteElement);
+        if (!globalDeleteTool) {
+            DeleteElementDescription deleteElement = ToolFactory.eINSTANCE.createDeleteElementDescription();
+            deleteElement.setName(baseId + "global.delete");
+            deleteElement.setLabel("Delete Tool");
+            toolSection.getOwnedTools().add(deleteElement);
 
-        for (DiagramElementMapping dem : mappings) {
-            deleteElement.getMappings().add(dem);
+            for (DiagramElementMapping dem : mappings) {
+                deleteElement.getMappings().add(dem);
+            }
+        } else {
+            for (DiagramElementMapping dem : mappings) {
+                DeleteElementDescription deleteElement = ToolFactory.eINSTANCE.createDeleteElementDescription();
+
+                deleteElement.setName(baseId + ".global.delete" + "." + dem.getName());
+                deleteElement.setLabel("Delete Tool" + " " + dem.getLabel());
+                toolSection.getOwnedTools().add(deleteElement);
+
+                deleteElement.getMappings().add(dem);
+            }
         }
+
     }
 
     private void createEditTool(ToolSection toolSection, DiagramElementMapping... mappings) {
-        DirectEditLabel directEditElement = ToolFactory.eINSTANCE.createDirectEditLabel();
-        directEditElement.setName(BASE_ID + ".global.directedit");
-        directEditElement.setLabel("Edit Tool");
-        toolSection.getOwnedTools().add(directEditElement);
+        if (!globalEditTool) {
+            DirectEditLabel directEditElement = ToolFactory.eINSTANCE.createDirectEditLabel();
+            directEditElement.setName(baseId + ".global.directedit");
+            directEditElement.setLabel("Edit Tool");
+            toolSection.getOwnedTools().add(directEditElement);
 
-        for (DiagramElementMapping dem : mappings) {
-            directEditElement.getMapping().add(dem);
+            for (DiagramElementMapping dem : mappings) {
+                directEditElement.getMapping().add(dem);
+            }
+        } else {
+            for (DiagramElementMapping dem : mappings) {
+                DirectEditLabel directEditElement = ToolFactory.eINSTANCE.createDirectEditLabel();
+                directEditElement.setName(baseId + ".global.directedit" + "." + dem.getName());
+                directEditElement.setLabel("Edit Tool" + " " + dem.getLabel());
+                toolSection.getOwnedTools().add(directEditElement);
+
+                directEditElement.getMapping().add(dem);
+            }
+
         }
     }
 
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/DiagramInitializerMenu.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/DiagramInitializerMenu.java
deleted file mode 100644
index c9aff4e..0000000
--- a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/DiagramInitializerMenu.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 - Joao Martins and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation
- *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
- *******************************************************************************/
-
-package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.emf.edit.command.CommandParameter;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.sirius.editor.tools.api.menu.AbstractEObjectRefactoringAction;
-import org.eclipse.sirius.editor.tools.api.menu.AbstractMenuBuilder;
-import org.eclipse.ui.IEditorPart;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Sets;
-
-/**
- * Menu of the Initializer.
- * 
- * @author Joao Martins
- * 
- */
-public class DiagramInitializerMenu extends AbstractMenuBuilder {
-
-    /**
-     * Initializer menu label.
-     */
-    public static final String INITIALIZER_MENU_LABEL = "Initializer";
-
-    @Override
-    public String getLabel() {
-        return INITIALIZER_MENU_LABEL;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void update(final Collection newChildDescriptors, final ISelection selection, final IEditorPart editor) {
-        depopulate();
-        advancedChildActions = generateInitializerActions(selection, editor);
-    }
-
-    private Collection generateInitializerActions(final ISelection selection, final IEditorPart editor) {
-
-        // We first build all candidate Actions
-        Set<AbstractEObjectRefactoringAction> allActions = Sets.newLinkedHashSet();
-        allActions.add(new InitializerAction(editor, selection));
-
-        // We only add to the menu the actions that have a valid selection
-        return Sets.filter(allActions, new Predicate<AbstractEObjectRefactoringAction>() {
-
-            public boolean apply(AbstractEObjectRefactoringAction candidateAction) {
-                return candidateAction.isSelectionValid();
-            }
-        });
-    }
-
-    @Override
-    protected boolean isMine(CommandParameter object) {
-        return false;
-    }
-
-}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/IPatternProvider.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/IPatternProvider.java
new file mode 100644
index 0000000..600e1fe
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/IPatternProvider.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.viewpoint.description.Viewpoint;
+
+/**
+ * Interface of Pattern provider.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public interface IPatternProvider {
+
+    /**
+     * Get Id.
+     * 
+     * @return Id.
+     */
+    String getId();
+
+    /**
+     * Get Label.
+     * 
+     * @return Label.
+     */
+    String getLabel();
+
+    /**
+     * Get Description.
+     * 
+     * @return Description.
+     */
+    String getDescription();
+
+    /**
+     * Get ImagePath.
+     * 
+     * @return ImagePath.
+     */
+    String getImagePath();
+
+    /**
+     * Get the command.
+     * 
+     * @param resourceSet
+     *            the resoureSet.
+     * @param viewpoint
+     *            the selection.
+     * @return Pattern Command.
+     */
+    Command getPatternCreationCommand(ResourceSet resourceSet, Viewpoint viewpoint);
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerAction.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerAction.java
deleted file mode 100644
index 8268287..0000000
--- a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 - Joao Martins and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
- *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
- *******************************************************************************/
-
-package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.sirius.editor.tools.api.menu.AbstractEObjectRefactoringAction;
-import org.eclipse.sirius.viewpoint.description.Viewpoint;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * Action to launch the Intializer, it is valid only when the selection contains
- * one Viewpoint.
- * 
- * 
- * @author Joao Martins.
- * 
- */
-public class InitializerAction extends AbstractEObjectRefactoringAction {
-
-    /**
-     * Create the action.
-     * 
-     * @param editor
-     *            the current editor.
-     * @param selection
-     *            the current selection.
-     */
-    public InitializerAction(final IEditorPart editor, final ISelection selection) {
-        super(editor, selection);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected Command buildActionCommand(final EditingDomain arg0, final Collection<EObject> selection) {
-        Command result = UnexecutableCommand.INSTANCE;
-        setSelectionValid(false);
-        if (selection.size() == 1 && selection.iterator().next() instanceof Viewpoint) {
-            setSelectionValid(true);
-            result = new InitializerCommand(arg0.getResourceSet(), selection);
-        }
-
-        return result;
-    }
-
-}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerMenu.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerMenu.java
new file mode 100644
index 0000000..21a93a2
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerMenu.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.sirius.editor.tools.api.menu.AbstractMenuBuilder;
+import org.eclipse.sirius.viewpoint.description.Viewpoint;
+import org.eclipse.ui.IEditorPart;
+
+import com.google.common.collect.Sets;
+
+/**
+ * Menu of the Initializer.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class InitializerMenu extends AbstractMenuBuilder {
+
+    /**
+     * Initializer menu label.
+     */
+    public static final String INITIALIZER_MENU_LABEL = "Initializer";
+
+    @Override
+    public String getLabel() {
+        return INITIALIZER_MENU_LABEL;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void update(final Collection newChildDescriptors, final ISelection selection, final IEditorPart editor) {
+        depopulate();
+
+        IStructuredSelection sselection = (IStructuredSelection) selection;
+        List<?> list = sselection.toList();
+        Collection<Object> collection = new ArrayList<Object>(list);
+
+        final Collection<EObject> selected = new ArrayList<EObject>();
+        for (final Object object : collection) {
+            if (object instanceof EObject) {
+                selected.add((EObject) object);
+            }
+        }
+        if (!selected.isEmpty() && selected.iterator().next() instanceof Viewpoint) {
+            Viewpoint viewpoint = (Viewpoint) selected.iterator().next();
+            advancedChildActions = generateInitializerActions(viewpoint, editor);
+        }
+    }
+
+    private Collection generateInitializerActions(final Viewpoint viewpoint, final IEditorPart editor) {
+
+        // We first build all candidate Actions
+        Set<Action> allActions = Sets.newLinkedHashSet();
+        allActions.add(new InitializerOpenWizardAction(editor, viewpoint));
+        return allActions;
+    }
+
+    @Override
+    protected boolean isMine(CommandParameter object) {
+        return false;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerOpenWizardAction.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerOpenWizardAction.java
new file mode 100644
index 0000000..1c06e13
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerOpenWizardAction.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.sirius.viewpoint.description.Viewpoint;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Initializer Action, only work when the specifier do a right click on
+ * Viewpoint.
+ * 
+ * @author Joao Martins.
+ * 
+ */
+public class InitializerOpenWizardAction extends Action {
+
+    /**
+     * Label on menu.
+     */
+    public static final String TEXT = "Initializer";
+
+    private final Viewpoint viewpoint;
+
+    private EditingDomain editingDomain;
+
+    /**
+     * Constructor.
+     * 
+     * @param set
+     *            Editing Domain.
+     * @param viewpoint
+     *            selection.
+     */
+    public InitializerOpenWizardAction(final IEditorPart set, final Viewpoint viewpoint) {
+        super();
+        this.viewpoint = viewpoint;
+        editingDomain = ((IEditingDomainProvider) set).getEditingDomain();
+    }
+
+    @Override
+    public void run() {
+        InitializerWizard wizard = new InitializerWizard();
+        WizardDialog dialog = new WizardDialog(null, wizard);
+        dialog.create();
+        if (dialog.open() == Window.OK) {
+            IPatternProvider patternProvider = wizard.getPattern();
+            if (patternProvider != null) {
+                Command cmd = patternProvider.getPatternCreationCommand(editingDomain.getResourceSet(), viewpoint);
+                if (cmd != null && cmd.canExecute()) {
+                    editingDomain.getCommandStack().execute(cmd);
+                }
+            }
+        }
+
+    }
+
+    public String getText() {
+        return TEXT;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerPatternSelectionPage.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerPatternSelectionPage.java
new file mode 100644
index 0000000..922b380
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerPatternSelectionPage.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Select Pattern page.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class InitializerPatternSelectionPage extends WizardPage {
+
+    private Composite container;
+
+    private Combo combo;
+
+    private List<IPatternProvider> patterns;
+
+    private IPatternProvider comboSelection;
+
+    private Canvas canvas;
+
+    private Label lblDescription;
+
+    private Label lblParagra;
+
+    /**
+     * Constructor.
+     * 
+     * @param collection
+     *            selected items.
+     */
+    public InitializerPatternSelectionPage(Collection<IPatternProvider> collection) {
+        super("PatternSelection");
+        setTitle("Pattern Selection");
+        setDescription("Select a pattern to init a representation.");
+        setPageComplete(false);
+        patterns = Lists.newArrayList(collection);
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+
+        setComposite(parent);
+        setControl(container);
+
+    }
+
+    private void setComposite(Composite parent) {
+        container = new Composite(parent, SWT.NONE);        
+        
+        Label lblSelectPattern = new Label(container, SWT.NONE);
+        lblSelectPattern.setBounds(10, 20, 76, 15);
+        lblSelectPattern.setText("Select Pattern");
+
+        combo = new Combo(container, SWT.READ_ONLY);
+        combo.setBounds(88, 17, 199, 23);
+        addPatternToCombo(combo);
+        combo.addListener(SWT.Selection, new Listener() {
+
+            @Override
+            public void handleEvent(Event event) {
+                setPageComplete(getComboSelect());
+
+                canvas = new Canvas(container, SWT.NONE);
+                canvas.setBounds(240, 130, 200, 160);
+                ImageDescriptor image = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.sirius.editor.diagram", comboSelection.getImagePath());
+                Image img = new Image(container.getDisplay(), image.getImageData());
+                canvas.setBackgroundImage(img);
+
+                lblParagra = new Label(container, SWT.WRAP);
+                lblParagra.setBounds(10, 132, 220, 170);
+                lblParagra.setText(comboSelection.getDescription());
+
+                if (getComboSelection() instanceof ClassDiagramPattern)
+                    ((ClassDiagramPatternConfigurationPage) getNextPage()).setSelectedPattern((ClassDiagramPattern) getComboSelection());
+
+                getContainer().updateButtons();
+            }
+        });
+
+        lblDescription = new Label(container, SWT.NONE);
+        lblDescription.setBounds(10, 90, 76, 15);
+        lblDescription.setText("Description:");
+
+    }
+
+    /**
+     * to get the selection of the combo.
+     * 
+     * @return true or false if get a valid pattern.
+     */
+    public boolean getComboSelect() {
+        int index = combo.getSelectionIndex();
+        if (combo != null && index >= 0) {
+            comboSelection = patterns.get(index);
+            return true;
+        } else
+            return false;
+    }
+
+    /**
+     * Add patterns to combo.
+     * 
+     * @param combo
+     *            Combo on page.
+     */
+    private void addPatternToCombo(Combo comb) {
+        for (IPatternProvider pattern : patterns) {
+            comb.add(pattern.getLabel());
+        }
+    }
+
+    /**
+     * get selection.
+     * 
+     * @return command.
+     */
+    public IPatternProvider getComboSelection() {
+        return this.comboSelection;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerWizard.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerWizard.java
new file mode 100644
index 0000000..74356a6
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/initializer/InitializerWizard.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+a * Copyright (c) 2014 - Joao Martins and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Joao Martins <joaomartins27396@gmail.com>  - initial API and implementation 
+ *   Maxime Porhel <maxime.porhel@obeo.fr> Obeo - Bug 438074, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.initializer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * Initializer Wizard.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class InitializerWizard extends Wizard {
+
+    private InitializerPatternSelectionPage selectionPage;
+
+    private ClassDiagramPatternConfigurationPage configurePage;
+
+    /**
+     * Constructor.
+     */
+    public InitializerWizard() {
+        super();
+    }
+
+    @Override
+    public String getWindowTitle() {
+        return "Initializer";
+    }
+
+    @Override
+    public void addPages() {
+        selectionPage = new InitializerPatternSelectionPage(getPatternsList());
+        addPage(selectionPage);
+        configurePage = new ClassDiagramPatternConfigurationPage();
+        addPage(configurePage);
+
+    }
+
+    @Override
+    public boolean performFinish() {
+        return true;
+    }
+
+    /**
+     * Insert all patterns in a Collection.
+     * 
+     * @return the collection of all patterns.
+     */
+    public Collection<IPatternProvider> getPatternsList() {
+        Collection<IPatternProvider> newPatternList = new ArrayList<IPatternProvider>();
+
+        // creating a class Diagram pattern
+        ClassDiagramPattern pattern = new ClassDiagramPattern();
+
+        newPatternList.add(pattern);
+
+        return newPatternList;
+    }
+
+    /**
+     * Getter to selected command on selectionPage.
+     * 
+     * @return the pattern that will be initialized.
+     */
+    public IPatternProvider getPattern() {
+        return selectionPage.getComboSelection();
+    }
+
+    @Override
+    public boolean canFinish() {
+        return !(getContainer().getCurrentPage() == selectionPage);
+
+    }
+
+}