Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/gui/sendsettings/SendSettingsTab.java


1   /*
2    * SendSettingsTab.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:34 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.gui.sendsettings;
12  
13  import java.awt.Panel;
14  import java.util.Vector;
15  
16  import com.flexstor.common.awt.dialogs.MessageBox;
17  import com.flexstor.common.awt.event.SettingsEvent;
18  import com.flexstor.common.awt.event.SettingsEventListener;
19  import com.flexstor.common.awt.field.FlexTextField;
20  import com.flexstor.common.data.ejb.SettingData;
21  
22  /**
23   * Each tab in ChangeSendSettingsDialog should extend this Abstract Class
24   */
25  public abstract class SendSettingsTab extends Panel implements SettingsComponentI
26  {
27    // For Email To Button
28    public static int     ACTION_EMAIL_TO         = 10;
29  
30    // For Email Cc Button
31    public static int     ACTION_EMAIL_CC         = 11;
32  
33    // For Email ftp Button
34    public static int     ACTION_FTP              = 12;
35  
36    // For Email browse Button
37    public static int     ACTION_BROWSE           = 13;
38  
39    protected Vector listeners = new Vector();
40  
41    /**
42      * Add listener to the list of Listeners
43      * @param listener listner to add to listener list
44      * @return void
45     */
46    public void addSettingsListener(SettingsEventListener listener)
47    {
48       if (find(listener) < 0)
49       {
50         listeners.addElement(listener);
51       }
52    }
53  
54    /**
55      * Remove listener to the list of Listeners
56      * @param listener listner to remove to listener list
57      * @return void
58     */
59    public void removeSettingsListener(SettingsEventListener listener)
60    {
61        int index = find(listener);
62        if (index > -1)
63        {
64          listeners.removeElement(listener);
65        }
66    }
67  
68    
69    /**
70     * Not usefull yet given for default implementaion
71     */
72    public boolean isModified()
73    {
74      return false;
75    }
76  
77  
78    /**
79      * Clean up all the fields from this tab
80     */
81    public abstract void cleanUpFields();
82  
83    //Stubs for implementation of SettingsComponentI /??
84    public void setModel(Object o)
85    {
86  
87    }
88  
89    //??
90    public SettingData getDataObject()
91    {
92      return null;
93    }
94  
95    /**
96     * Notify All Listeners
97     * @param e setting event
98     * @return void
99  
100    */
101   protected void fireSettingsEventListener(SettingsEvent e)
102   {
103     if (listeners.size() > 0 )
104     {
105       for (int index = 0; index < listeners.size(); ++index)
106       {
107          ((SettingsEventListener)(listeners.elementAt(index))).eventOccured(e);
108       }
109     }
110   }
111 
112   /**
113    *  Utility method to check for spaces
114    *  @param String value
115    *  @String fieldName
116    *  @return boolean has space
117    */
118   protected boolean verifyForSpaces(String value, String fieldName, String tabName)
119   {
120     if ( value.length() > 0 && value.trim().length() == 0 )
121     {
122       // 7023=The value containing only spaces is not valid for "%%1" field of %%2 tab.
123       MessageBox.showMessageDialog ( null,7023,MessageBox.OK, fieldName, tabName );
124       return false;
125     }
126     return true;
127   }
128 
129   /**
130   *  Utility method to validates required field and shows custom message
131   *  instead of validator's message
132   *  @param String value
133   *  @String tabName
134   *  @String fieldName
135   *  @return boolean valid or invalid
136   */
137   protected boolean verifyRequired(FlexTextField field, String tabName)
138   {
139     if (!field.verify(true))
140     {
141       // 7021=The field %%1 of %%2 tab is required.  Enter a value for this field.
142       MessageBox.showMessageDialog ( null,7021,MessageBox.OK,field.getName(),tabName );
143       return false;
144     }
145     return true;
146   }
147 
148 
149   /**
150     * Find listener's index in listener list
151     * @param listener
152     * @return int index of listener
153    */
154   private int find(SettingsEventListener listener)
155   {
156     if (listeners.size() > 0 )
157     {
158        for (int index = 0; index < listeners.size(); ++index)
159           if (listeners.elementAt(index) == listener)
160             return index;
161     }
162     return -1;
163   }
164 
165 } // End of class SendSettingTab