Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-04-29 13:56:09 +0000
committerCamille Letavernier2014-04-29 13:56:09 +0000
commit8f6b3539b5493f0ee4ed7324478371dcc6f2f7d0 (patch)
tree285b01c317ffcf0e01db302e8736a1509be4b632 /plugins/views
parent8ac0c599683e975713f09c629fc361f5b53b758d (diff)
downloadorg.eclipse.papyrus-8f6b3539b5493f0ee4ed7324478371dcc6f2f7d0.tar.gz
org.eclipse.papyrus-8f6b3539b5493f0ee4ed7324478371dcc6f2f7d0.tar.xz
org.eclipse.papyrus-8f6b3539b5493f0ee4ed7324478371dcc6f2f7d0.zip
351803: [UI Customizability] Papyrus shall provide a customizable "New
Child" menu within model explorer view https://bugs.eclipse.org/bugs/show_bug.cgi?id=351803 - Trivial: fix a NPE when the selection is empty
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer.newchild/src/org/eclipse/papyrus/views/modelexplorer/newchild/DynamicNewChild.java23
1 files changed, 12 insertions, 11 deletions
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 831bb1dc4ae..a56189c6ab3 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
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 413703
*
@@ -47,7 +47,7 @@ public class DynamicNewChild extends ContributionItem {
protected CreationMenuRegistry creationMenuRegistry;
/**
- *
+ *
* Constructor.
*
*/
@@ -56,7 +56,7 @@ public class DynamicNewChild extends ContributionItem {
}
/**
- *
+ *
* Constructor.
*
* @param id
@@ -70,27 +70,28 @@ public class DynamicNewChild extends ContributionItem {
return new IContributionItem[0];
}
+ @Override
public boolean isDynamic() {
return true;
}
+ @Override
public void fill(Menu menu, int index) {
EObject eObject = getSelection();
- if( eObject!=null){
+ if(eObject != null) {
CreationMenuFactory creationMenuFactory = new CreationMenuFactory(editingDomain);
ArrayList<Folder> folders = creationMenuRegistry.getRootFolder();
Iterator<Folder> iterFolder = folders.iterator();
while(iterFolder.hasNext()) {
Folder currentFolder = iterFolder.next();
- boolean hasbeenBuild=creationMenuFactory.populateMenu(menu, currentFolder, eObject, index);
- if( hasbeenBuild){
+ boolean hasbeenBuild = creationMenuFactory.populateMenu(menu, currentFolder, eObject, index);
+ if(hasbeenBuild) {
index++;
}
}
- }
- else{
+ } else {
super.fill(menu, index);
}
}
@@ -100,7 +101,7 @@ public class DynamicNewChild extends ContributionItem {
/**
* getSelected eObject in the model explorer
- *
+ *
* @return eObject or null
*/
protected EObject getSelection() {
@@ -123,8 +124,8 @@ public class DynamicNewChild extends ContributionItem {
try {
editingDomain = ServiceUtilsForEObject.getInstance().getService(org.eclipse.emf.transaction.TransactionalEditingDomain.class, editingDomainCitizen);
- } catch (Throwable ex) {
- Activator.log.error("Impossible to get the Transactional Editing Domain.", ex);
+ } catch (Exception ex) {
+ //Nothing to do. We can't handle this case
}
return selectedEObject;
}

Back to the top