ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard AbstractWizzardStep.java InstructionStep.java Wizzard.java WizzardStep.java
Date Mon, 15 Jan 2001 20:57:00 GMT
metasim     01/01/15 12:57:00

  Modified:    src/antidote/org/apache/tools/ant/gui/wizzard
                        AbstractWizzardStep.java InstructionStep.java
                        Wizzard.java WizzardStep.java
  Log:
  Wizzard tweaks.
  
  Revision  Changes    Path
  1.2       +36 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/AbstractWizzardStep.java
  
  Index: AbstractWizzardStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/AbstractWizzardStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractWizzardStep.java	2001/01/15 19:47:31	1.1
  +++ AbstractWizzardStep.java	2001/01/15 20:56:59	1.2
  @@ -52,18 +52,23 @@
    * <http://www.apache.org/>.
    */
   package org.apache.tools.ant.gui.wizzard;
  +import org.apache.tools.ant.gui.core.ResourceManager;
   import javax.swing.JComponent;
   
   
   /**
    * Abstract class implementing the basic support for the WizzardStep interface.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public abstract class  AbstractWizzardStep extends JComponent 
       implements WizzardStep {
       
  +    /** Flag to indicate whether or not init has been called. */
  +    private boolean _initialized = false;
  +    /** Resources. */
  +    private ResourceManager _resources = null;
       /** Step id. */
       private String _id = null;
       /** Step display title. */
  @@ -78,6 +83,31 @@
       private String _prevID = null;
   
       /** 
  +     * Called when the instance should initialize its contents, e.g.
  +     * create the widgets, etc. When this is called then all
  +     * data values, including the ResourceManager, have been setup.
  +     * 
  +     */
  +    protected abstract void init();
  +
  +    /** 
  +     * Set the step's resources.
  +     * 
  +     */
  +    public void setResources(ResourceManager resources) {
  +        _resources = resources;
  +    }
  +
  +    /** 
  +     * Get the step's resources.
  +     * 
  +     * @return Resources.
  +     */
  +    protected ResourceManager getResources() {
  +        return _resources;
  +    }
  +
  +    /** 
        * Set the step id. The id must be unique among steps within the wizzard.
        * 
        * @param id Wizzard id.
  @@ -195,6 +225,11 @@
        * @return Editing component.
        */
       public JComponent getEditorComponent() {
  +        if(!_initialized) {
  +            init();
  +            _initialized = true;
  +        }
  +
           return this;
       }
   
  
  
  
  1.2       +38 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/InstructionStep.java
  
  Index: InstructionStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/InstructionStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InstructionStep.java	2001/01/15 19:47:32	1.1
  +++ InstructionStep.java	2001/01/15 20:56:59	1.2
  @@ -53,13 +53,50 @@
    */
   package org.apache.tools.ant.gui.wizzard;
   import javax.swing.*;
  +import java.awt.BorderLayout;
  +import java.awt.Font;
  +import java.awt.Insets;
   
   /**
    * Wizzard step whose only purpose is to display some text.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class InstructionStep extends AbstractWizzardStep {
   
  +    /** 
  +     * Initialize the contents of the container.
  +     * 
  +     */
  +    protected void init() {
  +        setLayout(new BorderLayout());
  +        String msg = getResources().getString(getID() + ".instructions");
  +
  +        JTextArea text = new JTextArea(msg);
  +        text.setMargin(new Insets(30, 20, 5, 5));
  +        text.setOpaque(false);
  +        text.setFont(new Font("Serif", Font.PLAIN, 18));
  +        text.setEditable(false);
  +        text.setLineWrap(true);
  +        text.setWrapStyleWord(true);
  +        add(text);
  +    }
  +
  +    /** 
  +     * Called when the step should refresh its display based on the 
  +     * current model setting.
  +     * 
  +     */
  +    public void updateDisplay() {
  +        // NOOP
  +    }
  +    /** 
  +     * Called when the step should update the data model based on the
  +     * settings of its widgets.
  +     * 
  +     */
  +    public void updateDataModel() {
  +        // NOOP
  +    }
   }
  
  
  
  1.2       +37 -13    jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/Wizzard.java
  
  Index: Wizzard.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/Wizzard.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Wizzard.java	2001/01/15 19:47:32	1.1
  +++ Wizzard.java	2001/01/15 20:56:59	1.2
  @@ -60,12 +60,13 @@
   import java.awt.CardLayout;
   import java.awt.Dimension;
   import java.awt.Font;
  +import java.awt.Insets;
   import java.util.*;
   
   /**
    * Top level container and controller for wizzard-type GUI.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public class Wizzard extends JComponent {
  @@ -78,8 +79,12 @@
       private CardLayout _layout = null;
       /** Set initialized steps. */
       private Map _steps = new HashMap();
  +    /** Steps saved in a list to preserve ordering. */
  +    private List _stepOrdering = new ArrayList();
       /** Description text. XXX should probably change to some other widget. */
       private JTextArea _description = null;
  +    /** Progress meter. */
  +    private JProgressBar _progress = null;
       /** Widget for navigating through steps. */
       private WizzardNavigator _nav = null;
       /** The data model to pass on to each step. */
  @@ -100,21 +105,35 @@
           _resources = resources;
           _model = dataModel;
   
  -        TitledBorder border = new TitledBorder("Border");
  -        setBorder(border);
  -
  -        _description = new JTextArea(4, 40);
  -        _description.setBorder(BorderFactory.createEtchedBorder());
  -        _description.setOpaque(false);
  +        _progress = new JProgressBar();
  +        _progress.setBorder(BorderFactory.createTitledBorder(
  +            _resources.getString("progress")));
  +        _progress.setStringPainted(true);
  +        add(_progress, BorderLayout.NORTH);
  +
  +        _description = new JTextArea();
  +        _description.setMargin(new Insets(5, 5, 5, 5));
  +        _description.setPreferredSize(new Dimension(100, 100));
  +        _description.setOpaque(true);
           _description.setFont(new Font("Serif", Font.PLAIN, 12));
           _description.setEditable(false);
           _description.setLineWrap(true);
           _description.setWrapStyleWord(true);
   
  -        add(_description, BorderLayout.NORTH);
  +        JScrollPane scroller = new JScrollPane(
  +            _description, 
  +            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 
  +            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 
  +
  +        scroller.setBorder(BorderFactory.createTitledBorder(
  +            _resources.getString("help")));
  +        add(scroller, BorderLayout.WEST);
   
           _stepContainer = new JPanel(_layout = new CardLayout());
           _stepContainer.setBorder(BorderFactory.createEtchedBorder());
  +        _stepContainer.setPreferredSize(new Dimension(400, 400));
  +
  +
           add(_stepContainer, BorderLayout.CENTER);
   
           _nav = new ButtonNavigator(_resources);
  @@ -123,10 +142,12 @@
           add((ButtonNavigator)_nav, BorderLayout.SOUTH);
   
           String[] steps = _resources.getStringArray("steps");
  +        _progress.setMaximum(steps.length - 1);
           try {
               for(int i = 0; i < steps.length; i++) {
                   Class type = _resources.getClass(steps[i] + ".editor");
                   WizzardStep step = (WizzardStep) type.newInstance();
  +                step.setResources(_resources);
                   step.setID(steps[i]);
                   step.setTitle(_resources.getString(steps[i]+ ".title"));
                   step.setDescription(
  @@ -141,6 +162,7 @@
                   step.setPrevious(id);
   
                   _steps.put(steps[i], step);
  +                _stepOrdering.add(step);
                   _stepContainer.add(step.getEditorComponent(), steps[i]);
               }
               // Initialize the first screen with the data model.
  @@ -157,8 +179,6 @@
               ex.printStackTrace();
           }
   
  -        setPreferredSize(new Dimension(500, 400));
  -
       }
   
       /** 
  @@ -188,22 +208,26 @@
           if(step == null) return;
   
           // Transfer data model (in case step wants to create a new one.
  +        _curr.updateDataModel();
           step.setDataModel(_curr.getDataModel());
           
           // Update the title and description.
  -        TitledBorder border = (TitledBorder) getBorder();
  -        border.setTitle(step.getTitle());
  +        _stepContainer.setBorder(
  +            BorderFactory.createTitledBorder(step.getTitle()));
           _description.setText(step.getDescription());
   
           _nav.setBackEnabled(step.getPrevious() != null);
           _nav.setNextEnabled(step.getNext() != null);
           _nav.setFinishEnabled(step.getNext() == null);
  +        _progress.setValue(_stepOrdering.indexOf(step));
  +
  +        // Tell the step to refresh its display based on the data model.
  +        step.updateDisplay();
   
           // Display the step.
           _layout.show(_stepContainer, step.getID());
   
           _curr = step;
  -
       }
   
       /** Handler for actions invoked by wizzard. */
  
  
  
  1.2       +23 -1     jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/WizzardStep.java
  
  Index: WizzardStep.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/wizzard/WizzardStep.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WizzardStep.java	2001/01/15 19:47:32	1.1
  +++ WizzardStep.java	2001/01/15 20:56:59	1.2
  @@ -52,17 +52,24 @@
    * <http://www.apache.org/>.
    */
   package org.apache.tools.ant.gui.wizzard;
  +import org.apache.tools.ant.gui.core.ResourceManager;
   import javax.swing.JComponent;
   
   
   /**
    * Interface for classes defining a step in a wizzard.
    * 
  - * @version $Revision: 1.1 $ 
  + * @version $Revision: 1.2 $ 
    * @author Simeon Fitch 
    */
   public interface WizzardStep {
       /** 
  +     * Set the step's resources.
  +     * 
  +     */
  +    void setResources(ResourceManager resources);
  +
  +    /** 
        * Set the step id. The id must be unique among steps within the wizzard.
        * 
        * @param id Wizzard id.
  @@ -153,4 +160,19 @@
        * @return Editing component.
        */
       JComponent getEditorComponent();
  +
  +    /** 
  +     * Called when the step should refresh its display based on the 
  +     * current model setting.
  +     * 
  +     */
  +    void updateDisplay();
  +
  +    /** 
  +     * Called when the step should update the data model based on the
  +     * settings of its widgets.
  +     * 
  +     */
  +    void updateDataModel();
  +
   }
  
  
  

Mime
View raw message