00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
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 }
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 }