Commit 96f98fb2 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Icons received from model element handler can now change when some model...

Icons received from model element handler can now change when some model property changes. Both navigator view and GEF editors recognize the icon change now.
refs 2547
parent 0d01d14e
......@@ -73,7 +73,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 2CA4D9BEA4398F84CA04EB00ABD88A30
* @ConQAT.Rating YELLOW Hash: CD1071857B9255A7644C2F83F6366AE1
*/
public abstract class PositionedEditPartBase<T extends ILayoutedModelElement> extends
GraphicalEditPartBase<T> implements NodeEditPart {
......@@ -189,6 +189,8 @@ public abstract class PositionedEditPartBase<T extends ILayoutedModelElement> ex
if(labelFigure != null && labelFigure.getParent() != null) {
labelFigure.setText(determineLabelFigureText());
labelFigure.setIcon(IModelElementHandlerService.INSTANCE.getModelElementHandler(
getModel()).getIcon(getModel()));
Rectangle labelBounds = determineLabelFigureBounds();
labelFigure.setBounds(labelBounds);
labelFigure.getParent().setConstraint(labelFigure, labelBounds);
......
......@@ -18,7 +18,9 @@ $Id$
package org.fortiss.tooling.kernel.ui.extension.base;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
......@@ -36,12 +38,12 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: C9EDF1141B7267010D32E1FCE0D64F91
* @ConQAT.Rating YELLOW Hash: AF790167C4115EAF2DA3DFF030E670FC
*/
public abstract class ModelElementHandlerBase<T extends EObject> implements IModelElementHandler<T> {
/** Stores the icon image. */
private Image iconImage;
private Map<ImageDescriptor, Image> iconImages = new HashMap<ImageDescriptor, Image>();
/** {@inheritDoc} */
@Override
......@@ -52,11 +54,14 @@ public abstract class ModelElementHandlerBase<T extends EObject> implements IMod
/** {@inheritDoc} */
@Override
public final Image getIcon(T element) {
ImageDescriptor descr = getIconImageDescriptor(element);
if(descr == null) {
return null;
}
Image iconImage = iconImages.get(descr);
if(iconImage == null) {
ImageDescriptor descr = getIconImageDescriptor(element);
if(descr != null) {
iconImage = descr.createImage();
}
iconImage = descr.createImage();
iconImages.put(descr, iconImage);
}
return iconImage;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment