Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/WorkbenchUndoContextAdapterFactory.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.navigation; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
15 |
import org.eclipse.core.commands.operations.UndoContext; |
|
16 |
import org.eclipse.core.runtime.IAdapterFactory; |
|
17 |
|
|
18 |
|
|
19 |
/** |
|
20 |
* @author p.ciardelli |
|
21 |
* @created 04.06.2009 |
|
22 |
* @version 1.0 |
|
23 |
*/ |
|
24 |
public class WorkbenchUndoContextAdapterFactory implements IAdapterFactory { |
|
25 |
private static final Logger logger = Logger |
|
26 |
.getLogger(WorkbenchUndoContextAdapterFactory.class); |
|
27 |
private UndoContext defaultUndoContext; |
|
28 |
|
|
29 |
private static final Class[] ADAPTER_LIST = new Class[] { IUndoContext.class }; |
|
30 |
|
|
31 |
/* (non-Javadoc) |
|
32 |
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) |
|
33 |
*/ |
|
34 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
|
35 |
if (IUndoContext.class.equals(adapterType)) { |
|
36 |
return NavigationUtil.getWorkbenchUndoContext(); |
|
37 |
} |
|
38 |
return null; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* @return |
|
43 |
*/ |
|
44 |
private Object getDefaultUndoContext() { |
|
45 |
if (defaultUndoContext == null) { |
|
46 |
defaultUndoContext = new UndoContext(); |
|
47 |
} |
|
48 |
return defaultUndoContext; |
|
49 |
} |
|
50 |
|
|
51 |
/* (non-Javadoc) |
|
52 |
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() |
|
53 |
*/ |
|
54 |
public Class[] getAdapterList() { |
|
55 |
return ADAPTER_LIST; |
|
56 |
} |
|
57 |
} |
|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.taxeditor.navigation; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
15 |
import org.eclipse.core.commands.operations.UndoContext; |
|
16 |
import org.eclipse.core.runtime.IAdapterFactory; |
|
17 |
|
|
18 |
|
|
19 |
/** |
|
20 |
* <p>WorkbenchUndoContextAdapterFactory class.</p> |
|
21 |
* |
|
22 |
* @author p.ciardelli |
|
23 |
* @created 04.06.2009 |
|
24 |
* @version 1.0 |
|
25 |
*/ |
|
26 |
public class WorkbenchUndoContextAdapterFactory implements IAdapterFactory { |
|
27 |
private static final Logger logger = Logger |
|
28 |
.getLogger(WorkbenchUndoContextAdapterFactory.class); |
|
29 |
private UndoContext defaultUndoContext; |
|
30 |
|
|
31 |
private static final Class[] ADAPTER_LIST = new Class[] { IUndoContext.class }; |
|
32 |
|
|
33 |
/* (non-Javadoc) |
|
34 |
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) |
|
35 |
*/ |
|
36 |
/** {@inheritDoc} */ |
|
37 |
public Object getAdapter(Object adaptableObject, Class adapterType) { |
|
38 |
if (IUndoContext.class.equals(adapterType)) { |
|
39 |
return NavigationUtil.getWorkbenchUndoContext(); |
|
40 |
} |
|
41 |
return null; |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* @return |
|
46 |
*/ |
|
47 |
private Object getDefaultUndoContext() { |
|
48 |
if (defaultUndoContext == null) { |
|
49 |
defaultUndoContext = new UndoContext(); |
|
50 |
} |
|
51 |
return defaultUndoContext; |
|
52 |
} |
|
53 |
|
|
54 |
/* (non-Javadoc) |
|
55 |
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() |
|
56 |
*/ |
|
57 |
/** |
|
58 |
* <p>getAdapterList</p> |
|
59 |
* |
|
60 |
* @return an array of {@link java.lang.Class} objects. |
|
61 |
*/ |
|
62 |
public Class[] getAdapterList() { |
|
63 |
return ADAPTER_LIST; |
|
64 |
} |
|
65 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation