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.ChooseUninstallationTypeCtrl;
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 ChooseUninstallationType extends JPanel {
45 
46     private JRadioButton custom;
47     private JRadioButton complete;
48 
ChooseUninstallationType()49     public ChooseUninstallationType() {
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_ChooseUninstallationType1");
57         String subtitleText = ResourceManager.getString("String_ChooseUninstallationType2");
58         PanelTitle titleBox = new PanelTitle(titleText, subtitleText);
59         titleBox.addVerticalStrut(20);
60         add(titleBox, BorderLayout.NORTH);
61 
62         String borderTitle = ResourceManager.getString("String_ChooseUninstallationType1");
63         TitledBorder PanelBorder = BorderFactory.createTitledBorder(borderTitle);
64 
65         JPanel contentPanel = new JPanel();
66         contentPanel.setBorder(PanelBorder);
67         contentPanel.setLayout(new GridBagLayout());
68         if ( data.useRtl() ) { contentPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
69 
70             GridBagConstraints constraints = new GridBagConstraints();
71             constraints.insets = new Insets(0, 0, 0, 10);
72             // constraints.anchor = GridBagConstraints.NORTHWEST;
73 
74             String completeText = ResourceManager.getString("String_ChooseUninstallationType4");
75             PanelLabel completeComment = new PanelLabel(completeText, true);
76             if ( data.useRtl() ) { completeComment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
77             String customText  = ResourceManager.getString("String_ChooseUninstallationType5");
78             PanelLabel customComment  = new PanelLabel(customText, true);
79             if ( data.useRtl() ) { customComment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
80 
81             ButtonGroup group = new ButtonGroup();
82 
83             String completeButtonText = ResourceManager.getString("String_ChooseUninstallationType6");
84             complete = new JRadioButton(completeButtonText, true);
85             complete.setMnemonic(KeyEvent.VK_C);
86             if ( data.useRtl() ) { complete.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
87             String customButtonText  = ResourceManager.getString("String_ChooseUninstallationType3");
88             custom  = new JRadioButton(customButtonText,  false);
89             custom.setMnemonic(KeyEvent.VK_U);
90             if ( data.useRtl() ) { custom.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }
91 
92             group.add(complete);
93             group.add(custom);
94 
95             constraints.gridx = 0;
96             constraints.gridy = 0;
97             constraints.weightx = 0;
98             constraints.weighty = 1;
99             constraints.fill = GridBagConstraints.VERTICAL;
100 
101         contentPanel.add(new JPanel(), constraints);
102 
103             constraints.gridx = 0;
104             constraints.gridy = 1;
105             constraints.weightx = 0;
106             constraints.weighty = 0;
107             constraints.fill = GridBagConstraints.HORIZONTAL;
108 
109         contentPanel.add(complete, constraints);
110 
111             constraints.gridx = 1;
112             constraints.gridy = 1;
113             constraints.weightx = 1;
114             constraints.weighty = 0;
115             constraints.fill = GridBagConstraints.HORIZONTAL;
116 
117         contentPanel.add(completeComment, constraints);
118 
119             constraints.gridx = 0;
120             constraints.gridy = 2;
121             constraints.weightx = 0;
122             constraints.weighty = 1;
123             constraints.fill = GridBagConstraints.VERTICAL;
124 
125         contentPanel.add(new JPanel(), constraints);
126 
127             constraints.gridx = 0;
128             constraints.gridy = 3;
129             constraints.weightx = 0;
130             constraints.weighty = 0;
131             constraints.fill = GridBagConstraints.HORIZONTAL;
132 
133         contentPanel.add(custom, constraints);
134 
135             constraints.gridx = 1;
136             constraints.gridy = 3;
137             constraints.weightx = 1;
138             constraints.weighty = 0;
139             constraints.fill = GridBagConstraints.HORIZONTAL;
140 
141         contentPanel.add(customComment, constraints);
142 
143             constraints.gridx = 0;
144             constraints.gridy = 4;
145             constraints.weightx = 0;
146             constraints.weighty = 1;
147             constraints.fill = GridBagConstraints.VERTICAL;
148 
149         contentPanel.add(new JPanel(), constraints);
150 
151         add(contentPanel, BorderLayout.CENTER);
152     }
153 
setActionListener(ChooseUninstallationTypeCtrl actionListener)154     public void setActionListener(ChooseUninstallationTypeCtrl actionListener) {
155         complete.addActionListener(actionListener);
156         custom.addActionListener(actionListener);
157     }
158 
removeActionListener(ChooseUninstallationTypeCtrl actionListener)159     public void removeActionListener(ChooseUninstallationTypeCtrl actionListener) {
160         complete.removeActionListener(actionListener);
161         custom.removeActionListener(actionListener);
162     }
163 
setCompleteActionCommand(String completeActionCommand)164     public void setCompleteActionCommand(String completeActionCommand) {
165         complete.setActionCommand(completeActionCommand);
166     }
167 
setCustomActionCommand(String customActionCommand)168     public void setCustomActionCommand(String customActionCommand) {
169         custom.setActionCommand(customActionCommand);
170     }
171 
172 }
173