Drastically reducing code by using field editors for preferences
[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>
21 * Abstract AbstractIOHandler class.
22 * </p>
23 *
24 * @author n.hoffmann
25 * @created Sep 11, 2009
26 * @version 1.0
27 */
28 public abstract class AbstractIOManager<CONFIGURATOR extends IIoConfigurator> {
29
30 protected CdmApplicationController applicationController;
31
32 public static enum TYPE {
33 BerlinModel, Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd
34 }
35
36 /**
37 * <p>
38 * Constructor for AbstractIOHandler.
39 * </p>
40 *
41 * @param applicationController
42 * a
43 * {@link eu.etaxonomy.cdm.api.application.CdmApplicationController}
44 * object.
45 * @param <CONFIGURATOR>
46 * a CONFIGURATOR object.
47 */
48 protected AbstractIOManager(CdmApplicationController applicationController) {
49 this.applicationController = applicationController;
50 }
51
52 /**
53 * Starts the IO process
54 *
55 * @param configurator
56 * a CONFIGURATOR object.
57 */
58 public void run(final CONFIGURATOR configurator) {
59 // create job
60 Job job = createIOJob(configurator);
61 // configure the job
62 job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
63 job.setUser(true);
64 // schedule job
65 job.schedule();
66
67 }
68
69 /**
70 * <p>
71 * createIOJob
72 * </p>
73 *
74 * @param configurator
75 * a CONFIGURATOR object.
76 * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
77 */
78 protected abstract Job createIOJob(CONFIGURATOR configurator);
79 }