git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268519 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -122,7 +122,8 @@ public class Main { | |||
| // results of the wizard. | |||
| wiz.addWizardListener(new WizardListener() { | |||
| public void finished(Object model) { | |||
| System.out.println(model); | |||
| BuildData data = (BuildData) model; | |||
| System.out.println(data.createProject()); | |||
| System.exit(0); | |||
| } | |||
| public void canceled() { | |||
| @@ -50,6 +50,7 @@ setup.editor=org.apache.tools.ant.gui.wizard.build.ProjectSetupStep | |||
| setup.title=Setup project | |||
| setup.description=Give the project a name, and select the features you \ | |||
| wish to be included in the project file, such as JavaDoc and JAR creation. | |||
| setup.fileLabel=Build File: | |||
| setup.nameLabel=Project Name: | |||
| setup.optionsLabel=Options | |||
| setup.compile.label=Compiled Java code (.class files) | |||
| @@ -76,4 +76,14 @@ public interface WizardData { | |||
| */ | |||
| StateMachine getStateMachine(); | |||
| /** | |||
| * Get any listeners to register with the wizard controller. | |||
| * | |||
| * @return WizardListener instances to register for control events, or null | |||
| * for none. | |||
| */ | |||
| // XXX not sure about this yet. | |||
| //WizardListener[] getWizardListeners(); | |||
| } | |||
| @@ -57,6 +57,7 @@ import org.apache.tools.ant.gui.wizard.*; | |||
| import org.apache.tools.ant.gui.core.ResourceManager; | |||
| import org.apache.tools.ant.gui.acs.*; | |||
| import java.util.*; | |||
| import java.io.File; | |||
| /** | |||
| * Data model for the build wizard. | |||
| @@ -70,7 +71,8 @@ public class BuildData implements WizardData { | |||
| "org.apache.tools.ant.gui.resources.buildFileWizard"); | |||
| private StateMachine _stateMachine = new BuildStateMachine(); | |||
| private String _name = null; | |||
| private String _name = "MyProject"; | |||
| private File _outputFile = new File("build.xml"); | |||
| private boolean _isNewProject = true; | |||
| private List _optionalSteps = null; | |||
| @@ -119,6 +121,25 @@ public class BuildData implements WizardData { | |||
| return _name; | |||
| } | |||
| /** | |||
| * Set the output file. | |||
| * | |||
| * @param out Output file. | |||
| */ | |||
| public void setOutputFile(File out) { | |||
| _outputFile = out; | |||
| } | |||
| /** | |||
| * Get the output file. | |||
| * | |||
| * @return Output file. | |||
| */ | |||
| public File getOutputFile() { | |||
| return _outputFile; | |||
| } | |||
| /** | |||
| * Set whether or not a new project is being created. | |||
| * | |||
| @@ -156,4 +177,13 @@ public class BuildData implements WizardData { | |||
| } | |||
| /** | |||
| * Convert the state data into a project. | |||
| * | |||
| * @return Created project. | |||
| */ | |||
| public ACSProjectElement createProject() { | |||
| Builder builder = new Builder(this); | |||
| return builder.buildProject(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,92 @@ | |||
| /* | |||
| * 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.wizard.build; | |||
| import org.apache.tools.ant.gui.acs.*; | |||
| /** | |||
| * Class that takes care of converting the wizard state data stored in | |||
| * BuildData and translates it into a build file. | |||
| * | |||
| * @version $Revision$ | |||
| * @author Simeon Fitch | |||
| */ | |||
| public class Builder { | |||
| /** Build data. */ | |||
| private BuildData _data = null; | |||
| /** | |||
| * Constructor. | |||
| * | |||
| * @param data Build data to create project from. | |||
| */ | |||
| public Builder(BuildData data) { | |||
| _data = data; | |||
| } | |||
| /** | |||
| * Convert build data into a project. | |||
| * | |||
| * @return Project. | |||
| */ | |||
| public ACSProjectElement buildProject() { | |||
| ACSProjectElement retval = ACSFactory.getInstance().createProject(); | |||
| retval.setName(_data.getProjectName()); | |||
| return retval; | |||
| } | |||
| } | |||
| @@ -71,6 +71,9 @@ public class CompileStep extends AbstractWizardStep implements OptionalStep { | |||
| * | |||
| */ | |||
| protected void init() { | |||
| } | |||
| /** | |||
| @@ -54,11 +54,14 @@ | |||
| package org.apache.tools.ant.gui.wizard.build; | |||
| import org.apache.tools.ant.gui.wizard.AbstractWizardStep; | |||
| import org.apache.tools.ant.gui.util.LabelFieldGBC; | |||
| import org.apache.tools.ant.gui.customizer.FilePropertyEditor; | |||
| import javax.swing.*; | |||
| import java.awt.BorderLayout; | |||
| import java.awt.FlowLayout; | |||
| import java.awt.GridBagLayout; | |||
| import java.util.*; | |||
| import java.io.File; | |||
| /** | |||
| * Build file wizard step for naming the project and | |||
| @@ -89,6 +92,9 @@ public class ProjectSetupStep extends AbstractWizardStep { | |||
| /** Name of the project. */ | |||
| private JTextField _name = null; | |||
| /** Control for selecting a file. */ | |||
| private FilePropertyEditor _fileEditor = null; | |||
| /** | |||
| * Initialize the screen widgets. | |||
| @@ -97,12 +103,19 @@ public class ProjectSetupStep extends AbstractWizardStep { | |||
| protected void init() { | |||
| setLayout(new BorderLayout()); | |||
| JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT)); | |||
| LabelFieldGBC gbc = new LabelFieldGBC(); | |||
| JPanel p = new JPanel(new GridBagLayout()); | |||
| add(p, BorderLayout.NORTH); | |||
| _fileEditor = new FilePropertyEditor(); | |||
| p.add(new JLabel( | |||
| getResources().getString(getID() + ".fileLabel")), gbc.forLabel()); | |||
| p.add(_fileEditor.getCustomEditor(), gbc.forField()); | |||
| _name = new JTextField(10); | |||
| p.add(new JLabel(getResources().getString(getID() + ".nameLabel"))); | |||
| p.add(_name); | |||
| p.add(new JLabel( | |||
| getResources().getString(getID() + ".nameLabel")), gbc.forLabel()); | |||
| p.add(_name, gbc.forField()); | |||
| p = new JPanel(null); | |||
| p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); | |||
| @@ -131,6 +144,8 @@ public class ProjectSetupStep extends AbstractWizardStep { | |||
| BuildData data = (BuildData) getDataModel(); | |||
| _name.setText(data.getProjectName()); | |||
| _fileEditor.setValue(data.getOutputFile()); | |||
| // Steps. | |||
| List steps = data.getOptionalSteps(); | |||
| if(steps != null) { | |||
| @@ -150,6 +165,8 @@ public class ProjectSetupStep extends AbstractWizardStep { | |||
| BuildData data = (BuildData) getDataModel(); | |||
| data.setProjectName(_name.getText()); | |||
| data.setOutputFile((File)_fileEditor.getValue()); | |||
| // Steps. | |||
| List steps = new ArrayList(); | |||
| for(int i = 0; i < _selections.length; i++) { | |||