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.Panel;
25 
26 import org.openoffice.setup.Controller.ChooseInstallationTypeCtrl;
27 import org.openoffice.setup.PanelHelper.PanelLabel;
28 import org.openoffice.setup.PanelHelper.PanelTitle;
29 import org.openoffice.setup.ResourceManager;
30 import java.awt.BorderLayout;
31 import java.awt.ComponentOrientation;
32 import java.awt.GridBagConstraints;
33 import java.awt.GridBagLayout;
34 import java.awt.Insets;
35 import java.awt.event.KeyEvent;
36 import javax.swing.BorderFactory;
37 import javax.swing.ButtonGroup;
38 import javax.swing.JPanel;
39 import javax.swing.JRadioButton;
40 import javax.swing.border.EmptyBorder;
41 import javax.swing.border.TitledBorder;
42 import org.openoffice.setup.InstallData;
43 
44 public class ChooseInstallationType extends JPanel {
45 
46     private JRadioButton custom;
47     private JRadioButton typical;
48 
ChooseInstallationType()49     public ChooseInstallationType() {
50 
51         InstallData data = InstallData.getInstance();
52 
53         setLayout(new BorderLayout());
54         setBorder(new EmptyBorder(new Insets(10, 10, 10, 10)));
55 
56         String titleText    = ResourceManager.getString("String_ChooseInstallationType1");
57         String subtitleText = ResourceManager.getString("String_ChooseInstallationType2");
58         PanelTitle titleBox = new PanelTitle(titleText, subtitleText);
59         titleBox.addVerticalStrut(20);
60 
61         if ( data.useRtl() ) { titleBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
62 
63         add(titleBox, BorderLayout.NORTH);
64 
65         String borderTitle = ResourceManager.getString("String_ChooseInstallationType3");
66         TitledBorder PanelBorder = BorderFactory.createTitledBorder(borderTitle);
67 
68         JPanel contentPanel = new JPanel();
69         contentPanel.setBorder(PanelBorder);
70         contentPanel.setLayout(new GridBagLayout());
71         if ( data.useRtl() ) { contentPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
72 
73             GridBagConstraints constraints = new GridBagConstraints();
74             constraints.insets = new Insets(0, 0, 0, 10);
75             // constraints.anchor = GridBagConstraints.NORTHWEST;
76 
77             String typicalText = ResourceManager.getString("String_ChooseInstallationType4");
78             PanelLabel typicalComment = new PanelLabel(typicalText, true);
79             if ( data.useRtl() ) { typicalComment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
80             String customText  = ResourceManager.getString("String_ChooseInstallationType5");
81             PanelLabel customComment  = new PanelLabel(customText, true);
82             if ( data.useRtl() ) { customComment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
83 
84             ButtonGroup group = new ButtonGroup();
85 
86             String typicalButtonText = ResourceManager.getString("String_ChooseInstallationType6");
87             typical = new JRadioButton(typicalButtonText, true);
88             typical.setMnemonic(KeyEvent.VK_C);
89             if ( data.useRtl() ) { typical.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
90 
91             String customButtonText  = ResourceManager.getString("String_ChooseInstallationType7");
92             custom  = new JRadioButton(customButtonText,  false);
93             custom.setMnemonic(KeyEvent.VK_U);
94             if ( data.useRtl() ) { custom.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
95 
96             group.add(typical);
97             group.add(custom);
98 
99             constraints.gridx = 0;
100             constraints.gridy = 0;
101             constraints.weightx = 0;
102             constraints.weighty = 1;
103             constraints.fill = GridBagConstraints.VERTICAL;
104 
105         contentPanel.add(new JPanel(), constraints);
106 
107             constraints.gridx = 0;
108             constraints.gridy = 1;
109             constraints.weightx = 0;
110             constraints.weighty = 0;
111             constraints.fill = GridBagConstraints.HORIZONTAL;
112 
113         contentPanel.add(typical, constraints);
114 
115             constraints.gridx = 1;
116             constraints.gridy = 1;
117             constraints.weightx = 1;
118             constraints.weighty = 0;
119             constraints.fill = GridBagConstraints.HORIZONTAL;
120 
121         contentPanel.add(typicalComment, constraints);
122 
123             constraints.gridx = 0;
124             constraints.gridy = 2;
125             constraints.weightx = 0;
126             constraints.weighty = 1;
127             constraints.fill = GridBagConstraints.VERTICAL;
128 
129         contentPanel.add(new JPanel(), constraints);
130 
131             constraints.gridx = 0;
132             constraints.gridy = 3;
133             constraints.weightx = 0;
134             constraints.weighty = 0;
135             constraints.fill = GridBagConstraints.HORIZONTAL;
136 
137         contentPanel.add(custom, constraints);
138 
139             constraints.gridx = 1;
140             constraints.gridy = 3;
141             constraints.weightx = 1;
142             constraints.weighty = 0;
143             constraints.fill = GridBagConstraints.HORIZONTAL;
144 
145         contentPanel.add(customComment, constraints);
146 
147             constraints.gridx = 0;
148             constraints.gridy = 4;
149             constraints.weightx = 0;
150             constraints.weighty = 1;
151             constraints.fill = GridBagConstraints.VERTICAL;
152 
153         contentPanel.add(new JPanel(), constraints);
154 
155         add(contentPanel, BorderLayout.CENTER);
156     }
157 
setActionListener(ChooseInstallationTypeCtrl actionListener)158     public void setActionListener(ChooseInstallationTypeCtrl actionListener) {
159         typical.addActionListener(actionListener);
160         custom.addActionListener(actionListener);
161     }
162 
removeActionListener(ChooseInstallationTypeCtrl actionListener)163     public void removeActionListener(ChooseInstallationTypeCtrl actionListener) {
164         typical.removeActionListener(actionListener);
165         custom.removeActionListener(actionListener);
166     }
167 
setTypicalActionCommand(String typicalActionCommand)168     public void setTypicalActionCommand(String typicalActionCommand) {
169         typical.setActionCommand(typicalActionCommand);
170     }
171 
setCustomActionCommand(String customActionCommand)172     public void setCustomActionCommand(String customActionCommand) {
173         custom.setActionCommand(customActionCommand);
174     }
175 
176 }
177