Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2016-07-29 13:01:39 +0000
committerBenoit Maggi2016-07-29 13:01:39 +0000
commit0482fe93ac76b42b014592a09b34100b45745e75 (patch)
treed5b5138360c13720ea207e2ffba74756db7e16c5 /plugins/infra
parent94ee390226ed146e82491dacd7e87e810e7b4d87 (diff)
downloadorg.eclipse.papyrus-0482fe93ac76b42b014592a09b34100b45745e75.tar.gz
org.eclipse.papyrus-0482fe93ac76b42b014592a09b34100b45745e75.tar.xz
org.eclipse.papyrus-0482fe93ac76b42b014592a09b34100b45745e75.zip
Bug 498881 - [Performance] hasShapeToDisplay bad implementation in
ShapeService - filter the result to ensure that there is something more than null - remove nls warnings Change-Id: I00b9dec2a8a1af37a873a42c9e8cb2fc0a2b7a9a Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java43
1 files changed, 20 insertions, 23 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
index 3889f666124..97e0175affe 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/shape/ShapeService.java
@@ -9,7 +9,7 @@
* Contributors:
*
* CEA LIST - Initial API and implementation
- *
+ * Benoit Maggi (CEA) benoit.maggi@cea.fr - Bug 498881
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.service.shape;
@@ -28,8 +28,6 @@ import org.eclipse.gmf.runtime.common.ui.services.util.ActivityFilterProviderDes
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
-import org.eclipse.gmf.runtime.notation.IntValueStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
@@ -43,12 +41,12 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
/**
*
*/
- private static final String MAX_NUMBER_OF_SYMBOL = "maxNumberOfSymbol";
+ private static final String MAX_NUMBER_OF_SYMBOL = "maxNumberOfSymbol";//$NON-NLS-1$
/**
*
*/
- private static final String MAX_NUMBER_OF_SYMBOL_DECORATION = "maxNumberOfSymbolDecoration";
+ private static final String MAX_NUMBER_OF_SYMBOL_DECORATION = "maxNumberOfSymbolDecoration";//$NON-NLS-1$
/** singleton instance */
private static ShapeService instance;
@@ -67,9 +65,15 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
*/
public boolean hasShapeToDisplay(EObject view) {
@SuppressWarnings("unchecked")
- List<RenderedImage> images = execute(ExecutionStrategy.REVERSE, new GetShapesForViewOperation(view));
- return images != null && images.size() > 0;
- }
+ List<List<RenderedImage>> images = execute(ExecutionStrategy.REVERSE, new GetShapesForViewOperation(view));
+ Iterator<List<RenderedImage>> iterator = images.iterator();
+ boolean hasRealImage = false;
+ while (!hasRealImage && iterator.hasNext()) { // strategy gives a lot of null && empty list check if there is a real one
+ List<RenderedImage> next = iterator.next();
+ hasRealImage = next!=null && !next.isEmpty() ;
+ }
+ return hasRealImage;
+ }
/**
* Checks if the given element can display shapes as decoration.
@@ -78,8 +82,14 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
*/
public boolean hasShapeDecorationToDisplay(EObject view) {
@SuppressWarnings("unchecked")
- List<RenderedImage> images = execute(ExecutionStrategy.REVERSE, new GetShapeDecorationsForViewOperation(view));
- return images != null && images.size() > 0;
+ List<List<RenderedImage>> images = execute(ExecutionStrategy.REVERSE, new GetShapeDecorationsForViewOperation(view));
+ Iterator<List<RenderedImage>> iterator = images.iterator();
+ boolean hasRealImage = false;
+ while (!hasRealImage && iterator.hasNext()) { // strategy gives a lot of null && empty list check if there is a real one
+ List<RenderedImage> next = iterator.next();
+ hasRealImage = next!=null && !next.isEmpty() ;
+ }
+ return hasRealImage;
}
/**
@@ -150,19 +160,6 @@ public class ShapeService extends org.eclipse.gmf.runtime.common.core.service.Se
}
/**
- * Get the maximum number of images to be displayed
- *
- * @param view
- * @return
- */
- private int getMaxNumberOfSymbolToDisplay(EObject view) {
- // get the nbImagesToDisplay highest images from the list
- IntValueStyle maxNbImages = (IntValueStyle) ((View) view).getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), MAX_NUMBER_OF_SYMBOL);
- int nbImagesToDisplay = maxNbImages != null ? maxNbImages.getIntValue() : getDefaultMaxNumberOfSymbol();
- return nbImagesToDisplay;
- }
-
- /**
* @return
*/
private int getDefaultMaxNumberOfSymbol() {

Back to the top