Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Gabel2014-11-18 17:22:12 +0000
committerSebastien Gabel2014-11-18 17:22:12 +0000
commit79acd916737d71925836a4fc9dbdacc502cb0f62 (patch)
tree01de05c9dc9f3e9be9e12e0fac6292d433303283 /plugins/uml
parent39b0f1ac843d7d4368e9315033a8a58cd729fbe0 (diff)
downloadorg.eclipse.papyrus-79acd916737d71925836a4fc9dbdacc502cb0f62.tar.gz
org.eclipse.papyrus-79acd916737d71925836a4fc9dbdacc502cb0f62.tar.xz
org.eclipse.papyrus-79acd916737d71925836a4fc9dbdacc502cb0f62.zip
Fix access to the diagram edit part when the action is called outside of the diagram area.
Fix a potential OutOfBound exception when the current selection is empty. Change-Id: I6ab52d7887f4c23209da255e3363f7667f630d7b Signed-off-by: Sebastien Gabel <sebastien.gabel@esterel-technologies.com>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideLabelsAction.java32
1 files changed, 17 insertions, 15 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideLabelsAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideLabelsAction.java
index 5ceea8b2942..2186c501eb4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideLabelsAction.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/src/org/eclipse/papyrus/uml/diagram/menu/actions/ShowHideLabelsAction.java
@@ -54,13 +54,13 @@ import org.eclipse.papyrus.uml.diagram.menu.dialogs.ShowHideLabelSelectionDialog
import org.eclipse.papyrus.uml.diagram.menu.messages.Messages;
/**
- * Adapted code from {@link ShowConnectionLabelsAction}
+ * Adapted code from {@link ShowConnectionLabelsAction}.
*
- * This action allows to manage connection labels. 3 parameters are available for this actio :
+ * This action allows to manage connection labels. Three parameters are available for this action :
* <ul>
- * <li> {@link #HIDE_PARAMETER} : hide all labels for the selected elements</li>
- * <li> {@link #SHOW_PARAMETER} : show all labels for the selected elements</li>
- * <li> {@link #MANAGE_PARAMETER} : open a dialog to choose labels to display and labels to hide for the selected element</li>
+ * <li>{@link #HIDE_PARAMETER} : hide all labels for the selected elements</li>
+ * <li>{@link #SHOW_PARAMETER} : show all labels for the selected elements</li>
+ * <li>{@link #MANAGE_PARAMETER} : open a dialog to choose labels to display and labels to hide for the selected element</li>
* </ul>
*
*/
@@ -74,11 +74,11 @@ public class ShowHideLabelsAction extends AbstractGraphicalParametricAction {
public static final String HIDE_PARAMETER = "hide"; //$NON-NLS-1$
public static final String SHOW_PARAMETER = "show"; //$NON-NLS-1$
-
+
public ILabelProvider labelProvider;
-
+
public ITreeContentProvider contentProvider;
-
+
private DiagramEditPart diagramEditPart;
@@ -95,13 +95,15 @@ public class ShowHideLabelsAction extends AbstractGraphicalParametricAction {
super(parameter, selectedEditPart);
try {
- // Gets the diagram edit part
- diagramEditPart = DiagramEditPartsUtil.getDiagramEditPart(selectedEditPart.get(0));
- if (diagramEditPart != null) {
- // Initializes the label provider
- LabelProviderService labelProviderService = (LabelProviderService) ServiceUtilsForEditPart.getInstance().getServiceRegistry(diagramEditPart).getService(LabelProviderService.class);
- labelProvider = labelProviderService.getLabelProvider(diagramEditPart);
- contentProvider = new ContentProvider(diagramEditPart);
+ // Gets the diagram edit part if the selection is not empty
+ if (!selectedEditPart.isEmpty()) {
+ diagramEditPart = DiagramEditPartsUtil.getDiagramEditPart(selectedEditPart.get(0));
+ if (diagramEditPart != null) {
+ // Initializes the label provider
+ LabelProviderService labelProviderService = (LabelProviderService) ServiceUtilsForEditPart.getInstance().getServiceRegistry(diagramEditPart).getService(LabelProviderService.class);
+ labelProvider = labelProviderService.getLabelProvider(diagramEditPart);
+ contentProvider = new ContentProvider(diagramEditPart);
+ }
}
} catch (ServiceException e) {
Activator.log.error(e);

Back to the top