source: release-kits/shared/ant-installer/src/org/tp23/antinstaller/renderer/swing/LicensePageRenderer.java@ 15210

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

Lots of changes to the installer. Now only look in LanguagePack resource bundle for strings.

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("resources.LanguagePack");
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 //delete me
62 System.out.println( "licensein is null" );
63 throw new ConfigurationException("License resource '" + resource + "' is missing from installer");
64 }
65 BufferedReader reader = new BufferedReader(new InputStreamReader(licensein));
66 StringBuffer sb = new StringBuffer();
67 String line;
68 while((line = reader.readLine()) != null){
69 sb.append(line);
70 sb.append('\n');
71 }
72
73 licenseTextArea.setText(sb.toString());
74 licenseTextArea.setTabSize(4);
75 licenseTextArea.setAutoscrolls(true);
76 licenseTextArea.setCaretPosition(0);
77 licenseTextArea.setEditable(false);
78 licenseTextArea.setLineWrap(true);
79 licenseTextArea.setWrapStyleWord(true);
80 licenseTextArea.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
81 scrollPane.getViewport().add(licenseTextArea);
82 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
83
84 scrollPane.setBorder(
85 BorderFactory.createCompoundBorder(
86 BorderFactory.createEmptyBorder(4, 4, 4, 4),
87 BorderFactory.createEtchedBorder()
88 )
89 );
90 this.add(scrollPane, BorderLayout.CENTER);
91
92 getNextButton().setText( res.getString( "license.next.text" ) );
93 getNextButton().setIcon(getImage("/resources/icons/ok.png"));
94 getCancelButton().setText( res.getString( "license.cancel.text" ) );
95
96 }
97
98 public void updateInputFields(){
99 ;
100 }
101
102
103
104 /**
105 * updateDefaultValues
106 */
107 public void updateDefaultValues() {
108 }
109}
Note: See TracBrowser for help on using the repository browser.