X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FEventSupportImpl.java;fp=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FEventSupportImpl.java;h=89a1bfd3e145015758170bcbc8fa7f77a0c82889;hb=b2bb3ff110b5bf929b6d676f0122a15a43358440;hp=0000000000000000000000000000000000000000;hpb=1dfc44ff89362fb4500ee9427432541b92d1953f;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/EventSupportImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/EventSupportImpl.java new file mode 100644 index 000000000..89a1bfd3e --- /dev/null +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/EventSupportImpl.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2019 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 fi.vtt.simantics.procore.internal; + +import java.util.concurrent.CopyOnWriteArrayList; + +import org.simantics.db.service.EventSupport; + +/** + * Simple implementation for Event Support. + * + * Note: for more extended / complicated scenarios, we could use org.simantics.utils.threads.SyncListenerList. + * + * @author luukkainen + * + */ +public class EventSupportImpl implements EventSupport { + + private CopyOnWriteArrayList listeners = new CopyOnWriteArrayList<>(); + + @Override + public synchronized void addListener(EventListener l) { + listeners.add(l); + } + + @Override + public synchronized void removeListener(EventListener l) { + listeners.remove(l); + } + + public void fireEvent(String type, Object data) { + for (EventListener l : listeners) { + l.event(type, data); + } + } + +}