-/*******************************************************************************\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.diagram.symbolcontribution;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.simantics.diagram.symbollibrary.ISymbolGroup;\r
-\r
-public abstract class AbstractSymbolProvider implements ISymbolProvider {\r
- protected volatile boolean disposed = false;\r
- protected Runnable listener;\r
- protected Collection<ISymbolGroup> groups = Collections.emptyList();\r
- private Set<ISymbolGroup> groupSet = null;\r
-\r
- public Collection<ISymbolGroup> getSymbolGroups() {\r
- return groups;\r
- }\r
-\r
- public void setListener(Runnable listener) {\r
- this.listener = listener;\r
- }\r
-\r
- public void dispose() {\r
- disposed = true;\r
- }\r
-\r
- void setSymbolGroup(Collection<ISymbolGroup> groups) {\r
- if (groups == null)\r
- throw new NullPointerException("null groups");\r
- this.groups = groups;\r
- }\r
-\r
- protected Set<ISymbolGroup> getSymbolGroupSet() {\r
- synchronized (this) {\r
- if (groupSet != null)\r
- return groupSet;\r
- groupSet = new HashSet<ISymbolGroup>(getSymbolGroups());\r
- return groupSet;\r
- }\r
- }\r
-\r
- void lockGroups() {\r
- groups = Collections.unmodifiableCollection(groups);\r
- groupSet = null;\r
- getSymbolGroupSet();\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return getSymbolGroupSet().hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- if (obj == null)\r
- return false;\r
- if (!(obj instanceof AbstractSymbolProvider))\r
- return false;\r
- AbstractSymbolProvider other = (AbstractSymbolProvider) obj;\r
- return getSymbolGroupSet().equals( other.getSymbolGroupSet() );\r
- }\r
-\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.diagram.symbolcontribution;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.simantics.diagram.symbollibrary.ISymbolGroup;
+
+public abstract class AbstractSymbolProvider implements ISymbolProvider {
+ protected volatile boolean disposed = false;
+ protected Runnable listener;
+ protected Collection<ISymbolGroup> groups = Collections.emptyList();
+ private Set<ISymbolGroup> groupSet = null;
+
+ public Collection<ISymbolGroup> getSymbolGroups() {
+ return groups;
+ }
+
+ public void setListener(Runnable listener) {
+ this.listener = listener;
+ }
+
+ public void dispose() {
+ disposed = true;
+ }
+
+ void setSymbolGroup(Collection<ISymbolGroup> groups) {
+ if (groups == null)
+ throw new NullPointerException("null groups");
+ this.groups = groups;
+ }
+
+ protected Set<ISymbolGroup> getSymbolGroupSet() {
+ synchronized (this) {
+ if (groupSet != null)
+ return groupSet;
+ groupSet = new HashSet<ISymbolGroup>(getSymbolGroups());
+ return groupSet;
+ }
+ }
+
+ void lockGroups() {
+ groups = Collections.unmodifiableCollection(groups);
+ groupSet = null;
+ getSymbolGroupSet();
+ }
+
+ @Override
+ public int hashCode() {
+ return getSymbolGroupSet().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof AbstractSymbolProvider))
+ return false;
+ AbstractSymbolProvider other = (AbstractSymbolProvider) obj;
+ return getSymbolGroupSet().equals( other.getSymbolGroupSet() );
+ }
+
+}