KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > config > mailboximport > MailboxImporter


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//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 JavaDoc;
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 JavaDoc[] args = new Object JavaDoc[] { data.getData("Location.destination"),
48                 data.getData("Location.source") };
49
50         try {
51             IExtension extension = pluginHandler.getExtension((String JavaDoc) data
52                     .getData("Plugin.ID"));
53
54             importer = (AbstractMailboxImporter) extension
55                     .instanciateExtension(args);
56         } catch (PluginException e1) {
57             if (Logging.DEBUG)
58                 e1.printStackTrace();
59
60             return;
61         }
62
63         ImportFolderCommandReference r = new ImportFolderCommandReference(
64                 (IMailFolder) args[0], (File JavaDoc[]) args[1], importer);
65         CommandProcessor.getInstance().addOp(new ImportMessageCommand(r));
66     }
67
68     public void stepShown(WizardModelEvent e) {
69     }
70
71     public void wizardCanceled(WizardModelEvent e) {
72     }
73
74     public void wizardModelChanged(WizardModelEvent e) {
75     }
76 }
Popular Tags