blob: f1dd95f37793b2db54e8750a8c853b431ed835b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Copyright (c) 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);
}
|