Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 198836 Details for
Bug 348662
Setting tooptip to null in tool behavior provider doesn't clear up tooltip if the associated figure has a previous tooltip
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch containing the change checked-in to head
348662.patch (text/plain), 16.01 KB, created by
Michael Wenz
on 2011-06-29 10:55:44 EDT
(
hide
)
Description:
Patch containing the change checked-in to head
Filename:
MIME Type:
Creator:
Michael Wenz
Created:
2011-06-29 10:55:44 EDT
Size:
16.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.graphiti.bot.tests >Index: src/org/eclipse/graphiti/bot/tests/GFOtherTests.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmp/org.eclipse.gmp.graphiti/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java,v >retrieving revision 1.23 >diff -u -r1.23 GFOtherTests.java >--- src/org/eclipse/graphiti/bot/tests/GFOtherTests.java 16 May 2011 13:48:37 -0000 1.23 >+++ src/org/eclipse/graphiti/bot/tests/GFOtherTests.java 29 Jun 2011 14:46:18 -0000 >@@ -1,7 +1,7 @@ > /******************************************************************************* > * <copyright> > * >- * Copyright (c) 2005, 2010 SAP AG. >+ * Copyright (c) 2005, 2011 SAP AG. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,8 @@ > * Contributors: > * SAP AG - initial API, implementation and documentation > * mwenz - Bug 340627 - Features should be able to indicate cancellation >+ * mwenz - Bug 348662 - Setting tooptip to null in tool behavior provider doesn't clear up >+ * tooltip if the associated figure has a previous tooltip > * > * </copyright> > * >@@ -33,6 +35,8 @@ > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.draw2d.Ellipse; >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.Label; > import org.eclipse.draw2d.Polygon; > import org.eclipse.draw2d.SWTGraphics; > import org.eclipse.draw2d.geometry.Point; >@@ -51,6 +55,7 @@ > import org.eclipse.emf.transaction.RecordingCommand; > import org.eclipse.emf.transaction.TransactionalEditingDomain; > import org.eclipse.gef.EditPart; >+import org.eclipse.gef.GraphicalEditPart; > import org.eclipse.gef.GraphicalViewer; > import org.eclipse.gef.commands.Command; > import org.eclipse.gef.commands.CommandStack; >@@ -80,6 +85,7 @@ > import org.eclipse.graphiti.mm.algorithms.MultiText; > import org.eclipse.graphiti.mm.algorithms.Polyline; > import org.eclipse.graphiti.mm.algorithms.RoundedRectangle; >+import org.eclipse.graphiti.mm.algorithms.Text; > import org.eclipse.graphiti.mm.algorithms.styles.AdaptedGradientColoredAreas; > import org.eclipse.graphiti.mm.algorithms.styles.GradientColoredArea; > import org.eclipse.graphiti.mm.algorithms.styles.GradientColoredAreas; >@@ -120,6 +126,8 @@ > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart; >+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor; > import org.eclipse.swtbot.swt.finder.results.IntResult; > import org.eclipse.swtbot.swt.finder.results.Result; > import org.eclipse.swtbot.swt.finder.results.VoidResult; >@@ -259,6 +267,183 @@ > } > > @Test >+ public void testTooltip() throws Exception { >+ /* >+ * Tests if the tooltips displayed in a diagram are correctly updated. >+ * The test uses the tutorial diagram type because there we had the >+ * situation that setting a previously set tooltip to null did not >+ * remove the tooltip from the figure. This was caused by the remove of >+ * the tooltip happening in the method >+ * PictogramElementDelegate.indicateNeededUpdates for the >+ * selectionFigure which is in case of the tutorial different from the >+ * figure holding the tooltip. See Bugzilla 348662 for details. >+ */ >+ final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_TUTORIAL); >+ >+ /* >+ * Open a new diagram containing just one class >+ */ >+ syncExec(new VoidResult() { >+ @Override >+ public void run() { >+ >+ final IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); >+ final IFeatureProvider fp = diagramTypeProvider.getFeatureProvider(); >+ final Diagram currentDiagram = diagramTypeProvider.getDiagram(); >+ >+ TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain(); >+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { >+ >+ @Override >+ protected void doExecute() { >+ /* >+ * Reuse of functionality originally written to add >+ * classes for the ECore test tool. Might need adaption >+ * in case of future changes >+ */ >+ addClassToDiagram(fp, currentDiagram, 300, 300, "Shape"); >+ } >+ }); >+ } >+ >+ }); >+ >+ /* >+ * Check the correctness of the initial tooltip >+ */ >+ syncExec(new VoidResult() { >+ @Override >+ public void run() { >+ >+ // Get the figure to check the tooltip via SWTBot >+ SWTBotGefEditor ed = getGefEditor(); >+ SWTBotGefEditPart editPart = ed.getEditPart("Shape"); >+ IFigure figure = ((GraphicalEditPart) editPart.part()).getFigure(); >+ >+ // Check original tooltip >+ if (!"Shape".equals(((Label) figure.getToolTip()).getText())) { >+ fail("Tooltip must be 'Shape'"); >+ } >+ } >+ >+ }); >+ >+ /* >+ * Change the name of the eClass (and the display name in the diagram to >+ * avoid the need for calling the update feature) >+ */ >+ syncExec(new VoidResult() { >+ @Override >+ public void run() { >+ >+ final IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); >+ final Diagram currentDiagram = diagramTypeProvider.getDiagram(); >+ >+ TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain(); >+ >+ final ContainerShape tooltipShape = (ContainerShape) findShapeForEClass(currentDiagram, "Shape"); >+ >+ Object bo = diagramTypeProvider.getFeatureProvider().getBusinessObjectForPictogramElement(tooltipShape); >+ if (bo instanceof EClass) { >+ final EClass eClass = (EClass) bo; >+ >+ // Change the tooltip to something else and check it >+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { >+ @Override >+ protected void doExecute() { >+ eClass.setName("Changed"); >+ Text text = (Text) tooltipShape.getChildren().get(1).getGraphicsAlgorithm(); >+ text.setValue("Changed"); >+ } >+ }); >+ } >+ } >+ >+ }); >+ >+ /* >+ * Check that the tooltip of the figure has been updated >+ */ >+ syncExec(new VoidResult() { >+ @Override >+ public void run() { >+ >+ final IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); >+ final Diagram currentDiagram = diagramTypeProvider.getDiagram(); >+ >+ // Get the figure to check the tooltip via SWTBot >+ SWTBotGefEditor ed = getGefEditor(); >+ SWTBotGefEditPart editPart = ed.getEditPart("Changed"); >+ IFigure figure = ((GraphicalEditPart) editPart.part()).getFigure(); >+ >+ final ContainerShape tooltipShape = (ContainerShape) findShapeForEClass(currentDiagram, "Changed"); >+ >+ Object bo = diagramTypeProvider.getFeatureProvider().getBusinessObjectForPictogramElement(tooltipShape); >+ if (bo instanceof EClass) { >+ if (!"Changed".equals(((Label) figure.getToolTip()).getText())) { >+ fail("Tooltip must be 'Changed' but is '" + ((Label) figure.getToolTip()).getText() + "'"); >+ } >+ } >+ } >+ >+ }); >+ >+ /* >+ * Change the name of the eClass to the empty string (and the display >+ * name in the diagram to avoid the need for calling the update >+ * feature), this will end up showing no tooltip. >+ */ >+ syncExec(new VoidResult() { >+ @Override >+ public void run() { >+ >+ final IDiagramTypeProvider diagramTypeProvider = diagramEditor.getDiagramTypeProvider(); >+ final Diagram currentDiagram = diagramTypeProvider.getDiagram(); >+ >+ TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain(); >+ >+ final ContainerShape tooltipShape = (ContainerShape) findShapeForEClass(currentDiagram, "Changed"); >+ >+ Object bo = diagramTypeProvider.getFeatureProvider().getBusinessObjectForPictogramElement(tooltipShape); >+ if (bo instanceof EClass) { >+ final EClass eClass = (EClass) bo; >+ >+ // Change the tooltip to null and check it >+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { >+ @Override >+ protected void doExecute() { >+ eClass.setName(""); // Empty name means no tooltip >+ Text text = (Text) tooltipShape.getChildren().get(1).getGraphicsAlgorithm(); >+ text.setValue("Changed"); >+ } >+ }); >+ } >+ } >+ >+ }); >+ >+ /* >+ * Check that the tooltip of the figure has been removed >+ */ >+ syncExec(new VoidResult() { >+ @Override >+ public void run() { >+ >+ // Get the figure to check the tooltip via SWTBot >+ SWTBotGefEditor ed = getGefEditor(); >+ SWTBotGefEditPart editPart = ed.getEditPart(""); >+ IFigure figure = ((GraphicalEditPart) editPart.part()).getFigure(); >+ if (figure.getToolTip() != null) { >+ fail("Tooltip must be null, but was '" + ((Label) figure.getToolTip()).getText() + "'"); >+ } >+ } >+ >+ }); >+ >+ shutdownEditor(diagramEditor); >+ } >+ >+ @Test > public void testUndoRedo() throws Exception { > final DiagramEditor diagramEditor = openDiagram(ITestConstants.DIAGRAM_TYPE_ID_ECORE); > >Index: src/org/eclipse/graphiti/bot/tests/util/ITestConstants.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmp/org.eclipse.gmp.graphiti/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/util/ITestConstants.java,v >retrieving revision 1.4 >diff -u -r1.4 ITestConstants.java >--- src/org/eclipse/graphiti/bot/tests/util/ITestConstants.java 3 Aug 2010 15:17:19 -0000 1.4 >+++ src/org/eclipse/graphiti/bot/tests/util/ITestConstants.java 29 Jun 2011 14:46:18 -0000 >@@ -1,7 +1,7 @@ > /******************************************************************************* > * <copyright> > * >- * Copyright (c) 2005, 2010 SAP AG. >+ * Copyright (c) 2005, 2011 SAP AG. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,8 @@ > * > * Contributors: > * SAP AG - initial API, implementation and documentation >+ * mwenz - Bug 348662 - Setting tooptip to null in tool behavior provider doesn't clear up >+ * tooltip if the associated figure has a previous tooltip > * > * </copyright> > * >@@ -24,10 +26,16 @@ > */ > public static final String DIAGRAM_TYPE_ID_SKETCH = "testtool.sketch"; > >- > /** > * The Constant DIAGRAM_TYPE_ID_ECORE. > */ > public static final String DIAGRAM_TYPE_ID_ECORE = "testtool.ecore"; > >+ /** >+ * The Constant DIAGRAM_TYPE_ID_TUTORIAL. >+ * >+ * @since 0.9 >+ */ >+ public static final String DIAGRAM_TYPE_ID_TUTORIAL = "tutorial"; >+ > } >#P org.eclipse.graphiti.ui >Index: src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmp/org.eclipse.gmp.graphiti/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java,v >retrieving revision 1.24 >diff -u -r1.24 PictogramElementDelegate.java >--- src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java 22 Feb 2011 08:15:38 -0000 1.24 >+++ src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java 29 Jun 2011 14:46:20 -0000 >@@ -1,7 +1,7 @@ > /******************************************************************************* > * <copyright> > * >- * Copyright (c) 2005, 2010 SAP AG. >+ * Copyright (c) 2005, 2011 SAP AG. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,8 @@ > * > * Contributors: > * SAP AG - initial API, implementation and documentation >+ * mwenz - Bug 348662 - Setting tooptip to null in tool behavior provider doesn't clear up >+ * tooltip if the associated figure has a previous tooltip > * > * </copyright> > * >@@ -593,22 +595,32 @@ > // Retreat to graphiti behavior. > selectionFigure = figure; > } >- boolean indicatedNeededUpdates = false; >- // indicate needed updates onselectionFigure (using figure would cause >- // problems with invisible rectangles) >+ >+ // Create a tooltip label >+ Label tooltipLabel = null; >+ >+ // First check the need for an update needed tooltip >+ Label indicateUpdateNeedeTooltipLabel = null; > if (selectionFigure != null) { >- indicatedNeededUpdates = indicateNeededUpdates(selectionFigure, updateNeeded); >+ // Indicate needed updates on selectionFigure (using figure would cause problems with invisible rectangles) >+ indicateUpdateNeedeTooltipLabel = indicateNeededUpdates(selectionFigure, updateNeeded); > } > >- // set tool tips >- if (!indicatedNeededUpdates) { >- final String toolTip = toolBehaviorProvider.getToolTip(graphicsAlgorithm); >- //do not show empty tool tips >+ // Use the update needed tooltip in case it exists... >+ if (indicateUpdateNeedeTooltipLabel != null) { >+ // Use update needed tooltip in any case (tool provided tooltip would be probably invalid) >+ tooltipLabel = indicateUpdateNeedeTooltipLabel; >+ } else { >+ // ... if not get the tool provided tooltip (for performance reasons only called in case no update needed tooltip exists) >+ String toolTip = toolBehaviorProvider.getToolTip(graphicsAlgorithm); > if (toolTip != null && !toolTip.isEmpty()) { >- Label ttf = new Label(toolTip); >- figure.setToolTip(ttf); >+ // null or empty string means no tooltip wanted >+ tooltipLabel = new Label(toolTip); > } > } >+ >+ // Set the tooltip in any case, especially also when it's null to clean up a previously set tooltip (see Bugzilla 348662) >+ figure.setToolTip(tooltipLabel); > } > > private void refreshFont(AbstractText text, Figure label) { >@@ -912,34 +924,24 @@ > * @param figure > * @param updateNeeded > */ >- private boolean indicateNeededUpdates(IFigure figure, IReason updateNeeded) { >- boolean ret = false; >- if (figure != null && updateNeeded != null) { >+ private Label indicateNeededUpdates(IFigure figure, IReason updateNeeded) { >+ Label ret = null; >+ if (figure != null && updateNeeded != null && updateNeeded.toBoolean()) { >+ // The figure needs an update, we indicate that with a red border and a tooltip showing the reason for the update >+ figure.setForegroundColor(ColorConstants.red); > if (figure instanceof Shape) { > Shape draw2dShape = (Shape) figure; >- IFigure toolTip = draw2dShape.getToolTip(); >- if (toolTip != null) { >- draw2dShape.setToolTip(null); >- } >- } >+ draw2dShape.setLineWidth(2); >+ draw2dShape.setLineStyle(Graphics.LINE_DOT); > >- if (updateNeeded.toBoolean()) { >- figure.setForegroundColor(ColorConstants.red); >- if (figure instanceof Shape) { >- Shape draw2dShape = (Shape) figure; >- draw2dShape.setLineWidth(2); >- draw2dShape.setLineStyle(Graphics.LINE_DOT); >- >- String updateNeededText = updateNeeded.getText(); >- if (updateNeededText != null && updateNeededText.length() > 0) { >- Label toolTipFigure = new Label(); >- toolTipFigure.setText(updateNeededText); >- org.eclipse.swt.graphics.Image image = PlatformUI.getWorkbench().getSharedImages() >- .getImage(ISharedImages.IMG_OBJS_WARN_TSK); >- toolTipFigure.setIcon(image); >- draw2dShape.setToolTip(toolTipFigure); >- ret = true; >- } >+ String updateNeededText = updateNeeded.getText(); >+ if (updateNeededText != null && updateNeededText.length() > 0) { >+ Label toolTipFigure = new Label(); >+ toolTipFigure.setText(updateNeededText); >+ org.eclipse.swt.graphics.Image image = PlatformUI.getWorkbench().getSharedImages() >+ .getImage(ISharedImages.IMG_OBJS_WARN_TSK); >+ toolTipFigure.setIcon(image); >+ ret = toolTipFigure; > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 348662
:
197551
| 198836