Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2016-05-30 13:29:42 +0000
committerShuai Li2016-05-30 13:29:42 +0000
commita184cf4e46d73cb7e5c820dcc81ae23ce7d6d0c2 (patch)
tree7ed71aa6ac640c97063f1516f68db8f6f9d229ed /plugins
parentf8b6d5acedf3c00a8300c0cddbb67965c8505aea (diff)
downloadorg.eclipse.papyrus-a184cf4e46d73cb7e5c820dcc81ae23ce7d6d0c2.tar.gz
org.eclipse.papyrus-a184cf4e46d73cb7e5c820dcc81ae23ce7d6d0c2.tar.xz
org.eclipse.papyrus-a184cf4e46d73cb7e5c820dcc81ae23ce7d6d0c2.zip
Bug 494738 - [Test Failure] StackOverFlow in canonical test caused by
ShortCutPreviewEditPolicy - Refactor previewImage creation from mouseHover into showDiagramAssistant - Do not create a preview image if one already exists (even if it is not up-to-date) Change-Id: I70c0a18e258e17ead50810854d0bea53e2846048 Signed-off-by: Shuai Li <shuai.li@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShortCutPreviewEditPolicy.java59
1 files changed, 23 insertions, 36 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShortCutPreviewEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShortCutPreviewEditPolicy.java
index 6ba9db34e41..fe5ce88784b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShortCutPreviewEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/ShortCutPreviewEditPolicy.java
@@ -73,46 +73,33 @@ public class ShortCutPreviewEditPolicy extends PapyrusPopupBarEditPolicy {
}
}
- /**
- * Loads the preview
- */
- @Override
- public void mouseHover(MouseEvent me) {
- if (diagram != null) {
- try {
- previewImage = DiagramRenderUtil.renderToSWTImage(diagram);
- } catch(Exception e) {
- Activator.log.error(e);
- }
- super.mouseHover(me);
- }
- }
-
@Override
protected void showDiagramAssistant(Point referencePoint) {
- if (diagram != null && previewImage != null) { // In case activation failed
- // Only show the popup if we hover over the shortcut edit part (not its diagram name edit part for example)
- /*EditPart hoveredOverEditPart = getHost().getViewer().findObjectAt(getMouseLocation());
- if (!(hoveredOverEditPart instanceof AbstractShortCutDiagramEditPart)) {
- return;
- }*/
-
- int optimalWidth = (int) (this.getHost().getRoot().getViewer().getControl().getBounds().width * SCALE_FACTOR);
- int optimalHeight = (int) (this.getHost().getRoot().getViewer().getControl().getBounds().height * SCALE_FACTOR);
-
- if (scaledPreviewImage == null || optimalWidth != maxWidth || optimalHeight != maxHeight) {
- maxHeight = (int) optimalHeight;
- maxWidth = (int) optimalWidth;
- if (scaledPreviewImage != null) {
- scaledPreviewImage.dispose();
+ if (diagram != null) {
+ if (previewImage == null) {
+ try {
+ previewImage = DiagramRenderUtil.renderToSWTImage(diagram);
+ } catch(Exception e) {
+ Activator.log.error(e);
+ }
+ } else {
+ int optimalWidth = (int) (this.getHost().getRoot().getViewer().getControl().getBounds().width * SCALE_FACTOR);
+ int optimalHeight = (int) (this.getHost().getRoot().getViewer().getControl().getBounds().height * SCALE_FACTOR);
+
+ if (scaledPreviewImage == null || optimalWidth != maxWidth || optimalHeight != maxHeight) {
+ maxHeight = (int) optimalHeight;
+ maxWidth = (int) optimalWidth;
+ if (scaledPreviewImage != null) {
+ scaledPreviewImage.dispose();
+ }
+ scaledPreviewImage = resize(previewImage, maxHeight, maxWidth);
}
- scaledPreviewImage = resize(previewImage, maxHeight, maxWidth);
+
+ CUSTOM_ITEM_WIDTH = scaledPreviewImage.getBounds().width;
+ CUSTOM_ITEM_HEIGHT = scaledPreviewImage.getBounds().height;
+
+ super.showDiagramAssistant(referencePoint);
}
-
- CUSTOM_ITEM_WIDTH = scaledPreviewImage.getBounds().width;
- CUSTOM_ITEM_HEIGHT = scaledPreviewImage.getBounds().height;
-
- super.showDiagramAssistant(referencePoint);
}
}

Back to the top