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