Merge branch 'master' into gsoc2014
diff --git a/plugins/org.eclipse.sirius.editor.diagram/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.editor.diagram/META-INF/MANIFEST.MF
index 030208f..6e8e4a5 100644
--- a/plugins/org.eclipse.sirius.editor.diagram/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.sirius.editor.diagram/META-INF/MANIFEST.MF
@@ -138,6 +138,7 @@
  org.eclipse.sirius.diagram.editor.tools.internal.editor;x-internal:=true;version="2.0.0",
  org.eclipse.sirius.diagram.editor.tools.internal.menu.child;x-internal:=true;version="2.0.0",
  org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring;x-internal:=true;version="2.0.0",
- org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.border;x-internal:=true;version="2.0.0"
+ org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.border;x-internal:=true;version="2.0.0",
+ org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;x-internal:=true;version="2.0.0"
 Import-Package: org.eclipse.sirius.ext.base;version="2.0.0",
  org.eclipse.sirius.ext.swt;version="2.0.0"
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/DiagramRefactoringMenu.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/DiagramRefactoringMenu.java
index e6a5368..c1320f0 100644
--- a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/DiagramRefactoringMenu.java
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/DiagramRefactoringMenu.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES 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
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *    Obeo - initial API and implementation
+ *    Joao Martins <joaomartins27396@gmail.com> - Bug 434698
  *******************************************************************************/
 package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring;
 
@@ -16,6 +17,9 @@
 import org.eclipse.emf.edit.command.CommandParameter;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.border.BorderRefactoringAction;
+import org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping.GroupIntoToolGroupAction;
+import org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping.GroupIntoToolGroupExtensionAction;
+import org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping.GroupIntoToolSectionAction;
 import org.eclipse.sirius.editor.tools.api.menu.AbstractEObjectRefactoringAction;
 import org.eclipse.sirius.editor.tools.api.menu.AbstractMenuBuilder;
 import org.eclipse.sirius.editor.tools.internal.menu.refactoring.RefactoringMenu;
@@ -55,6 +59,10 @@
         allActions.add(new BorderRefactoringAction(editor, selection));
         allActions.add(new EdgeMappingRefactoringAction(editor, selection));
 
+        allActions.add(new GroupIntoToolSectionAction(editor, selection));
+        allActions.add(new GroupIntoToolGroupAction(editor, selection));
+        allActions.add(new GroupIntoToolGroupExtensionAction(editor, selection));
+
         // We only add to the menu the actions that have a valid selection
         return Sets.filter(allActions, new Predicate<AbstractEObjectRefactoringAction>() {
 
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/AbstractToolGroupIntoAction.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/AbstractToolGroupIntoAction.java
new file mode 100644
index 0000000..d46277d
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/AbstractToolGroupIntoAction.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+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.business.api.query.EObjectQuery;
+import org.eclipse.sirius.diagram.description.tool.ToolPackage;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.sirius.editor.tools.api.menu.AbstractEObjectRefactoringAction;
+import org.eclipse.sirius.ext.base.Option;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Useful to the creation of the ToolGroupIntoActions.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public abstract class AbstractToolGroupIntoAction extends AbstractEObjectRefactoringAction {
+
+    /**
+     * Constructor.
+     * 
+     * @param editor
+     *            the current editor.
+     * @param selection
+     *            the current selection.
+     */
+
+    public AbstractToolGroupIntoAction(IEditorPart editor, ISelection selection) {
+        super(editor, selection);
+    }
+
+    @Override
+    protected Command buildActionCommand(EditingDomain arg0, Collection<EObject> selection) {
+        Command result = UnexecutableCommand.INSTANCE;
+        ToolSection foundParent = findParentSection(selection);
+        setSelectionValid(false);
+        if (selection.size() > 1) {
+            // we only want to display this action when we have several items
+            // selected
+            if (foundParent != null) {
+                setSelectionValid(true);
+                result = createGroupIntoCommand(arg0, foundParent, selection);
+            }
+        }
+        return result;
+
+    }
+
+    /**
+     * Get the action Command.
+     * 
+     * @param arg0
+     *            Domain.
+     * @param parent
+     *            ToolSection.
+     * @param selection
+     *            the current selection.
+     * @return the action Command.
+     */
+    protected abstract Command createGroupIntoCommand(EditingDomain arg0, ToolSection parent, Collection<EObject> selection);
+
+    /**
+     * This is useful to find a Parent(ToolSection) to group all selected tools.
+     * 
+     * @param selection
+     *            the current selection.
+     * @return Return the parent if can be found otherwise return null.
+     */
+    protected ToolSection findParentSection(Collection<EObject> selection) {
+        Option<EObject> toolsection;
+        for (EObject tool : selection) {
+            toolsection = new EObjectQuery(tool).getFirstAncestorOfType(ToolPackage.eINSTANCE.getToolSection());
+            if (toolsection.some()) {
+                return (ToolSection) toolsection.get();
+            }
+        }
+        return null;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/AbstractToolGroupIntoCommand.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/AbstractToolGroupIntoCommand.java
new file mode 100644
index 0000000..3d4c3b1
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/AbstractToolGroupIntoCommand.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.sirius.editor.tools.api.menu.AbstractUndoRecordingCommand;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * Useful to create GroupingCommands.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public abstract class AbstractToolGroupIntoCommand extends AbstractUndoRecordingCommand {
+    /**
+     * Selected items to group.
+     */
+    protected Collection<EObject> selection;
+
+    /**
+     * Tool section in which the created item will be added.
+     */
+    protected ToolSection parent;
+
+    /**
+     * Constructor.
+     * 
+     * @param set
+     *            the current resourceset.
+     * @param parent
+     *            ToolSection to group the selection.
+     * @param selection
+     *            the current selection.
+     */
+    public AbstractToolGroupIntoCommand(ResourceSet set, ToolSection parent, Collection<EObject> selection) {
+        super(set);
+        this.selection = selection;
+        this.parent = parent;
+    }
+
+    /**
+     * Checks current selection to determine if action can be executed.
+     * 
+     * @return true if selection is valid.
+     */
+    public boolean canExecute() {
+        boolean canExecute = false;
+        if (selection != null) {
+            canExecute = Iterables.all(selection, getSelectionFilter());
+        }
+        return canExecute;
+    }
+
+    /**
+     * To know the Selection.
+     * 
+     * @return the Selection depending of the action command.
+     */
+    protected abstract Predicate<Object> getSelectionFilter();
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupAction.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupAction.java
new file mode 100644
index 0000000..d59f162
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupAction.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * This action allows the user to group several tools (AbstractToolDescription)
+ * into a new ToolGroup.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class GroupIntoToolGroupAction extends AbstractToolGroupIntoAction {
+
+    /**
+     * Constructor.
+     * 
+     * @param editor
+     *            the current editor.
+     * @param selection
+     *            the current selection.
+     */
+    public GroupIntoToolGroupAction(final IEditorPart editor, final ISelection selection) {
+        super(editor, selection);
+        setTextIfDisable(GroupIntoToolGroupCommand.TEXT);
+    }
+
+    @Override
+    protected Command createGroupIntoCommand(EditingDomain arg0, ToolSection parent, Collection<EObject> selection) {
+        return new GroupIntoToolGroupCommand(arg0.getResourceSet(), parent, selection);
+    }
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupCommand.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupCommand.java
new file mode 100644
index 0000000..dadff06
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupCommand.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.diagram.description.tool.ToolFactory;
+import org.eclipse.sirius.diagram.description.tool.ToolGroup;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * Group the current selection on ToolGroup.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class GroupIntoToolGroupCommand extends AbstractToolGroupIntoCommand {
+
+    /**
+     * Label of this command.
+     */
+    public static final String TEXT = "Group into a new Tool Group";
+
+    /**
+     * Constructor.
+     * 
+     * @param set
+     *            the current resourceset.
+     * @param parent
+     *            ToolSection to group the selection.
+     * @param selection
+     *            the current selection.
+     */
+    public GroupIntoToolGroupCommand(ResourceSet set, ToolSection parent, Collection<EObject> selection) {
+        super(set, parent, selection);
+    }
+
+    @Override
+    protected void doExecute() {
+        ToolGroup toolGroup = ToolFactory.eINSTANCE.createToolGroup();
+        Iterables.addAll(toolGroup.getTools(), Iterables.filter(selection, AbstractToolDescription.class));
+        this.parent.getOwnedTools().add(toolGroup);
+    }
+
+    protected Predicate<Object> getSelectionFilter() {
+        return Predicates.instanceOf(AbstractToolDescription.class);
+    }
+
+    @Override
+    protected String getText() {
+        return TEXT;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupExtensionAction.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupExtensionAction.java
new file mode 100644
index 0000000..1320015
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupExtensionAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * This action allows the user to group several tools (AbstractToolDescription)
+ * into a new ToolGroupExtension.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class GroupIntoToolGroupExtensionAction extends AbstractToolGroupIntoAction {
+
+    /**
+     * Constructor.
+     * 
+     * @param editor
+     *            the current editor.
+     * @param selection
+     *            the current selection.
+     */
+    public GroupIntoToolGroupExtensionAction(final IEditorPart editor, final ISelection selection) {
+        super(editor, selection);
+        setTextIfDisable(GroupIntoToolGroupExtensionCommand.TEXT);
+    }
+
+    @Override
+    protected Command createGroupIntoCommand(EditingDomain arg0, ToolSection parent, Collection<EObject> selection) {
+        return new GroupIntoToolGroupExtensionCommand(arg0.getResourceSet(), parent, selection);
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupExtensionCommand.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupExtensionCommand.java
new file mode 100644
index 0000000..dc4fb92
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolGroupExtensionCommand.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.diagram.description.tool.ToolFactory;
+import org.eclipse.sirius.diagram.description.tool.ToolGroupExtension;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * Group the current selection on ToolGroupExtension.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class GroupIntoToolGroupExtensionCommand extends AbstractToolGroupIntoCommand {
+
+    /**
+     * Label of this command.
+     */
+    public static final String TEXT = "Group into a new Tool Group Extension";
+
+    /**
+     * Constructor.
+     * 
+     * @param set
+     *            the current resourceset.
+     * @param parent
+     *            ToolSection to group the selection.
+     * @param selection
+     *            the current selection.
+     */
+    public GroupIntoToolGroupExtensionCommand(ResourceSet set, ToolSection parent, Collection<EObject> selection) {
+        super(set, parent, selection);
+    }
+
+    @Override
+    protected void doExecute() {
+        ToolGroupExtension toolgroupExtension = ToolFactory.eINSTANCE.createToolGroupExtension();
+        Iterables.addAll(toolgroupExtension.getTools(), Iterables.filter(selection, AbstractToolDescription.class));
+        this.parent.getGroupExtensions().add(toolgroupExtension);
+    }
+
+    protected Predicate<Object> getSelectionFilter() {
+        return Predicates.instanceOf(AbstractToolDescription.class);
+    }
+
+    @Override
+    protected String getText() {
+        return TEXT;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolSectionAction.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolSectionAction.java
new file mode 100644
index 0000000..f720fd2
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolSectionAction.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * This action allows the user to group several tools (ToolEntry) into a new
+ * ToolSection.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class GroupIntoToolSectionAction extends AbstractToolGroupIntoAction {
+
+    /**
+     * Constructor.
+     * 
+     * @param editor
+     *            the current editor.
+     * @param selection
+     *            the current selection.
+     */
+    public GroupIntoToolSectionAction(final IEditorPart editor, final ISelection selection) {
+        super(editor, selection);
+        setTextIfDisable(GroupIntoToolSectionCommand.TEXT);
+    }
+
+    @Override
+    protected Command createGroupIntoCommand(EditingDomain arg0, ToolSection parent, Collection<EObject> selection) {
+        return new GroupIntoToolSectionCommand(arg0.getResourceSet(), parent, selection);
+    }
+}
diff --git a/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolSectionCommand.java b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolSectionCommand.java
new file mode 100644
index 0000000..b95610b
--- /dev/null
+++ b/plugins/org.eclipse.sirius.editor.diagram/src/org/eclipse/sirius/diagram/editor/tools/internal/menu/refactoring/grouping/GroupIntoToolSectionCommand.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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 434698, remarks and correction during review.
+ *******************************************************************************/
+
+package org.eclipse.sirius.diagram.editor.tools.internal.menu.refactoring.grouping;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.sirius.diagram.description.tool.ToolFactory;
+import org.eclipse.sirius.diagram.description.tool.ToolSection;
+import org.eclipse.sirius.viewpoint.description.tool.ToolEntry;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * Group the current selection on ToolSection.
+ * 
+ * @author Joao Martins
+ * 
+ */
+public class GroupIntoToolSectionCommand extends AbstractToolGroupIntoCommand {
+
+    /**
+     * Label of this command.
+     */
+    public static final String TEXT = "Group into a new Tool Section";
+
+    /**
+     * Constructor.
+     * 
+     * @param set
+     *            the current resourceset.
+     * @param parent
+     *            ToolSection to group the selection.
+     * @param selection
+     *            the current selection.
+     */
+    public GroupIntoToolSectionCommand(ResourceSet set, ToolSection parent, Collection<EObject> selection) {
+        super(set, parent, selection);
+    }
+
+    @Override
+    protected void doExecute() {
+        ToolSection toolSection = ToolFactory.eINSTANCE.createToolSection();
+        Iterables.addAll(toolSection.getOwnedTools(), Iterables.filter(selection, ToolEntry.class));
+        this.parent.getSubSections().add(toolSection);
+    }
+
+    protected Predicate<Object> getSelectionFilter() {
+        return Predicates.instanceOf(ToolEntry.class);
+    }
+
+    @Override
+    protected String getText() {
+        return TEXT;
+    }
+
+}
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/tools/internal/presentation/CustomSiriusActionBarContributor.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/tools/internal/presentation/CustomSiriusActionBarContributor.java
index 397d62a..1660cff 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/tools/internal/presentation/CustomSiriusActionBarContributor.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/tools/internal/presentation/CustomSiriusActionBarContributor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2014 THALES GLOBAL SERVICES 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
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *    Obeo - initial API and implementation
+ *    Joao Martins <joaomartins27396@gmail.com> - Bug 434698
  *******************************************************************************/
 package org.eclipse.sirius.editor.tools.internal.presentation;
 
@@ -337,12 +338,17 @@
         depopulateMenus();
         Collection<?> newChildDescriptors = null;
 
-        if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
-            final Object object = ((IStructuredSelection) selection).getFirstElement();
+        if (selection instanceof IStructuredSelection) {
+            IStructuredSelection stsel = (IStructuredSelection) selection;
+            if (stsel.size() == 1) {
+                final Object object = ((IStructuredSelection) selection).getFirstElement();
 
-            final EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain();
+                final EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain();
 
-            newChildDescriptors = domain.getNewChildDescriptors(object, null);
+                newChildDescriptors = domain.getNewChildDescriptors(object, null);
+            } else if (stsel.size() > 1) {
+                newChildDescriptors = Lists.newArrayList();
+            }
         }
 
         // Generate actions for selection; populate and redraw the menus.