source: release-kits/lirk3/bin/ant-installer/src/org/tp23/antinstaller/renderer/swing/LicensePageRenderer.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 3.3 KB
Line 
1/*
2 * Copyright 2005 Paul Hinds
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
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/**
33 *
34 * <p>Renders the license page </p>
35 * <p> </p>
36 * <p>Copyright: Copyright (c) 2004</p>
37 * <p>Company: tp23</p>
38* @todo this could be an input type and simple renderer
39 * @author Paul Hinds
40 * @version $Id: LicensePageRenderer.java,v 1.5 2007/01/12 10:49:09 anothermwilson Exp $
41 */
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; // @todo option to force accepting or tick box to accept
55 }
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 /**
99 * updateDefaultValues
100 */
101 public void updateDefaultValues() {
102 }
103}
Note: See TracBrowser for help on using the repository browser.