summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2008-06-30 07:19:18 (EDT)
committerCarsten Drossel2008-06-30 07:19:18 (EDT)
commit5f0a38e3f4f4bd6349404b842472451f029e9f05 (patch)
tree50ccd317a29dff1e8c3ff102eb9ee26d8a0444a8
parent5ae498d24d74815210e72b46d65496f80e1ce7bc (diff)
downloadorg.eclipse.riena-5f0a38e3f4f4bd6349404b842472451f029e9f05.zip
org.eclipse.riena-5f0a38e3f4f4bd6349404b842472451f029e9f05.tar.gz
org.eclipse.riena-5f0a38e3f4f4bd6349404b842472451f029e9f05.tar.bz2
ensure consistently ordered messages when showing multiple markers
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/TooltipMessageMarkerViewerTest.java12
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/marker/AbstractMessageMarkerViewer.java18
2 files changed, 27 insertions, 3 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/TooltipMessageMarkerViewerTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/TooltipMessageMarkerViewerTest.java
index 9878560..26c2b3f 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/TooltipMessageMarkerViewerTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/ui/ridgets/marker/TooltipMessageMarkerViewerTest.java
@@ -141,7 +141,7 @@ public class TooltipMessageMarkerViewerTest extends TestCase {
assertNull(ridget.getToolTipText());
ridget.addMarker(errorMessageMarker);
- String secondMessage = "TestASecondMarker";
+ String secondMessage = errorMessage + 2;
MessageMarker secondMarker = new MessageMarker(secondMessage);
tooltipMessageMarkerViewer.addMarkerType(MessageMarker.class);
ridget.addMarker(secondMarker);
@@ -156,6 +156,16 @@ public class TooltipMessageMarkerViewerTest extends TestCase {
assertEquals(null, ridget.getToolTipText());
assertNull(ridget.getToolTipText());
+
+ ridget.addMarker(errorMessageMarker);
+ ridget.addMarker(secondMarker);
+ ridget.addMarker(new MessageMarker(errorMessage + 3));
+ ridget.addMarker(new MessageMarker(errorMessage + 4));
+ ridget.addMarker(new MessageMarker(errorMessage + 5));
+
+ assertEquals(errorMessage + "; " + secondMessage + "; " + errorMessage + "3; " + errorMessage + "4; "
+ + errorMessage + "5", ridget.getToolTipText());
+
}
}
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/marker/AbstractMessageMarkerViewer.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/marker/AbstractMessageMarkerViewer.java
index 1fd19ee..66ed3fe 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/marker/AbstractMessageMarkerViewer.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/marker/AbstractMessageMarkerViewer.java
@@ -12,10 +12,12 @@ package org.eclipse.riena.ui.ridgets.marker;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
-import java.util.Vector;
+import java.util.List;
import org.eclipse.riena.ui.core.marker.IMessageMarker;
import org.eclipse.riena.ui.ridgets.IMarkableRidget;
@@ -98,7 +100,7 @@ public abstract class AbstractMessageMarkerViewer implements IMessageMarkerViewe
}
protected Collection<IMessageMarker> getMessageMarker(IMarkableRidget markableRidget, boolean pRemove) {
- Collection<IMessageMarker> result = new Vector<IMessageMarker>();
+ List<IMessageMarker> result = new ArrayList<IMessageMarker>();
for (Class<? extends IMessageMarker> nextMessageMarkerType : markerTypes) {
Collection<? extends IMessageMarker> nextMessageMarkers = markableRidget
.getMarkersOfType(nextMessageMarkerType);
@@ -111,7 +113,19 @@ public abstract class AbstractMessageMarkerViewer implements IMessageMarkerViewe
markableRidget.removeMarker((IMessageMarker) j.next());
}
}
+ Collections.sort(result, new MessageMarkerComparator());
return result;
}
+ private class MessageMarkerComparator implements Comparator<IMessageMarker> {
+
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(IMessageMarker o1, IMessageMarker o2) {
+ return o1.getMessage().compareTo(o2.getMessage());
+ }
+
+ }
+
}