48e92ffa1bce34c7411e223c7ecef06a80cc131a
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
.editor
;
13 import java
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.ui
.IElementFactory
;
18 import org
.eclipse
.ui
.IMemento
;
20 import eu
.etaxonomy
.taxeditor
.model
.TaxonUtil
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
30 public class TaxonEditorInputFactory
implements IElementFactory
{
31 private static final Logger logger
= Logger
32 .getLogger(TaxonEditorInputFactory
.class);
35 * Factory id. The workbench plug-in registers a factory by this name
36 * with the "org.eclipse.ui.elementFactories" extension point.
38 private static final String ID_FACTORY
= "eu.etaxonomy.taxeditor.editor.TaxonEditorInputFactory"; //$NON-NLS-1$
41 * Tag for the IFile.fullPath of the file resource.
43 private static final String TAXON_UUID
= "uuid"; //$NON-NLS-1$
46 * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
48 public IAdaptable
createElement(IMemento memento
) {
50 String uuid
= memento
.getString(TAXON_UUID
);
54 // StoreUtil.checktaxonExists(UUID.fromString(uuid));
55 if (CdmStore
.getTaxonService().getTaxonByUuid(UUID
.fromString(uuid
)) == null) {
56 logger
.warn("Couldn't find taxon with UUID " + uuid
);
59 logger
.info("Creating taxon from memento w UUID " + uuid
);
60 return TaxonEditorInput
.NewInstance(UUID
.fromString(uuid
));
64 * Returns the element factory id for this class.
66 * @return the element factory id
68 public static String
getFactoryId() {
73 * Saves the state of the given file editor input into the given memento.
75 * @param memento the storage area for element state
76 * @param input the file editor input
78 public static void saveState(IMemento memento
, TaxonEditorInput input
) {
79 String uuid
= input
.getTaxon().getUuid().toString();
80 memento
.putString(TAXON_UUID
, uuid
);