001 /** ===================================================================== 002 * 003 * File Name : $Id: ModifyFormPanel.java,v 1.8 2008/01/15 11:08:15 cb Exp $ 004 * 005 * Description 006 * ----------- 007 * 008 * See javadoc comment 009 * 010 * ===================================================================== 011 * 012 * @Author : Craige Bevil 013 * Control Software Group 014 * Isaac Newton Group of Telescopes 015 * 016 * ===================================================================== 017 * 018 * Modification Log 019 * 020 * Vers Date Author Reason 021 * ---- ---- ------ ------ 022 * 1 C.Bevil First Release 023 * 024 * Commissioning Notes 025 * ------------------- 026 * 027 * None 028 * 029 * ===================================================================== 030 * 031 * @Version : $Id: ModifyFormPanel.java,v 1.8 2008/01/15 11:08:15 cb Exp $ 032 * 033 * @Author : $Author: cb $ 034 * 035 * Header : $Header: /opt/INGsrc/src/CVS/softproj/FaultDatabase/src/FaultDatabase/FaultDatabase/src/GWTApplication/client/ModifyFormPanel.java,v 1.8 2008/01/15 11:08:15 cb Exp $ 036 * 037 * Log : $Log: ModifyFormPanel.java,v $ 038 * Log : Revision 1.8 2008/01/15 11:08:15 cb 039 * Log : Ran through PMD and sorted out the javadoc so that we could export the 040 * Log : javadoc to the javadoc repository. 041 * Log : 042 * Log : Revision 1.7 2007/12/12 15:26:12 cb 043 * Log : Added new javascript library which allows fancy message boxes to be 044 * Log : displayed. 045 * Log : 046 * Log : Revision 1.6 2007/08/17 14:26:41 cb 047 * Log : Updated for lastest prototype incorporating a lot of Nikos comments 048 * Log : 049 * Log : Revision 1.5 2007/08/09 08:34:59 cb 050 * Log : Modified so that we select a different tab in the main menu when we do 051 * Log : not have any more faults to update. 052 * Log : 053 * Log : Revision 1.4 2007/08/01 13:00:05 cb 054 * Log : First prototype after import 055 * Log : 056 * Log : Revision 1.3 2007/07/24 08:31:19 cb 057 * Log : Added a method which can be used to estalish if the fault is being 058 * Log : edited or not 059 * Log : 060 * Log : Revision 1.2 2007/07/13 10:54:05 cb 061 * Log : Complete interface prototype 062 * Log : 063 * Log : Revision 1.1.1.1 2007/06/01 08:33:26 cb 064 * Log : Imported using TkCVS 065 * Log : 066 * 067 * =====================================================================*/ 068 069 package GWTApplication.client; 070 071 import com.google.gwt.user.client.*; 072 import com.google.gwt.user.client.rpc.*; 073 import com.google.gwt.user.client.ui.*; 074 import com.google.gwt.user.client.ui.FlexTable.*; 075 076 import com.gwtext.client.core.EventObject; 077 import com.gwtext.client.util.Format; 078 import com.gwtext.client.widgets.MessageBox; 079 import com.gwtext.client.widgets.MessageBoxConfig; 080 081 /** 082 * This class is used to create a tab into which panels are placed 083 * from where the user can modify faults. Each tab associated with 084 * this tab will have associated with it a defect fault report number. 085 * @author Craige Bevil 086 * @version $Id: ModifyFormPanel.java,v 1.8 2008/01/15 11:08:15 cb Exp $ 087 */ 088 089 class ModifyFormPanel extends FaultDBForm { 090 091 /** 092 * This is the main tab panel 093 */ 094 095 final private TabPanel MainTabPanel; 096 097 /** 098 * This is a tab widget which will contain a series of tabs each 099 * one containing the details of a fault which has been requested 100 * to be modified 101 */ 102 103 final TabPanel ModifyFaultTabs = new TabPanel(); 104 105 /** 106 * Returns the number of faults being edited 107 * @return The number of faults which are being edited. 108 */ 109 110 public int getNumberOfFaultsBeingEdited () { 111 return ModifyFaultTabs.getTabBar().getTabCount(); 112 } 113 114 /** 115 * Reports whether the fault specified is being edited or not. 116 * @param faultId The fault identifier of the fault to be checked 117 */ 118 119 public boolean isFaultBeingEdited(final int faultId) { 120 121 for (int i=0; i < ModifyFaultTabs.getWidgetCount();i++) { 122 123 final ModifyFault temp = (ModifyFault)ModifyFaultTabs.getWidget(i); 124 125 if (temp.getFaultNumber() == faultId) { 126 return true; 127 } 128 } 129 130 return false; 131 } 132 133 /** 134 * This is used to create a new tab panel which will be used to 135 * modify the fault which has been specified 136 * @param FaultNumber This is the number of the fault which is to 137 * be presented to the user for modification. 138 */ 139 140 public void addNewFaultTab (final int FaultNumber) { 141 142 ModifyFault temp; 143 144 // First we need to find out if there is already a tab which 145 // contains the details of the fault being edited and if so 146 // then we tell the user that he is already editing that fault. 147 148 for (int i=0; i < ModifyFaultTabs.getWidgetCount();i++) { 149 150 temp = (ModifyFault)ModifyFaultTabs.getWidget(i); 151 152 if (temp.getFaultNumber() == FaultNumber) { 153 MessageBox.alert(internationalizationConstants.information(),"Fault number " + FaultNumber + " is already being modified."); 154 ModifyFaultTabs.selectTab(i); 155 return; 156 } 157 } 158 159 // Now show that we are busy whilst we build the form which 160 // the user will use to modify the fault. 161 162 busyIndicator.showBusy(true); 163 164 // Now add a tab for modifying a fault, first we need to get 165 // the fault data from the servlet. 166 167 temp = new ModifyFault(FaultNumber,svc,internationalizationConstants,ModifyFaultTabs,UserAuthentication,MainTabPanel); 168 169 ModifyFaultTabs.add(temp,internationalizationConstants.fault() + " " + FaultNumber); 170 171 // Now select the tab which has just been created for the user 172 // to modify the fault 173 174 ModifyFaultTabs.selectTab(ModifyFaultTabs.getTabBar().getTabCount() - 1); 175 176 busyIndicator.showBusy(false); 177 } 178 179 ModifyFormPanel (final TabPanel MainTabPanel,final FaultServiceAsync svc,final AuthenticationDetails UserAuthentication) { 180 181 this.svc = svc; 182 this.UserAuthentication = UserAuthentication; 183 this.MainTabPanel = MainTabPanel; 184 185 MainTabPanel.add(ModifyFaultTabs,internationalizationConstants.updateFault()); 186 } 187 } 188 189