1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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.JAXPSAXParserFactory;
29 import org.xmlhammer.model.jaxp.JAXPSchemaFactory;
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 NewSchemaValidatorWizard 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 private SchemaPage schemaPage = null;
43
44 public NewSchemaValidatorWizard(Frame parent) {
45 super(parent);
46
47 schemaPage = new SchemaPage("new.schema.specify");
48 filterPage = new InputFilterPage("new.schema.input.filter", schemaPage);
49 urisPage = new InputURIsPage("new.schema.input.specify", schemaPage);
50 typeSelectionPage = new InputTypeSelectionPage("new.schema.input.selection", filterPage, urisPage);
51
52 addPage(typeSelectionPage);
53 addPage(urisPage);
54 addPage(filterPage);
55 addPage(schemaPage);
56
57 setPage(typeSelectionPage);
58 }
59
60 public String getWizardTitle() {
61 return "New Schema Validator";
62 }
63
64 public Project getProject() {
65 Project project = new Project();
66 Settings settings = new Settings();
67 settings.setJAXPSAXParserFactory(new JAXPSAXParserFactory());
68 settings.setJAXPSchemaFactory(new JAXPSchemaFactory());
69 project.setJAXPSettings(settings);
70 project.setSchemaValidator(schemaPage.getSchemaValidator());
71
72
73 Input input = new Input();
74
75 if (typeSelectionPage.isInputFilterSelected()) {
76 input.setFilter(filterPage.getFilter());
77 } else {
78 List<Document> uris = urisPage.getURIs();
79
80 for (Document document : uris) {
81 input.getSourceOrSourceAndResult().add(document);
82 }
83 }
84
85 project.setInput(input);
86
87 return project;
88 }
89 }