|
From: <tr...@us...> - 2003-09-13 15:33:21
|
Update of /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig In directory sc8-pr-cvs1:/tmp/cvs-serv19450/com/babeldoc/gui/wizard/addconfig Added Files: AddConfigController.java AddConfigModel.java AddConfigWizard.java AddConfigWizardCommand.java AddConfigWizardPanel.java NameAddConfigWizardPanel.java TypeAddConfigWizardPanel.java Log Message: Lots of GUI loving! Been working on the pipeline builder tool and getting into some shape. Now the pipeline stage configuration editing is looking a whole lot better. --- NEW FILE: AddConfigController.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig/AddConfigController.java,v 1.1 2003/09/13 15:33:11 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.wizard.addconfig; import com.babeldoc.gui.wizard.SimpleWizardController; import com.babeldoc.gui.wizard.StandardWizardPanel; import com.babeldoc.gui.wizard.WizardPanel; /** * The controller to manage the movement between the two panels in the add * pipeline wizard. */ public class AddConfigController extends SimpleWizardController { private AddConfigModel model; /** * Constructor. * * @param model */ public AddConfigController(AddConfigModel model) { this.setModel(model); this.panels = new StandardWizardPanel[] { new NameAddConfigWizardPanel(model), new TypeAddConfigWizardPanel(model) }; } /** * TODO: DOCUMENT ME! * * @param model DOCUMENT ME! */ public void setModel(AddConfigModel model) { this.model = model; } /** * Get the model. * * @return */ public AddConfigModel getModel() { return model; } /** * Can only go back if there is a panel to go back to and it is allowed to * change the pipeline (this is because the model was constructed using the * pipeline name) * * @param current * * @return */ public boolean canDoBack(WizardPanel current) { int number = ((StandardWizardPanel) current).getNumber(); return (number > 0); } /** * Can only finish on final panel. * * @param current * * @return */ public boolean canDoFinish(WizardPanel current) { int number = ((StandardWizardPanel) current).getNumber(); return number == TypeAddConfigWizardPanel.NUMBER && getModel().getConfigName()!=null; } /** * Finish the wizard. * * @param current */ public void finish(WizardPanel current) { this.getModel().setFinished(true); closeDialog(); } /** * Validate some of the panels. * * @param current * * @return */ public WizardPanel next(WizardPanel current) { return super.next(current); } /** * Little bit of trickery here - start from 1 if pipeline set. * * @return */ public WizardPanel start() { return panels[0]; } } --- NEW FILE: AddConfigModel.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig/AddConfigModel.java,v 1.1 2003/09/13 15:33:11 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.wizard.addconfig; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; import com.babeldoc.core.LogService; import com.babeldoc.gui.wizard.WizardModel; import java.lang.reflect.Field; import java.util.Map; import java.util.HashMap; /** * AddConfigModel contains the data to manage the creation of a new configuration * option. * * @author bmcdonald * @version 1.1 */ public class AddConfigModel extends WizardModel { private String configName; private String configType; private String configDesc; private ConfigOption configOption; private Map map; private String [] types; /** * Ctor */ public AddConfigModel() { } /** * We write the pipeline stage information to the configuration files. * * @param finished */ public void setFinished(boolean finished) { super.setFinished(finished); if (finished) { Class c = (Class)map.get(getConfigType()); System.out.println(c); try { IConfigOptionType type = (IConfigOptionType)(c.newInstance()); setConfigOption(new ConfigOption(getConfigName(), type, null, false, getConfigDesc())); } catch (InstantiationException e) { LogService.getInstance().logError(e); } catch (IllegalAccessException e) { LogService.getInstance().logError(e); } } } public String getConfigName() { return configName; } public void setConfigName(String configName) { this.configName = configName; } public String getConfigType() { return configType; } public void setConfigType(String configType) { this.configType = configType; } public ConfigOption getConfigOption() { return configOption; } public void setConfigOption(ConfigOption configOption) { this.configOption = configOption; } /** * @return Get the list of possible configuration option types */ public String[] getConfigOptionTypes() { if(map==null) { Class optionType = IConfigOptionType.class; map = new HashMap(); Field[] fields = optionType.getDeclaredFields(); types = new String[fields.length]; for (int i = 0; i < fields.length; i++) { Field field = fields[i]; map.put(field.getName(), field.getType()); types[i] = field.getName(); } } return types; } public String getConfigDesc() { return configDesc; } public void setConfigDesc(String configDesc) { this.configDesc = configDesc; } } --- NEW FILE: AddConfigWizard.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig/AddConfigWizard.java,v 1.1 2003/09/13 15:33:11 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.wizard.addconfig; import com.babeldoc.core.I18n; import com.babeldoc.gui.wizard.WizardDialog; /** * The AddPipelineStageWizard allows for quick and easy access to the wizard. * Simply execute the static run method and then browse the returned model * object to getChild the results. * * @author bmcdonald * @version 1.1 */ public class AddConfigWizard { private AddConfigModel model; /** * Private constructor - use the run method getChild an instance. * * @param model */ private AddConfigWizard(AddConfigModel model) { this.model = model; } /** * Run the wizard. * * @return */ public static final AddConfigWizard run() { AddConfigWizard wizard = new AddConfigWizard(new AddConfigModel()); WizardDialog wiz = new WizardDialog(I18n.get("gui.wizard.addstage.title"), new AddConfigController(wizard.getModel())); wiz.pack(); wiz.show(); return wizard; } /** * Get the stored model * * @return */ public AddConfigModel getModel() { return model; } } --- NEW FILE: AddConfigWizardCommand.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig/AddConfigWizardCommand.java,v 1.1 2003/09/13 15:33:11 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.wizard.addconfig; import com.babeldoc.core.BabeldocCommand; import com.babeldoc.core.I18n; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; /** * The AddConfigWizardCommnand drives the configuration wizard code. * * @author bmcdonald * @version 1.1 */ public class AddConfigWizardCommand extends BabeldocCommand { /** * Creates a new LightConfigCommand object. */ public AddConfigWizardCommand() { } /** * Process the commands on the command line * * @param args the command line */ public AddConfigWizardCommand(String[] args) { super("addconfig", "Add a configuration option", args); } /** * Execute the commandline * * @param commandLine */ public void execute(CommandLine commandLine) { AddConfigWizard.run(); System.exit(0); } /** * Main routine * * @param args */ public static void main(String[] args) { new AddConfigWizardCommand(args); System.exit(0); } /** * Setup the command line arguments * * @param options the commandline options to look for */ public void setupCommandLine(Options options) { super.setupCommandLine(options); } } --- NEW FILE: AddConfigWizardPanel.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig/AddConfigWizardPanel.java,v 1.1 2003/09/13 15:33:11 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.wizard.addconfig; import com.babeldoc.gui.wizard.StandardWizardPanel; /** * Base class of the add * * @author bmcdonald * @version 1.1 */ public abstract class AddConfigWizardPanel extends StandardWizardPanel { private AddConfigModel model = null; /** * Constructor to set the model, panel number and the left hand side * information panel. * * @param model * @param number * @param info */ public AddConfigWizardPanel(AddConfigModel model, int number, String info) { super(number, info); this.model = model; } /** * Set the model * * @param model */ public void setModel(AddConfigModel model) { this.model = model; } /** * Get the model * * @return */ public AddConfigModel getModel() { return model; } } --- NEW FILE: NameAddConfigWizardPanel.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/wizard/addconfig/NameAddConfigWizardPanel.java,v 1.1 2003/09/13 15:33:11 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.wizard.addconfig; import javax.swing.*; import java.awt.*; import java.awt.event.FocusListener; import java.awt.event.FocusEvent; /** * The name selection wizard panel in this wizard * * @author bmcdonald * @version 1.1 */ public class NameAddConfigWizardPanel extends AddConfigWizardPanel implements FocusListener { public static final int NUMBER = 0; /** swing components */ private JTextField name = new JTextField(); private JTextField desc = new JTextField(); /** * Constructor to set the model, panel number and the left hand side * information panel. * * @param model */ public NameAddConfigWizardPanel(AddConfigModel model) { super(model, NUMBER, "Enter the name of the\n configuration option"); setupRightPanel(); } /** * Override this method. This is called from the wizard dialog just prior to * showing your wizard panel. This is used to setup the components on the * the panel */ protected void initialize() { if(getModel().getConfigName()!=null) { name.setText(getModel().getConfigName()); name.requestFocus(); } } /** * Add the list to the panel, setup the listener to set the model when the * pipeline selection changes. */ private void setupRightPanel() { JPanel downpanel = new JPanel(); downpanel.setLayout(new BoxLayout(downpanel, BoxLayout.PAGE_AXIS)); downpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); name.setMaximumSize(new Dimension(1000, 20)); downpanel.add(name); downpanel.add(Box.createVerticalBox()); this.add(downpanel, BorderLayout.CENTER); name.addFocusListener(this); } /** * Invoked when a component gains the keyboard focus. */ public void focusGained(FocusEvent e) { } /** * Invoked when a component loses the keyboard focus. */ public void focusLost(FocusEvent e) { if(name.getText()!=null) { getModel().setConfigName(name.getText()); } } } --- NEW FILE: TypeAddConfigWizardPanel.java --- package com.babeldoc.gui.wizard.addconfig; import javax.swing.*; import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent; /** * The add configuration option wizard panel in this wizard for selecting the * type of the configuration option. * * @author bmcdonald * @version 1.1 */ public class TypeAddConfigWizardPanel extends AddConfigWizardPanel{ public static final int NUMBER = 1; /** swing components */ private DefaultListModel listmodel; private JList list; /** * Constructor to set the model, panel number and the left hand side * information panel. * * @param model */ public TypeAddConfigWizardPanel(AddConfigModel model) { super(model, NUMBER, "Select the type of the configuration option"); setupRightPanel(); } /** * Override this method. This is called from the wizard dialog just prior to * showing your wizard panel. This is used to setup the components on the * the panel */ protected void initialize() { int selected = 0; String [] types = getModel().getConfigOptionTypes(); for(int i = 0; i < types.length; ++i) { listmodel.addElement(types[i]); if(types[i].equals(getModel().getConfigType())) { selected = i; } } list.setSelectedIndex(selected); list.requestFocus(); } /** * Add the list to the panel, setup the listener to set the model when the * pipeline selection changes. */ private void setupRightPanel() { listmodel = new DefaultListModel(); list = new JList(); list.setModel(listmodel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { // int index = e.getFirstIndex(); String configType = (String) list.getSelectedValue(); if (configType != null) { getModel().setConfigType(configType); } } } }); this.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); this.add(new JScrollPane(list)); } } |