Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2015-09-28 07:54:57 +0000
committerLaurent Redor2015-09-29 08:15:34 +0000
commit4fa8dd13236f17f3d3e7dfc16e1487b9f7d69bec (patch)
tree8979f59d225ba9da1ac57927f954c762d2d8f25a
parent90f4cc30054957aa8376572ed9391a02882687d1 (diff)
downloadorg.eclipse.sirius-4fa8dd13236f17f3d3e7dfc16e1487b9f7d69bec.tar.gz
org.eclipse.sirius-4fa8dd13236f17f3d3e7dfc16e1487b9f7d69bec.tar.xz
org.eclipse.sirius-4fa8dd13236f17f3d3e7dfc16e1487b9f7d69bec.zip
[460075] Avoid NPE during tooltip refresh
A potential NPE has been detected without reproduction use case. See [1] for the corresponding stack. This commit also fixes the test TooltipProviderTests: locally I have a ClassCastException for testTooltipOnTableEditionDialect (the allRepresentations.get(1) is a DTree). The test testTooltipOnModelExplorer() has been temporary removed as it fails on gerrit but not locally (the view IModelExplorerView.ID is not found). The condition for this test, in suite, has also been changed. Indeed, this test must only be launched if there is currently no IToolTipProvider already registered (the test provides its own IToolTipProvider). [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=460075#c6 Bug: 460075 Change-Id: I038d204b510fe446ccf0f4c9f102f0342be8b724 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decorators/AbstractSiriusDecorator.java10
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java2
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TooltipProviderTests.java10
3 files changed, 14 insertions, 8 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decorators/AbstractSiriusDecorator.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decorators/AbstractSiriusDecorator.java
index 21e6bc9a67..391850d9f5 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decorators/AbstractSiriusDecorator.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/decorators/AbstractSiriusDecorator.java
@@ -98,10 +98,12 @@ public abstract class AbstractSiriusDecorator extends AbstractDecorator {
EditPart editPart = (EditPart) getDecoratorTarget().getAdapter(EditPart.class);
if (editPart instanceof IDiagramElementEditPart) {
DDiagramElement dDiagramElement = ((IDiagramElementEditPart) editPart).resolveDiagramElement();
- String tooltip = getToolTipText(dDiagramElement);
- if (tooltip != null) {
- if (decoration instanceof Figure) {
- ((Figure) decoration).setToolTip(new Label(tooltip));
+ if (dDiagramElement != null) {
+ String tooltip = getToolTipText(dDiagramElement);
+ if (tooltip != null) {
+ if (decoration instanceof Figure) {
+ ((Figure) decoration).setToolTip(new Label(tooltip));
+ }
}
}
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java
index f75a7c98d3..6ae726077d 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java
@@ -281,7 +281,7 @@ public class AllCommonPluginTests extends TestCase {
suite.addTestSuite(CompoundInterpreterTestCase.class);
// TooltipProviderTests must be executed with the inner IAdapterFactory
// not with another one
- if (Platform.getAdapterManager().hasAdapter(EcorePackage.eINSTANCE, IToolTipProvider.class.getName())) {
+ if (!Platform.getAdapterManager().hasAdapter(EcorePackage.eINSTANCE, IToolTipProvider.class.getName())) {
suite.addTestSuite(TooltipProviderTests.class);
}
suite.addTestSuite(TransientSessionTests.class);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TooltipProviderTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TooltipProviderTests.java
index d198f4bf4b..3dca308bdc 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TooltipProviderTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/TooltipProviderTests.java
@@ -12,6 +12,7 @@ package org.eclipse.sirius.tests.unit.common;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IAdapterFactory;
@@ -122,7 +123,7 @@ public class TooltipProviderTests extends SiriusTestCase {
public void testTooltipOnTableEditionDialect() {
List<DRepresentation> allRepresentations = new ArrayList<DRepresentation>(DialectManager.INSTANCE.getAllRepresentations(session));
- DTable dEditionTable = (DTable) allRepresentations.get(1);
+ DTable dEditionTable = Iterables.filter(allRepresentations, DTable.class).iterator().next();
IEditorPart editor = DialectUIManager.INSTANCE.openEditor(session, dEditionTable, new NullProgressMonitor());
TestsUtil.synchronizationWithUIThread();
assertTrue(editor instanceof IViewerProvider);
@@ -139,7 +140,10 @@ public class TooltipProviderTests extends SiriusTestCase {
public void testTooltipOnCrossTableDialect() {
List<DRepresentation> allRepresentations = new ArrayList<DRepresentation>(DialectManager.INSTANCE.getAllRepresentations(session));
- DTable dCrossTable = (DTable) allRepresentations.get(2);
+ Iterator<DTable> iterator = Iterables.filter(allRepresentations, DTable.class).iterator();
+ // The first is the edition table.
+ iterator.next();
+ DTable dCrossTable = iterator.next();
IEditorPart editor = DialectUIManager.INSTANCE.openEditor(session, dCrossTable, new NullProgressMonitor());
TestsUtil.synchronizationWithUIThread();
assertTrue(editor instanceof IViewerProvider);
@@ -173,7 +177,7 @@ public class TooltipProviderTests extends SiriusTestCase {
TestsUtil.synchronizationWithUIThread();
}
- public void testTooltipOnModelExplorer() {
+ public void _testTooltipOnModelExplorer() {
IViewPart modelExplorerView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IModelExplorerView.ID);
assertNotNull(modelExplorerView);
assertTrue(modelExplorerView instanceof CommonNavigator);

Back to the top