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;
25 
26 import org.openoffice.setup.Dialogs.DetailsDialog;
27 import org.openoffice.setup.Dialogs.HelpDialog;
28 import org.openoffice.setup.Util.AbortInstaller;
29 import java.awt.Dimension;
30 import java.awt.event.ActionListener;
31 import javax.swing.JDialog;
32 import javax.swing.JOptionPane;
33 
34 public class SetupActionListener implements ActionListener {
35 
36     private SetupFrame setupFrame;
37 
SetupActionListener(SetupFrame setup)38     public SetupActionListener(SetupFrame setup) {
39         setupFrame = setup;
40     }
41 
actionPerformed(java.awt.event.ActionEvent evt)42     public void actionPerformed (java.awt.event.ActionEvent evt) {
43         if (evt.getActionCommand().equals(SetupFrame.ACTION_CANCEL)) {
44             String StringCancelDialog;
45             String StringCancelDialogTitle;
46             InstallData data = InstallData.getInstance();
47             if ( data.isInstallationMode() ) {
48                 StringCancelDialog = ResourceManager.getString("String_Cancel_Dialog");
49             } else {
50                 StringCancelDialog = ResourceManager.getString("String_Cancel_Dialog_Uninstallation");
51             }
52             StringCancelDialogTitle = ResourceManager.getString("String_Cancel_Dialog_Title");
53             JDialog dialog = setupFrame.getDialog();
54             int n = JOptionPane.showConfirmDialog(dialog, StringCancelDialog, StringCancelDialogTitle,
55                                                       JOptionPane.YES_NO_OPTION);
56             if ( n == 0 ) {
57                 setupFrame.close(SetupFrame.CODE_CANCEL);
58             }
59             setupFrame.setButtonSelected(setupFrame.BUTTON_CANCEL);
60         } else if (evt.getActionCommand().equals(SetupFrame.ACTION_STOP)) {
61             String StringStopDialog;
62             String StringStopDialogTitle;
63             InstallData data = InstallData.getInstance();
64             if ( data.isInstallationMode() ) {
65                 StringStopDialog = ResourceManager.getString("String_Stop_Dialog");
66                 StringStopDialogTitle = ResourceManager.getString("String_Stop_Dialog_Title");
67             } else {
68                 StringStopDialog = ResourceManager.getString("String_Stop_Dialog_Uninstallation");
69                 StringStopDialogTitle = ResourceManager.getString("String_Stop_Dialog_Title_Uninstallation");
70             }
71             JDialog dialog = setupFrame.getDialog();
72             int n = JOptionPane.showConfirmDialog(dialog, StringStopDialog, StringStopDialogTitle,
73                                                       JOptionPane.YES_NO_OPTION);
74             if ( n == 0 ) {
75                 AbortInstaller.abortInstallProcess();
76             }
77             // setting focus on help button, if not aborted
78             setupFrame.setButtonSelected(setupFrame.BUTTON_HELP);
79             // PanelController panel = setupFrame.getCurrentPanel();
80             // panel.setStopButtonSelected();
81         } else if (evt.getActionCommand().equals(SetupFrame.ACTION_PREVIOUS)) {
82             PanelController panel = setupFrame.getCurrentPanel();
83             String previous = panel.getPrevious();
84             setupFrame.setCurrentPanel(previous, true, false);
85         } else if (evt.getActionCommand().equals(SetupFrame.ACTION_NEXT)) {
86             PanelController panel = setupFrame.getCurrentPanel();
87             String next = panel.getNext();
88             if (next == null) {
89                 setupFrame.close(SetupFrame.CODE_OK);
90             } else {
91                 setupFrame.setCurrentPanel(next, false, true);
92             }
93         } else if (evt.getActionCommand().equals(SetupFrame.ACTION_DETAILS)) {
94             JDialog dialog = setupFrame.getDialog();
95             DetailsDialog detailsdialog = new DetailsDialog(setupFrame);
96             detailsdialog.setModal(true);
97             detailsdialog.setSize(new Dimension(600, 300));
98             detailsdialog.setLocationRelativeTo(dialog);
99             detailsdialog.setVisible(true);
100             // setting focus on next button, if details dialog is closed
101             setupFrame.setButtonSelected(setupFrame.BUTTON_NEXT);
102         } else if (evt.getActionCommand().equals(SetupFrame.ACTION_HELP)) {
103             JDialog dialog = setupFrame.getDialog();
104             HelpDialog helpdialog = new HelpDialog(setupFrame);
105             helpdialog.setModal(true);
106             helpdialog.setSize(new Dimension(400, 300));
107             helpdialog.setLocationRelativeTo(dialog);
108             helpdialog.setVisible(true);
109             setupFrame.setButtonSelected(setupFrame.BUTTON_HELP);
110         }
111     }
112 }
113