Project

General

Profile

Download (1.66 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.navigation;
11

    
12
import org.apache.log4j.Logger;
13
import org.eclipse.core.commands.operations.IUndoContext;
14
import org.eclipse.core.commands.operations.UndoContext;
15
import org.eclipse.core.runtime.IAdapterFactory;
16

    
17

    
18
/**
19
 * <p>WorkbenchUndoContextAdapterFactory class.</p>
20
 *
21
 * @author p.ciardelli
22
 * @created 04.06.2009
23
 * @version 1.0
24
 */
25
public class WorkbenchUndoContextAdapterFactory implements IAdapterFactory {
26
	private static final Logger logger = Logger
27
			.getLogger(WorkbenchUndoContextAdapterFactory.class);
28
	private UndoContext defaultUndoContext;
29

    
30
	private static final Class[] ADAPTER_LIST = new Class[] { IUndoContext.class };
31
	
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
34
	 */
35
	/** {@inheritDoc} */
36
	public Object getAdapter(Object adaptableObject, Class adapterType) {
37
		if (IUndoContext.class.equals(adapterType)) {
38
			return NavigationUtil.getWorkbenchUndoContext();
39
		}
40
		return null;
41
	}
42

    
43
	/**
44
	 * @return
45
	 */
46
	private Object getDefaultUndoContext() {
47
		if (defaultUndoContext == null) {
48
			defaultUndoContext = new UndoContext();
49
		}
50
		return defaultUndoContext;
51
	}
52

    
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
55
	 */
56
	/**
57
	 * <p>getAdapterList</p>
58
	 *
59
	 * @return an array of {@link java.lang.Class} objects.
60
	 */
61
	public Class[] getAdapterList() {
62
		return ADAPTER_LIST;
63
	}
64
}
(4-4/4)