Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

TAbstractDialog.java

00001 /*
00002 *  Name:      TAbstractDialog.java
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   Abstract dialog class
00005 *  Date:      $Date: 2003/10/06 12:45:11 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 2003  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00027 package org.mpcl.nui;
00028 
00029 import java.awt.BorderLayout;
00030 import java.awt.Color;
00031 import java.awt.GridLayout;
00032 import java.awt.event.ActionEvent;
00033 import java.util.ArrayList;
00034 import java.util.List;
00035 import javax.swing.BorderFactory;
00036 import javax.swing.JComponent;
00037 import javax.swing.JPanel;
00038 import javax.swing.JDialog;
00039 import javax.swing.JFrame;
00040 import javax.swing.JPanel;
00041 import javax.swing.border.Border;
00042 import org.mpcl.designpatterns.mvc.controller.TAbstractController;
00043 
00044 
00046 public abstract class TAbstractDialog extends JDialog
00047 {
00048 
00053   private List   tVerifiedComponentList;
00054 
00056   protected static final int   _kiEmptyBorderLength = 10;
00057 
00062   protected TAbstractController   tController;
00063 
00068   protected JPanel   tMainPanel;
00069 
00070 
00071   //
00072   //  C O N S T R U C T O R S
00073   //
00074 
00083   public TAbstractDialog ( JFrame              tFRAME_OWNER ,
00084                            String              yTITLE       ,
00085                            TAbstractController tCONTROLLER  ,
00086                            boolean             gIS_MODAL    )
00087   {
00088     super (tFRAME_OWNER, yTITLE, gIS_MODAL);
00089     tController            = tCONTROLLER;
00090     tMainPanel             = new JPanel();
00091     tVerifiedComponentList = new ArrayList();
00092     tMainPanel.setLayout (new BorderLayout());
00093     tMainPanel.setBorder (BorderFactory.createEmptyBorder (_kiEmptyBorderLength, _kiEmptyBorderLength, _kiEmptyBorderLength, _kiEmptyBorderLength));
00094     getContentPane().setLayout (new GridLayout (1, 1));
00095     getContentPane().add (tMainPanel);
00096   }
00097 
00102   public void addToVerifieds (JComponent tCOMPONENT)
00103   {
00104     tVerifiedComponentList.add (tCOMPONENT);
00105   }
00106 
00108   public void initialize() {}
00109 
00114   void attachToObservable() {}
00115 
00120   void detachFromObservable() {}
00121 
00122 
00123   //
00124   //  S E L E C T O R S
00125   //
00126 
00131   public boolean isValid()
00132   {
00133 
00134     ActionEvent              tActionEvent;
00135     JComponent               tComponent;
00136     TAbstractInputVerifier   tInputVerifier;
00137     boolean                  gIsValid = true;
00138 
00139     for (int I = 0; ( I < tVerifiedComponentList.size() ) ;++I)
00140     {
00141       tComponent     = (JComponent) tVerifiedComponentList.get (I);
00142       tInputVerifier = (TAbstractInputVerifier) tComponent.getInputVerifier();
00143       if ( !tInputVerifier.verify (tComponent) )
00144       {
00145         gIsValid     = false;
00146         tActionEvent = new ActionEvent (this, tInputVerifier.hashCode(), tInputVerifier.toString());
00147         tController.actionPerformed (tActionEvent);
00148         tComponent.requestFocus();
00149         break;
00150       }
00151     }
00152     return gIsValid;
00153 
00154   }  // isValid()
00155 
00160   public Border createBorder()
00161   {
00162     Border   tDefaultBorder;
00163     Border   tEmptyBorder;
00164 
00165     tDefaultBorder = BorderFactory.createLineBorder (Color.gray);
00166     tEmptyBorder   = BorderFactory.createEmptyBorder (_kiEmptyBorderLength, _kiEmptyBorderLength, _kiEmptyBorderLength, _kiEmptyBorderLength);
00167     return BorderFactory.createCompoundBorder (tDefaultBorder, tEmptyBorder);
00168   }
00169 
00170 }  // class TAbstractDialog

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18