001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.core.gui.externaltools;
019:
020: import javax.help.CSH;
021:
022: import net.javaprog.ui.wizard.DataLookup;
023: import net.javaprog.ui.wizard.DataModel;
024: import net.javaprog.ui.wizard.DefaultWizardModel;
025: import net.javaprog.ui.wizard.JavaHelpSupport;
026: import net.javaprog.ui.wizard.Step;
027: import net.javaprog.ui.wizard.Wizard;
028: import net.javaprog.ui.wizard.WizardModel;
029:
030: import org.columba.api.plugin.IExtension;
031: import org.columba.api.plugin.IExtensionHandler;
032: import org.columba.api.plugin.IExtensionHandlerKeys;
033: import org.columba.api.plugin.PluginHandlerNotFoundException;
034: import org.columba.core.help.HelpManager;
035: import org.columba.core.plugin.PluginManager;
036: import org.columba.core.resourceloader.IconKeys;
037: import org.columba.core.resourceloader.ImageLoader;
038:
039: /**
040: * Launches external tools wizard.
041: *
042: * @author fdietz
043: */
044: public class ExternalToolsWizardLauncher {
045: protected DataModel data;
046:
047: protected ExternalToolsWizardModelListener listener;
048:
049: public void launchWizard(final String pluginID, boolean firstTime) {
050: final AbstractExternalToolsPlugin plugin;
051: IExtensionHandler handler = null;
052:
053: try {
054: handler = PluginManager
055: .getInstance()
056: .getExtensionHandler(
057: IExtensionHandlerKeys.ORG_COLUMBA_CORE_EXTERNALTOOLS);
058: } catch (PluginHandlerNotFoundException e) {
059: e.printStackTrace();
060: }
061:
062: try {
063: IExtension extension = handler.getExtension(pluginID);
064:
065: plugin = (AbstractExternalToolsPlugin) extension
066: .instanciateExtension(null);
067: } catch (Exception e1) {
068: e1.printStackTrace();
069:
070: return;
071: }
072:
073: data = new DataModel();
074: data.registerDataLookup("id", new DataLookup() {
075: public Object lookupData() {
076: return pluginID;
077: }
078: });
079:
080: data.registerDataLookup("Plugin", new DataLookup() {
081: public Object lookupData() {
082: return plugin;
083: }
084: });
085:
086: WizardModel model;
087:
088: if (firstTime) {
089: model = new DefaultWizardModel(new Step[] {
090: new DescriptionStep(data), new LocationStep(data) });
091: } else {
092: model = new DefaultWizardModel(new Step[] { new InfoStep(),
093: new DescriptionStep(data), new LocationStep(data) });
094: }
095:
096: listener = new ExternalToolsWizardModelListener(data);
097: model.addWizardModelListener(listener);
098:
099: // TODO (@author fdietz): i18n
100: Wizard wizard = new Wizard(model,
101: "External Tools Configuration", ImageLoader
102: .getSmallIcon(IconKeys.PREFERENCES));
103: wizard.setStepListRenderer(null);
104: CSH.setHelpIDString(wizard, "extending_columba_2");
105: JavaHelpSupport.enableHelp(wizard, HelpManager.getInstance()
106: .getHelpBroker());
107:
108: wizard.pack();
109: wizard.setLocationRelativeTo(null);
110: wizard.setVisible(true);
111: }
112:
113: public boolean isFinished() {
114: return listener.isFinished();
115: }
116:
117: /**
118: * @return
119: */
120: public DataModel getData() {
121: return data;
122: }
123: }
|