Project

General

Profile

Download (3.54 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.store;
11

    
12
import java.util.UUID;
13

    
14
import org.eclipse.core.commands.operations.IOperationHistory;
15
import org.eclipse.core.commands.operations.IUndoContext;
16
import org.eclipse.jface.action.IStatusLineManager;
17
import org.eclipse.ui.IEditorInput;
18

    
19
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
20
import eu.etaxonomy.cdm.model.common.CdmBase;
21
import eu.etaxonomy.taxeditor.model.AbstractUtility;
22
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
23
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
24

    
25
/**
26
 * <p>StoreUtil class.</p>
27
 *
28
 * @author n.hoffmann
29
 * @created 11.05.2009
30
 * @version 1.0
31
 */
32
public class StoreUtil extends AbstractUtility {
33

    
34
	/**
35
	 * <p>checktaxonExists</p>
36
	 *
37
	 * @param fromString a {@link java.util.UUID} object.
38
	 */
39
	public static void checktaxonExists(UUID fromString) {
40
//        if (CdmStore.getTaxonService().getTaxonByUuid(UUID.fromString(uuid)) == null) {
41
//        	logger.warn("Couldn't find taxon with UUID " + uuid);
42
//        	return null;
43
//        }
44
	}
45

    
46
	/**
47
	 * If the object given is already a {@link CdmBase} then it is returned.<br>
48
	 * If it is a kind of "container" for CDM objects then it is asked for its "responsible" CdmBase entity.<br>
49
	 * Otherwise an exception is thrown.
50
	 * @param object the object to test for CdmBase
51
	 * @return a CdmBase object
52
	 * @throws IllegalArgumentException if the tested object is neither a CdmBase nor a CDM "container"
53
	 */
54
	public static CdmBase getCdmEntity(Object object){
55
        // TODO temporary solution for ticket #4091????
56
        if (object == null){
57
        	return null;   //not sure if an object should ever be null at this point, but this needs to be handled in calling methods
58
        }else if(object instanceof DerivedUnitFacade){
59
            return ((DerivedUnitFacade)object).baseUnit();
60
        }
61
        else if(object instanceof FeatureNodeContainer){
62
            return ((FeatureNodeContainer) object).getFeatureNode();
63
        }
64
        else if(object instanceof CdmBase){
65
            return (CdmBase) object;
66
        }
67
        throw new IllegalArgumentException("Object " + object.toString() + " is neither a CdmBase nor a CDM \"container\"");
68
	}
69

    
70
	/**
71
	 * <p>getOperationHistory</p>
72
	 *
73
	 * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
74
	 */
75
	public static IOperationHistory getOperationHistory() {
76
		return TaxeditorStorePlugin.getDefault().getWorkbench().
77
					getOperationSupport().getOperationHistory();
78
	}
79

    
80
	/**
81
	 * <p>setStatusLineManager</p>
82
	 *
83
	 * @param manager a {@link org.eclipse.jface.action.IStatusLineManager} object.
84
	 */
85
	public static void setStatusLineManager(IStatusLineManager manager) {
86
		statusLineManager = manager;
87
	}
88

    
89

    
90
	/**
91
	 * <p>getUndoContext</p>
92
	 *
93
	 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
94
	 */
95
	public static IUndoContext getUndoContext(){
96
		return IOperationHistory.GLOBAL_UNDO_CONTEXT;
97
	}
98

    
99
	/**
100
	 * <p>getPluginId</p>
101
	 *
102
	 * @return a {@link java.lang.String} object.
103
	 */
104
	public static String getPluginId(){
105
		return TaxeditorStorePlugin.PLUGIN_ID;
106
	}
107

    
108
	/**
109
	 *
110
	 * @return
111
	 */
112
	public static IEditorInput getActiveEditorInput() {
113
//		IEditorPart activeEditor = getActiveEditor();
114
//		if (activeEditor != null){
115
//			return activeEditor.getEditorInput();
116
//		}
117
		return null;
118
	}
119
}
(9-9/13)