View Javadoc

1   /*
2    * $Id$
3    *
4    * The contents of this file are subject to the Mozilla Public License 
5    * Version 1.1 (the "License"); you may not use this file except in 
6    * compliance with the License. You may obtain a copy of the License at 
7    * http://www.mozilla.org/MPL/ 
8    *
9    * Software distributed under the License is distributed on an "AS IS" basis, 
10   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
11   * for the specific language governing rights and limitations under the License.
12   *
13   * The Original Code is XML Hammer code. (org.xmlhammer.*)
14   *
15   * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
16   * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
17   * All Rights Reserved.
18   *
19   * Contributor(s): Edwin Dankert <edankert@gmail.com>
20   */
21  
22  package org.xmlhammer.gui.wizard;
23  
24  import java.awt.Frame;
25  import java.util.List;
26  
27  import org.xmlhammer.gui.util.wizard.HelpEnabledWizard;
28  import org.xmlhammer.model.jaxp.JAXPSchemaFactory;
29  import org.xmlhammer.model.jaxp.JAXPTransformerFactory;
30  import org.xmlhammer.model.jaxp.Settings;
31  import org.xmlhammer.model.project.Document;
32  import org.xmlhammer.model.project.Input;
33  import org.xmlhammer.model.project.Project;
34  
35  public class NewStylesheetValidatorWizard extends HelpEnabledWizard {
36  
37      private static final long serialVersionUID = -2924107376836737591L;
38      
39      private InputFilterPage filterPage = null;
40      private InputURIsPage urisPage = null;
41      private InputTypeSelectionPage typeSelectionPage = null;
42  
43      public NewStylesheetValidatorWizard(Frame parent) {
44          super(parent);
45          
46          filterPage = new InputFilterPage("new.style.input.filter", null);
47          urisPage = new InputURIsPage("new.style.input.specify", null);
48          typeSelectionPage = new InputTypeSelectionPage("new.style.input.selection", filterPage, urisPage);
49  
50          addPage(typeSelectionPage);
51          addPage(urisPage);
52          addPage(filterPage);
53          
54          setPage(typeSelectionPage);
55      }
56      
57      public String getWizardTitle() {
58          return "New XML Stylesheet Validator";
59      }
60      
61      public Project getProject() {
62          Project project = new Project();
63          Settings settings = new Settings();
64          settings.setJAXPTransformerFactory(new JAXPTransformerFactory());
65          settings.setJAXPSchemaFactory(new JAXPSchemaFactory());
66          project.setJAXPSettings(settings);
67          
68          // Set the input information
69          Input input = new Input();
70  
71          if (typeSelectionPage.isInputFilterSelected()) {
72              input.setFilter(filterPage.getFilter());
73          } else {
74              List<Document> uris = urisPage.getURIs();
75  
76              for (Document document : uris) {
77                  input.getSourceOrSourceAndResult().add(document);
78              }
79          }
80          
81          project.setInput(input);
82          
83          return project;
84      }
85  }