Skip to content
Snippets Groups Projects
Commit 05a3fc48 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

fixed marker refresh

refs 307
parent f47d5c71
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 3B050D7FB691B8F17BBADB932EFF2BF2
* @ConQAT.Rating YELLOW Hash: 3F8B52876DADB7B723518D32AFDAD2AD
*/
public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
extends GraphicalEditPartBase<T> implements NodeEditPart {
......@@ -204,10 +204,9 @@ public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
decorationFigure.getParent().setConstraint(decorationFigure,
decorationBounds);
Image icon = null;
ESeverity sev = IMarkerService.INSTANCE
.getHighestViolationSeverity(getModel());
Image icon = null;
switch (sev) {
case ERROR:
icon = IMarkerService.INSTANCE.getImageFor(ESeverity.ERROR,
......@@ -217,6 +216,7 @@ public abstract class PositionedEditPartBase<T extends ILayoutedModelElement>
icon = IMarkerService.INSTANCE.getImageFor(ESeverity.WARNING,
useSmallDecorationImage()).createImage();
break;
default:
}
decorationFigure.setIcon(icon);
}
......
......@@ -31,6 +31,8 @@ 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;
......@@ -55,7 +57,7 @@ import org.fortiss.tooling.kernel.ui.service.IMarkerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: BD8AB2A7EDA9DB684707242CAC441F6F
* @ConQAT.Rating YELLOW Hash: 242B488A1C4D7DDB614EB3E75F8D9294
*/
public class MarkerService implements IMarkerService,
IPersistencyServiceListener, ILightweightLabelDecorator {
......@@ -156,7 +158,7 @@ public class MarkerService implements IMarkerService,
ITopLevelElement top = IPersistencyService.INSTANCE
.getTopLevelElementFor(element);
if (top == null) {
return ESeverity.lowest();
return null;
}
return getCacheEntry(top).getHighestSeverity(element);
}
......@@ -289,6 +291,26 @@ public class MarkerService implements IMarkerService,
/** Stores the top-level element. */
private ITopLevelElement topElement;
/** 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);
for (IConstraintViolation<? extends EObject> viol : violationsMap
.get(eo)) {
viol.getSource().eNotify(refreshOnly);
}
}
return Status.OK_STATUS;
}
};
/** Constructor. */
public CacheEntry(ITopLevelElement topElement) {
this.topElement = topElement;
......@@ -296,11 +318,10 @@ public class MarkerService implements IMarkerService,
/** Returns the highest severity for the given element. */
public ESeverity getHighestSeverity(EObject element) {
ESeverity severity = highestSeverityMap.get(element);
if (severity == null) {
severity = ESeverity.lowest();
if (!highestSeverityMap.containsKey(element)) {
return ESeverity.lowest();
}
return severity;
return highestSeverityMap.get(element);
}
/** Updates the cache entry. */
......@@ -325,6 +346,8 @@ public class MarkerService implements IMarkerService,
}
// project severity to parent
computeHighestSeverity(topElement.getRootModelElement());
// refresh display
refreshElementDisplay.schedule();
}
/** Recursively projects highest severity from children to parents. */
......
......@@ -55,7 +55,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 2EC4BD8032972D2AFD4E88B3F34E5049
* @ConQAT.Rating YELLOW Hash: CBDF2C05D0E2D9AC3FAC9D3030ECAC05
*/
public class MarkerViewPart extends ViewPart {
......@@ -113,9 +113,9 @@ public class MarkerViewPart extends ViewPart {
@Override
public Object[] getElements(Object inputElement) {
List<ESeverity> result = new ArrayList<ESeverity>(5);
List<ESeverity> result = new ArrayList<ESeverity>();
for (ESeverity sev : ESeverity.values()) {
if (toggleState.get(sev)) {
if (sev != ESeverity.lowest() && toggleState.get(sev)) {
result.add(sev);
}
}
......@@ -213,7 +213,9 @@ public class MarkerViewPart extends ViewPart {
/** Refreshes the view. Needs to be called on UI thread. */
public void refresh() {
gui.getTreeViewer().refresh();
if (!gui.getTreeViewer().getControl().isDisposed()) {
gui.getTreeViewer().refresh();
}
}
/** Creates the toggle actions. */
......
......@@ -35,7 +35,7 @@ import org.fortiss.tooling.kernel.ui.internal.MarkerService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 7CA4B3A1CFB5DAA9243A2537F4C75C02
* @ConQAT.Rating YELLOW Hash: 2AF8DAFE162ECF932E56C8770FADF137
*/
public interface IMarkerService {
......@@ -50,7 +50,8 @@ public interface IMarkerService {
EObject element);
/**
* /** Returns the highest severity for the given element.
* /** Returns the highest severity for the given element or
* <code>null</code> if there are no violations for this element.
*/
ESeverity getHighestViolationSeverity(EObject element);
......
......@@ -37,7 +37,7 @@ import org.fortiss.tooling.kernel.extension.base.ConstraintViolationBase;
* @author hoelzlf
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 11AEB121B98133BB02808AA44C0BFFDB
* @ConQAT.Rating YELLOW Hash: 7C5D15AAF9D6703ABFECFDF82B5D45B8
*/
public interface IConstraintViolation<T extends EObject> extends IAdaptable {
......@@ -64,7 +64,10 @@ public interface IConstraintViolation<T extends EObject> extends IAdaptable {
/** Information severity. */
INFO,
/** Debug severity. */
DEBUG;
DEBUG,
/** The lowest None severity. */
NONE;
/** Translates ESeverity to int. */
public static int getIntSeverity(ESeverity severity) {
......@@ -77,14 +80,16 @@ public interface IConstraintViolation<T extends EObject> extends IAdaptable {
return -1;
case INFO:
return 1;
case DEBUG:
return 5;
}
// ESeverity.DEBUG
return 5;
// ESeverity.NONE
return 10000;
}
/** Returns the lowest severity level. */
public static ESeverity lowest() {
return DEBUG;
return NONE;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment