09b5afca00d2e8472cf84901c9368d610cedb8a7
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / AbstractIOManager.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.io;
12
13 import org.eclipse.core.runtime.jobs.Job;
14 import org.eclipse.ui.progress.IProgressConstants;
15
16 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
17 import eu.etaxonomy.cdm.io.common.IIoConfigurator;
18
19 /**
20 * <p>Abstract AbstractIOHandler class.</p>
21 *
22 * @author n.hoffmann
23 * @created Sep 11, 2009
24 * @version 1.0
25 */
26 public abstract class AbstractIOManager<CONFIGURATOR extends IIoConfigurator> {
27
28 protected CdmApplicationController applicationController;
29
30 public static enum TYPE {
31 BerlinModel, Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd
32 }
33
34 /**
35 * <p>Constructor for AbstractIOHandler.</p>
36 *
37 * @param applicationController a {@link eu.etaxonomy.cdm.api.application.CdmApplicationController} object.
38 * @param <CONFIGURATOR> a CONFIGURATOR object.
39 */
40 protected AbstractIOManager(CdmApplicationController applicationController){
41 this.applicationController = applicationController;
42 }
43
44 /**
45 * Starts the IO process
46 *
47 * @param configurator a CONFIGURATOR object.
48 */
49 public void run(final CONFIGURATOR configurator){
50 // create job
51 Job job = createIOJob(configurator);
52 // configure the job
53 job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
54 job.setUser(true);
55 // schedule job
56 job.schedule();
57
58 }
59
60 /**
61 * <p>createIOJob</p>
62 *
63 * @param configurator a CONFIGURATOR object.
64 * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
65 */
66 protected abstract Job createIOJob(CONFIGURATOR configurator);
67 }