X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2Feditor%2FEditorMappingImpl.java;fp=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2Feditor%2FEditorMappingImpl.java;h=085c074276b00b0a17828a3f0352b4b441590910;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=a3355beb362a188de8cfe6b70e43462b3d92d9f9;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/EditorMappingImpl.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/EditorMappingImpl.java index a3355beb3..085c07427 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/EditorMappingImpl.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/EditorMappingImpl.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * 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.ui.workbench.editor; - -import java.lang.ref.WeakReference; -import java.util.WeakHashMap; - -/** - * A class for holding a set of (Object, ResourceEditorAdapter) bindings. These - * bindings are used to store the latest editor opened for input objects. This - * is used by the default UI double click actions. - * - * @author Tuukka Lehtonen - */ -public class EditorMappingImpl implements EditorMapping { - - /** - * Prevent the map from holding on to resource editor adapters. - */ - WeakHashMap> resourceToAdapter = new WeakHashMap>(); - - @Override - public synchronized void put(Object o, EditorAdapter adapter) { - assert o != null; - if (adapter != null) { - resourceToAdapter.put(o, new WeakReference(adapter)); - } else { - resourceToAdapter.remove(o); - } - } - - @Override - public synchronized EditorAdapter get(Object o) { - //System.out.println("EditorMapping.get(" + o + "): key set=" + resourceToAdapter.keySet()); - WeakReference ref = resourceToAdapter.get(o); - if (ref == null) - return null; - EditorAdapter adapter = ref.get(); - if (adapter == null) { - resourceToAdapter.remove(o); - return null; - } - return adapter; - } - - @Override - public synchronized void clear() { - resourceToAdapter.clear(); - } - -} +/******************************************************************************* + * 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.ui.workbench.editor; + +import java.lang.ref.WeakReference; +import java.util.WeakHashMap; + +/** + * A class for holding a set of (Object, ResourceEditorAdapter) bindings. These + * bindings are used to store the latest editor opened for input objects. This + * is used by the default UI double click actions. + * + * @author Tuukka Lehtonen + */ +public class EditorMappingImpl implements EditorMapping { + + /** + * Prevent the map from holding on to resource editor adapters. + */ + WeakHashMap> resourceToAdapter = new WeakHashMap>(); + + @Override + public synchronized void put(Object o, EditorAdapter adapter) { + assert o != null; + if (adapter != null) { + resourceToAdapter.put(o, new WeakReference(adapter)); + } else { + resourceToAdapter.remove(o); + } + } + + @Override + public synchronized EditorAdapter get(Object o) { + //System.out.println("EditorMapping.get(" + o + "): key set=" + resourceToAdapter.keySet()); + WeakReference ref = resourceToAdapter.get(o); + if (ref == null) + return null; + EditorAdapter adapter = ref.get(); + if (adapter == null) { + resourceToAdapter.remove(o); + return null; + } + return adapter; + } + + @Override + public synchronized void clear() { + resourceToAdapter.clear(); + } + +}