1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.setup.Dialogs;
25 
26 import org.openoffice.setup.ResourceManager;
27 import org.openoffice.setup.SetupFrame;
28 import org.openoffice.setup.Util.DialogFocusTraversalPolicy;
29 import java.awt.BorderLayout;
30 import java.awt.ComponentOrientation;
31 import java.awt.Dimension;
32 import java.awt.Insets;
33 import java.awt.event.ActionListener;
34 import javax.swing.JButton;
35 import javax.swing.JComponent;
36 import javax.swing.JDialog;
37 import javax.swing.JEditorPane;
38 import javax.swing.JPanel;
39 import javax.swing.JScrollPane;
40 import javax.swing.JSeparator;
41 import javax.swing.JViewport;
42 import javax.swing.ScrollPaneConstants;
43 import javax.swing.border.EmptyBorder;
44 import org.openoffice.setup.InstallData;
45 
46 public class DetailsDialog extends JDialog implements ActionListener {
47 
48     private JButton okButton;
49     private String helpFileName;
50     private String helpFileString;
51 
DetailsDialog(SetupFrame setupFrame)52     public DetailsDialog(SetupFrame setupFrame) {
53 
54         super(setupFrame.getDialog());
55 
56         InstallData data = InstallData.getInstance();
57 
58         String dialogTitle = ResourceManager.getString("String_InstallationCompleted_Button");
59         String dialogText = setupFrame.getCurrentPanel().getDialogText();
60 
61         setTitle(dialogTitle);
62         this.getContentPane().setLayout(new java.awt.BorderLayout());
63 
64         JPanel toppanel = new JPanel();
65         toppanel.setLayout(new java.awt.BorderLayout());
66         toppanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
67 
68         JPanel buttonpanel = new JPanel();
69         buttonpanel.setLayout(new java.awt.FlowLayout());
70         buttonpanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
71         if ( data.useRtl() ) { buttonpanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
72 
73         //Create an editor pane.
74         JEditorPane editorPane = createEditorPane(dialogText);
75         editorPane.setCaretPosition(0);
76         if ( data.useRtl() ) { editorPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
77         JScrollPane editorScrollPane = new JScrollPane(editorPane,
78                 ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
79                 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
80         editorScrollPane.setPreferredSize(new Dimension(250, 145));
81         editorScrollPane.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
82         if ( data.useRtl() ) { editorScrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
83 
84         JViewport port = editorScrollPane.getViewport();
85         port.getVisibleRect().setLocation(0,0);
86         if ( data.useRtl() ) { port.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
87         editorScrollPane.setViewport(port);
88 
89         // String helpTitle1 = ResourceManager.getString("String_Details_Title_1");
90         // PanelLabel label1 = new PanelLabel(helpTitle1, true);
91         // String helpTitle2 = ResourceManager.getString("String_Details_Title_2");
92         // PanelLabel label2 = new PanelLabel(helpTitle2);
93 
94         String okString = ResourceManager.getString("String_OK");
95         okButton = new JButton(okString);
96         okButton.setEnabled(true);
97         okButton.addActionListener(this);
98 
99         JSeparator separator = new JSeparator();
100 
101         // toppanel.add(label1, BorderLayout.NORTH);
102         // toppanel.add(label2, BorderLayout.CENTER);
103         buttonpanel.add(okButton);
104 
105         this.getContentPane().add(toppanel, BorderLayout.NORTH);
106         this.getContentPane().add(editorScrollPane, BorderLayout.CENTER);
107         this.getContentPane().add(buttonpanel, BorderLayout.SOUTH);
108 
109         // JScrollBar ScrollBar = editorScrollPane.getVerticalScrollBar();
110         // if ( ScrollBar.isShowing() ) {
111         //     editorPane.setFocusable(false);
112         // } else {
113         //     editorPane.setFocusable(true);
114         // }
115 
116         // Setting tab-order and focus on okButton
117         DialogFocusTraversalPolicy policy = new DialogFocusTraversalPolicy(new JComponent[] {okButton, editorScrollPane});
118         this.setFocusTraversalPolicy(policy);  // set policy
119         this.setFocusCycleRoot(true); // enable policy
120     }
121 
createEditorPane(String dialogText)122      private JEditorPane createEditorPane(String dialogText) {
123         JEditorPane editorPane = new JEditorPane();
124         editorPane.setEditable(false);
125         editorPane.setContentType("text/html");
126         editorPane.setText(dialogText);
127         return editorPane;
128     }
129 
actionPerformed(java.awt.event.ActionEvent evt)130     public void actionPerformed (java.awt.event.ActionEvent evt) {
131         setVisible(false);
132         dispose();
133     }
134 
135 }
136