/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: DetailsDialog.java,v $
*
* $Revision: 1.3 $
*
* last change: $Author: rt $ $Date: 2007/07/03 11:53:20 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
package org.openoffice.setup.Dialogs;
import org.openoffice.setup.ResourceManager;
import org.openoffice.setup.SetupFrame;
import org.openoffice.setup.Util.DialogFocusTraversalPolicy;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JViewport;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.EmptyBorder;
public class DetailsDialog extends JDialog implements ActionListener {
private JButton okButton;
private String helpFileName;
private String helpFileString;
public DetailsDialog(SetupFrame setupFrame) {
super(setupFrame.getDialog());
String dialogTitle = ResourceManager.getString("String_InstallationCompleted_Button");
String dialogText = setupFrame.getCurrentPanel().getDialogText();
setTitle(dialogTitle);
this.getContentPane().setLayout(new java.awt.BorderLayout());
JPanel toppanel = new JPanel();
toppanel.setLayout(new java.awt.BorderLayout());
toppanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
JPanel buttonpanel = new JPanel();
buttonpanel.setLayout(new java.awt.FlowLayout());
buttonpanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
//Create an editor pane.
JEditorPane editorPane = createEditorPane(dialogText);
editorPane.setCaretPosition(0);
JScrollPane editorScrollPane = new JScrollPane(editorPane,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
editorScrollPane.setPreferredSize(new Dimension(250, 145));
editorScrollPane.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
JViewport port = editorScrollPane.getViewport();
port.getVisibleRect().setLocation(0,0);
editorScrollPane.setViewport(port);
// String helpTitle1 = ResourceManager.getString("String_Details_Title_1");
// PanelLabel label1 = new PanelLabel(helpTitle1, true);
// String helpTitle2 = ResourceManager.getString("String_Details_Title_2");
// PanelLabel label2 = new PanelLabel(helpTitle2);
String okString = ResourceManager.getString("String_OK");
okButton = new JButton(okString);
okButton.setEnabled(true);
okButton.addActionListener(this);
JSeparator separator = new JSeparator();
// toppanel.add(label1, BorderLayout.NORTH);
// toppanel.add(label2, BorderLayout.CENTER);
buttonpanel.add(okButton);
this.getContentPane().add(toppanel, BorderLayout.NORTH);
this.getContentPane().add(editorScrollPane, BorderLayout.CENTER);
this.getContentPane().add(buttonpanel, BorderLayout.SOUTH);
// JScrollBar ScrollBar = editorScrollPane.getVerticalScrollBar();
// if ( ScrollBar.isShowing() ) {
// editorPane.setFocusable(false);
// } else {
// editorPane.setFocusable(true);
// }
// Setting tab-order and focus on okButton
DialogFocusTraversalPolicy policy = new DialogFocusTraversalPolicy(new JComponent[] {okButton, editorScrollPane});
this.setFocusTraversalPolicy(policy); // set policy
this.setFocusCycleRoot(true); // enable policy
}
private JEditorPane createEditorPane(String dialogText) {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setContentType("text/html");
editorPane.setText(dialogText);
return editorPane;
}
public void actionPerformed (java.awt.event.ActionEvent evt) {
setVisible(false);
dispose();
}
}