-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.browsing.ui.common.internal;\r
-\r
-import gnu.trove.set.hash.THashSet;\r
-\r
-import java.util.Collection;\r
-import java.util.Set;\r
-\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.NodeContext.CacheKey;\r
-\r
-public interface IGECache {\r
-\r
- interface IGECacheEntry {\r
- Object getValue();\r
- void setValue(Object value);\r
-// Collection<NodeQueryUpdater> getDependencies();\r
-// void addDependency(NodeQueryUpdater caller);\r
- NodeContext getContext();\r
- CacheKey<?> getKey();\r
- Collection<IGECacheEntry> getDependencies();\r
- void addDependency(IGECacheEntry caller);\r
- void reset();\r
- }\r
-\r
- class GECacheEntry implements IGECacheEntry {\r
-\r
- private Object result;\r
- final private NodeContext context;\r
- final private CacheKey<?> key;\r
- private Set<IGECacheEntry> callers = new THashSet<IGECacheEntry>(2);\r
-\r
- public <T> GECacheEntry(NodeContext context, CacheKey<T> key, T result) {\r
- this.context = context;\r
- this.key = key;\r
- this.result = result;\r
- }\r
- @Override\r
- public Collection<IGECacheEntry> getDependencies() {\r
- return callers;\r
- }\r
- @Override\r
- public Object getValue() {\r
- return result;\r
- }\r
- @Override\r
- public void addDependency(IGECacheEntry caller) {\r
- assert(caller != null);\r
- callers.add(caller);\r
- }\r
- @Override\r
- public void setValue(Object value) {\r
- result = value;\r
- }\r
- @Override\r
- public NodeContext getContext() {\r
- return context;\r
- }\r
- @Override\r
- public CacheKey<?> getKey() {\r
- return key;\r
- }\r
- @Override\r
- public void reset() {\r
- callers = new THashSet<IGECacheEntry>(2);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return 31 * context.hashCode() | key.hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object object) {\r
-\r
- if (this == object)\r
- return true;\r
- else if (object == null)\r
- return false;\r
- else if (getClass() != object.getClass())\r
- return false;\r
-\r
- GECacheEntry i = (GECacheEntry)object;\r
-\r
- return key.equals(i.key) && context.equals(i.context);\r
-\r
- }\r
-\r
-// @Override\r
-// public String toString() {\r
-// return "GECacheEntry[" + result + ", " + context + ", " + key + "]";\r
-// }\r
-\r
- }\r
-\r
- <T> IGECacheEntry getEntry(NodeContext context, CacheKey<T> key);\r
-\r
- <T> IGECacheEntry put(NodeContext context, CacheKey<T> key, T value);\r
- <T> void putTreeReference(NodeContext context, CacheKey<T> key, UIElementReference reference);\r
-\r
- <T> T get(NodeContext context, CacheKey<T> key);\r
- <T> Set<UIElementReference> getTreeReference(NodeContext context, CacheKey<T> key);\r
-\r
- <T> void remove(NodeContext context, CacheKey<T> key);\r
- <T> Set<UIElementReference> removeTreeReference(NodeContext context, CacheKey<T> key);\r
- \r
- boolean isShown(NodeContext context);\r
- void incRef(NodeContext context);\r
- void decRef(NodeContext context);\r
- \r
- void dispose();\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.common.internal;
+
+import gnu.trove.set.hash.THashSet;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.NodeContext.CacheKey;
+
+public interface IGECache {
+
+ interface IGECacheEntry {
+ Object getValue();
+ void setValue(Object value);
+// Collection<NodeQueryUpdater> getDependencies();
+// void addDependency(NodeQueryUpdater caller);
+ NodeContext getContext();
+ CacheKey<?> getKey();
+ Collection<IGECacheEntry> getDependencies();
+ void addDependency(IGECacheEntry caller);
+ void reset();
+ }
+
+ class GECacheEntry implements IGECacheEntry {
+
+ private Object result;
+ final private NodeContext context;
+ final private CacheKey<?> key;
+ private Set<IGECacheEntry> callers = new THashSet<IGECacheEntry>(2);
+
+ public <T> GECacheEntry(NodeContext context, CacheKey<T> key, T result) {
+ this.context = context;
+ this.key = key;
+ this.result = result;
+ }
+ @Override
+ public Collection<IGECacheEntry> getDependencies() {
+ return callers;
+ }
+ @Override
+ public Object getValue() {
+ return result;
+ }
+ @Override
+ public void addDependency(IGECacheEntry caller) {
+ assert(caller != null);
+ callers.add(caller);
+ }
+ @Override
+ public void setValue(Object value) {
+ result = value;
+ }
+ @Override
+ public NodeContext getContext() {
+ return context;
+ }
+ @Override
+ public CacheKey<?> getKey() {
+ return key;
+ }
+ @Override
+ public void reset() {
+ callers = new THashSet<IGECacheEntry>(2);
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * context.hashCode() | key.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object object) {
+
+ if (this == object)
+ return true;
+ else if (object == null)
+ return false;
+ else if (getClass() != object.getClass())
+ return false;
+
+ GECacheEntry i = (GECacheEntry)object;
+
+ return key.equals(i.key) && context.equals(i.context);
+
+ }
+
+// @Override
+// public String toString() {
+// return "GECacheEntry[" + result + ", " + context + ", " + key + "]";
+// }
+
+ }
+
+ <T> IGECacheEntry getEntry(NodeContext context, CacheKey<T> key);
+
+ <T> IGECacheEntry put(NodeContext context, CacheKey<T> key, T value);
+ <T> void putTreeReference(NodeContext context, CacheKey<T> key, UIElementReference reference);
+
+ <T> T get(NodeContext context, CacheKey<T> key);
+ <T> Set<UIElementReference> getTreeReference(NodeContext context, CacheKey<T> key);
+
+ <T> void remove(NodeContext context, CacheKey<T> key);
+ <T> Set<UIElementReference> removeTreeReference(NodeContext context, CacheKey<T> key);
+
+ boolean isShown(NodeContext context);
+ void incRef(NodeContext context);
+ void decRef(NodeContext context);
+
+ void dispose();
+}