--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * 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.swt;\r
+\r
+\r
+import java.util.function.Consumer;\r
+\r
+import org.simantics.db.common.procedure.adapter.ListenerSupport;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.utils.ObjectUtils;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class PartNameListener extends PartNameProcedure implements Listener<String> {\r
+\r
+ private boolean disposed = false;\r
+ private ListenerSupport support;\r
+\r
+ public PartNameListener(Consumer<String> updateCallback) {\r
+ super(updateCallback);\r
+ support = null;\r
+ }\r
+\r
+ public PartNameListener(Consumer<String> updateCallback, ListenerSupport support) {\r
+ super(updateCallback);\r
+ this.support = support;\r
+ }\r
+\r
+ @Override\r
+ public void exception(Throwable t) {\r
+ if (support != null)\r
+ support.exception(t);\r
+ else\r
+ super.exception(t);\r
+ }\r
+\r
+ public void dispose() {\r
+ disposed = true;\r
+ }\r
+\r
+ @Override\r
+ public boolean isDisposed() {\r
+ boolean d = disposed || (support != null && support.isDisposed());\r
+ return d;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return ObjectUtils.hashCode(support) + 31 * ObjectUtils.hashCode(updateCallback);\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 (getClass() != obj.getClass())\r
+ return false;\r
+ PartNameListener other = (PartNameListener) obj;\r
+ return ObjectUtils.objectEquals(support, other.support)\r
+ && ObjectUtils.objectEquals(updateCallback, other.updateCallback);\r
+ }\r
+\r
+}\r