KickJava   Java API By Example, From Geeks To Geeks.

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


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16

17 package org.columba.mail.gui.config.mailboximport;
18
19 import javax.help.CSH;
20
21 import net.javaprog.ui.wizard.DataLookup;
22 import net.javaprog.ui.wizard.DataModel;
23 import net.javaprog.ui.wizard.DefaultWizardModel;
24 import net.javaprog.ui.wizard.JavaHelpSupport;
25 import net.javaprog.ui.wizard.Step;
26 import net.javaprog.ui.wizard.Wizard;
27 import net.javaprog.ui.wizard.WizardModel;
28
29 import org.columba.api.gui.frame.IFrameMediator;
30 import org.columba.api.plugin.IExtensionHandler;
31 import org.columba.api.plugin.PluginHandlerNotFoundException;
32 import org.columba.core.help.HelpManager;
33 import org.columba.core.plugin.PluginManager;
34 import org.columba.core.resourceloader.IconKeys;
35 import org.columba.core.resourceloader.ImageLoader;
36 import org.columba.mail.util.MailResourceLoader;
37
38 /**
39  * Responsible for starting the mailbox import wizard.
40  */

41 public class ImportWizardLauncher {
42     private IFrameMediator mediator;
43     
44     public ImportWizardLauncher(IFrameMediator mediator) {
45         this.mediator = mediator;
46     }
47
48     public void launchWizard() {
49         final IExtensionHandler pluginHandler;
50
51         try {
52             pluginHandler = PluginManager.getInstance().getExtensionHandler(
53                     "org.columba.mail.import");
54         } catch (PluginHandlerNotFoundException ex) {
55             throw new RuntimeException JavaDoc(ex);
56         }
57
58         DataModel data = new DataModel();
59         data.registerDataLookup("Plugin.handler",
60             new DataLookup() {
61                 public Object JavaDoc lookupData() {
62                     return pluginHandler;
63                 }
64             });
65
66         WizardModel model = new DefaultWizardModel(new Step[] {
67                 new PluginStep(data), new LocationStep(mediator, data)
68         });
69         model.addWizardModelListener(new MailboxImporter(data));
70
71         Wizard wizard = new Wizard(model,
72                 MailResourceLoader.getString("dialog", "mailboximport", "title"),
73                 ImageLoader.getIcon(IconKeys.PREFERENCES));
74         wizard.setStepListRenderer(null);
75         CSH.setHelpIDString(wizard, "organising_and_managing_your_email_1");
76         JavaHelpSupport.enableHelp(wizard,
77             HelpManager.getInstance().getHelpBroker());
78         wizard.pack();
79         wizard.setLocationRelativeTo(null);
80         wizard.setVisible(true);
81     }
82 }
83
Popular Tags