diff options
author | Eike Stepper | 2012-10-20 11:29:28 +0000 |
---|---|---|
committer | Eike Stepper | 2012-10-20 11:29:28 +0000 |
commit | 45a4279f1cf4f77f4bdd29a576c8d79dc37d54dd (patch) | |
tree | 817f1b5b7bf2712e57390e22d7e987bf26c28833 | |
parent | 20e5d75aa6d6c741f9d6c557bb3d90e04fbdbde5 (diff) | |
download | cdo-45a4279f1cf4f77f4bdd29a576c8d79dc37d54dd.tar.gz cdo-45a4279f1cf4f77f4bdd29a576c8d79dc37d54dd.tar.xz cdo-45a4279f1cf4f77f4bdd29a576c8d79dc37d54dd.zip |
[392503] Provide a convenient CDODirtyStateAdapter drops/I20121020-0730
https://bugs.eclipse.org/bugs/show_bug.cgi?id=392503
-rw-r--r-- | plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDODirtyStateAdapter.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDODirtyStateAdapter.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDODirtyStateAdapter.java new file mode 100644 index 0000000000..9af677e70f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDODirtyStateAdapter.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.view; + +import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent; +import org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent; + +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; + +/** + * A {@link IListener listener} that calls the {@link #onDirtyStateChanged(boolean)} method when the {@link CDOView#isDirty() dirty} state + * of the {@link CDOView view} this listener is {@link CDOView#addListener(IListener) registered} with has changed. + * + * @author Eike Stepper + * @since 4.2 + */ +public abstract class CDODirtyStateAdapter implements IListener +{ + public void notifyEvent(IEvent event) + { + if (event instanceof CDOTransactionStartedEvent) + { + onDirtyStateChanged(true); + } + else if (event instanceof CDOTransactionFinishedEvent) + { + onDirtyStateChanged(false); + } + else + { + notifyOtherEvent(event); + } + } + + protected void notifyOtherEvent(IEvent event) + { + } + + protected abstract void onDirtyStateChanged(boolean dirty); +} |