Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-07-13 04:36:18 -0400
committerQuentin Le Menez2018-11-12 04:56:14 -0500
commit06a76e61edc6786f78ffaf329e5d7d565a7d2b17 (patch)
treebc44b26cada3e91e4d6dae8c92c6c9d87034e9e0
parent739596f2e83e679a30cf3da818d42a4f23bbedbf (diff)
downloadorg.eclipse.papyrus-06a76e61edc6786f78ffaf329e5d7d565a7d2b17.tar.gz
org.eclipse.papyrus-06a76e61edc6786f78ffaf329e5d7d565a7d2b17.tar.xz
org.eclipse.papyrus-06a76e61edc6786f78ffaf329e5d7d565a7d2b17.zip
Bug 393750: [TextEditors] NPE in MessagePopupEditor when the Message
name is null Change-Id: I7d7a56f4cee2515d19073ab69e79349e5cab2879 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.message.xtext.ui/src/org/eclipse/papyrus/uml/textedit/message/xtext/ui/contributions/MessagePopupEditor.java32
1 files changed, 18 insertions, 14 deletions
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.message.xtext.ui/src/org/eclipse/papyrus/uml/textedit/message/xtext/ui/contributions/MessagePopupEditor.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.message.xtext.ui/src/org/eclipse/papyrus/uml/textedit/message/xtext/ui/contributions/MessagePopupEditor.java
index 3969587e49e..b44a2bf4558 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.message.xtext.ui/src/org/eclipse/papyrus/uml/textedit/message/xtext/ui/contributions/MessagePopupEditor.java
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.message.xtext.ui/src/org/eclipse/papyrus/uml/textedit/message/xtext/ui/contributions/MessagePopupEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2018 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Saadia Dhouib (CEA LIST) saadia.dhouib@cea.fr - Initial API and implementation
- * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905, 393750
*
*****************************************************************************/
package org.eclipse.papyrus.uml.textedit.message.xtext.ui.contributions;
@@ -56,13 +56,13 @@ public class MessagePopupEditor extends DefaultXtextDirectEditorConfiguration {
MessageRule messageRuleObject = (MessageRule) xtextObject;
// Retrieves the information to be populated in modelObject
- String newName = "" + messageRuleObject.getName();
+ String newName = "" + messageRuleObject.getName(); //$NON-NLS-1$
int ocnumber = messageRuleObject.getSequenceTerm().get(0).getSequencialOrder();
- String ocname = "";
+ String ocname = ""; //$NON-NLS-1$
- String newSequenceTermList = "";
+ String newSequenceTermList = ""; //$NON-NLS-1$
int i = 0;
String recurrence;
for (i = 0; i < messageRuleObject.getSequenceTerm().size(); i++) {
@@ -76,7 +76,7 @@ public class MessagePopupEditor extends DefaultXtextDirectEditorConfiguration {
if ((i == 0)) {
newSequenceTermList = newSequenceTermList + ocnumber + ocname;
} else {
- newSequenceTermList = newSequenceTermList + '.' + ocnumber + ocname;
+ newSequenceTermList = newSequenceTermList + '.' + ocnumber + ocname; // $NON-NLS-1$
}
}
@@ -95,7 +95,11 @@ public class MessagePopupEditor extends DefaultXtextDirectEditorConfiguration {
public String getTextToEdit(Object editedObject) {
if (editedObject instanceof Message) {
- String texttoedit = UMLLabelInternationalization.getInstance().getLabel(((Message) editedObject)).trim();
+ String name = UMLLabelInternationalization.getInstance().getLabel(((Message) editedObject));
+ if (null == name) {
+ name = ""; //$NON-NLS-1$
+ }
+ String texttoedit = name.trim();
Interaction interaction = ((Message) editedObject).getInteraction();
@@ -104,16 +108,16 @@ public class MessagePopupEditor extends DefaultXtextDirectEditorConfiguration {
sequencenumber++;
Message childElement = (Message) it.next();
if (childElement.equals(editedObject)) {
- if ((texttoedit.charAt(0) >= 48) && (texttoedit.charAt(0) <= 57)) {
+ if (!texttoedit.isEmpty() && Character.isDigit(texttoedit.charAt(0))) {
return texttoedit;
} else {
- return texttoedit = sequencenumber + ":" + texttoedit;
+ return texttoedit = sequencenumber + ":" + texttoedit; //$NON-NLS-1$
}
}
}
}
- return "not a Message";
+ return "not a Message"; //$NON-NLS-1$
}
/**
@@ -129,16 +133,16 @@ public class MessagePopupEditor extends DefaultXtextDirectEditorConfiguration {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException {
- if(InternationalizationPreferencesUtils.getInternationalizationPreference(message) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(message)){
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(message) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(message)) {
UMLLabelInternationalization.getInstance().setLabel(message, newName, null);
- }else{
- this.message.setName(newSequenceTermList + ':' + newName);
+ } else {
+ this.message.setName(newSequenceTermList + ':' + newName); // $NON-NLS-1$
}
return CommandResult.newOKCommandResult(message);
}
public UpdateUMLMessageCommand(Message message, String newName, String newSequenceTermList) {
- super(TransactionUtil.getEditingDomain(message), "Message Update", getWorkspaceFiles(message));
+ super(TransactionUtil.getEditingDomain(message), "Message Update", getWorkspaceFiles(message)); //$NON-NLS-1$
this.message = message;
this.newName = newName;
this.newSequenceTermList = newSequenceTermList;

Back to the top