001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.addressbook.main;
017:
018: import java.util.logging.Logger;
019:
020: import org.apache.commons.cli.CommandLine;
021: import org.apache.commons.cli.Option;
022: import org.columba.addressbook.facade.ContactFacade;
023: import org.columba.addressbook.facade.DialogFacade;
024: import org.columba.addressbook.facade.FolderFacade;
025: import org.columba.addressbook.facade.ModelFacade;
026: import org.columba.addressbook.shutdown.SaveAllAddressbooksPlugin;
027: import org.columba.api.plugin.PluginLoadingFailedException;
028: import org.columba.core.backgroundtask.BackgroundTaskManager;
029: import org.columba.core.component.api.IComponentPlugin;
030: import org.columba.core.facade.ServiceFacadeRegistry;
031: import org.columba.core.gui.frame.FrameManager;
032: import org.columba.core.main.ColumbaCmdLineParser;
033: import org.columba.core.resourceloader.GlobalResourceLoader;
034: import org.columba.core.shutdown.ShutdownManager;
035:
036: /**
037: * Main entrypoint for addressbook component
038: *
039: * @author fdietz
040: */
041: public class AddressbookMain implements IComponentPlugin {
042: /** JDK 1.4+ logging framework logger, used for logging. */
043: private static final Logger LOG = Logger
044: .getLogger("org.columba.addressbook.main");
045:
046: private static final String RESOURCE_PATH = "org.columba.addressbook.i18n.global";
047:
048: public AddressbookMain() {
049: }
050:
051: /**
052: * @see org.columba.core.component.api.IComponentPlugin#handleCommandLineParameters()
053: */
054: public void handleCommandLineParameters(CommandLine commandLine) {
055: if (commandLine.hasOption("addressbook")) {
056: try {
057: FrameManager.getInstance().openView("Addressbook");
058:
059: ColumbaCmdLineParser.getInstance()
060: .setRestoreLastSession(false);
061: } catch (PluginLoadingFailedException e) {
062: LOG.severe(e.getLocalizedMessage());
063: }
064: }
065: }
066:
067: /**
068: * @see org.columba.core.component.api.IComponentPlugin#init()
069: */
070: public void init() {
071: // init addressbook plugin handlers
072: // PluginManager.getInstance().addHandlers(
073: // "org/columba/addressbook/plugin/pluginhandler.xml");
074:
075: /* try {
076: InputStream is = this.getClass().getResourceAsStream(
077: "/org/columba/addressbook/action/action.xml");
078: PluginManager.getInstance().getHandler(
079: IExtensionHandlerKeys.ORG_COLUMBA_CORE_ACTION).loadExtensionsFromStream(is);
080: } catch (PluginHandlerNotFoundException ex) {
081: }*/
082:
083: Runnable plugin = new SaveAllAddressbooksPlugin();
084: BackgroundTaskManager.getInstance().register(plugin);
085: ShutdownManager.getInstance().register(plugin);
086:
087: ServiceFacadeRegistry.getInstance().register(
088: org.columba.addressbook.facade.IContactFacade.class,
089: new ContactFacade());
090: ServiceFacadeRegistry.getInstance().register(
091: org.columba.addressbook.facade.IFolderFacade.class,
092: new FolderFacade());
093: ServiceFacadeRegistry.getInstance().register(
094: org.columba.addressbook.facade.IModelFacade.class,
095: new ModelFacade());
096: ServiceFacadeRegistry.getInstance().register(
097: org.columba.addressbook.facade.IDialogFacade.class,
098: new DialogFacade());
099: }
100:
101: /**
102: * @see org.columba.core.component.api.IComponentPlugin#postStartup()
103: */
104: public void postStartup() {
105: }
106:
107: /**
108: * @see org.columba.core.component.api.IComponentPlugin#registerCommandLineArguments()
109: */
110: public void registerCommandLineArguments() {
111: ColumbaCmdLineParser parser = ColumbaCmdLineParser
112: .getInstance();
113:
114: parser.addOption(new Option("addressbook", GlobalResourceLoader
115: .getString(RESOURCE_PATH, "global",
116: "cmdline_addressbook")));
117:
118: }
119: }
|