1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.setup.Panel;
25 
26 import org.openoffice.setup.InstallData;
27 import org.openoffice.setup.PanelHelper.PanelLabel;
28 import org.openoffice.setup.PanelHelper.PanelTitle;
29 import org.openoffice.setup.ResourceManager;
30 import java.awt.BorderLayout;
31 import java.awt.Color;
32 import java.awt.Dimension;
33 import java.awt.Insets;
34 import java.io.File;
35 import javax.swing.JPanel;
36 import javax.swing.JEditorPane;
37 import javax.swing.JScrollPane;
38 import javax.swing.border.EmptyBorder;
39 public class AcceptLicense extends JPanel {
40 
AcceptLicense()41     public AcceptLicense() {
42 
43         setLayout(new java.awt.BorderLayout());
44         setBorder(new EmptyBorder(new Insets(10, 10, 10, 10)));
45 
46         String titletext = ResourceManager.getString("String_AcceptLicense1");
47         PanelTitle titlebox = new PanelTitle(titletext);
48         add(titlebox, BorderLayout.NORTH);
49 
50         JPanel contentpanel = new JPanel();
51         contentpanel.setLayout(new java.awt.BorderLayout());
52 
53         String text1 = ResourceManager.getString("String_AcceptLicense2");
54         PanelLabel label1 = new PanelLabel(text1);
55 
56         String text2 = ResourceManager.getString("String_AcceptLicense3");
57         PanelLabel label2 = new PanelLabel(text2, true);
58 
59         JEditorPane editorPane = createEditorPane();
60         JScrollPane editorScrollPane = new JScrollPane(editorPane);
61 
62         editorScrollPane.setPreferredSize(new Dimension(250, 145));
63         editorScrollPane.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
64 
65         contentpanel.add(label1, BorderLayout.NORTH);
66         contentpanel.add(editorScrollPane, BorderLayout.CENTER);
67         contentpanel.add(label2, BorderLayout.SOUTH);
68 
69         add(contentpanel, BorderLayout.CENTER);
70     }
71 
createEditorPane()72     private JEditorPane createEditorPane() {
73         JEditorPane editorPane = new JEditorPane();
74         editorPane.setEditable(false);
75 
76         InstallData data = InstallData.getInstance();
77         File htmlDirectory = data.getInfoRoot("html");
78         String licenseFile = ResourceManager.getFileName("String_License_Filename");
79 
80         if ( htmlDirectory != null) {
81             File htmlFile = new File(htmlDirectory, licenseFile);
82             if (! htmlFile.exists()) {
83                 System.err.println("Couldn't find file: " + htmlFile.toString());
84             }
85 
86             try {
87                 // System.err.println("URLPath: " + htmlFile.toURL());
88                 editorPane.setContentType("text/html;charset=utf-8");
89                 editorPane.setPage(htmlFile.toURL());
90             } catch (Exception e) {
91                 e.printStackTrace();
92                 System.err.println("Attempted to read a bad URL");
93             }
94         } else {
95             System.err.println("Did not find html directory");
96         }
97 
98         return editorPane;
99     }
100 }
101