You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by me...@apache.org on 2001/01/15 20:47:32 UTC
cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard AbstractWizzardStep.java ButtonNavigator.java InstructionStep.java NavigatorListener.java Wizzard.java WizzardListener.java WizzardNavigator.java WizzardStep.java
metasim 01/01/15 11:47:32
Added: src/antidote/org/apache/tools/ant/gui/wizzard
AbstractWizzardStep.java ButtonNavigator.java
InstructionStep.java NavigatorListener.java
Wizzard.java WizzardListener.java
WizzardNavigator.java WizzardStep.java
Log:
Initial framework for a build-file wizzard.
Revision Changes Path
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/AbstractWizzardStep.java
Index: AbstractWizzardStep.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
import javax.swing.JComponent;
/**
* Abstract class implementing the basic support for the WizzardStep interface.
*
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
public abstract class AbstractWizzardStep extends JComponent
implements WizzardStep {
/** Step id. */
private String _id = null;
/** Step display title. */
private String _title = null;
/** Description of the step. */
private String _description = null;
/** Data model. */
private Object _model = null;
/** ID of next step. */
private String _nextID = null;
/** ID of previous step. */
private String _prevID = null;
/**
* Set the step id. The id must be unique among steps within the wizzard.
*
* @param id Wizzard id.
*/
public void setID(String id) {
_id = id;
}
/**
* Get the step id.
*
* @return Step id.
*/
public String getID() {
return _id;
}
/**
* Set the step title.
*
* @param title Step title.
*/
public void setTitle(String title) {
_title = title;
}
/**
* Get the step title.
*
* @return Step title.
*/
public String getTitle() {
return _title;
}
/**
* Set the step description.
*
* @param desc Step description.
*/
public void setDescription(String desc) {
_description = desc;
}
/**
* Get the step description.
*
* @return Step description.
*/
public String getDescription() {
return _description;
}
/**
* Set the default id of the next step.
*
* @param nextID ID of next step.
*/
public void setNext(String nextID) {
_nextID = nextID;
}
/**
* Get the id of the next step.
*
* @return ID of next step.
*/
public String getNext() {
return _nextID;
}
/**
* Set the default id of the previous step.
*
* @param prevID ID of previous step.
*/
public void setPrevious(String prevID) {
_prevID = prevID;
}
/**
* Get the id of the previous step.
*
* @return Previous step.
*/
public String getPrevious() {
return _prevID;
}
/**
* Set the data model object that the step will edit. It is assumed
* that all steps initialized within a single wizzard agree on the
* data model type.
*
* @param model Data model to edit.
*/
public void setDataModel(Object model) {
_model = model;
}
/**
* Get the data model that should be passeed on to the next step.
*
* @return Current data model.
*/
public Object getDataModel() {
return _model;
}
/**
* Get the component that should be displayed to the user for
* editing the model. This component should <b>not</b> include the
* title and text display, which is handled by the wizzard container.
*
* @return Editing component.
*/
public JComponent getEditorComponent() {
return this;
}
/**
* Get a string representation of this.
*
* @return String representation.
*/
public String toString() {
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append("[id=");
buf.append(getID());
buf.append(",prev=");
buf.append(getPrevious());
buf.append(",next=");
buf.append(getNext());
buf.append("]");
return buf.toString();
}
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/ButtonNavigator.java
Index: ButtonNavigator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
import org.apache.tools.ant.gui.core.ResourceManager;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
import java.util.*;
class ButtonNavigator extends JComponent implements WizzardNavigator {
public static final String NEXT = "next";
public static final String BACK = "back";
public static final String CANCEL = "cancel";
public static final String FINISH = "finish";
/** Resources. */
private ResourceManager _resources = null;
/** Event listeners. */
private List _listeners = new ArrayList();
/* Buttons. */
private JButton _next = null;
private JButton _back = null;
private JButton _cancel = null;
private JButton _finish = null;
/** Action handler. */
private ActionHandler _handler = new ActionHandler();
public ButtonNavigator(ResourceManager resources) {
_resources = resources;
setLayout(new FlowLayout(FlowLayout.RIGHT));
_back = new JButton(_resources.getString(BACK));
_next = new JButton(_resources.getString(NEXT));
_finish = new JButton(_resources.getString(FINISH));
_cancel = new JButton(_resources.getString(CANCEL));
_back.setActionCommand(BACK);
_next.setActionCommand(NEXT);
_finish.setActionCommand(FINISH);
_cancel.setActionCommand(CANCEL);
_back.addActionListener(_handler);
_next.addActionListener(_handler);
_finish.addActionListener(_handler);
_cancel.addActionListener(_handler);
_back.setEnabled(false);
_next.setEnabled(false);
_finish.setEnabled(false);
_cancel.setEnabled(true);
add(_back);
add(_next);
add(_finish);
add(_cancel);
}
/**
* Add a navigator listener.
*
* @param l Listener to add.
*/
public void addNavigatorListener(NavigatorListener l) {
_listeners.add(l);
}
/**
* Remove a navigator listener.
*
* @param l Listener to remove.
*/
public void removeNavigatorListener(NavigatorListener l) {
_listeners.remove(l);
}
/**
* Set the enabled state of the back button.
*
* @param state True for enabled, false for disabled.
*/
public void setBackEnabled(boolean state) {
_back.setEnabled(state);
}
/**
* Set the enabled state of the next button.
*
* @param state True for enabled, false for disabled.
*/
public void setNextEnabled(boolean state) {
_next.setEnabled(state);
}
/**
* Set the enabled state of the finished button.
*
* @param state True for enabled, false for disabled.
*/
public void setFinishEnabled(boolean state) {
_finish.setEnabled(state);
}
/** Handler of the button presses. */
private class ActionHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
// Predetermine which method to call so that
// we don't traverse if statements for each iteration.
int idx = -1;
if(source == _next) {
idx = 0;
}
else if(source == _back) {
idx = 1;
}
else if(source == _cancel) {
idx = 2;
}
else if(source == _finish) {
idx = 3;
}
Iterator it = _listeners.iterator();
while(it.hasNext()) {
NavigatorListener l = (NavigatorListener) it.next();
switch(idx) {
case 0:
l.nextStep();
break;
case 1:
l.backStep();
break;
case 2:
l.cancel();
break;
case 3:
l.finish();
break;
}
}
}
}
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/InstructionStep.java
Index: InstructionStep.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
import javax.swing.*;
/**
* Wizzard step whose only purpose is to display some text.
*
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
public class InstructionStep extends AbstractWizzardStep {
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/NavigatorListener.java
Index: NavigatorListener.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
/**
* Interface for classes interested in events from the WizzardNavigator.
*
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
public interface NavigatorListener {
/**
* Called when the wizzard should show the next step.
*
*/
void nextStep();
/**
* Called when the wizzard should show the previous step.
*
*/
void backStep();
/**
* Called when the wizzard should show the step with the given id.
*
* @param stepID ID of step to show.
*/
void gotoStep(String stepID);
/**
* Called when the wizzard activity shold be cancelled.
*
*/
void cancel();
/**
* Called when the wizzard is finished.
*
*/
void finish();
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/Wizzard.java
Index: Wizzard.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
import org.apache.tools.ant.gui.core.ResourceManager;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.util.*;
/**
* Top level container and controller for wizzard-type GUI.
*
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
public class Wizzard extends JComponent {
/** Resources defining the wizzard contents. Separate from the
* application context resources. */
private ResourceManager _resources = null;
/** Container for the step editors. */
private JPanel _stepContainer = null;
/** Layout manager for all the step panels. */
private CardLayout _layout = null;
/** Set initialized steps. */
private Map _steps = new HashMap();
/** Description text. XXX should probably change to some other widget. */
private JTextArea _description = null;
/** Widget for navigating through steps. */
private WizzardNavigator _nav = null;
/** The data model to pass on to each step. */
private Object _model = null;
/** The current Wizzard step. */
private WizzardStep _curr = null;
/** The set of wizzard listeners. */
private List _listeners = new ArrayList(1);
/**
* Standard ctor.
*
* @param resources Wizzard definition resources
* @param dataModel Initial data model.
*/
public Wizzard(ResourceManager resources, Object dataModel) {
setLayout(new BorderLayout());
_resources = resources;
_model = dataModel;
TitledBorder border = new TitledBorder("Border");
setBorder(border);
_description = new JTextArea(4, 40);
_description.setBorder(BorderFactory.createEtchedBorder());
_description.setOpaque(false);
_description.setFont(new Font("Serif", Font.PLAIN, 12));
_description.setEditable(false);
_description.setLineWrap(true);
_description.setWrapStyleWord(true);
add(_description, BorderLayout.NORTH);
_stepContainer = new JPanel(_layout = new CardLayout());
_stepContainer.setBorder(BorderFactory.createEtchedBorder());
add(_stepContainer, BorderLayout.CENTER);
_nav = new ButtonNavigator(_resources);
_nav.addNavigatorListener(new NavHandler());
((ButtonNavigator)_nav).setBorder(BorderFactory.createEtchedBorder());
add((ButtonNavigator)_nav, BorderLayout.SOUTH);
String[] steps = _resources.getStringArray("steps");
try {
for(int i = 0; i < steps.length; i++) {
Class type = _resources.getClass(steps[i] + ".editor");
WizzardStep step = (WizzardStep) type.newInstance();
step.setID(steps[i]);
step.setTitle(_resources.getString(steps[i]+ ".title"));
step.setDescription(
_resources.getString(steps[i]+ ".description"));
String id = _resources.getString(steps[i] + ".next");
id = (id == null && i < steps.length - 1) ? steps[i + 1] : id;
step.setNext(id);
id = _resources.getString(steps[i] + ".prev");
id = (id == null && i > 0) ? steps[i - 1] : id;
step.setPrevious(id);
_steps.put(steps[i], step);
_stepContainer.add(step.getEditorComponent(), steps[i]);
}
// Initialize the first screen with the data model.
if(steps.length > 0) {
WizzardStep first = (WizzardStep)_steps.get(steps[0]);
first.setDataModel(_model);
_curr = first;
showStep(first);
}
}
catch(Exception ex) {
// If we get here then the wizzard didn't initialize properly.
// XXX log me.
ex.printStackTrace();
}
setPreferredSize(new Dimension(500, 400));
}
/**
* Add a wizzard listener.
*
* @param l Listener to add.
*/
public void addWizzardListener(WizzardListener l) {
_listeners.add(l);
}
/**
* Remove a wizzard listener.
*
* @param l Listener to remove.
*/
public void removeWizzardListener(WizzardListener l) {
_listeners.remove(l);
}
/**
* Go to the given step.
*
* @param step Step to go to.
*/
private void showStep(WizzardStep step) {
if(step == null) return;
// Transfer data model (in case step wants to create a new one.
step.setDataModel(_curr.getDataModel());
// Update the title and description.
TitledBorder border = (TitledBorder) getBorder();
border.setTitle(step.getTitle());
_description.setText(step.getDescription());
_nav.setBackEnabled(step.getPrevious() != null);
_nav.setNextEnabled(step.getNext() != null);
_nav.setFinishEnabled(step.getNext() == null);
// Display the step.
_layout.show(_stepContainer, step.getID());
_curr = step;
}
/** Handler for actions invoked by wizzard. */
private class NavHandler implements NavigatorListener {
public void nextStep() {
String nextID = _curr.getNext();
if(nextID != null) {
showStep((WizzardStep)_steps.get(nextID));
}
}
public void backStep() {
String prevID = _curr.getPrevious();
if(prevID != null) {
showStep((WizzardStep)_steps.get(prevID));
}
}
public void gotoStep(String stepID){
showStep((WizzardStep) _steps.get(stepID));
}
public void cancel() {
Iterator it = _listeners.iterator();
while(it.hasNext()) {
WizzardListener l = (WizzardListener) it.next();
l.canceled();
}
}
public void finish() {
Iterator it = _listeners.iterator();
while(it.hasNext()) {
WizzardListener l = (WizzardListener) it.next();
l.finished(_curr.getDataModel());
}
}
}
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/WizzardListener.java
Index: WizzardListener.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
/**
* Interface for classes desiring notifiction of when the user
* completes his/her use of wizzard.
*
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
public interface WizzardListener {
/**
* Called when the user has clicked the finish button.
*
* @param model Last state of the object model.
*/
void finished(Object model);
/**
* Called when the user has clicked the cancel button.
*
*/
void canceled();
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/WizzardNavigator.java
Index: WizzardNavigator.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
public interface WizzardNavigator {
/**
* Add a navigator listener.
*
* @param l Listener to add.
*/
void addNavigatorListener(NavigatorListener l);
/**
* Remove a navigator listener.
*
* @param l Listener to remove.
*/
void removeNavigatorListener(NavigatorListener l);
/**
* Set the enabled state of the back control.
*
* @param state True for enabled, false for disabled.
*/
void setBackEnabled(boolean state);
/**
* Set the enabled state of the next control.
*
* @param state True for enabled, false for disabled.
*/
void setNextEnabled(boolean state);
/**
* Set the enabled state of the finished control.
*
* @param state True for enabled, false for disabled.
*/
void setFinishEnabled(boolean state);
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/WizzardStep.java
Index: WizzardStep.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", 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 apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*/
package org.apache.tools.ant.gui.wizzard;
import javax.swing.JComponent;
/**
* Interface for classes defining a step in a wizzard.
*
* @version $Revision: 1.1 $
* @author Simeon Fitch
*/
public interface WizzardStep {
/**
* Set the step id. The id must be unique among steps within the wizzard.
*
* @param id Wizzard id.
*/
void setID(String id);
/**
* Get the step id.
*
* @return Step id.
*/
String getID();
/**
* Set the step title.
*
* @param title Step title.
*/
void setTitle(String title);
/**
* Get the step title.
*
* @return Step title.
*/
String getTitle();
/**
* Set the step description.
*
* @param desc Step description.
*/
void setDescription(String desc);
/**
* Get the step description.
*
* @return Step description.
*/
String getDescription();
/**
* Set the default id of the next step.
*
* @param nextID ID of next step.
*/
void setNext(String nextID);
/**
* Get the id of the next step.
*
* @return ID of next step.
*/
String getNext();
/**
* Set the default id of the previous step.
*
* @param prevID ID of previous step.
*/
void setPrevious(String prevID);
/**
* Get the id of the previous step.
*
* @return Previous step.
*/
String getPrevious();
/**
* Set the data model object that the step will edit. It is assumed
* that all steps initialized within a single wizzard agree on the
* data model type.
*
* @param model Data model to edit.
*/
void setDataModel(Object model);
/**
* Get the data model that should be passeed on to the next step.
*
* @return Current data model.
*/
Object getDataModel();
/**
* Get the component that should be displayed to the user for
* editing the model. This component should <b>not</b> include the
* title and text display, which is handled by the wizzard container.
*
* @return Editing component.
*/
JComponent getEditorComponent();
}