1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package org.openoffice.setup.Panel; 29 30 import org.openoffice.setup.InstallData; 31 import org.openoffice.setup.PanelHelper.PanelLabel; 32 import org.openoffice.setup.PanelHelper.PanelTitle; 33 import org.openoffice.setup.ResourceManager; 34 import java.awt.BorderLayout; 35 import java.awt.Color; 36 import java.awt.Dimension; 37 import java.awt.Insets; 38 import java.io.File; 39 import javax.swing.JPanel; 40 import javax.swing.JEditorPane; 41 import javax.swing.JScrollPane; 42 import javax.swing.border.EmptyBorder; 43 public class AcceptLicense extends JPanel { 44 45 public AcceptLicense() { 46 47 setLayout(new java.awt.BorderLayout()); 48 setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); 49 50 String titletext = ResourceManager.getString("String_AcceptLicense1"); 51 PanelTitle titlebox = new PanelTitle(titletext); 52 add(titlebox, BorderLayout.NORTH); 53 54 JPanel contentpanel = new JPanel(); 55 contentpanel.setLayout(new java.awt.BorderLayout()); 56 57 String text1 = ResourceManager.getString("String_AcceptLicense2"); 58 PanelLabel label1 = new PanelLabel(text1); 59 60 String text2 = ResourceManager.getString("String_AcceptLicense3"); 61 PanelLabel label2 = new PanelLabel(text2, true); 62 63 JEditorPane editorPane = createEditorPane(); 64 JScrollPane editorScrollPane = new JScrollPane(editorPane); 65 66 editorScrollPane.setPreferredSize(new Dimension(250, 145)); 67 editorScrollPane.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); 68 69 contentpanel.add(label1, BorderLayout.NORTH); 70 contentpanel.add(editorScrollPane, BorderLayout.CENTER); 71 contentpanel.add(label2, BorderLayout.SOUTH); 72 73 add(contentpanel, BorderLayout.CENTER); 74 } 75 76 private JEditorPane createEditorPane() { 77 JEditorPane editorPane = new JEditorPane(); 78 editorPane.setEditable(false); 79 80 InstallData data = InstallData.getInstance(); 81 File htmlDirectory = data.getInfoRoot("html"); 82 String licenseFile = ResourceManager.getFileName("String_License_Filename"); 83 84 if ( htmlDirectory != null) { 85 File htmlFile = new File(htmlDirectory, licenseFile); 86 if (! htmlFile.exists()) { 87 System.err.println("Couldn't find file: " + htmlFile.toString()); 88 } 89 90 try { 91 // System.err.println("URLPath: " + htmlFile.toURL()); 92 editorPane.setContentType("text/html;charset=utf-8"); 93 editorPane.setPage(htmlFile.toURL()); 94 } catch (Exception e) { 95 e.printStackTrace(); 96 System.err.println("Attempted to read a bad URL"); 97 } 98 } else { 99 System.err.println("Did not find html directory"); 100 } 101 102 return editorPane; 103 } 104 } 105