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
.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 facade 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 facade
55 public static CdmBase
getCdmEntity(Object object
){
56 // TODO temporary solution for ticket #4091????
57 if(object
instanceof DerivedUnitFacade
){
58 return ((DerivedUnitFacade
)object
).baseUnit();
60 else if(object
instanceof CdmBase
){
61 return (CdmBase
) object
;
63 throw new IllegalArgumentException("Object is neither a CdmBase nor an EntityFacade");
67 * <p>getOperationHistory</p>
69 * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
71 public static IOperationHistory
getOperationHistory() {
72 return TaxeditorStorePlugin
.getDefault().getWorkbench().
73 getOperationSupport().getOperationHistory();
77 * <p>setStatusLineManager</p>
79 * @param manager a {@link org.eclipse.jface.action.IStatusLineManager} object.
81 public static void setStatusLineManager(IStatusLineManager manager
) {
82 statusLineManager
= manager
;
87 * <p>getUndoContext</p>
89 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
91 public static IUndoContext
getUndoContext(){
92 return IOperationHistory
.GLOBAL_UNDO_CONTEXT
;
98 * @return a {@link java.lang.String} object.
100 public static String
getPluginId(){
101 return TaxeditorStorePlugin
.PLUGIN_ID
;
108 public static IEditorInput
getActiveEditorInput() {
109 IEditorPart activeEditor
= getActiveEditor();
110 if (activeEditor
!= null){
111 return activeEditor
.getEditorInput();