2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.store
;
12 import java
.util
.UUID
;
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 import org
.eclipse
.ui
.IEditorPart
;
20 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
21 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
22 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
23 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
24 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
27 * <p>StoreUtil class.</p>
33 public class StoreUtil
extends AbstractUtility
{
36 * <p>checktaxonExists</p>
38 * @param fromString a {@link java.util.UUID} object.
40 public static void checktaxonExists(UUID fromString
) {
41 // if (CdmStore.getTaxonService().getTaxonByUuid(UUID.fromString(uuid)) == null) {
42 // logger.warn("Couldn't find taxon with UUID " + uuid);
48 * If the object given is already a {@link CdmBase} then it is returned.<br>
49 * If it is a kind of "container" for CDM objects then it is asked for its "responsible" CdmBase entity.<br>
50 * Otherwise an exception is thrown.
51 * @param object the object to test for CdmBase
52 * @return a CdmBase object
53 * @throws IllegalArgumentException if the tested object is neither a CdmBase nor a CDM "container"
55 public static CdmBase
getCdmEntity(Object object
){
56 // TODO temporary solution for ticket #4091????
58 return null; //not sure if an object should ever be null at this point, but this needs to be handled in calling methods
59 }else if(object
instanceof DerivedUnitFacade
){
60 return ((DerivedUnitFacade
)object
).baseUnit();
62 else if(object
instanceof FeatureNodeContainer
){
63 return ((FeatureNodeContainer
) object
).getFeatureNode();
65 else if(object
instanceof CdmBase
){
66 return (CdmBase
) object
;
68 throw new IllegalArgumentException("Object " + object
.toString() + " is neither a CdmBase nor a CDM \"container\"");
72 * <p>getOperationHistory</p>
74 * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
76 public static IOperationHistory
getOperationHistory() {
77 return TaxeditorStorePlugin
.getDefault().getWorkbench().
78 getOperationSupport().getOperationHistory();
82 * <p>setStatusLineManager</p>
84 * @param manager a {@link org.eclipse.jface.action.IStatusLineManager} object.
86 public static void setStatusLineManager(IStatusLineManager manager
) {
87 statusLineManager
= manager
;
92 * <p>getUndoContext</p>
94 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
96 public static IUndoContext
getUndoContext(){
97 return IOperationHistory
.GLOBAL_UNDO_CONTEXT
;
103 * @return a {@link java.lang.String} object.
105 public static String
getPluginId(){
106 return TaxeditorStorePlugin
.PLUGIN_ID
;
113 public static IEditorInput
getActiveEditorInput() {
114 IEditorPart activeEditor
= getActiveEditor();
115 if (activeEditor
!= null){
116 return activeEditor
.getEditorInput();