]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Remove unused ProfileUpdateIntervalRead from ThrottledStyleBase 23/3223/1
authorjsimomaa <jani.simomaa@gmail.com>
Fri, 6 Sep 2019 12:06:20 +0000 (15:06 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 6 Sep 2019 12:06:20 +0000 (15:06 +0300)
gitlab #30

Change-Id: I5c663aa5a9a45921d5f4b3a5def6ce1b50ae91fd

org.simantics.district.network/src/org/simantics/district/network/profile/ThrottledStyleBase.java

index 93af11c4fa633e73dbc8ca4e885fe2e4a45ad599..f820c9222a121537742df253be60889d7a3ee685 100644 (file)
@@ -14,7 +14,6 @@ package org.simantics.district.network.profile;
 import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -44,23 +43,7 @@ public abstract class ThrottledStyleBase<Result> extends StyleBase<Optional<Resu
 
     @Override
     protected Read<Optional<Result>> getStyleCalculationRequest(Resource runtimeDiagram, Resource entry, Resource item) {
-        Simantics.getSession().asyncRequest(new ProfileUpdateIntervalRead(runtimeDiagram), new Listener<Long>() {
-
-            @Override
-            public void execute(Long result) {
-                interval.set(result);
-            }
-
-            @Override
-            public void exception(Throwable t) {
-                LOGGER.error("Could not listen interval from runtime diagram {}", runtimeDiagram, t);
-            }
-
-            @Override
-            public boolean isDisposed() {
-                return resultListener.isDisposed();
-            }
-        });
+        //Simantics.getSession().asyncRequest(new ProfileUpdateIntervalRead(runtimeDiagram), new ProfileUpdateIntervalListener(runtimeDiagram, entry, item)); 
         return super.getStyleCalculationRequest(runtimeDiagram, entry, item);
     }
 
@@ -115,4 +98,77 @@ public abstract class ThrottledStyleBase<Result> extends StyleBase<Optional<Resu
             return interval != null ? interval : DEFAULT_INTERVAL;
         }
     }
+    
+    private class ProfileUpdateIntervalListener implements Listener<Long> {
+
+        private Resource runtimeDiagram;
+        private Resource entry;
+        private Resource item;
+
+        public ProfileUpdateIntervalListener(Resource runtimeDiagram, Resource entry, Resource item) {
+            this.runtimeDiagram = runtimeDiagram;
+            this.entry = entry;
+            this.item = item;
+        }
+
+        @Override
+        public void execute(Long result) {
+            interval.set(result);
+        }
+
+        @Override
+        public void exception(Throwable t) {
+            LOGGER.error("Could not listen interval from runtime diagram {}", runtimeDiagram, t);
+        }
+
+        @Override
+        public boolean isDisposed() {
+            return resultListener.isDisposed();
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + getEnclosingInstance().hashCode();
+            result = prime * result + ((entry == null) ? 0 : entry.hashCode());
+            result = prime * result + ((item == null) ? 0 : item.hashCode());
+            result = prime * result + ((runtimeDiagram == null) ? 0 : runtimeDiagram.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            ProfileUpdateIntervalListener other = (ProfileUpdateIntervalListener) obj;
+            if (!getEnclosingInstance().equals(other.getEnclosingInstance()))
+                return false;
+            if (entry == null) {
+                if (other.entry != null)
+                    return false;
+            } else if (!entry.equals(other.entry))
+                return false;
+            if (item == null) {
+                if (other.item != null)
+                    return false;
+            } else if (!item.equals(other.item))
+                return false;
+            if (runtimeDiagram == null) {
+                if (other.runtimeDiagram != null)
+                    return false;
+            } else if (!runtimeDiagram.equals(other.runtimeDiagram))
+                return false;
+            return true;
+        }
+
+        private ThrottledStyleBase<Result> getEnclosingInstance() {
+            return ThrottledStyleBase.this;
+        }
+    }
+
 }