001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * Portions Copyrighted 2007 Sun Microsystems, Inc.
016: */
017: package org.netbeans.modules.bpel.design.model;
018:
019: import javax.swing.SwingUtilities;
020: import org.netbeans.modules.bpel.model.api.events.ArrayUpdateEvent;
021: import org.netbeans.modules.bpel.model.api.events.ChangeEventListener;
022: import org.netbeans.modules.bpel.model.api.events.EntityInsertEvent;
023: import org.netbeans.modules.bpel.model.api.events.EntityRemoveEvent;
024: import org.netbeans.modules.bpel.model.api.events.EntityUpdateEvent;
025: import org.netbeans.modules.bpel.model.api.events.PropertyRemoveEvent;
026: import org.netbeans.modules.bpel.model.api.events.PropertyUpdateEvent;
027:
028: /**
029: *
030: * @author Alexey
031: */
032: public class DelegatingChangeEventListener implements
033: ChangeEventListener {
034:
035: private ChangeEventListener delegate;
036:
037: public DelegatingChangeEventListener(ChangeEventListener delegate) {
038: this .delegate = delegate;
039: }
040:
041: public void notifyPropertyRemoved(final PropertyRemoveEvent event) {
042: run(new Runnable() {
043:
044: public void run() {
045: delegate.notifyPropertyRemoved(event);
046: }
047: });
048: }
049:
050: public void notifyEntityInserted(final EntityInsertEvent event) {
051: run(new Runnable() {
052:
053: public void run() {
054: delegate.notifyEntityInserted(event);
055: }
056: });
057: }
058:
059: public void notifyPropertyUpdated(final PropertyUpdateEvent event) {
060: run(new Runnable() {
061:
062: public void run() {
063: delegate.notifyPropertyUpdated(event);
064: }
065: });
066: }
067:
068: public void notifyEntityRemoved(final EntityRemoveEvent event) {
069: run(new Runnable() {
070:
071: public void run() {
072: delegate.notifyEntityRemoved(event);
073: }
074: });
075: }
076:
077: public void notifyEntityUpdated(final EntityUpdateEvent event) {
078: run(new Runnable() {
079:
080: public void run() {
081: delegate.notifyEntityUpdated(event);
082: }
083: });
084: }
085:
086: public void notifyArrayUpdated(final ArrayUpdateEvent event) {
087: run(new Runnable() {
088:
089: public void run() {
090: delegate.notifyArrayUpdated(event);
091: }
092: });
093: }
094:
095: private void run(Runnable r) {
096: SwingUtilities.isEventDispatchThread();
097: if (SwingUtilities.isEventDispatchThread()) {
098: r.run();
099: } else {
100: SwingUtilities.invokeLater(r);
101: }
102: }
103: }
|