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.Dialogs; 29 30 import org.openoffice.setup.ResourceManager; 31 import org.openoffice.setup.SetupFrame; 32 import org.openoffice.setup.Util.DialogFocusTraversalPolicy; 33 import java.awt.BorderLayout; 34 import java.awt.ComponentOrientation; 35 import java.awt.Dimension; 36 import java.awt.Insets; 37 import java.awt.event.ActionListener; 38 import javax.swing.JButton; 39 import javax.swing.JComponent; 40 import javax.swing.JDialog; 41 import javax.swing.JEditorPane; 42 import javax.swing.JPanel; 43 import javax.swing.JScrollPane; 44 import javax.swing.JSeparator; 45 import javax.swing.JViewport; 46 import javax.swing.ScrollPaneConstants; 47 import javax.swing.border.EmptyBorder; 48 import org.openoffice.setup.InstallData; 49 50 public class DetailsDialog extends JDialog implements ActionListener { 51 52 private JButton okButton; 53 private String helpFileName; 54 private String helpFileString; 55 56 public DetailsDialog(SetupFrame setupFrame) { 57 58 super(setupFrame.getDialog()); 59 60 InstallData data = InstallData.getInstance(); 61 62 String dialogTitle = ResourceManager.getString("String_InstallationCompleted_Button"); 63 String dialogText = setupFrame.getCurrentPanel().getDialogText(); 64 65 setTitle(dialogTitle); 66 this.getContentPane().setLayout(new java.awt.BorderLayout()); 67 68 JPanel toppanel = new JPanel(); 69 toppanel.setLayout(new java.awt.BorderLayout()); 70 toppanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); 71 72 JPanel buttonpanel = new JPanel(); 73 buttonpanel.setLayout(new java.awt.FlowLayout()); 74 buttonpanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); 75 if ( data.useRtl() ) { buttonpanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 76 77 //Create an editor pane. 78 JEditorPane editorPane = createEditorPane(dialogText); 79 editorPane.setCaretPosition(0); 80 if ( data.useRtl() ) { editorPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 81 JScrollPane editorScrollPane = new JScrollPane(editorPane, 82 ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 83 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); 84 editorScrollPane.setPreferredSize(new Dimension(250, 145)); 85 editorScrollPane.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); 86 if ( data.useRtl() ) { editorScrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 87 88 JViewport port = editorScrollPane.getViewport(); 89 port.getVisibleRect().setLocation(0,0); 90 if ( data.useRtl() ) { port.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 91 editorScrollPane.setViewport(port); 92 93 // String helpTitle1 = ResourceManager.getString("String_Details_Title_1"); 94 // PanelLabel label1 = new PanelLabel(helpTitle1, true); 95 // String helpTitle2 = ResourceManager.getString("String_Details_Title_2"); 96 // PanelLabel label2 = new PanelLabel(helpTitle2); 97 98 String okString = ResourceManager.getString("String_OK"); 99 okButton = new JButton(okString); 100 okButton.setEnabled(true); 101 okButton.addActionListener(this); 102 103 JSeparator separator = new JSeparator(); 104 105 // toppanel.add(label1, BorderLayout.NORTH); 106 // toppanel.add(label2, BorderLayout.CENTER); 107 buttonpanel.add(okButton); 108 109 this.getContentPane().add(toppanel, BorderLayout.NORTH); 110 this.getContentPane().add(editorScrollPane, BorderLayout.CENTER); 111 this.getContentPane().add(buttonpanel, BorderLayout.SOUTH); 112 113 // JScrollBar ScrollBar = editorScrollPane.getVerticalScrollBar(); 114 // if ( ScrollBar.isShowing() ) { 115 // editorPane.setFocusable(false); 116 // } else { 117 // editorPane.setFocusable(true); 118 // } 119 120 // Setting tab-order and focus on okButton 121 DialogFocusTraversalPolicy policy = new DialogFocusTraversalPolicy(new JComponent[] {okButton, editorScrollPane}); 122 this.setFocusTraversalPolicy(policy); // set policy 123 this.setFocusCycleRoot(true); // enable policy 124 } 125 126 private JEditorPane createEditorPane(String dialogText) { 127 JEditorPane editorPane = new JEditorPane(); 128 editorPane.setEditable(false); 129 editorPane.setContentType("text/html"); 130 editorPane.setText(dialogText); 131 return editorPane; 132 } 133 134 public void actionPerformed (java.awt.event.ActionEvent evt) { 135 setVisible(false); 136 dispose(); 137 } 138 139 } 140