1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.swt;
\r
15 import java.util.function.Consumer;
\r
17 import org.simantics.db.common.procedure.adapter.ListenerSupport;
\r
18 import org.simantics.db.procedure.Listener;
\r
19 import org.simantics.utils.ObjectUtils;
\r
22 * @author Tuukka Lehtonen
\r
24 public class PartNameListener extends PartNameProcedure implements Listener<String> {
\r
26 private boolean disposed = false;
\r
27 private ListenerSupport support;
\r
29 public PartNameListener(Consumer<String> updateCallback) {
\r
30 super(updateCallback);
\r
34 public PartNameListener(Consumer<String> updateCallback, ListenerSupport support) {
\r
35 super(updateCallback);
\r
36 this.support = support;
\r
40 public void exception(Throwable t) {
\r
41 if (support != null)
\r
42 support.exception(t);
\r
47 public void dispose() {
\r
52 public boolean isDisposed() {
\r
53 boolean d = disposed || (support != null && support.isDisposed());
\r
58 public int hashCode() {
\r
59 return ObjectUtils.hashCode(support) + 31 * ObjectUtils.hashCode(updateCallback);
\r
63 public boolean equals(Object obj) {
\r
68 if (getClass() != obj.getClass())
\r
70 PartNameListener other = (PartNameListener) obj;
\r
71 return ObjectUtils.objectEquals(support, other.support)
\r
72 && ObjectUtils.objectEquals(updateCallback, other.updateCallback);
\r