diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java index bfaf74fd5e2a343d069cc4d8cd8d51ef8eed4104..29be8909dac5320fb336f69bf20733020ee4ad88 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/MarkerService.java @@ -17,6 +17,8 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.internal; +import static org.fortiss.tooling.kernel.utils.EcoreUtils.postRefreshNotification; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -31,8 +33,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.NotificationImpl; import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IDecoration; @@ -57,7 +57,7 @@ import org.fortiss.tooling.kernel.ui.service.IMarkerService; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating RED Hash: A2A864DADACAF09ABE26E40754307016 + * @ConQAT.Rating YELLOW Hash: 17A1ACFF311CC8EBE383929A19604E0C */ public class MarkerService implements IMarkerService, IPersistencyServiceListener, ILightweightLabelDecorator { @@ -291,21 +291,16 @@ public class MarkerService implements IMarkerService, /** Stores the top-level element. */ private ITopLevelElement topElement; - // TODO @Review CD: magic number AND totally incomprehensible - /** Notification to cause model element display refresh. */ - private Notification refreshOnly = new NotificationImpl( - Notification.EVENT_TYPE_COUNT + 256, null, null); - /** Stores the display update UI job. */ private final UIJob refreshElementDisplay = new UIJob("Update Markers") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { for (EObject eo : violationsMap.keySet()) { - eo.eNotify(refreshOnly); + postRefreshNotification(eo); for (IConstraintViolation<? extends EObject> viol : violationsMap .get(eo)) { - viol.getSource().eNotify(refreshOnly); + postRefreshNotification(viol.getSource()); } } return Status.OK_STATUS; diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java index bdd4c03498344ac805700234f3227fd187d93303..dc9a5f0e43997721ad0265ef4208fb7ffa311628 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java @@ -17,9 +17,13 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.utils; +import static org.eclipse.emf.common.notify.Notification.EVENT_TYPE_COUNT; + import java.util.Collection; import java.util.List; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.NotificationImpl; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.ECollections; import org.eclipse.emf.common.util.EList; @@ -34,10 +38,19 @@ import org.eclipse.emf.ecore.util.EcoreUtil; * @author ratiu * @author $Author: hoelzl $ * @version $Rev: 18709 $ - * @ConQAT.Rating YELLOW Hash: 85264FC59A1B469EBEBF06B27CCDF9B5 + * @ConQAT.Rating YELLOW Hash: D2EE43270D816D9D45663D29F23C739F */ public class EcoreUtils { + /** The new event type count defined by the kernel. */ + public static final int KERNEL_EMF_EVENT_TYPE_COUNT = EVENT_TYPE_COUNT + 1; + + /** Notification to cause model element display refresh. */ + // we use a large number above EMF standard notifications to avoid collision + // with other EMF tools. + private static final Notification refreshNotification = new NotificationImpl( + EVENT_TYPE_COUNT + 1, null, null); + /** * Converts an EList of a given type into an EList of one of its subtypes. * Utility method to avoid unnecessary casts. @@ -154,4 +167,15 @@ public class EcoreUtils { } return children; } + + /** + * Posts a {@link Notification} with an event type ID outside the EMF + * default notification IDs to cause UI refreshes. + * + * @param eObject + * the target model element to be refreshed + */ + public static void postRefreshNotification(EObject eObject) { + eObject.eNotify(refreshNotification); + } }