KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > gui > dialog > importfilter > 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.addressbook.gui.dialog.importfilter;
18
19 import net.javaprog.ui.wizard.DataLookup;
20 import net.javaprog.ui.wizard.DataModel;
21 import net.javaprog.ui.wizard.DefaultWizardModel;
22 import net.javaprog.ui.wizard.Step;
23 import net.javaprog.ui.wizard.Wizard;
24 import net.javaprog.ui.wizard.WizardModel;
25
26 import org.columba.addressbook.util.AddressbookResourceLoader;
27 import org.columba.api.plugin.IExtensionHandler;
28 import org.columba.api.plugin.PluginHandlerNotFoundException;
29 import org.columba.core.plugin.PluginManager;
30 import org.columba.core.resourceloader.IconKeys;
31 import org.columba.core.resourceloader.ImageLoader;
32
33 /**
34  * Responsible for launching the addressbook import wizard.
35  */

36 public class ImportWizardLauncher {
37     public ImportWizardLauncher() {}
38
39     public void launchWizard() {
40         final IExtensionHandler pluginHandler;
41
42         try {
43             pluginHandler = PluginManager.getInstance().getExtensionHandler(
44                     "org.columba.addressbook.import");
45         } catch (PluginHandlerNotFoundException ex) {
46             throw new RuntimeException JavaDoc(ex);
47         }
48
49         DataModel data = new DataModel();
50         data.registerDataLookup("Plugin.handler",
51             new DataLookup() {
52                 public Object JavaDoc lookupData() {
53                     return pluginHandler;
54                 }
55             }
56         );
57
58         WizardModel model = new DefaultWizardModel(new Step[] {
59             new PluginStep(data), new LocationStep(data)
60         });
61         model.addWizardModelListener(new AddressbookImporter(data));
62
63         Wizard wizard = new Wizard(model,
64                 AddressbookResourceLoader.getString("dialog",
65                     "addressbookimport", "title"),
66                 ImageLoader.getSmallIcon(IconKeys.PREFERENCES));
67         wizard.setStepListRenderer(null);
68         wizard.pack();
69         wizard.setLocationRelativeTo(null);
70         wizard.setVisible(true);
71     }
72 }
73
Popular Tags