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