KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > gui > MainFrame


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.tools.upgrade.gui;
24
25 import java.util.*;
26 import javax.swing.*;
27 import java.io.*;
28 import com.sun.enterprise.tools.upgrade.gui.util.DialogEvent;
29 import com.sun.enterprise.tools.upgrade.gui.util.DialogListener;
30 import com.sun.enterprise.tools.upgrade.gui.util.Utils;
31 import java.util.*;
32 import com.sun.enterprise.tools.upgrade.common.*;
33 import java.util.logging.*;
34 import com.sun.enterprise.util.i18n.StringManager;
35 import com.sun.enterprise.tools.upgrade.logging.*;
36
37 import javax.help.*;
38 /**
39  * Insert the type's description here.
40  *
41  * @author: Prakash Aradhya
42  */

43 public class MainFrame extends JFrame implements LogMessageListener, UpgradeUpdateListener{
44
45     private JButton backButton = null;
46     private JPanel buttonsPanel = null;
47     private JButton cancelButton = null;
48     private JButton helpButton = null;
49     private JPanel JDialogContentPane = null;
50     private JButton nextButton = null;
51
52     private ProgressPanel progressPanel = null;
53     private DataCollectionPanel dataCollectionPanel = null;
54     private CertificatePanel certificatePanel = null;
55     private ClusterDetailsPanel clusterDetailsPanel = null;
56
57     EventHandler eventHandler = new EventHandler();
58     private JPanel navigationPanel = null;
59
60     private static final int DETAILS_COLLECTION_PANEL = 1;
61     private static final int CERTIFICATE_PANEL = 2;
62     private static final int PROGRESS_PANEL = 3;
63     private static final int CLUSTER_DETAILS_PANEL = 4;
64     private int currentNavigationPanel = DETAILS_COLLECTION_PANEL;
65
66     private static int UPGRADE_STARTED = 1;
67     private static int UPGRADE_FINISHED = 2;
68     private static int DATA_COLLECTION_PENDING = 3;
69     private static int CRTIFICATION_PENDING = 4;
70     private static int CLUSTER_DETAILS_PENDING = 5;
71
72     private CommonInfoModel commonInfoModel;
73     
74     private DomainPathSelectionDialog domainPathSelectionDialog;
75
76     private Vector dialogListeners = new Vector();
77     public void addDialogListener(DialogListener listener){
78         this.dialogListeners.addElement(listener);
79     }
80     public void removeDialogListener(DialogListener listener){
81         this.dialogListeners.removeElement(listener);
82     }
83
84     private StringManager stringManager = StringManager.getManager("com.sun.enterprise.tools.upgrade.gui");
85     private static Logger logger = com.sun.enterprise.tools.upgrade.common.CommonInfoModel.getDefaultLogger();
86
87     class EventHandler implements java.awt.event.ActionListener JavaDoc {
88         public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
89             if (e.getSource() == MainFrame.this.getcancelButton())
90                 processCancelAction();
91             if (e.getSource() == MainFrame.this.getbackButton())
92                 processBackAction();
93             if (e.getSource() == MainFrame.this.getnextButton())
94                 processNextAction();
95             if (e.getSource() == MainFrame.this.gethelpButton())
96                 processHelpAction();
97         }
98     }
99     /**
100      * MainFrame constructor comment.
101      */

102     public MainFrame(CommonInfoModel coInfoModel) {
103         //super(stringManager.getString("upgrade.gui.mainframe.titleMessage"));
104
if(coInfoModel.getTargetEdition().equals(UpgradeConstants.EDITION_PE)){
105             super.setTitle(stringManager.getString("upgrade.gui.mainframe.titleMessage"));
106         }else{
107             super.setTitle(stringManager.getString("upgrade.gui.mainframe.eetitleMessage"));
108         }
109         this.commonInfoModel = coInfoModel;
110         initialize();
111     }
112
113     private void processCancelAction() {
114         int option = javax.swing.JOptionPane.showConfirmDialog(this,
115         stringManager.getString("upgrade.gui.mainframe.exitMessage"),
116         stringManager.getString("upgrade.gui.mainframe.exitMessageTitle"),
117         javax.swing.JOptionPane.YES_NO_OPTION,
118         javax.swing.JOptionPane.QUESTION_MESSAGE);
119         if (option == javax.swing.JOptionPane.NO_OPTION) {
120             return;
121         }
122         logger.info("Before Recover Call");
123         // START CR 6348866
124
commonInfoModel.recover();
125         // END CR 6348866
126
DialogEvent de = new DialogEvent(this, DialogEvent.CANCEL_ACTION);
127         for(int i=0 ; i<this.dialogListeners.size(); i++){
128             ((DialogListener)dialogListeners.elementAt(i)).dialogProcessed(de);
129         }
130         this.dispose();
131     }
132     
133     /**
134      * Return the backButton property value.
135      * @return javax.swing.JButton
136      */

137     private javax.swing.JButton JavaDoc getbackButton() {
138         if (backButton == null) {
139             backButton = new javax.swing.JButton JavaDoc();
140             backButton.setName("backButton");
141             backButton.setText(stringManager.getString("upgrade.gui.mainframe.backbutton"));
142         }
143         return backButton;
144     }
145
146     /**
147      * Return the JPanel1 property value.
148      * @return javax.swing.JPanel
149      */

150     private javax.swing.JPanel JavaDoc getProgressPanel() {
151         if (progressPanel == null) {
152             progressPanel = new ProgressPanel();
153         }
154         return progressPanel;
155     }
156
157
158     /**
159      * Return the buttonsPanel property value.
160      * @return javax.swing.JPanel
161      */

162     private javax.swing.JPanel JavaDoc getbuttonsPanel() {
163         if (buttonsPanel == null) {
164             buttonsPanel = new javax.swing.JPanel JavaDoc();
165             buttonsPanel.setName("buttonsPanel");
166             buttonsPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
167             JPanel placeHolderPanel1 = new JPanel();
168             JPanel placeHolderPanel2 = new JPanel();
169             placeHolderPanel1.add(getbackButton());
170             placeHolderPanel1.add(getnextButton());
171             placeHolderPanel2.add(getcancelButton());
172             placeHolderPanel2.add(gethelpButton());
173
174             java.awt.GridBagConstraints JavaDoc constraints = new java.awt.GridBagConstraints JavaDoc();
175             constraints.gridx = 0; constraints.gridy = 0;
176             constraints.anchor = java.awt.GridBagConstraints.WEST;
177             constraints.gridwidth = 1; constraints.gridheight = 1;
178             constraints.weightx = 1.0; constraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
179             constraints.insets = new java.awt.Insets JavaDoc(5, 10, 10, 20);
180             getbuttonsPanel().add(placeHolderPanel1, constraints);
181
182             constraints = new java.awt.GridBagConstraints JavaDoc();
183             constraints.gridx = 1; constraints.gridy = 0;
184             constraints.anchor = java.awt.GridBagConstraints.EAST;
185             constraints.gridwidth = 1; constraints.gridheight = 1;
186             constraints.weightx = 1.0; constraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
187             constraints.insets = new java.awt.Insets JavaDoc(5, 10, 10, 20);
188             getbuttonsPanel().add(placeHolderPanel2, constraints);
189         }
190         return buttonsPanel;
191     }
192     /**
193      * Return the cancelButton property value.
194      * @return javax.swing.JButton
195      */

196     private javax.swing.JButton JavaDoc getcancelButton() {
197         if (cancelButton == null) {
198             cancelButton = new javax.swing.JButton JavaDoc();
199             cancelButton.setName("cancelButton");
200             cancelButton.setText(stringManager.getString("upgrade.gui.mainframe.cancelbutton"));
201         }
202         return cancelButton;
203     }
204     /**
205      * Return the helpButton property value.
206      * @return javax.swing.JButton
207      */

208     private javax.swing.JButton JavaDoc gethelpButton() {
209         if (helpButton == null) {
210             helpButton = new javax.swing.JButton JavaDoc();
211             helpButton.setName("helpButton");
212             helpButton.setText(stringManager.getString("upgrade.gui.mainframe.helpbutton"));
213             if(Utils.getHelpBroker() != null)
214                 Utils.getHelpBroker().enableHelpOnButton(helpButton, "WIZARD_FIRST", null);
215         }
216         return helpButton;
217     }
218
219     /**
220      * Return the JDialogContentPane property value.
221      * @return javax.swing.JPanel
222      */

223     public javax.swing.JPanel JavaDoc getJDialogContentPane() {
224         if (JDialogContentPane == null) {
225             JDialogContentPane = new javax.swing.JPanel JavaDoc();
226             JDialogContentPane.setName("JDialogContentPane");
227             JDialogContentPane.setLayout(new java.awt.GridBagLayout JavaDoc());
228
229             java.awt.GridBagConstraints JavaDoc imageconstraintsPanel = new java.awt.GridBagConstraints JavaDoc();
230             imageconstraintsPanel.gridx = 0; imageconstraintsPanel.gridy = 0;
231             imageconstraintsPanel.fill = java.awt.GridBagConstraints.BOTH;
232             imageconstraintsPanel.weightx = 0;
233             imageconstraintsPanel.weighty = 0;
234             ImagePanel imagePanel = new ImagePanel(new java.awt.Insets JavaDoc(5,10,5,10));
235             java.awt.Image JavaDoc image = this.getUpgradeToolImage();
236             //imagePanel.setImage(java.awt.Toolkit.getDefaultToolkit().createImage("C:\\Sources\\ASUTws\\tools\\src\\java\\com\\sun\\enterprise\\tools\\upgrade\\gui\\Appserv_upgrade_wizard.gif"));
237
imagePanel.setImage(image);
238             getJDialogContentPane().add(imagePanel, imageconstraintsPanel);
239
240             java.awt.GridBagConstraints JavaDoc constraintsnavigationPanel = new java.awt.GridBagConstraints JavaDoc();
241             constraintsnavigationPanel.gridx = 1; constraintsnavigationPanel.gridy = 0;
242             constraintsnavigationPanel.fill = java.awt.GridBagConstraints.BOTH;
243             constraintsnavigationPanel.weightx = 1.0;
244             constraintsnavigationPanel.weighty = 1.0;
245             getJDialogContentPane().add(getnavigationPanel(), constraintsnavigationPanel);
246
247             java.awt.GridBagConstraints JavaDoc constraintsSeparator = new java.awt.GridBagConstraints JavaDoc();
248             constraintsSeparator.gridx = 0; constraintsSeparator.gridy = 1;
249             constraintsSeparator.gridwidth = 2; constraintsSeparator.gridheight = 1;
250             constraintsSeparator.fill = java.awt.GridBagConstraints.HORIZONTAL;
251             constraintsSeparator.weightx = 1.0;
252             constraintsSeparator.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
253             javax.swing.JSeparator JavaDoc separatorPanel = new javax.swing.JSeparator JavaDoc();
254             getJDialogContentPane().add(separatorPanel, constraintsSeparator);
255
256             java.awt.GridBagConstraints JavaDoc constraintsbuttonsPanel = new java.awt.GridBagConstraints JavaDoc();
257             constraintsbuttonsPanel.gridx = 0; constraintsbuttonsPanel.gridy = 2;
258             constraintsbuttonsPanel.gridwidth = 2; constraintsbuttonsPanel.gridheight = 1;
259             constraintsbuttonsPanel.fill = java.awt.GridBagConstraints.HORIZONTAL;
260             constraintsbuttonsPanel.weightx = 1.0;
261             constraintsbuttonsPanel.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
262             getJDialogContentPane().add(getbuttonsPanel(), constraintsbuttonsPanel);
263         }
264         return JDialogContentPane;
265     }
266     private java.awt.Image JavaDoc getUpgradeToolImage(){
267         java.net.URL JavaDoc imageURL = ClassLoader.getSystemClassLoader().getResource("com/sun/enterprise/tools/upgrade/gui/Appserv_upgrade_wizard.gif");
268         return (imageURL != null)? java.awt.Toolkit.getDefaultToolkit().getImage(imageURL) : null;
269     }
270     /**
271      * Return the navigationPanel property value.
272      * @return javax.swing.JPanel
273      */

274     private javax.swing.JPanel JavaDoc getnavigationPanel() {
275         if (navigationPanel == null) {
276             navigationPanel = new javax.swing.JPanel JavaDoc();
277             navigationPanel.setName("navigationPanel");
278             navigationPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
279
280             java.awt.GridBagConstraints JavaDoc constraintsbeanNameBeanTypePanel = new java.awt.GridBagConstraints JavaDoc();
281             constraintsbeanNameBeanTypePanel.gridx = 0; constraintsbeanNameBeanTypePanel.gridy = 0;
282             constraintsbeanNameBeanTypePanel.fill = java.awt.GridBagConstraints.BOTH;
283             constraintsbeanNameBeanTypePanel.weightx = 1.0;
284             constraintsbeanNameBeanTypePanel.weighty = 1.0;
285             getnavigationPanel().add(getDataCollectionPanel(), constraintsbeanNameBeanTypePanel);
286         }
287         return navigationPanel;
288     }
289     /**
290      * Return the nextButton property value.
291      * @return javax.swing.JButton
292      */

293     private javax.swing.JButton JavaDoc getnextButton() {
294         if (nextButton == null) {
295             nextButton = new javax.swing.JButton JavaDoc();
296             nextButton.setName("nextButton");
297             nextButton.setText(stringManager.getString("upgrade.gui.mainframe.nextbutton"));
298             nextButton.setActionCommand("next");
299         }
300         return nextButton;
301     }
302
303     /**
304      * Initializes connections
305      * @exception java.lang.Exception The exception description.
306      */

307     private void initConnections() {
308         getcancelButton().addActionListener(eventHandler);
309         getbackButton().addActionListener(eventHandler);
310         getnextButton().addActionListener(eventHandler);
311         gethelpButton().addActionListener(eventHandler);
312         dataCollectionPanel.addDialogListener(new DialogListener(){
313             public void dialogProcessed(DialogEvent evt){
314                 setNextButtonStateForDataCollectionPanel();
315             }
316         });
317         this.addWindowListener(new java.awt.event.WindowAdapter JavaDoc(){
318             public void windowClosing(java.awt.event.WindowEvent JavaDoc e){
319                 processCancelAction();
320             }
321         });
322     }
323
324     /**
325      * Initialize the class.
326      */

327     private void initialize() {
328         setName("MainFrame");
329         setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
330         setSize(725, 545);
331         setContentPane(getJDialogContentPane());
332         initConnections();
333         this.setFrameNavigationState(this.DATA_COLLECTION_PENDING);
334         this.setBounds(new java.awt.Rectangle JavaDoc(100,100,this.getWidth(),this.getHeight()));
335     }
336     /**
337      * Starts the application.
338      * @param args an array of command-line arguments
339      */

340     public static void main(java.lang.String JavaDoc[] args) {
341         // Insert code to start the application here.
342
try{
343             MainFrame wiz = new MainFrame(new CommonInfoModel());
344             wiz.show();
345         }catch(java.lang.Throwable JavaDoc th){
346             logger.severe(th.getMessage());
347         }
348     }
349     public void processBackAction() {
350         if(currentNavigationPanel == PROGRESS_PANEL){
351             this.currentNavigationPanel = CERTIFICATE_PANEL ;
352             CSH.setHelpIDString(gethelpButton(),"WIZARD_CERT");
353         }else if(currentNavigationPanel == CERTIFICATE_PANEL){
354             this.currentNavigationPanel = DETAILS_COLLECTION_PANEL ;
355             CSH.setHelpIDString(gethelpButton(),"WIZARD_FIRST");
356         }else if(currentNavigationPanel == CLUSTER_DETAILS_PANEL){
357             if(commonInfoModel.getCertificateConversionFlag()){
358                 this.currentNavigationPanel = CERTIFICATE_PANEL;
359                 CSH.setHelpIDString(gethelpButton(),"WIZARD_CERT");
360             }else{
361                 this.currentNavigationPanel = DETAILS_COLLECTION_PANEL ;
362                 CSH.setHelpIDString(gethelpButton(),"WIZARD_FIRST");
363             }
364         }else if(currentNavigationPanel == DETAILS_COLLECTION_PANEL){
365             //
366
}
367         this.setCurrentNavigationPanel();
368     }
369     public void processHelpAction() {
370         /*DialogEvent de = new DialogEvent(this, DialogEvent.HELP_ACTION);
371         if(currentNavigationPanel == PROGRESS_PANEL){
372             Utils.getHelpBroker().setCurrentID("top");
373         }
374         else if(currentNavigationPanel == CERTIFICATE_PANEL){
375             Utils.getHelpBroker().setCurrentID("WIZARD_CERT");
376         }
377         else if(currentNavigationPanel == DETAILS_COLLECTION_PANEL){
378             Utils.getHelpBroker().setCurrentID("WIZARD_FIRST");
379         }
380         / *
381         for(int i=0 ; i<this.dialogListeners.size(); i++){
382             ((DialogListener)dialogListeners.elementAt(i)).dialogProcessed(de);
383         }*/

384     }
385     public void processNextAction() {
386         DialogEvent de = null;
387         if(getnextButton().getActionCommand().equals("finish")){
388             de = new DialogEvent(this, DialogEvent.FINISH_ACTION);
389             this.dispose();
390         }else if(currentNavigationPanel == DETAILS_COLLECTION_PANEL){
391             if(!this.validateInputs()) return;
392             commonInfoModel.setSourceInstallDir(dataCollectionPanel.getSourceDirectoryPath());
393             if(commonInfoModel.checkSourceInputAsDomainRoot(commonInfoModel.getSourceInstallDir()))
394                 commonInfoModel.setSourceDomainRoot(commonInfoModel.getSourceInstallDir());
395             commonInfoModel.setTargetDomainRoot(dataCollectionPanel.getDestinationDirectoryPath());
396             commonInfoModel.setAdminUserName(dataCollectionPanel.getAdminUserName());
397             commonInfoModel.setAdminPassword(dataCollectionPanel.getAdminPassword());
398             commonInfoModel.setCertificateConversionFlag(dataCollectionPanel.isUpgradeCertificatesSelected());
399             
400             if(!this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){
401                 commonInfoModel.setMasterPassword(dataCollectionPanel.getMasterPassword());
402             }
403             // It is decided not to ask users for additional domain info.
404
/*if(this.commonInfoModel.getSourceVersion().equals(UpgradeConstants.VERSION_80) ||
405                 this.commonInfoModel.getSourceVersion().equals(UpgradeConstants.VERSION_81)){
406                     java.util.List domainsList = this.getUserDefinedSourceDomains(commonInfoModel);
407                     // If user has selected option that domains are not created in other locations then continue as such
408                     if(domainsList != null){
409                         // User had selected YES option and added domain directories.
410                         commonInfoModel.enlistDomainsFromSource(domainsList);
411                     }
412             }*/

413             commonInfoModel.enlistDomainsFromSource();
414             if(dataCollectionPanel.isUpgradeCertificatesSelected()){
415                 commonInfoModel.setCertificateConversionFlag(true);
416                 this.currentNavigationPanel = CERTIFICATE_PANEL;
417                 CSH.setHelpIDString(gethelpButton(),"WIZARD_CERT");
418             }else if(commonInfoModel.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_EE)){
419                 this.currentNavigationPanel = CLUSTER_DETAILS_PANEL;
420                 CSH.setHelpIDString(gethelpButton(),"WIZARD_CLUSTER");
421             }else{
422                 de = new DialogEvent(this, DialogEvent.UPGRADE_ACTION);
423                 this.currentNavigationPanel = PROGRESS_PANEL ;
424                 CSH.setHelpIDString(gethelpButton(),"WIZARD_RESULT");
425             }
426             this.setCurrentNavigationPanel();
427         }else if(currentNavigationPanel == CERTIFICATE_PANEL){
428             if(commonInfoModel.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_EE)){
429                 this.currentNavigationPanel = CLUSTER_DETAILS_PANEL ;
430                 CSH.setHelpIDString(gethelpButton(),"WIZARD_CLUSTER");
431             }else{
432                 de = new DialogEvent(this, DialogEvent.UPGRADE_ACTION);
433                 this.currentNavigationPanel = PROGRESS_PANEL ;
434                 CSH.setHelpIDString(gethelpButton(),"WIZARD_RESULT");
435             }
436             this.setCurrentNavigationPanel();
437         }else if(currentNavigationPanel == CLUSTER_DETAILS_PANEL){
438             // gather data from cluster details panel and save it in common info.
439
Vector clusterFileNames = this.clusterDetailsPanel.getClusterFilesTableModel().getClusterFiles();
440             // Do error check here. Check to see whether the entered list of files are valid or not.
441
if((clusterFileNames != null) && (!clusterFileNames.isEmpty())){
442                 if(!commonInfoModel.processClinstnceConfFiles(clusterFileNames)){
443                     javax.swing.JOptionPane.showMessageDialog(this, stringManager.getString("upgrade.gui.mainframe.clusterListInvalidMsg"),
444                                                           stringManager.getString("upgrade.gui.mainframe.lusterListInvalidTitle"),
445                                                           javax.swing.JOptionPane.ERROR_MESSAGE);
446                     return;
447                 }
448             }
449             de = new DialogEvent(this, DialogEvent.UPGRADE_ACTION);
450             this.currentNavigationPanel = PROGRESS_PANEL ;
451             this.setCurrentNavigationPanel();
452             CSH.setHelpIDString(gethelpButton(),"WIZARD_RESULT");
453         }else if(currentNavigationPanel == PROGRESS_PANEL){
454             // should be a Finish button now. Close the upgrade tool
455
de = new DialogEvent(this, DialogEvent.FINISH_ACTION);
456             this.dispose();
457         }
458         if(de != null){
459             new UpgradeActionThread(dialogListeners, de).start();
460         }
461     }
462     private java.util.List JavaDoc getUserDefinedSourceDomains(CommonInfoModel commonInfoModel){
463         int returnedOption = javax.swing.JOptionPane.showConfirmDialog(this, stringManager.getString("upgrade.gui.mainframe.multiplDomainsMsg"),
464                               stringManager.getString("upgrade.gui.mainframe.multiplDomainsTitle"),
465                               javax.swing.JOptionPane.YES_NO_OPTION,javax.swing.JOptionPane.QUESTION_MESSAGE);
466         if(returnedOption == javax.swing.JOptionPane.NO_OPTION)
467             return null;
468         // Bring up the dialog here.
469
this.getDomainPathSelectionDialog().show();
470         // The dialog is modal untill it is closed.
471
if(this.getDomainPathSelectionDialog().USER_ACTION == DomainPathSelectionDialog.CANCEL_ACTION){
472             return null;
473         }else{
474             return this.getDomainPathSelectionDialog().getDomainPathTableModel().getDomainPaths();
475         }
476     }
477     private DomainPathSelectionDialog getDomainPathSelectionDialog(){
478         if(this.domainPathSelectionDialog == null){
479             domainPathSelectionDialog = new DomainPathSelectionDialog();
480             centerDialog(domainPathSelectionDialog);
481             domainPathSelectionDialog.addDialogListener(new DialogListener(){
482                 public void dialogProcessed(DialogEvent evt){
483                     
484                 }
485             });
486         }
487         return domainPathSelectionDialog;
488     }
489     public void centerDialog(javax.swing.JDialog JavaDoc dialog) {
490         java.awt.Rectangle JavaDoc bounds = this.getBounds();
491         java.awt.Rectangle JavaDoc dialogLocation = new java.awt.Rectangle JavaDoc();
492         dialogLocation.x = bounds.x+((bounds.width-dialog.getWidth())/2);
493         dialogLocation.y = bounds.y+((bounds.height-dialog.getHeight())/2);
494         dialogLocation.setSize(dialog.getWidth(),dialog.getHeight());
495         dialog.setBounds(dialogLocation);
496     }
497     public void setCurrentNavigationPanel() {
498         getnavigationPanel().removeAll();
499         this.getJDialogContentPane().invalidate();
500         java.awt.GridBagConstraints JavaDoc constraintsPanel = new java.awt.GridBagConstraints JavaDoc();
501         constraintsPanel.gridx = 0; constraintsPanel.gridy = 0;
502         constraintsPanel.fill = java.awt.GridBagConstraints.BOTH;
503         constraintsPanel.weightx = 1.0;
504         constraintsPanel.weighty = 1.0;
505         if(this.PROGRESS_PANEL == currentNavigationPanel){
506             getnavigationPanel().add(getProgressPanel(), constraintsPanel);
507             this.setFrameNavigationState(this.UPGRADE_STARTED);
508         }else if(this.CERTIFICATE_PANEL == currentNavigationPanel){
509             getnavigationPanel().add(getCertificatePanel(), constraintsPanel);
510             this.setFrameNavigationState(this.CRTIFICATION_PENDING);
511             ((CertificatePanel)getCertificatePanel()).reInitializeAddDomainDialog();
512         }else if(this.DETAILS_COLLECTION_PANEL == currentNavigationPanel){
513             getnavigationPanel().add(getDataCollectionPanel(), constraintsPanel);
514             this.setFrameNavigationState(this.DATA_COLLECTION_PENDING);
515         }else if(this.CLUSTER_DETAILS_PANEL == currentNavigationPanel){
516             getnavigationPanel().add(getClusterDetailsPanel(), constraintsPanel);
517             this.setFrameNavigationState(this.CLUSTER_DETAILS_PENDING);
518         }
519         this.getJDialogContentPane().validate();
520         this.repaint();
521     }
522
523     private void setFrameNavigationState(int state){
524         if(this.UPGRADE_FINISHED == state){
525             getcancelButton().setEnabled(false);
526             getnextButton().setEnabled(true);
527             getnextButton().setActionCommand("finish");
528             getnextButton().setText(stringManager.getString("upgrade.gui.mainframe.finishbutton"));
529             getbackButton().setEnabled(false);
530         }else if(this.UPGRADE_STARTED == state){
531             getnextButton().setEnabled(false);
532             getbackButton().setEnabled(false);
533         }else if(this.CRTIFICATION_PENDING == state){
534             getnextButton().setEnabled(true);
535             getbackButton().setEnabled(true);
536         }else if(this.CLUSTER_DETAILS_PENDING == state){
537             getnextButton().setEnabled(true);
538             getbackButton().setEnabled(true);
539             //setNextButtonStateForClusterDetailsPanel();
540
}else{
541             // Data collection panel is currently shown.
542
getcancelButton().setEnabled(true);
543             this.setNextButtonStateForDataCollectionPanel();
544             getnextButton().setActionCommand("next");
545             getbackButton().setEnabled(false);
546         }
547     }
548     private void setNextButtonStateForDataCollectionPanel(){
549         String JavaDoc sourcePath = this.dataCollectionPanel.getSourceDirectoryPath();
550         String JavaDoc destPath = this.dataCollectionPanel.getDestinationDirectoryPath();
551         String JavaDoc adminUserName = this.dataCollectionPanel.getAdminUserName();
552         String JavaDoc adminPassword = this.dataCollectionPanel.getAdminPassword();
553
554         if(this.commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){
555
556             if((sourcePath == null) || (destPath == null) || (adminUserName == null) || (adminPassword == null) ||
557             ("".equals(adminUserName)) || ("".equals(adminPassword)) || ("".equals(sourcePath)) || ("".equals(destPath))){
558                 getnextButton().setEnabled(false);
559             }else{
560                 getnextButton().setEnabled(true);
561             }
562         }else{
563             String JavaDoc masterPassword = this.dataCollectionPanel.getMasterPassword();
564
565             if((sourcePath == null) || (destPath == null) || (adminUserName == null) || (adminPassword == null) || (masterPassword == null) ||
566             ("".equals(adminUserName)) || ("".equals(adminPassword)) || ("".equals(sourcePath)) || ("".equals(masterPassword)) || ("".equals(destPath))){
567                 getnextButton().setEnabled(false);
568             }else{
569                 getnextButton().setEnabled(true);
570             }
571         }
572     }
573     private void setNextButtonStateForClusterDetailsPanel(){
574         if(this.clusterDetailsPanel.getClusterFilesTableModel().getClusterFiles().size() == 0){
575             getnextButton().setEnabled(false);
576         }else{
577             getnextButton().setEnabled(true);
578         }
579     }
580     private boolean validateInputs() {
581         if(currentNavigationPanel == DETAILS_COLLECTION_PANEL){
582             String JavaDoc sourceDir = dataCollectionPanel.getSourceDirectoryPath();
583             String JavaDoc destDir = dataCollectionPanel.getDestinationDirectoryPath();
584             if(!UpgradeUtils.getUpgradeUtils(commonInfoModel).isValidSourcePath(sourceDir)){
585                 if( !(commonInfoModel.checkSourceInputAsDomainRoot(dataCollectionPanel.getSourceDirectoryPath())) ||
586                     commonInfoModel.getSourceVersion().equals(UpgradeConstants.VERSION_7X)) {
587                 // pop up error message
588
javax.swing.JOptionPane.showMessageDialog(this, stringManager.getString("upgrade.gui.mainframe.invalidSourceMsg"),
589                               stringManager.getString("upgrade.gui.mainframe.invalidSourceTitle"),
590                               javax.swing.JOptionPane.ERROR_MESSAGE);
591                     return false;
592                 }
593             }
594             //File runtime80Jar = new File(destDir+File.separator+"lib"+File.separator+"j2ee.jar");
595
//if((runtime80Jar == null) || !runtime80Jar.exists()) {
596
if(!UpgradeUtils.getUpgradeUtils(commonInfoModel).isValidTargetPath(destDir)){
597                 // pop up error message
598
javax.swing.JOptionPane.showMessageDialog(this, stringManager.getString("upgrade.gui.mainframe.invalidTargetMsg"),
599                               stringManager.getString("upgrade.gui.mainframe.invalidTargetTitle"),
600                               javax.swing.JOptionPane.ERROR_MESSAGE);
601                 return false;
602             }
603             commonInfoModel.setSourceInstallDir(sourceDir);
604             commonInfoModel.setTargetDomainRoot(destDir);
605             if(commonInfoModel.checkSourceInputAsDomainRoot(commonInfoModel.getSourceInstallDir()))
606                 commonInfoModel.setSourceDomainRoot(commonInfoModel.getSourceInstallDir());
607             //System.out.println("MainFrame::validateInputs:Source Version......:"+commonInfoModel.getSourceVersionAndEdition());
608
//System.out.println("MainFrame::validateInputs:Target Version......:"+commonInfoModel.getTargetVersionAndEdition());
609

610             if(!commonInfoModel.isUpgradeSupported()){
611                 javax.swing.JOptionPane.showMessageDialog(this, stringManager.getString("upgrade.gui.mainframe.versionNotSupportedMsg1")+
612                                                       UpgradeConstants.readableString(commonInfoModel.getSourceVersionAndEdition())+
613                                                       stringManager.getString("upgrade.gui.mainframe.versionNotSupportedMsg2")+
614                                                       UpgradeConstants.readableString(commonInfoModel.getTargetVersionAndEdition()),
615                               stringManager.getString("upgrade.gui.mainframe.versionNotSupportedTitle"),
616                               javax.swing.JOptionPane.ERROR_MESSAGE);
617                 commonInfoModel.clearSourceAndTargetVersions();
618                 return false;
619             }
620             String JavaDoc userName = dataCollectionPanel.getAdminUserName();
621             String JavaDoc adminPasswd = dataCollectionPanel.getAdminPassword();
622             String JavaDoc masterPwd = null;
623             if(!commonInfoModel.getTargetVersionAndEdition().equals(UpgradeConstants.VERSION_AS90_PE)){
624                 masterPwd = dataCollectionPanel.getMasterPassword();
625             }
626             if(!UpgradeUtils.getUpgradeUtils(commonInfoModel).validateUserDetails(userName,adminPasswd,masterPwd)){
627                 javax.swing.JOptionPane.showMessageDialog(this, stringManager.getString("upgrade.gui.mainframe.invalidUserDetailsMsg"),
628                               stringManager.getString("upgrade.gui.mainframe.invalidUserDetailsTitle"),
629                               javax.swing.JOptionPane.ERROR_MESSAGE);
630                     return false;
631             }
632             commonInfoModel.clearSourceAndTargetVersions();
633             return true;
634         }
635         return true;
636     }
637     private javax.swing.JPanel JavaDoc getDataCollectionPanel() {
638         if (dataCollectionPanel == null) {
639             dataCollectionPanel = new DataCollectionPanel(commonInfoModel);
640         }
641         return dataCollectionPanel;
642     }
643     private javax.swing.JPanel JavaDoc getClusterDetailsPanel() {
644         if (clusterDetailsPanel == null) {
645             clusterDetailsPanel = new ClusterDetailsPanel();
646             clusterDetailsPanel.addDialogListener(new DialogListener(){
647             public void dialogProcessed(DialogEvent evt){
648                 //setNextButtonStateForClusterDetailsPanel();
649
}
650         });
651         }
652         return clusterDetailsPanel;
653     }
654     private javax.swing.JPanel JavaDoc getCertificatePanel() {
655         if (certificatePanel == null) {
656             certificatePanel = new CertificatePanel(this.commonInfoModel, this);
657         }
658         return certificatePanel;
659     }
660
661     public void logMessageReceived(LogMessageEvent evt) {
662         // retrive message and show it in Process panel.
663
if(this.progressPanel != null){
664             this.progressPanel.updateLog(evt);
665         }
666     }
667
668     public void upgradeProcessUpdate(UpgradeUpdateEvent evt) {
669         if(this.progressPanel != null){
670             this.progressPanel.updateProgress(evt);
671             if(evt.getProgressState() == 100){
672                 this.setFrameNavigationState(this.UPGRADE_FINISHED);
673             }
674         }
675     }
676     class UpgradeActionThread extends Thread JavaDoc{
677         private Vector dialogListeners;
678         private DialogEvent de;
679         public UpgradeActionThread(Vector listeners, DialogEvent d){
680             this.dialogListeners = listeners;
681             this.de = d;
682         }
683         public void run(){
684             for(int i=0 ; i<this.dialogListeners.size(); i++){
685                 ((DialogListener)dialogListeners.elementAt(i)).dialogProcessed(de);
686             }
687         }
688     }
689
690 }
691
Popular Tags