f8bd22a3fab9210cb856ea17f5c565e47a0e64e2
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
.store
.CdmStore
;
28 public class TaxonEditorInputFactory
implements IElementFactory
{
29 private static final Logger logger
= Logger
30 .getLogger(TaxonEditorInputFactory
.class);
33 * Factory id. The workbench plug-in registers a factory by this name
34 * with the "org.eclipse.ui.elementFactories" extension point.
36 private static final String ID_FACTORY
= "eu.etaxonomy.taxeditor.editor.TaxonEditorInputFactory"; //$NON-NLS-1$
39 * Tag for the IFile.fullPath of the file resource.
41 private static final String TAXON_UUID
= "uuid"; //$NON-NLS-1$
44 * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
46 public IAdaptable
createElement(IMemento memento
) {
48 String uuid
= memento
.getString(TAXON_UUID
);
52 if (CdmStore
.getTaxonService().getTaxonByUuid(UUID
.fromString(uuid
)) == null) {
53 logger
.warn("Couldn't find taxon with UUID " + uuid
);
56 logger
.info("Creating taxon from memento w UUID " + uuid
);
57 return TaxonEditorInput
.NewInstance(UUID
.fromString(uuid
));
61 * Returns the element factory id for this class.
63 * @return the element factory id
65 public static String
getFactoryId() {
70 * Saves the state of the given file editor input into the given memento.
72 * @param memento the storage area for element state
73 * @param input the file editor input
75 public static void saveState(IMemento memento
, TaxonEditorInput input
) {
76 String uuid
= input
.getTaxon().getUuid().toString();
77 memento
.putString(TAXON_UUID
, uuid
);