]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "DelayedWriteGraph denyValue should deny the value statement as well" into...
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 25 Feb 2019 12:21:42 +0000 (12:21 +0000)
committerGerrit Code Review <gerrit2@simantics>
Mon, 25 Feb 2019 12:21:42 +0000 (12:21 +0000)
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/factory/TroveBindingsProvider.java
bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/HashMapBinding.java
bundles/org.simantics.g2d/src/org/simantics/g2d/event/adapter/SWTMouseEventAdapter.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/EventQueue.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/MouseEvent.java
bundles/org.simantics.utils/src/org/simantics/utils/ReflectionUtils.java

index 3eb17213be03a74d8a6ac00da6dde81ea48dc7d1..e8047450e331f59a1ce5900a7cd8c4d62eb43591 100644 (file)
@@ -75,7 +75,6 @@ public class TroveBindingsProvider implements BindingProvider {
                        
                        for (int i=0; i<len; i++) {
                                Object key = keys[i];
-                               key = getComparableKey(result, key);                    
                                Object value = values[i];
                                result.put(key, value);
                        }
@@ -93,7 +92,6 @@ public class TroveBindingsProvider implements BindingProvider {
                        
                        for (int i=0; i<len; i++) {
                                Object key = keys.get(i);
-                               key = getComparableKey(result, key);
                                Object value = values.get(i);
                                result.put(key, value);
                        }
index d8c63e34d15b8b72e03b9c216dc63877a06cd8fa..97eb55ac17d63a8bf93debb6188b6288a40425da 100644 (file)
@@ -68,7 +68,6 @@ public class HashMapBinding extends MapBinding {
                
                for (int i=0; i<len; i++) {
                        Object key = keys[i];
-                       key = getComparableKey(result, key);                    
                        Object value = values[i];
                        result.put(key, value);
                }
@@ -86,7 +85,6 @@ public class HashMapBinding extends MapBinding {
                
                for (int i=0; i<len; i++) {
                        Object key = keys.get(i);
-                       key = getComparableKey(result, key);
                        Object value = values.get(i);
                        result.put(key, value);
                }
@@ -225,27 +223,11 @@ public class HashMapBinding extends MapBinding {
                }
                return values;
        }
-
-       @SuppressWarnings("unchecked")
-       protected Object getComparableKey(Object map, Object key) {
-               // if (keyIsComparable) return key;
-               
-               Map<Object, Object> m = ((Map<Object, Object>)map);
-               Binding kb = getKeyBinding();
-               for (Object k : m.keySet())
-               {
-                       if (kb.equals(k, key))
-                               return k;
-               }
-               return key;
-       }
        
        @SuppressWarnings("unchecked")
        @Override
        public void put(Object map, Object key, Object value) {
                Map<Object, Object> m = ((Map<Object, Object>)map);
-               Object ck = getComparableKey(m, key);
-               m.remove(ck);
                m.put(key, value);
        }
 
@@ -254,8 +236,6 @@ public class HashMapBinding extends MapBinding {
        public <K, V> void putAll(Object map, Map<K, V>  src) throws BindingException {
                Map<K, V>  m = ((Map<K, V> )map);
                for (Entry<K, V>  e : (Set<Entry<K, V> >) src.entrySet()) {
-                       Object ck = getComparableKey(map, e.getKey());
-                       m.remove(ck);
                        m.put(e.getKey(), e.getValue());
                }
        }
index 924c7c252b47a929183cfcb4403784486d5f1615..1da7fe6472ee78af0900d84d64f85ba3a9e5d312 100644 (file)
@@ -166,8 +166,8 @@ public class SWTMouseEventAdapter extends AbstractEventAdapter implements MouseL
                                sender, e.time & 0xffffffff, MOUSE_ID, buttonStatus, 
                                getStateMask(e),
                                getControlPosition(e), getScreenPosition(e), 
-                               MouseWheelMovedEvent.WHEEL_UNIT_SCROLL, 
-                               0, 
+                               MouseWheelMovedEvent.WHEEL_UNIT_SCROLL,
+                               MouseWheelMovedEvent.SCROLL_AMOUNT_ZERO,
                                e.count
                                ));
        }
index 9b0980600990695e785e2d1040c58ae6e13f4a16..d3ab613557cc874858b40c36d76d4cf6555e57c3 100644 (file)
@@ -42,20 +42,19 @@ public class EventQueue implements IEventQueue, IEventHandler {
         return EventTypes.AnyMask;
     }
 
-    /**
-     * 
-     */
-    private MouseWheelMovedEvent lastMouseWheelMovedEvent;
-    
     private static final String DISABLE_DUPLICATE_REMOVAL = "org.simantics.scenegraph.g2d.events.disableDuplicateMouseWheelEvent";
     private static final boolean IGNORE_DUPLICATE = !Boolean.parseBoolean(System.getProperty(DISABLE_DUPLICATE_REMOVAL));
     
     private boolean ignoreDuplicateMouseWheelMovedEvent(Event e) {
         if (IGNORE_DUPLICATE && e instanceof MouseWheelMovedEvent) {
-            if (e.time > 0 && (lastMouseWheelMovedEvent != null && lastMouseWheelMovedEvent.time < 0)) {
+            MouseWheelMovedEvent event = (MouseWheelMovedEvent) e;
+            // if (e.time > 0 && (lastMouseWheelMovedEvent != null && lastMouseWheelMovedEvent.time < 0)) {
+            // apparently this is a better way to distinguish between SWT & AWT events
+            // SWT based event constructs the scrollAmount to = 0
+            // See org.simantics.g2d.event.adapter.SWTMouseEventAdapter.mouseScrolled(MouseEvent) L171
+            if (event.scrollAmount != MouseWheelMovedEvent.SCROLL_AMOUNT_ZERO) {
                 return true;
             }
-            lastMouseWheelMovedEvent = (MouseWheelMovedEvent) e;
         }
         return false;
     }
index 92c97b78766c2548f9ea10a3d334a1e4fa6b6972..8070ae35821de1999da64ef0638a9081764c1827 100644 (file)
@@ -154,6 +154,8 @@ public abstract class MouseEvent extends Event {
 
         private static final long serialVersionUID = -7896477913481842708L;
 
+        public static final int SCROLL_AMOUNT_ZERO = 0;
+
         /**
          * Constant representing scrolling by "units" (like scrolling with the
          * arrow keys)
index b9d794e4043d2fc73346fd77049fcf7fc67cbe06..7f0f6c589a4c8f290db1c48eccf915535e477340 100644 (file)
@@ -58,6 +58,14 @@ public class ReflectionUtils {
     public static <T> Class<T> getSingleParameterTypeExtending(Class<?> clazz) {
 
         Type t = clazz.getGenericSuperclass();
+        while (t instanceof Class<?>) {
+            Class<?> cl = (Class) t;
+            t = cl.getGenericSuperclass();
+            if (t == null) {
+                // according to javadoc, we have reached java.lang.Object so no can do
+                break;
+            }
+        }
         if(t instanceof Class<?>) {
             throw new UnsupportedOperationException("Missing parameter type for input class '" + clazz.getCanonicalName() + "'");
         } else if (t instanceof ParameterizedType) {