3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.store
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.core
.commands
.operations
.IOperationHistory
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.jface
.action
.IStatusLineManager
;
18 import org
.eclipse
.ui
.IEditorInput
;
19 import org
.eclipse
.ui
.IEditorPart
;
21 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
22 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
23 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
24 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
25 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
28 * <p>StoreUtil class.</p>
34 public class StoreUtil
extends AbstractUtility
{
37 * <p>checktaxonExists</p>
39 * @param fromString a {@link java.util.UUID} object.
41 public static void checktaxonExists(UUID fromString
) {
42 // if (CdmStore.getTaxonService().getTaxonByUuid(UUID.fromString(uuid)) == null) {
43 // logger.warn("Couldn't find taxon with UUID " + uuid);
49 * If the object given is already a {@link CdmBase} then it is returned.<br>
50 * If it is a kind of "container" for CDM objects then it is asked for its "responsible" CdmBase entity.<br>
51 * Otherwise an exception is thrown.
52 * @param object the object to test for CdmBase
53 * @return a CdmBase object
54 * @throws IllegalArgumentException if the tested object is neither a CdmBase nor a CDM "container"
56 public static CdmBase
getCdmEntity(Object object
){
57 // TODO temporary solution for ticket #4091????
58 if(object
instanceof DerivedUnitFacade
){
59 return ((DerivedUnitFacade
)object
).baseUnit();
61 else if(object
instanceof FeatureNodeContainer
){
62 return ((FeatureNodeContainer
) object
).getFeatureNode();
64 else if(object
instanceof CdmBase
){
65 return (CdmBase
) object
;
67 throw new IllegalArgumentException("Object " + object
.toString() + " is neither a CdmBase nor a CDM \"container\"");
71 * <p>getOperationHistory</p>
73 * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
75 public static IOperationHistory
getOperationHistory() {
76 return TaxeditorStorePlugin
.getDefault().getWorkbench().
77 getOperationSupport().getOperationHistory();
81 * <p>setStatusLineManager</p>
83 * @param manager a {@link org.eclipse.jface.action.IStatusLineManager} object.
85 public static void setStatusLineManager(IStatusLineManager manager
) {
86 statusLineManager
= manager
;
91 * <p>getUndoContext</p>
93 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
95 public static IUndoContext
getUndoContext(){
96 return IOperationHistory
.GLOBAL_UNDO_CONTEXT
;
102 * @return a {@link java.lang.String} object.
104 public static String
getPluginId(){
105 return TaxeditorStorePlugin
.PLUGIN_ID
;
112 public static IEditorInput
getActiveEditorInput() {
113 IEditorPart activeEditor
= getActiveEditor();
114 if (activeEditor
!= null){
115 return activeEditor
.getEditorInput();