01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //limitations under the License.
10: //
11: //The Original Code is "The Columba Project"
12: //
13: //The Initial Developers of the Original Code are Frederik Dietz and Timo
14: // Stich.
15: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16: //
17: //All Rights Reserved.
18: package org.columba.mail.gui.config.mailboximport;
19:
20: import java.io.File;
21:
22: import net.javaprog.ui.wizard.DataModel;
23: import net.javaprog.ui.wizard.WizardModelEvent;
24: import net.javaprog.ui.wizard.WizardModelListener;
25:
26: import org.columba.api.plugin.IExtension;
27: import org.columba.api.plugin.IExtensionHandler;
28: import org.columba.api.plugin.PluginException;
29: import org.columba.core.command.CommandProcessor;
30: import org.columba.core.logging.Logging;
31: import org.columba.mail.command.ImportFolderCommandReference;
32: import org.columba.mail.folder.IMailFolder;
33: import org.columba.mail.folder.command.ImportMessageCommand;
34: import org.columba.mail.folder.mailboximport.AbstractMailboxImporter;
35:
36: class MailboxImporter implements WizardModelListener {
37: protected DataModel data;
38:
39: public MailboxImporter(DataModel data) {
40: this .data = data;
41: }
42:
43: public void wizardFinished(WizardModelEvent e) {
44: IExtensionHandler pluginHandler = (IExtensionHandler) data
45: .getData("Plugin.handler");
46: AbstractMailboxImporter importer = null;
47: Object[] args = new Object[] {
48: data.getData("Location.destination"),
49: data.getData("Location.source") };
50:
51: try {
52: IExtension extension = pluginHandler
53: .getExtension((String) data.getData("Plugin.ID"));
54:
55: importer = (AbstractMailboxImporter) extension
56: .instanciateExtension(args);
57: } catch (PluginException e1) {
58: if (Logging.DEBUG)
59: e1.printStackTrace();
60:
61: return;
62: }
63:
64: ImportFolderCommandReference r = new ImportFolderCommandReference(
65: (IMailFolder) args[0], (File[]) args[1], importer);
66: CommandProcessor.getInstance().addOp(
67: new ImportMessageCommand(r));
68: }
69:
70: public void stepShown(WizardModelEvent e) {
71: }
72:
73: public void wizardCanceled(WizardModelEvent e) {
74: }
75:
76: public void wizardModelChanged(WizardModelEvent e) {
77: }
78: }
|