-/*******************************************************************************\r
- * Copyright (c) 2014 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
- * Semantum Oy - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.workbench.internal.contributions.search;\r
-\r
-import java.util.Collection;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.procedure.adapter.DisposableListener;\r
-import org.simantics.workbench.internal.Activator;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-class ActiveModelsListener extends DisposableListener<Collection<Resource>> {\r
-\r
- private Runnable callback;\r
- private Set<Resource> previouslyActive;\r
-\r
- public ActiveModelsListener(Runnable callback) {\r
- if (callback == null)\r
- throw new NullPointerException("null callback");\r
- this.callback = callback;\r
- }\r
-\r
- @Override\r
- public void execute(Collection<Resource> models) {\r
- Set<Resource> set = new HashSet<Resource>(models);\r
- Set<Resource> previous = previouslyActive;\r
- if (previous != null && !previous.equals(set))\r
- callback.run();\r
- previouslyActive = set;\r
- }\r
-\r
- @Override\r
- public void exception(Throwable t) {\r
- Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, t.getLocalizedMessage(), t));\r
- }\r
-\r
- @Override\r
- public void dispose() {\r
- super.dispose();\r
- previouslyActive = null;\r
- }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2014 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:
+ * Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.workbench.internal.contributions.search;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.DisposableListener;
+import org.simantics.workbench.internal.Activator;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+class ActiveModelsListener extends DisposableListener<Collection<Resource>> {
+
+ private Runnable callback;
+ private Set<Resource> previouslyActive;
+
+ public ActiveModelsListener(Runnable callback) {
+ if (callback == null)
+ throw new NullPointerException("null callback");
+ this.callback = callback;
+ }
+
+ @Override
+ public void execute(Collection<Resource> models) {
+ Set<Resource> set = new HashSet<Resource>(models);
+ Set<Resource> previous = previouslyActive;
+ if (previous != null && !previous.equals(set))
+ callback.run();
+ previouslyActive = set;
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, t.getLocalizedMessage(), t));
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ previouslyActive = null;
+ }
+
}
\ No newline at end of file