Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2015-02-13 10:17:46 -0500
committerRemi Schnekenburger2015-02-13 10:17:46 -0500
commitd98ede1f357d7efe805b4e4c4a5b445e160adcc0 (patch)
treeafd9ea099ea1d648d6da177328816efcf6c373b7
parenta5290e42357e5fef10d87bb358637b54eb4df0c9 (diff)
downloadorg.eclipse.papyrus-d98ede1f357d7efe805b4e4c4a5b445e160adcc0.tar.gz
org.eclipse.papyrus-d98ede1f357d7efe805b4e4c4a5b445e160adcc0.tar.xz
org.eclipse.papyrus-d98ede1f357d7efe805b4e4c4a5b445e160adcc0.zip
320908: [Model Explorer] Newly created objects (via "New Child" menu)
shall get focus and be in rename mode https://bugs.eclipse.org/bugs/show_bug.cgi?id=320908 - port the fix from master Change-Id: Ib5c1dd9a4b926f197f74e9815661736f49be50e6 Signed-off-by: Remi Schnekenburger <remi.schnekenburger@cea.fr>
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF67
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/RevealResultCommand.java219
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/META-INF/MANIFEST.MF50
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/build.properties17
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties2
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/plugin.xml69
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/DynamicNewChild.java3
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java87
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/handlers/DefaultSelectionHandler.java51
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/messages/Messages.java40
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java47
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java71
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java26
13 files changed, 669 insertions, 80 deletions
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
index 8b00241344a..b92cd9269a6 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
@@ -1,33 +1,34 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.infra.widgets,
- org.eclipse.papyrus.infra.widgets.creation,
- org.eclipse.papyrus.infra.widgets.databinding,
- org.eclipse.papyrus.infra.widgets.editors,
- org.eclipse.papyrus.infra.widgets.messages,
- org.eclipse.papyrus.infra.widgets.providers,
- org.eclipse.papyrus.infra.widgets.selectors,
- org.eclipse.papyrus.infra.widgets.strategy,
- org.eclipse.papyrus.infra.widgets.util,
- org.eclipse.papyrus.infra.widgets.validator
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.databinding.property;bundle-version="1.3.0",
- org.eclipse.core.databinding,
- org.eclipse.jface.databinding,
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.100",
- org.eclipse.core.resources;bundle-version="3.7.100",
- org.eclipse.ui.ide;bundle-version="3.7.0",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
- com.ibm.icu;bundle-version="4.4.2",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.2"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.2.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.infra.widgets.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.infra.widgets;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.infra.widgets,
+ org.eclipse.papyrus.infra.widgets.creation,
+ org.eclipse.papyrus.infra.widgets.databinding,
+ org.eclipse.papyrus.infra.widgets.editors,
+ org.eclipse.papyrus.infra.widgets.messages,
+ org.eclipse.papyrus.infra.widgets.providers,
+ org.eclipse.papyrus.infra.widgets.selectors,
+ org.eclipse.papyrus.infra.widgets.strategy,
+ org.eclipse.papyrus.infra.widgets.util,
+ org.eclipse.papyrus.infra.widgets.validator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.databinding.property;bundle-version="1.3.0",
+ org.eclipse.core.databinding,
+ org.eclipse.jface.databinding,
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.100",
+ org.eclipse.core.resources;bundle-version="3.7.100",
+ org.eclipse.ui.ide;bundle-version="3.7.0",
+ org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
+ com.ibm.icu;bundle-version="4.4.2",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.2",
+ org.eclipse.emf.ecore;bundle-version="2.10.1"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.0.2.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.infra.widgets.Activator
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.infra.widgets;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/RevealResultCommand.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/RevealResultCommand.java
new file mode 100644
index 00000000000..324a02ac7ae
--- /dev/null
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/RevealResultCommand.java
@@ -0,0 +1,219 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.widgets.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandWrapper;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * Wrapper to reveal the results (using with reveal semantic protocol) after a command in View.
+ *
+ * @author Gabriel Pascual
+ */
+public class RevealResultCommand extends CommandWrapper {
+
+ /** The view part. */
+ private IViewPart viewPart = null;
+
+ /** The source object. */
+ private Object sourceObject = null;
+
+ /** The reveal all results. */
+ private boolean revealAllResults = false;
+
+ /**
+ * Constructor.
+ *
+ * @param command
+ */
+ public RevealResultCommand(Command command, IViewPart part, Object editObject) {
+ super("Select result", command);
+ viewPart = part;
+ sourceObject = editObject;
+ }
+
+ /**
+ * Sets the reveal all results.
+ *
+ * @param revealAllResults
+ * the revealAllResults to set
+ */
+ private void setRevealAllResults(boolean revealAllResults) {
+ this.revealAllResults = revealAllResults;
+ }
+
+ /**
+ * Wrap.
+ *
+ * @param command
+ * the command
+ * @param part
+ * the part
+ * @param container
+ * the container
+ * @param revealAllResults
+ * the reveal all results
+ * @return the command
+ */
+ public static Command wrap(Command command, IViewPart part, EObject container, boolean revealAllResults) {
+ RevealResultCommand wrappedCommand = new RevealResultCommand(command, part, container);
+ wrappedCommand.setRevealAllResults(revealAllResults);
+ return wrappedCommand;
+ }
+
+ /**
+ * Wrap.
+ *
+ * @param command
+ * the command
+ * @param part
+ * the part
+ * @param container
+ * the container
+ * @return the command
+ */
+ public static Command wrap(Command command, IViewPart part, EObject container) {
+ return new RevealResultCommand(command, part, container);
+ }
+
+ /**
+ * Wrap.
+ *
+ * @param command
+ * the command
+ * @param part
+ * the part
+ * @return the command
+ */
+ public static Command wrap(Command command, IViewPart part) {
+ return wrap(command, part, null);
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.CommandWrapper#execute()
+ *
+ */
+ @Override
+ public void execute() {
+
+ super.execute();
+ selectResult();
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.CommandWrapper#undo()
+ *
+ */
+ @Override
+ public void undo() {
+ super.undo();
+ selectSource();
+ }
+
+ /**
+ * @see org.eclipse.emf.common.command.CommandWrapper#redo()
+ *
+ */
+ @Override
+ public void redo() {
+ super.redo();
+ selectResult();
+ }
+
+ /**
+ * Reveal target.
+ *
+ * @param target
+ * the target
+ */
+ private void revealTarget(final List<?> target) {
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+
+ if (viewPart instanceof IRevealSemanticElement) {
+ ((IRevealSemanticElement) viewPart).revealSemanticElement(target);
+
+ }
+
+ }
+ });
+ }
+
+ /**
+ * Select command result.
+ */
+ private void selectResult() {
+ Collection<?> results = getResultsCommand();
+ if (!results.isEmpty()) {
+ if (revealAllResults) {
+ revealTarget(Arrays.asList(results.toArray()));
+
+ } else {
+
+
+ Iterator<?> resultIterator = results.iterator();
+
+ // Get first result
+ final Object result = resultIterator.next();
+ revealTarget(Arrays.asList(new Object[] { result }));
+ }
+
+ }
+ }
+
+ /**
+ * Gets the results command.
+ *
+ * @return the results command
+ */
+ private Collection<?> getResultsCommand() {
+
+ // Get results list
+ Collection<?> resultsCommand = getResult();
+ if (getResult().isEmpty()) {
+
+ // Get affected objects list if it is not a command with result
+ resultsCommand = getAffectedObjects();
+ }
+
+ return resultsCommand;
+ }
+
+ /**
+ * Select source.
+ */
+ private void selectSource() {
+
+ if (sourceObject != null) {
+ revealTarget(Arrays.asList(new Object[] { sourceObject }));
+
+ } else if (!getAffectedObjects().isEmpty()) {
+
+ // Try with the affected objects
+ revealTarget(Arrays.asList(getAffectedObjects().toArray()));
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/META-INF/MANIFEST.MF b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/META-INF/MANIFEST.MF
index 0c81b6b0609..bd8e8232184 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/META-INF/MANIFEST.MF
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/META-INF/MANIFEST.MF
@@ -1,24 +1,26 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.emf.transaction,
- org.eclipse.papyrus.infra.core;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.2",
- org.eclipse.papyrus.uml.service.types;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2",
- org.eclipse.gmf.runtime.common.core,
- org.eclipse.gmf.runtime.emf.type.core,
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.newchild;bundle-version="1.0.2"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.2.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.views.modelexplorer.newchild.Activator
-Bundle-Description: The purpose of this plugin is to do the connection with the model explorer is org.eclipse.papyrus.view.modelexplorer.newchild. More documentation (models and file.doc) has been store in the docs directory of the plugin org.eclipse.papyrus.infra.newchild
-Bundle-SymbolicName: org.eclipse.papyrus.views.modelexplorer.newchild;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.transaction,
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.2",
+ org.eclipse.papyrus.uml.service.types;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2",
+ org.eclipse.gmf.runtime.common.core,
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.newchild;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.0.2",
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="1.0.2"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.0.2.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.views.modelexplorer.newchild.Activator
+Bundle-Description: The purpose of this plugin is to do the connection with the model explorer is org.eclipse.papyrus.view.modelexplorer.newchild. More documentation (models and file.doc) has been store in the docs directory of the plugin org.eclipse.papyrus.infra.newchild
+Bundle-SymbolicName: org.eclipse.papyrus.views.modelexplorer.newchild;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/build.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/build.properties
index 653ec3c3daf..a71730a671f 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/build.properties
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/build.properties
@@ -1,8 +1,9 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- about.html,\
- plugin.properties
-src.includes = about.html
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html,\
+ plugin.properties,\
+ messages.properties
+src.includes = about.html
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties
new file mode 100644
index 00000000000..c425ccb8551
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/messages.properties
@@ -0,0 +1,2 @@
+NewChildPreferencePage.desciption=Behaviour after creation of a new child in the model:
+NewChildPreferencePage.selection.label=Select the new element(s)
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/plugin.xml b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/plugin.xml
index bd442c984e7..7f2428bff3f 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/plugin.xml
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/plugin.xml
@@ -1,14 +1,55 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-<extension point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?before=org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram">
- <dynamic
- class="org.eclipse.papyrus.views.modelexplorer.newchild.DynamicNewChild"
- id="org.eclipse.papyrus.views.modelexplorer.newchild.dynamic">
- </dynamic>
- </menuContribution>
- </extension>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+<extension point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?before=org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram">
+ <dynamic
+ class="org.eclipse.papyrus.views.modelexplorer.newchild.DynamicNewChild"
+ id="org.eclipse.papyrus.views.modelexplorer.newchild.dynamic">
+ </dynamic>
+ </menuContribution>
+ </extension>
+<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.papyrus.views.modelexplorer.preferences.NavigatorPreferencePage"
+ class="org.eclipse.papyrus.views.modelexplorer.newchild.preferences.NewChildPreferencePage"
+ id="org.eclipse.papyrus.views.modelexplorer.preferences.selection"
+ name="New Child Menu Preferences...">
+ </page>
+</extension>
+<extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.papyrus.views.modelexplorer.newchild.preferences.NewChildPreferenceInitializer">
+ </initializer>
+</extension>
+<extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.papyrus.views.modelexplorer.modelexplorer?after=additions">
+ <command
+ commandId="org.eclipse.papyrus.views.modelexplorer.newchild.defaultSelection"
+ label="New Child Menu Preferences..."
+ style="push">
+ </command>
+ </menuContribution>
+</extension>
+<extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.views.modelexplorer.newchild.handlers.DefaultSelectionHandler"
+ commandId="org.eclipse.papyrus.views.modelexplorer.newchild.defaultSelection">
+ </handler>
+</extension>
+<extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.papyrus.views.modelexplorer.newchild.defaultSelection"
+ name="New Child Preferences">
+ </command>
+</extension>
+</plugin>
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/DynamicNewChild.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/DynamicNewChild.java
index b64bbfb2986..d053284e784 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/DynamicNewChild.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/DynamicNewChild.java
@@ -10,6 +10,7 @@
*
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 413703
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Bug 436954
*
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.newchild;
@@ -81,7 +82,7 @@ public class DynamicNewChild extends ContributionItem {
public void fill(Menu menu, int index) {
EObject eObject = getSelection();
if (eObject != null) {
- CreationMenuFactory creationMenuFactory = new CreationMenuFactory(editingDomain);
+ CreationMenuFactory creationMenuFactory = new ModelExplorerMenuFactory(editingDomain);
ArrayList<Folder> folders = creationMenuRegistry.getRootFolder();
Iterator<Folder> iterFolder = folders.iterator();
while (iterFolder.hasNext()) {
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java
new file mode 100644
index 00000000000..d4ba25ed35d
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/ModelExplorerMenuFactory.java
@@ -0,0 +1,87 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.newchild.CreationMenuFactory;
+import org.eclipse.papyrus.infra.widgets.util.RevealResultCommand;
+import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.MultiViewPageBookView;
+import org.eclipse.papyrus.views.modelexplorer.newchild.preferences.NewChildPreferences;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Override of creation menu factory to select created element in Model Explorer view.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public class ModelExplorerMenuFactory extends CreationMenuFactory {
+
+ /**
+ * Default constructor.
+ *
+ * @param editingDomain
+ */
+ public ModelExplorerMenuFactory(TransactionalEditingDomain editingDomain) {
+ super(editingDomain);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.newchild.CreationMenuFactory#buildCommand(org.eclipse.emf.ecore.EReference, org.eclipse.emf.ecore.EObject, java.lang.String)
+ *
+ * @param reference
+ * @param container
+ * @param extendedType
+ * @return
+ */
+ @Override
+ protected Command buildCommand(EReference reference, EObject container, String extendedType) {
+ Command buildCommand = super.buildCommand(reference, container, extendedType);
+
+ boolean defaultSelectionPreference = Activator.getDefault().getPreferenceStore().getBoolean(NewChildPreferences.DEFAULT_SELECTION);
+
+ if (defaultSelectionPreference) {
+
+ IViewPart viewPart = getActiveViewPart();
+ // Wrap command to select created element
+ buildCommand = RevealResultCommand.wrap(buildCommand, viewPart, container);
+ }
+
+ return buildCommand;
+ }
+
+
+ /**
+ * Gets the active view part.
+ *
+ * @return the active view part
+ */
+ private IViewPart getActiveViewPart() {
+ IViewPart activeView = null;
+ // Get Model Explorer view part
+ IViewPart modelExplorerView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ModelExplorerPageBookView.VIEW_ID);
+
+ if (modelExplorerView instanceof MultiViewPageBookView) {
+ MultiViewPageBookView pageBook = (MultiViewPageBookView) modelExplorerView;
+ activeView = pageBook.getActiveView();
+ }
+
+ return activeView;
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/handlers/DefaultSelectionHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/handlers/DefaultSelectionHandler.java
new file mode 100644
index 00000000000..1b06119ad2c
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/handlers/DefaultSelectionHandler.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+/**
+ * Handler to open default selection preference page through a menu in Model Explorer.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public class DefaultSelectionHandler extends AbstractHandler {
+
+ /** The Constant PREFERENCES_SELECTION_PAGE_ID. */
+ private static final String PREFERENCES_SELECTION_PAGE_ID = "org.eclipse.papyrus.views.modelexplorer.preferences.selection"; //$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(Display.getDefault().getActiveShell(), PREFERENCES_SELECTION_PAGE_ID, null, null);
+ if (dialog != null) {
+ dialog.open();
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/messages/Messages.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/messages/Messages.java
new file mode 100644
index 00000000000..5a17e9abca9
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/messages/Messages.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net- Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild.messages;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Externalisation of string.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public class Messages {
+ private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java
new file mode 100644
index 00000000000..8d6220631d0
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferenceInitializer.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.views.modelexplorer.newchild.Activator;
+
+/**
+ * Initialiser for new child preferences in Model Explorer.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public class NewChildPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Constructor.
+ *
+ */
+ public NewChildPreferenceInitializer() {
+ super();
+ }
+
+ /**
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ *
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setDefault(NewChildPreferences.DEFAULT_SELECTION, true);
+
+ }
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java
new file mode 100644
index 00000000000..7ca0d19571a
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferencePage.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild.preferences;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.papyrus.views.modelexplorer.newchild.Activator;
+import org.eclipse.papyrus.views.modelexplorer.newchild.messages.Messages;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Preference page to define enable/disable default selection in Model Explorer.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public class NewChildPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ /** The Constant DEFAULT_SELECTION_LABEL. */
+ private static final String DEFAULT_SELECTION_LABEL = Messages.getString("NewChildPreferencePage.selection.label"); //$NON-NLS-1$
+
+ /** The Constant PAGE_DESCRIPTION. */
+ private static final String PAGE_DESCRIPTION = Messages.getString("NewChildPreferencePage.desciption"); //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ */
+ public NewChildPreferencePage() {
+ super();
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ *
+ * @param workbench
+ */
+ @Override
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ setDescription(PAGE_DESCRIPTION);
+
+ }
+
+ /**
+ * Creates the field editors.
+ *
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ @Override
+ protected void createFieldEditors() {
+ addField(new BooleanFieldEditor(NewChildPreferences.DEFAULT_SELECTION, DEFAULT_SELECTION_LABEL, getFieldEditorParent()));
+
+ }
+
+
+
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java
new file mode 100644
index 00000000000..f6012323b70
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/preferences/NewChildPreferences.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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:
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.views.modelexplorer.newchild.preferences;
+
+/**
+ * Preference's keys for new child behaviour of Model Explorer view.
+ *
+ * @author Gabriel Pascual
+ *
+ */
+public interface NewChildPreferences {
+
+ /** The Constant DEFAULT_SELECTION. */
+ public static final String DEFAULT_SELECTION = "defaultSelection"; //$NON-NLS-1$
+}

Back to the top