1
16package org.tp23.antinstaller.renderer.swing;
17
18import java.awt.BorderLayout;
19import java.io.BufferedReader;
20import java.io.InputStream;
21import java.io.InputStreamReader;
22import java.util.ResourceBundle;
23
24import javax.swing.BorderFactory;
25import javax.swing.JScrollPane;
26import javax.swing.JTextArea;
27
28import org.tp23.antinstaller.ValidationException;
29import org.tp23.antinstaller.page.LicensePage;
30import org.tp23.antinstaller.runtime.ConfigurationException;
31
32
42public class LicensePageRenderer
43 extends SwingPageRenderer {
44
45 private static final ResourceBundle res = ResourceBundle.getBundle("org.tp23.antinstaller.renderer.Res");
46
47 private JTextArea licenseTextArea = new JTextArea();
48 private JScrollPane scrollPane = new JScrollPane();
49
50 public LicensePageRenderer(){
51 }
52
53 public boolean validateFields()throws ValidationException{
54 return true; }
56
57 public void instanceInit() throws Exception {
58 String resource = ((LicensePage)page).getResource();
59 InputStream licensein = this.getClass().getResourceAsStream(resource);
60 if (licensein == null) {
61 throw new ConfigurationException("License resource '" + resource + "' is missing from installer");
62 }
63 BufferedReader reader = new BufferedReader(new InputStreamReader(licensein));
64 StringBuffer sb = new StringBuffer();
65 String line;
66 while((line = reader.readLine()) != null){
67 sb.append(line);
68 sb.append('\n');
69 }
70
71 licenseTextArea.setText(sb.toString());
72 licenseTextArea.setTabSize(4);
73 licenseTextArea.setAutoscrolls(true);
74 licenseTextArea.setCaretPosition(0);
75 licenseTextArea.setEditable(false);
76 licenseTextArea.setLineWrap(true);
77 licenseTextArea.setWrapStyleWord(true);
78 licenseTextArea.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
79 scrollPane.getViewport().add(licenseTextArea);
80 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
81 scrollPane.setBorder(BorderFactory.createCompoundBorder(
82 BorderFactory.createEmptyBorder(4, 4, 4, 4),
83 BorderFactory.createEtchedBorder()));
84 this.add(scrollPane, BorderLayout.CENTER);
85
86 getNextButton().setText( res.getString( "license.next.text" ) );
87 getNextButton().setIcon(getImage("/resources/icons/ok.png"));
88 getCancelButton().setText( res.getString( "license.cancel.text" ) );
89
90 }
91
92 public void updateInputFields(){
93 ;
94 }
95
96
97
98
01 public void updateDefaultValues() {
02 }
03}
04