- Timestamp:
- 03/14/2017 04:20:05 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
- 3 copied
-
config/svn-version.txt (copied) (copied from trunk/config/svn-version.txt) (1 diff)
-
config/testConfig/cad_simulator_logging.properties (modified) (1 diff)
-
images/CADMenuImages/US_101_icon.png (added)
-
images/CADicon.png (added)
-
src/tmcsim/application.properties (modified) (1 diff)
-
src/tmcsim/cadsimulator/Coordinator.java (modified) (9 diffs)
-
src/tmcsim/client/CADClockDisplay.java (copied) (copied from trunk/src/tmcsim/client/CADClient.java) (7 diffs)
-
src/tmcsim/client/CADClockView.java (copied) (copied from trunk/src/tmcsim/client/CADClientView.java) (5 diffs)
-
test/tmcsim/cadsimulator/GetCadDataUnitValueTest.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/config/svn-version.txt
r40 r54 1 37M2 3 # Do not edit. This file is autogenerated by the Ant build script #4 -
trunk/config/testConfig/cad_simulator_logging.properties
r32 r54 14 14 # Set the default formatter for new ConsoleHandler instances 15 15 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 16 -
trunk/src/tmcsim/application.properties
r52 r54 1 # Sun, 03 Jul 2016 08:10:42-07001 #Tue, 14 Mar 2017 17:07:19 -0700 2 2 3 Application.revision= 513 Application.revision=49 4 4 5 Application.buildnumber=2 15 Application.buildnumber=24 -
trunk/src/tmcsim/cadsimulator/Coordinator.java
r44 r54 38 38 import tmcsim.client.cadclientgui.data.Incident; 39 39 import tmcsim.client.cadclientgui.data.IncidentEvent; 40 import tmcsim.client.cadclientgui.data.Unit; 40 41 import tmcsim.client.cadclientgui.enums.CADDataEnums.CARDFILE; 41 42 import tmcsim.client.cadclientgui.enums.CADDataEnums.EditCommand; … … 87 88 implements CoordinatorInterface 88 89 { 89 90 90 /** 91 91 * Error logger. … … 133 133 } 134 134 135 /** Dependency Injection for testing */ 136 void setCadData(CADData theData) 137 { 138 cadData = theData; 139 } 140 135 141 public void registerForCallback(CADClientInterface client) throws RemoteException 136 142 { … … 914 920 if (tag.equals(INC_TABLE.COMMENTS_NOTES)) 915 921 { 916 return cadData.getIncident(incidentId).getCommentsNotesTable(); 922 Incident myIncident = cadData.getIncident(incidentId); 923 if (myIncident == null) return new DefaultTableModel(); 924 return myIncident.getCommentsNotesTable(); 917 925 } 918 926 return null; … … 955 963 public Object getCadDataIncVal(INC_VAL tag, int incidentId) throws RemoteException 956 964 { 957 if (tag.equals(INC_VAL.LOG_NUM)) 958 { 959 return cadData.getIncident(incidentId).getLogNum(); 960 } 961 else if (tag.equals(INC_VAL.MASTER_INC)) 962 { 963 return cadData.getIncident(incidentId).getMasterInc(); 964 } 965 else if (tag.equals(INC_VAL.OAU)) 966 { 967 return cadData.getIncident(incidentId).getOau(); 968 } 969 else if (tag.equals(INC_VAL.P)) 970 { 971 return cadData.getIncident(incidentId).getP(); 972 } 973 else if (tag.equals(INC_VAL.DESCRIPTION)) 974 { 975 return cadData.getIncident(incidentId).getDescription(); 976 } 977 else if (tag.equals(INC_VAL.RP)) 978 { 979 return cadData.getIncident(incidentId).getRp(); 980 } 981 else if (tag.equals(INC_VAL.RP_TYPE)) 982 { 983 return cadData.getIncident(incidentId).getRpType(); 984 } 985 else if (tag.equals(INC_VAL.ALI)) 986 { 987 return cadData.getIncident(incidentId).getAli(); 988 } 989 else if (tag.equals(INC_VAL.MEDIA)) 990 { 991 return cadData.getIncident(incidentId).getMedia(); 992 } 993 else 994 { 995 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncVal"); 965 Incident current = cadData.getIncident(incidentId); 966 if (current != null) 967 { 968 if (tag.equals(INC_VAL.LOG_NUM)) 969 { 970 return current.getLogNum(); 971 } 972 else if (tag.equals(INC_VAL.MASTER_INC)) 973 { 974 return current.getMasterInc(); 975 } 976 else if (tag.equals(INC_VAL.OAU)) 977 { 978 return current.getOau(); 979 } 980 else if (tag.equals(INC_VAL.P)) 981 { 982 return current.getP(); 983 } 984 else if (tag.equals(INC_VAL.DESCRIPTION)) 985 { 986 return current.getDescription(); 987 } 988 else if (tag.equals(INC_VAL.RP)) 989 { 990 return current.getRp(); 991 } 992 else if (tag.equals(INC_VAL.RP_TYPE)) 993 { 994 return current.getRpType(); 995 } 996 else if (tag.equals(INC_VAL.ALI)) 997 { 998 return current.getAli(); 999 } 1000 else if (tag.equals(INC_VAL.MEDIA)) 1001 { 1002 return current.getMedia(); 1003 } 1004 else 1005 { 1006 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncVal"); 1007 } 1008 } 1009 else 1010 { 1011 return null; 996 1012 } 997 1013 } … … 1049 1065 public String getCadDataIncLoc(INC_LOC tag, int incidentId) throws RemoteException 1050 1066 { 1051 if (tag.equals(INC_LOC.ADDRESS)) 1052 { 1053 return cadData.getIncident(incidentId).getIncidentLocation().getAddress(); 1054 } 1055 else if (tag.equals(INC_LOC.LOC)) 1056 { 1057 return cadData.getIncident(incidentId).getIncidentLocation().getLoc(); 1058 } 1059 else if (tag.equals(INC_LOC.CITY)) 1060 { 1061 return cadData.getIncident(incidentId).getIncidentLocation().getCity(); 1062 } 1063 else if (tag.equals(INC_LOC.COUNTY)) 1064 { 1065 return cadData.getIncident(incidentId).getIncidentLocation().getCounty(); 1066 } 1067 else if (tag.equals(INC_LOC.STATE)) 1068 { 1069 return cadData.getIncident(incidentId).getIncidentLocation().getState(); 1070 } 1071 else if (tag.equals(INC_LOC.ZIP)) 1072 { 1073 return cadData.getIncident(incidentId).getIncidentLocation().getZip(); 1074 } 1075 else if (tag.equals(INC_LOC.BEAT)) 1076 { 1077 return cadData.getIncident(incidentId).getIncidentLocation().getBeat(); 1078 } 1079 else if (tag.equals(INC_LOC.AREA)) 1080 { 1081 return cadData.getIncident(incidentId).getIncidentLocation().getArea(); 1082 } 1083 else if (tag.equals(INC_LOC.SECTOR)) 1084 { 1085 return cadData.getIncident(incidentId).getIncidentLocation().getSector(); 1086 } 1087 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1088 { 1089 return cadData.getIncident(incidentId).getIncidentLocation().getSectorCode(); 1090 } 1091 else if (tag.equals(INC_LOC.DIVISION)) 1092 { 1093 return cadData.getIncident(incidentId).getIncidentLocation().getDivision(); 1094 } 1095 else if (tag.equals(INC_LOC.APT)) 1096 { 1097 return cadData.getIncident(incidentId).getIncidentLocation().getApt(); 1098 } 1099 else if (tag.equals(INC_LOC.BUILDING)) 1100 { 1101 return cadData.getIncident(incidentId).getIncidentLocation().getBuilding(); 1102 } 1103 else if (tag.equals(INC_LOC.CROSS_ST)) 1104 { 1105 return cadData.getIncident(incidentId).getIncidentLocation().getCrossSt(); 1106 } 1107 else if (tag.equals(INC_LOC.LAW)) 1108 { 1109 return cadData.getIncident(incidentId).getIncidentLocation().getLaw(); 1110 } 1111 else if (tag.equals(INC_LOC.FIRE)) 1112 { 1113 return cadData.getIncident(incidentId).getIncidentLocation().getFire(); 1114 } 1115 else if (tag.equals(INC_LOC.EMS)) 1116 { 1117 return cadData.getIncident(incidentId).getIncidentLocation().getEms(); 1118 } 1119 else 1120 { 1121 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncLoc"); 1067 Incident current = cadData.getIncident(incidentId); 1068 if (current != null) 1069 { 1070 if (tag.equals(INC_LOC.ADDRESS)) 1071 { 1072 return current.getIncidentLocation().getAddress(); 1073 } 1074 else if (tag.equals(INC_LOC.LOC)) 1075 { 1076 return current.getIncidentLocation().getLoc(); 1077 } 1078 else if (tag.equals(INC_LOC.CITY)) 1079 { 1080 return current.getIncidentLocation().getCity(); 1081 } 1082 else if (tag.equals(INC_LOC.COUNTY)) 1083 { 1084 return current.getIncidentLocation().getCounty(); 1085 } 1086 else if (tag.equals(INC_LOC.STATE)) 1087 { 1088 return current.getIncidentLocation().getState(); 1089 } 1090 else if (tag.equals(INC_LOC.ZIP)) 1091 { 1092 return current.getIncidentLocation().getZip(); 1093 } 1094 else if (tag.equals(INC_LOC.BEAT)) 1095 { 1096 return current.getIncidentLocation().getBeat(); 1097 } 1098 else if (tag.equals(INC_LOC.AREA)) 1099 { 1100 return current.getIncidentLocation().getArea(); 1101 } 1102 else if (tag.equals(INC_LOC.SECTOR)) 1103 { 1104 return current.getIncidentLocation().getSector(); 1105 } 1106 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1107 { 1108 return current.getIncidentLocation().getSectorCode(); 1109 } 1110 else if (tag.equals(INC_LOC.DIVISION)) 1111 { 1112 return current.getIncidentLocation().getDivision(); 1113 } 1114 else if (tag.equals(INC_LOC.APT)) 1115 { 1116 return current.getIncidentLocation().getApt(); 1117 } 1118 else if (tag.equals(INC_LOC.BUILDING)) 1119 { 1120 return current.getIncidentLocation().getBuilding(); 1121 } 1122 else if (tag.equals(INC_LOC.CROSS_ST)) 1123 { 1124 return current.getIncidentLocation().getCrossSt(); 1125 } 1126 else if (tag.equals(INC_LOC.LAW)) 1127 { 1128 return current.getIncidentLocation().getLaw(); 1129 } 1130 else if (tag.equals(INC_LOC.FIRE)) 1131 { 1132 return current.getIncidentLocation().getFire(); 1133 } 1134 else if (tag.equals(INC_LOC.EMS)) 1135 { 1136 return current.getIncidentLocation().getEms(); 1137 } 1138 else 1139 { 1140 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncLoc"); 1141 } 1142 } 1143 else 1144 { 1145 return ""; 1122 1146 } 1123 1147 } … … 1132 1156 public void setCadDataIncLoc(INC_LOC tag, int incidentId, String value) throws RemoteException 1133 1157 { 1134 if (tag.equals(INC_LOC.ADDRESS)) 1135 { 1136 cadData.getIncident(incidentId).getIncidentLocation().setAddress(value); 1137 } 1138 else if (tag.equals(INC_LOC.LOC)) 1139 { 1140 cadData.getIncident(incidentId).getIncidentLocation().setLoc(value); 1141 } 1142 else if (tag.equals(INC_LOC.CITY)) 1143 { 1144 cadData.getIncident(incidentId).getIncidentLocation().setCity(value); 1145 } 1146 else if (tag.equals(INC_LOC.COUNTY)) 1147 { 1148 cadData.getIncident(incidentId).getIncidentLocation().setCounty(value); 1149 } 1150 else if (tag.equals(INC_LOC.STATE)) 1151 { 1152 cadData.getIncident(incidentId).getIncidentLocation().setState(value); 1153 } 1154 else if (tag.equals(INC_LOC.ZIP)) 1155 { 1156 cadData.getIncident(incidentId).getIncidentLocation().setZip(value); 1157 } 1158 else if (tag.equals(INC_LOC.BEAT)) 1159 { 1160 cadData.getIncident(incidentId).getIncidentLocation().setBeat(value); 1161 } 1162 else if (tag.equals(INC_LOC.AREA)) 1163 { 1164 cadData.getIncident(incidentId).getIncidentLocation().setArea(value); 1165 } 1166 else if (tag.equals(INC_LOC.SECTOR)) 1167 { 1168 cadData.getIncident(incidentId).getIncidentLocation().setSector(value); 1169 } 1170 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1171 { 1172 cadData.getIncident(incidentId).getIncidentLocation().setSectorCode(value); 1173 } 1174 else if (tag.equals(INC_LOC.DIVISION)) 1175 { 1176 cadData.getIncident(incidentId).getIncidentLocation().setDivision(value); 1177 } 1178 else if (tag.equals(INC_LOC.APT)) 1179 { 1180 cadData.getIncident(incidentId).getIncidentLocation().setApt(value); 1181 } 1182 else if (tag.equals(INC_LOC.BUILDING)) 1183 { 1184 cadData.getIncident(incidentId).getIncidentLocation().setBuilding(value); 1185 } 1186 else if (tag.equals(INC_LOC.CROSS_ST)) 1187 { 1188 cadData.getIncident(incidentId).getIncidentLocation().setCrossSt(value); 1189 } 1190 else if (tag.equals(INC_LOC.LAW)) 1191 { 1192 cadData.getIncident(incidentId).getIncidentLocation().setLaw(value); 1193 } 1194 else if (tag.equals(INC_LOC.FIRE)) 1195 { 1196 cadData.getIncident(incidentId).getIncidentLocation().setFire(value); 1197 } 1198 else if (tag.equals(INC_LOC.EMS)) 1199 { 1200 cadData.getIncident(incidentId).getIncidentLocation().setEms(value); 1201 } 1202 else 1203 { 1204 throw new RemoteException("Wrong Enum sent into Coordinator.setCadDataIncLoc"); 1158 Incident current = cadData.getIncident(incidentId); 1159 if (current != null) 1160 { 1161 if (tag.equals(INC_LOC.ADDRESS)) 1162 { 1163 current.getIncidentLocation().setAddress(value); 1164 } 1165 else if (tag.equals(INC_LOC.LOC)) 1166 { 1167 current.getIncidentLocation().setLoc(value); 1168 } 1169 else if (tag.equals(INC_LOC.CITY)) 1170 { 1171 current.getIncidentLocation().setCity(value); 1172 } 1173 else if (tag.equals(INC_LOC.COUNTY)) 1174 { 1175 current.getIncidentLocation().setCounty(value); 1176 } 1177 else if (tag.equals(INC_LOC.STATE)) 1178 { 1179 current.getIncidentLocation().setState(value); 1180 } 1181 else if (tag.equals(INC_LOC.ZIP)) 1182 { 1183 current.getIncidentLocation().setZip(value); 1184 } 1185 else if (tag.equals(INC_LOC.BEAT)) 1186 { 1187 current.getIncidentLocation().setBeat(value); 1188 } 1189 else if (tag.equals(INC_LOC.AREA)) 1190 { 1191 current.getIncidentLocation().setArea(value); 1192 } 1193 else if (tag.equals(INC_LOC.SECTOR)) 1194 { 1195 current.getIncidentLocation().setSector(value); 1196 } 1197 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1198 { 1199 current.getIncidentLocation().setSectorCode(value); 1200 } 1201 else if (tag.equals(INC_LOC.DIVISION)) 1202 { 1203 current.getIncidentLocation().setDivision(value); 1204 } 1205 else if (tag.equals(INC_LOC.APT)) 1206 { 1207 current.getIncidentLocation().setApt(value); 1208 } 1209 else if (tag.equals(INC_LOC.BUILDING)) 1210 { 1211 current.getIncidentLocation().setBuilding(value); 1212 } 1213 else if (tag.equals(INC_LOC.CROSS_ST)) 1214 { 1215 current.getIncidentLocation().setCrossSt(value); 1216 } 1217 else if (tag.equals(INC_LOC.LAW)) 1218 { 1219 current.getIncidentLocation().setLaw(value); 1220 } 1221 else if (tag.equals(INC_LOC.FIRE)) 1222 { 1223 current.getIncidentLocation().setFire(value); 1224 } 1225 else if (tag.equals(INC_LOC.EMS)) 1226 { 1227 current.getIncidentLocation().setEms(value); 1228 } 1229 else 1230 { 1231 throw new RemoteException("Wrong Enum sent into Coordinator.setCadDataIncLoc"); 1232 } 1233 } 1234 else 1235 { 1236 return; 1205 1237 } 1206 1238 } … … 2076 2108 public UnitStatusEnums getCadDataUnitStatus(String unitNum) throws RemoteException 2077 2109 { 2078 return cadData.getUnit(unitNum).getUnitStatus(); 2110 // Validate input parameter 2111 if (unitNum.equals("")) 2112 { 2113 coorLogger.logp(Level.INFO, "Coordinator", "getCadDataUnitStatus", 2114 "Unitnum parameter is blank.", "Error"); 2115 return UnitStatusEnums.NotAssignable; 2116 } 2117 else 2118 { 2119 Unit desiredUnit = cadData.getUnit(unitNum); 2120 // If it exists 2121 if (desiredUnit != null) 2122 { 2123 // Fetch and return its status (an enum) 2124 return desiredUnit.getUnitStatus(); 2125 } 2126 else 2127 { 2128 return UnitStatusEnums.NotAssignable; 2129 } 2130 } 2079 2131 } 2080 2132 … … 2089 2141 public String getCadDataUnitValue(String unitNum, UNIT_TAGS tag) throws RemoteException 2090 2142 { 2091 if (tag.equals(UNIT_TAGS.MASTER_INC_NUM)) 2092 { 2093 return cadData.getUnit(unitNum).getMasterInc(); 2094 } 2095 else if (tag.equals(UNIT_TAGS.STATUS)) 2096 { 2097 return cadData.getUnit(unitNum).getStatus(); 2098 } 2099 else if (tag.equals(UNIT_TAGS.OOS)) 2100 { 2101 return cadData.getUnit(unitNum).getOos(); 2102 } 2103 else if (tag.equals(UNIT_TAGS.TYPE)) 2104 { 2105 return cadData.getUnit(unitNum).getType(); 2106 } 2107 else if (tag.equals(UNIT_TAGS.CURR_LOC)) 2108 { 2109 return cadData.getUnit(unitNum).getCurrentLocation(); 2110 } 2111 else if (tag.equals(UNIT_TAGS.DESTINATION)) 2112 { 2113 return cadData.getUnit(unitNum).getDestination(); 2114 } 2115 else if (tag.equals(UNIT_TAGS.MISC_INFO)) 2116 { 2117 return cadData.getUnit(unitNum).getMisc(); 2118 } 2119 else if (tag.equals(UNIT_TAGS.STACK)) 2120 { 2121 return cadData.getUnit(unitNum).getStack(); 2122 } 2123 else if (tag.equals(UNIT_TAGS.AREA)) 2124 { 2125 return cadData.getUnit(unitNum).getArea(); 2126 } 2127 else if (tag.equals(UNIT_TAGS.OFFICER)) 2128 { 2129 return cadData.getUnit(unitNum).getOfficer(); 2130 } 2131 else if (tag.equals(UNIT_TAGS.BADGE_NUM)) 2132 { 2133 return cadData.getUnit(unitNum).getBadge(); 2134 } 2135 else if (tag.equals(UNIT_TAGS.TIMER)) 2136 { 2137 return cadData.getUnit(unitNum).getTimerInString(); 2138 } 2139 else if (tag.equals(UNIT_TAGS.OFFICE)) 2140 { 2141 return cadData.getUnit(unitNum).getOffice(); 2142 } 2143 else if (tag.equals(UNIT_TAGS.P)) 2144 { 2145 return cadData.getUnit(unitNum).getP(); 2146 } 2147 else if (tag.equals(UNIT_TAGS.AGY)) 2148 { 2149 return cadData.getUnit(unitNum).getAgy(); 2150 } 2151 else if (tag.equals(UNIT_TAGS.ALIAS)) 2152 { 2153 return cadData.getUnit(unitNum).getAlias(); 2154 } 2155 else 2156 { 2157 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataUnitValue"); 2143 // Fetch unit, given it's string representation 2144 Unit desiredUnit = cadData.getUnit(unitNum); 2145 // If it exists 2146 if (desiredUnit != null) 2147 { 2148 if (tag.equals(UNIT_TAGS.MASTER_INC_NUM)) 2149 { 2150 return desiredUnit.getMasterInc(); 2151 } 2152 else if (tag.equals(UNIT_TAGS.STATUS)) 2153 { 2154 return desiredUnit.getStatus(); 2155 } 2156 else if (tag.equals(UNIT_TAGS.OOS)) 2157 { 2158 return desiredUnit.getOos(); 2159 } 2160 else if (tag.equals(UNIT_TAGS.TYPE)) 2161 { 2162 return desiredUnit.getType(); 2163 } 2164 else if (tag.equals(UNIT_TAGS.CURR_LOC)) 2165 { 2166 return desiredUnit.getCurrentLocation(); 2167 } 2168 else if (tag.equals(UNIT_TAGS.DESTINATION)) 2169 { 2170 return desiredUnit.getDestination(); 2171 } 2172 else if (tag.equals(UNIT_TAGS.MISC_INFO)) 2173 { 2174 return desiredUnit.getMisc(); 2175 } 2176 else if (tag.equals(UNIT_TAGS.STACK)) 2177 { 2178 return desiredUnit.getStack(); 2179 } 2180 else if (tag.equals(UNIT_TAGS.AREA)) 2181 { 2182 return desiredUnit.getArea(); 2183 } 2184 else if (tag.equals(UNIT_TAGS.OFFICER)) 2185 { 2186 return desiredUnit.getOfficer(); 2187 } 2188 else if (tag.equals(UNIT_TAGS.BADGE_NUM)) 2189 { 2190 return desiredUnit.getBadge(); 2191 } 2192 else if (tag.equals(UNIT_TAGS.TIMER)) 2193 { 2194 return desiredUnit.getTimerInString(); 2195 } 2196 else if (tag.equals(UNIT_TAGS.OFFICE)) 2197 { 2198 return desiredUnit.getOffice(); 2199 } 2200 else if (tag.equals(UNIT_TAGS.P)) 2201 { 2202 return desiredUnit.getP(); 2203 } 2204 else if (tag.equals(UNIT_TAGS.AGY)) 2205 { 2206 return desiredUnit.getAgy(); 2207 } 2208 else if (tag.equals(UNIT_TAGS.ALIAS)) 2209 { 2210 return desiredUnit.getAlias(); 2211 } 2212 else 2213 { 2214 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataUnitValue"); 2215 } 2216 } 2217 else 2218 { 2219 coorLogger.logp(Level.INFO, "Coordinator", "getCadDataUnitValue", 2220 "Desired unit not found: " + unitNum 2221 + ". Proceeding with empty string value.", "Error"); 2222 return ""; 2158 2223 } 2159 2224 } -
trunk/src/tmcsim/client/CADClockDisplay.java
r33 r54 37 37 * between the CAD Client and the CAD Simulator. The CADClientModel object is 38 38 * instantiated and the CAD Client registers itself with the CAD Simulator. 39 * Finally, the CADCl ientView is initialized, the model-view and observer39 * Finally, the CADClockView is initialized, the model-view and observer 40 40 * relationships are established, and the view is shown.<br> 41 41 * <br> … … 61 61 */ 62 62 63 public class CADCl ientextends UnicastRemoteObject implements63 public class CADClockDisplay extends UnicastRemoteObject implements 64 64 CADClientInterface { 65 65 … … 96 96 private CADClientModel theClientScreenModel; 97 97 98 /** Instance of the CADCl ientView. */99 private CADCl ientView theClientScreenView;100 101 /** 102 * Instance of the CADCLientGUI Replaces CADCl ientView98 /** Instance of the CADClockView. */ 99 private CADClockView theClientScreenView; 100 101 /** 102 * Instance of the CADCLientGUI Replaces CADClockView 103 103 */ 104 104 private CADClientGUI theClientGUI; … … 131 131 * containing configuration data. 132 132 */ 133 public CADCl ient(String propertiesFile) throws SimulationException,133 public CADClockDisplay(String propertiesFile) throws SimulationException, 134 134 RemoteException { 135 135 if (!verifyProperties(propertiesFile)) … … 155 155 // Instantiate the CADScreenView and set up the model-view observer 156 156 // relationship. 157 theClientScreenView = new CADCl ientView(theClientScreenModel);157 theClientScreenView = new CADClockView(theClientScreenModel); 158 158 theClientScreenView.setVisible(false); 159 159 … … 163 163 // modify in parallel 164 164 // This is required to perform powerline commands on the data 165 theClientGUI = new CADClientGUI();165 // theClientGUI = new CADClientGUI(); 166 166 167 167 // Each screen of the UI should have a reference to either it's parent 168 168 // object or the main client 169 169 // This ensures they all have access to each other and the data model 170 theClientGUI.screen = new ScreenManager(theCoorInt);171 theClientGUI.login = new Login();172 theClientGUI.client = this;170 // theClientGUI.screen = new ScreenManager(theCoorInt); 171 // theClientGUI.login = new Login(); 172 // theClientGUI.client = this; 173 173 174 174 // setup keyboard settings for CAD Client 175 if (cadClientProp.getProperty(PROPERTIES.KEYBOARD_TYPE.name).trim()176 .equals("CAD")) {177 CADEnums.CAD_KEYS.setupCADKeyboard();178 }179 // STD180 else {181 CADEnums.CAD_KEYS.setupStandardKeyboard();182 }183 184 theClientScreenModel.addObserver(theClientScreenView);185 186 // Initialize the display187 if (cadClientProp.getProperty(PROPERTIES.DISPLAY_TYPE.name).equals(188 "FULL_SCREEN")) {189 190 theClientScreenView.addWindowListener(new WindowListener() {191 public void windowClosed(WindowEvent e) {192 }193 194 public void windowOpened(WindowEvent e) {195 }196 197 public void windowIconified(WindowEvent e) {198 }199 200 public void windowDeiconified(WindowEvent e) {201 }202 203 public void windowActivated(WindowEvent e) {204 }205 206 public void windowDeactivated(WindowEvent e) {207 }208 209 public void windowClosing(WindowEvent e) {210 211 try {212 theClientSocket.closeSocket();213 } catch (SimulationException se) {214 }215 216 System.exit(0);217 }218 });219 220 theClientScreenView.initWindow();221 theClientScreenView.setVisible(false);222 } else {223 JFrame cadFrame = new JFrame("CAD Client");224 cadFrame.add(theClientScreenView.initBox());225 cadFrame.setSize(800, 600);226 227 cadFrame.addWindowListener(new WindowListener() {228 public void windowClosed(WindowEvent e) {229 }230 231 public void windowOpened(WindowEvent e) {232 }233 234 public void windowIconified(WindowEvent e) {235 }236 237 public void windowDeiconified(WindowEvent e) {238 }239 240 public void windowActivated(WindowEvent e) {241 }242 243 public void windowDeactivated(WindowEvent e) {244 }245 246 public void windowClosing(WindowEvent e) {247 248 try {249 theClientSocket.closeSocket();250 } catch (SimulationException se) {251 }252 253 System.exit(0);254 }255 });256 257 cadFrame.setVisible(true);258 }259 260 // Create the CAD Client thread to run the CADClientModel Object.261 Thread clientThread = new Thread(theClientScreenModel);262 clientThread.start();175 // if (cadClientProp.getProperty(PROPERTIES.KEYBOARD_TYPE.name).trim() 176 // .equals("CAD")) { 177 // CADEnums.CAD_KEYS.setupCADKeyboard(); 178 // } 179 // // STD 180 // else { 181 // CADEnums.CAD_KEYS.setupStandardKeyboard(); 182 // } 183 // 184 // theClientScreenModel.addObserver(theClientScreenView); 185 // 186 // // Initialize the display 187 // if (cadClientProp.getProperty(PROPERTIES.DISPLAY_TYPE.name).equals( 188 // "FULL_SCREEN")) { 189 // 190 // theClientScreenView.addWindowListener(new WindowListener() { 191 // public void windowClosed(WindowEvent e) { 192 // } 193 // 194 // public void windowOpened(WindowEvent e) { 195 // } 196 // 197 // public void windowIconified(WindowEvent e) { 198 // } 199 // 200 // public void windowDeiconified(WindowEvent e) { 201 // } 202 // 203 // public void windowActivated(WindowEvent e) { 204 // } 205 // 206 // public void windowDeactivated(WindowEvent e) { 207 // } 208 // 209 // public void windowClosing(WindowEvent e) { 210 // 211 // try { 212 // theClientSocket.closeSocket(); 213 // } catch (SimulationException se) { 214 // } 215 // 216 // System.exit(0); 217 // } 218 // }); 219 // 220 // theClientScreenView.initWindow(); 221 // theClientScreenView.setVisible(false); 222 // } else { 223 // JFrame cadFrame = new JFrame("CAD Client"); 224 // cadFrame.add(theClientScreenView.initBox()); 225 // cadFrame.setSize(800, 600); 226 // 227 // cadFrame.addWindowListener(new WindowListener() { 228 // public void windowClosed(WindowEvent e) { 229 // } 230 // 231 // public void windowOpened(WindowEvent e) { 232 // } 233 // 234 // public void windowIconified(WindowEvent e) { 235 // } 236 // 237 // public void windowDeiconified(WindowEvent e) { 238 // } 239 // 240 // public void windowActivated(WindowEvent e) { 241 // } 242 // 243 // public void windowDeactivated(WindowEvent e) { 244 // } 245 // 246 // public void windowClosing(WindowEvent e) { 247 // 248 // try { 249 // theClientSocket.closeSocket(); 250 // } catch (SimulationException se) { 251 // } 252 // 253 // System.exit(0); 254 // } 255 // }); 256 // 257 // cadFrame.setVisible(true); 258 // } 259 // 260 // // Create the CAD Client thread to run the CADClientModel Object. 261 // Thread clientThread = new Thread(theClientScreenModel); 262 // clientThread.start(); 263 263 264 264 ensureProperShutdown(); … … 482 482 try { 483 483 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 484 new CADCl ient(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME);484 new CADClockDisplay(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 485 485 486 486 } catch (Exception e) { -
trunk/src/tmcsim/client/CADClockView.java
r37 r54 45 45 /** 46 46 * The CADClientView class is the view component to the CAD Client application. 47 * The CADSCreen is displayed with three separate view components: Command Line, 48 * Main Text Area, and Footer. User input is handled by the Command Line Pane. 49 * Any commands are sent to the model which are then transmitted to the 50 * CAD Simulator. The view keeps track of current CAD Screen Number and the 51 * current page being displayed on each screen. This allows for the screen 52 * refresh and cycle commands to return the screen to its previous page. 53 * 47 * 54 48 * This view class observers the CADClientModel, listening for updates 55 * from the CAD Simulator. Updates include new CADScreenModel objects notifying 56 * that a new screen is to be displayed. Other update data includes the current 57 * CAD time, number of routed messages, screen update map, and information messages. 58 * These are all displayed in the CAD Footer. 59 * 60 * @author Matthew Cechini (mcechini@calpoly.edu) 61 * @version $Date: 2009/04/20 17:58:27 $ $Revision: 1.7 $ 62 */ 49 * from the CAD Simulator. Updates includes the current 50 * CAD time */ 63 51 @SuppressWarnings("serial") 64 public class CADCl ientView extends JFrame implements KeyListener, Observer {52 public class CADClockView extends JFrame implements KeyListener, Observer { 65 53 66 54 /** Error Logger. */ … … 69 57 /** Reference to the CADClient model object. */ 70 58 private CADClientModel theModel = null; 71 72 /** View pane for the CAD Screen command line area. */ 73 private CADCommandLineView CADCommandLinePane = null; 74 75 /** View pane for the CAD Screen main area. */ 76 private CADMainView CADMainPane = null; 77 78 /** View pane for the CAD Screen footer area. */ 79 private CADFooterView CADFooterPane = null; 80 81 /** CAD Command Line Parser. */ 82 private CADCommandParser cmdParser; 83 84 /** Boolean flag to designate whether the shift key is being pressed. */ 85 private boolean shiftKeyPressed = false; 86 59 87 60 /** Current CAD Screen number. */ 88 61 private CADScreenNum currentScreenNum = null; 89 62 90 /** Map of CADScreen numbers and the current page displayed on that screen. */91 private TreeMap<CADScreenNum, Integer> pageLocationMap = null;92 93 /** Flag designating whether the screen's page location has been saved. */94 private boolean pageLocationSaved = false;95 63 96 64 /** … … 101 69 * The CAD position for this client terminal. 102 70 */ 103 public CADCl ientView(CADClientModel mod) {71 public CADClockView(CADClientModel mod) { 104 72 super("CAD Client"); 105 73 theModel = mod; 106 74 107 108 cmdParser = new CADCommandParser();109 110 //Build and initialize all initial screens to the first page.111 pageLocationMap = new TreeMap<CADScreenNum, Integer>();112 for(CADScreenNum screen : CADScreenNum.values())113 {114 pageLocationMap.put(screen, 1);115 }116 117 currentScreenNum = CADScreenNum.orderedList().get(0);118 119 buildPanes();120 buildPanels();121 122 cmdLineTextPane.addKeyListener(this);123 mainTextPane.addKeyListener(this);124 footerTextPane.addKeyListener(this);125 126 127 CADMainPane.addObserver(CADFooterPane);128 129 }130 131 /**132 * Build the command line, main, and footer text panes.133 */134 private void buildPanes() {135 136 cmdLineTextPane = new JTextPane();137 cmdLineTextPane.setSize(new Dimension(730, 50));138 cmdLineTextPane.setMinimumSize(new Dimension(730, 50));139 cmdLineTextPane.setMaximumSize(new Dimension(730, 50));140 cmdLineTextPane.setBorder(BorderFactory.createLineBorder(Color.black));141 142 cmdLineTextPane.setBackground(Color.black);143 cmdLineTextPane.setEditable(false);144 CADCommandLinePane = new CADCommandLineView(cmdLineTextPane);145 146 mainTextPane = new JTextPane();147 mainTextPane.setSize(new Dimension(730, 455));148 mainTextPane.setMaximumSize(new Dimension(730, 455));149 mainTextPane.setMinimumSize(new Dimension(730, 455));150 mainTextPane.setBorder(BorderFactory.createLineBorder(Color.black));151 mainTextPane.setBackground(Color.black);152 mainTextPane.setEditable(false);153 CADMainPane = new CADMainView(mainTextPane.getDocument());154 155 footerTextPane = new JTextPane();156 footerTextPane.setSize(new Dimension(730, 95));157 footerTextPane.setMaximumSize(new Dimension(730, 95));158 footerTextPane.setMinimumSize(new Dimension(730, 95));159 footerTextPane.setBorder(BorderFactory.createLineBorder(Color.black));160 footerTextPane.setBackground(Color.black);161 footerTextPane.setEditable(false);162 CADFooterPane = new CADFooterView(footerTextPane.getDocument());163 }164 165 166 /**167 * Build the command line, main, and footer panels.168 */169 private void buildPanels() {170 171 cmdLinePanel = new JPanel();172 cmdLinePanel.setSize(new Dimension(800, 50));173 cmdLinePanel.setMinimumSize(new Dimension(800, 50));174 cmdLinePanel.setMaximumSize(new Dimension(800, 50));175 cmdLinePanel.setBackground(Color.black);176 177 Box cmdLineBox = new Box(BoxLayout.Y_AXIS);178 cmdLineBox.add(Box.createHorizontalStrut(35));179 cmdLineBox.add(cmdLineTextPane);180 cmdLineBox.add(Box.createHorizontalStrut(35));181 182 cmdLinePanel.add(cmdLineBox);183 184 //***************************************************//185 186 mainPanel = new JPanel();187 mainPanel.setSize(new Dimension(800, 455));188 mainPanel.setMaximumSize(new Dimension(800, 455));189 mainPanel.setMinimumSize(new Dimension(800, 455));190 mainPanel.setBackground(Color.black);191 192 193 Box mainBox = new Box(BoxLayout.Y_AXIS);194 mainBox.add(Box.createHorizontalStrut(35));195 mainBox.add(mainTextPane);196 mainBox.add(Box.createHorizontalStrut(35));197 198 mainPanel.add(mainBox);199 200 //***************************************************//201 202 footerPanel = new JPanel();203 footerPanel.setSize(new Dimension(800, 95));204 footerPanel.setMaximumSize(new Dimension(800, 95));205 footerPanel.setMinimumSize(new Dimension(800, 95));206 footerPanel.setBackground(Color.black);207 208 Box footerBox = new Box(BoxLayout.Y_AXIS);209 footerBox.add(Box.createHorizontalStrut(35));210 footerBox.add(footerTextPane);211 footerBox.add(Box.createHorizontalStrut(35));212 213 footerPanel.add(footerBox);214 215 }216 217 218 /**219 * Method adds the three CAD Screen components (CommandLine, MainTextArea,220 * Footer) to this view class. The background is set to black, resized221 * to 800x600, and shown to the screen.222 */223 public void initWindow() {224 add(initBox());225 226 addKeyListener(this);227 setBackground(Color.black);228 setSize(new Dimension(800, 600));229 setUndecorated(true);230 setDefaultCloseOperation(EXIT_ON_CLOSE);231 //setVisible(true);232 233 }234 235 /**236 * Method contructs a box out of the three CAD Screen components:237 * CommandLine, MainTextArea, Footer. The Command Line panel is placed238 * above the main text area panel, which is above the footer panel.239 *240 * @return Box Box containing all three panels.241 */242 public Box initBox() {243 Box theBox = new Box(BoxLayout.Y_AXIS);244 theBox.add(cmdLinePanel);245 theBox.add(mainPanel);246 theBox.add(footerPanel);247 theBox.setBackground(Color.black);248 249 return theBox;250 }251 252 /**253 * This method is called by the implemented KeyListener whenever a key is pressed. The following254 * keystrokes are listened for in this method. Each keystroke pressed is referenced by the keycode255 * for the associated key. These key codes are defined in the CADProtocol class.256 *257 *258 *<table cellpadding="2" cellspacing="2" border="1"259 * style="text-align: left; width: 250px;">260 * <tbody>261 * <tr>262 * <th>CAD Protocol Command<br></th>263 * <th>Action Taken<br></th>264 * </tr>265 * <tr>266 * <td>SHIFT_KEY<br></td>267 * <td>Set shiftKeyPressed flag to true.<br></td>268 * </tr>269 * <tr>270 * <td>COMMAND_LINE_CLEAR<br></td>271 * <td>If the shift key is pressed, clear the current CAD Screen's command line.<br></td>272 * </tr>273 * <tr>274 * <td>SCREEN_CLEAR<br></td>275 * <td>If the shift key is pressed, transmit the SCREEN_CLEAR276 * command as a TERMINAL_FUNCTION to the CAD Simulator<br></td>277 * </tr>278 * </tbody>279 *</table>280 *281 * @param e KeyEvent282 */283 public void keyPressed(KeyEvent evt) {284 //System.out.println("keyPressed" + evt.getKeyCode());285 286 switch(CAD_KEYS.fromValue(CAD_KEYS.keyboard_type, evt.getKeyCode())) {287 case SHIFT_KEY:288 shiftKeyPressed = true;289 break;290 291 case COMMAND_LINE_CLEAR:292 if(shiftKeyPressed) {293 CADCommandLinePane.clearCommandLine();294 }295 break;296 297 case SCREEN_CLEAR:298 if(shiftKeyPressed) {299 try {300 Document cmdDoc = DocumentBuilderFactory.newInstance()301 .newDocumentBuilder().newDocument();302 Element cmdElem = cmdDoc.createElement(303 CAD_CLIENT_CMD.TERMINAL_FUNCTION.type);304 cmdElem.appendChild(cmdDoc.createTextNode(305 CAD_KEYS.keyboard_type + ":" +306 String.valueOf(evt.getKeyCode())));307 cmdDoc.appendChild(cmdElem);308 theModel.transmitCommand(cmdDoc);309 } catch (Exception e) {310 cadLogger.logp(Level.SEVERE, "CADClientView", "keyPressed()",311 "Exception in sending screen clear command.", e);312 }313 }314 break;315 }316 }317 318 /**319 * This method is called by the implemented KeyListener whenever a key is released. The following320 * keystrokes are listened for in this method. Each keystroke released is referenced by the keycode321 * for the associated key. These key codes are defined in the CADProtocol class.322 *323 *<table cellpadding="2" cellspacing="2" border="1"324 * style="text-align: left; width: 250px;">325 * <tbody>326 * <tr>327 * <th>CAD Protocol Command<br></th>328 * <th>Action Taken<br></th>329 * </tr>330 * <tr>331 * <td>SHIFT_KEY<br></td>332 * <td>Set the shiftKeyPressed flag to false.<br></td>333 * </tr>334 * <tr>335 * <td>CYCLE<br></td>336 * <td>Preserve the current page number to return the screen to the same location after337 * the cycle. Transmit the current command line to the CAD Simulator with a338 * SAVE_COMMAND_LINE message type. Transmit the CYCLE command as a339 * TERMINAL_FUNCTION to the CAD Simulator.<br></td>340 * </tr>341 * <tr>342 * <td>REFRESH<br></td>343 * <td>Preserve the current page number to return the screen to the same location after344 * the refresh. Transmit the current command line to the CAD Simulator with a345 * SAVE_COMMAND_LINE message type. Transmit the CYCLE command as a346 * TERMINAL_FUNCTION to the CAD Simulator.<br></td>347 * </tr>348 * <tr>349 * <td>PGDN</td>350 * <td>Notify the main pane object of the received page down command.<br></td>351 * </tr>352 * <tr>353 * <td>PGUP</td>354 * <td>Notify the main pane object of the received page up command.<br> </td>355 * </tr>356 * <tr>357 * <td>LEFT_ARROW</td>358 * <td>Notify the command line pane object of the received left arrow.<br> </td>359 * </tr>360 * <tr>361 * <td>UP_ARROW</td>362 * <td>Notify the command line pane object of the received up arrow.<br> </td>363 * </tr>364 * <tr>365 * <td>RIGHT_ARROW</td>366 * <td>Notify the command line pane object of the received right arrow.<br> </td>367 * </tr>368 * <tr>369 * <td>DOWN_ARROW</td>370 * <td>Notify the command line pane object of the received down arrow.<br> </td>371 * </tr>372 * <tr>373 * <td>COMMAND_LINE_TX<br> </td>374 * <td>Parse the current command line and create an XMLWriter with the375 * converted XML representation of the command line data.376 * Transmit the command line as a TERMINAL_CMD_LINE message to377 * the CAD Simulator. Clear the current CAD screen's command line.378 * If there is an error in parsing, show the corresponding error379 * message and clear the command line.<br></td>380 * </tr>381 * <tr>382 * <td>NEXT_QUEUE<br></td>383 * <td>Transmit the NEXT_QUEUE command as a TERMINAL_FUNCTION to the CAD Simulator.<br></td>384 * </tr>385 * <tr>386 * <td>DELETE_QUEUE<br></td>387 * <td>Transmit the DELETE_QUEUE command as a TERMINAL_FUNCTION to the CAD Simulator.<br></td>388 * </tr>389 * <tr>390 * <td>PREV_QUEUE<br></td>391 * <td>Transmit the PREV_QUEUE command as a TERMINAL_FUNCTION to the CAD Simulator.<br></td>392 * </tr>393 * <tr>394 * <td>BACKSPACE<br></td>395 * <td>Notify the command line pane of the received backspace command.<br></td>396 * </tr>397 * <tr>398 * <td>ENTER<br></td>399 * <td>Currently, do nothing<br></td>400 * </tr>401 * </tbody>402 *</table>403 *404 * @param e KeyEvent405 */406 public void keyReleased(KeyEvent evt) {407 //System.out.println("keyReleased" + evt.getKeyCode());408 409 switch(CAD_KEYS.fromValue(CAD_KEYS.keyboard_type, evt.getKeyCode())) {410 411 case SHIFT_KEY:412 shiftKeyPressed = false;413 break;414 415 case REFRESH:416 case CYCLE:417 418 pageLocationSaved = true;419 pageLocationMap.put(currentScreenNum, CADMainPane.getCurrentPage());420 421 try {422 Document cmdDoc = DocumentBuilderFactory.newInstance()423 .newDocumentBuilder().newDocument();424 Element cmdElem = cmdDoc.createElement(425 CAD_CLIENT_CMD.SAVE_COMMAND_LINE.type);426 cmdElem.appendChild(cmdDoc.createTextNode(427 CADCommandLinePane.getCommandLine()));428 cmdDoc.appendChild(cmdElem);429 theModel.transmitCommand(cmdDoc);430 431 cmdDoc = DocumentBuilderFactory.newInstance()432 .newDocumentBuilder().newDocument();433 cmdElem = cmdDoc.createElement(434 CAD_CLIENT_CMD.TERMINAL_FUNCTION.type);435 cmdElem.appendChild(cmdDoc.createTextNode(436 CAD_KEYS.keyboard_type + ":" +437 String.valueOf(evt.getKeyCode())));438 cmdDoc.appendChild(cmdElem);439 theModel.transmitCommand(cmdDoc);440 441 } catch (Exception e) {442 cadLogger.logp(Level.SEVERE, "CADClientView",443 "keyReleased()",444 "Exception in sending cycle command.", e);445 }446 break;447 448 case PGDN:449 450 CADMainPane.pageDown();451 break;452 453 case PGUP:454 455 CADMainPane.pageUp();456 break;457 458 case LEFT_ARROW:459 460 CADCommandLinePane.receiveArrow(ARROW.LEFT);461 break;462 463 case UP_ARROW:464 465 CADCommandLinePane.receiveArrow(ARROW.UP);466 break;467 468 case RIGHT_ARROW:469 470 CADCommandLinePane.receiveArrow(ARROW.RIGHT);471 break;472 473 case DOWN_ARROW:474 475 CADCommandLinePane.receiveArrow(ARROW.DOWN);476 break;477 478 case COMMAND_LINE_TX:479 480 try {481 Document cmdDoc = DocumentBuilderFactory.newInstance()482 .newDocumentBuilder().newDocument();483 Element cmdElem = cmdDoc.createElement(CAD_CLIENT_CMD.TERMINAL_CMD_LINE.type);484 485 cmdParser.parseCommand(cmdElem, CADCommandLinePane.getCommandLine());486 cmdDoc.appendChild(cmdElem);487 488 theModel.transmitCommand(cmdDoc);489 490 CADCommandLinePane.clearCommandLine();491 492 pageLocationSaved = false;493 }494 catch (Exception ex) {495 CADFooterPane.displayInfoMessage(CAD_ERROR.UNAUTH_CMD.message);496 CADCommandLinePane.clearCommandLine();497 }498 break;499 500 case PREV_QUEUE:501 case DELETE_QUEUE:502 case NEXT_QUEUE:503 try {504 Document cmdDoc = DocumentBuilderFactory.newInstance()505 .newDocumentBuilder().newDocument();506 Element cmdElem = cmdDoc.createElement(507 CAD_CLIENT_CMD.TERMINAL_FUNCTION.type);508 509 cmdElem.appendChild(cmdDoc.createTextNode(510 CAD_KEYS.keyboard_type + ":" +511 String.valueOf(evt.getKeyCode())));512 cmdDoc.appendChild(cmdElem);513 theModel.transmitCommand(cmdDoc);514 515 } catch (Exception e) {516 cadLogger.logp(Level.SEVERE, "CADClientView", "keyReleased()",517 "Exception in sending queue command.", e);518 }519 break;520 521 case BACKSPACE:522 CADCommandLinePane.backspace();523 break;524 case ENTER:525 break;526 default:527 }528 529 }530 531 /**532 * This method implements the necessary KeyListener functionality, and is533 * called whenever a key is typed. Only letters, numbers, and standard534 * keyboard symbols, whose ascii value is between 32(inclusive) and535 * 127(exclusive). Lower case character are in the range between 97 and536 * 122, inclusive. These characters are made uppercase by substracting537 * 32 from their ascii value. The ascii value for an upper case character538 * is 32 less than its lower case representation. The valid character539 * is then sent to the CADCommandLinePane.540 *541 * @param e KeyEvent received.542 */543 public void keyTyped(KeyEvent e) {544 //System.out.println("keyTyped" + e.getKeyCode());545 546 char key = e.getKeyChar();547 //if valid character548 if(key >= 32 && key < 127) {549 //lower case letter550 if(key >= 97 && key <= 122)551 key -= 32; //make uppercase552 553 CADCommandLinePane.receiveKeyPress(key);554 555 }556 75 } 557 76 … … 572 91 * </tr> 573 92 * <tr> 574 * <td>INCIDENT_INQUIRY<br></td>575 * <td>IncidentInquiryModel<br></td>576 * <td>Construct a new II_IncidentInquiry view pane from the model data.577 * Reset the observer relationship between the footer and main pane.578 * Update the page location map and update the views with the model data.579 * </td>580 * </tr>581 * <tr>582 * <td>INCIDENT_SUMMARY<br></td>583 * <td>IncidentSummaryModel<br></td>584 * <td>Construct a new SA_IncidentSummary view pane from the model data.585 * Reset the observer relationship between the footer and main pane.586 * Update the page location map and update the views with the model data.587 * </td>588 * </tr>589 * <tr>590 * <td>INCIDENT_BOARD<br></td>591 * <td>IncidentBoardModel<br></td>592 * <td>Construct a new IB_IncidentBoard view pane from the model data.593 * Reset the observer relationship between the footer and main pane.594 * Update the page location map and update the views with the model data.595 * </td>596 * </tr>597 * <tr>598 * <td>ROUTED_MESSAGE<br></td>599 * <td>RoutedMessageModel<br></td>600 * <td>Construct a new TO_RoutedMessage view pane from the model data.601 * Reset the observer relationship between the footer and main pane.602 * Update the page location map and update the views with the model data.603 * </td>604 * </tr>605 * <tr>606 * <td>BLANK_SCREEN<br></td>607 * <td>BlankScreenModel<br></td>608 * <td>Construct a new empty view pane.609 * Reset the observer relationship between the footer and main pane.610 * Update the page location map and update the views with the model data.611 * </td>612 * </tr>613 * <tr>614 * <td>SCREEN_UPDATE<br></td>615 * <td>TreeMap<CADScreenNum, Boolean><br></td>616 * <td>Update the footer pane with the new screen updates map.</td>617 * </tr>618 * <tr>619 93 * <td>TIME_UPDATE<br></td> 620 94 * <td>Time String<br></td> 621 95 * <td>Update the footer pane with the new time.</td> 622 * </tr>623 * <tr>624 * <td>ROUTED_MESSAGE_COUNT_UPDATE<br></td>625 * <td># Routed Messages<br></td>626 * <td>Update the footer pane with the new number of routed messages.</td>627 * </tr>628 * <tr>629 * <td>ROUTED_MESSAGE_UNREAD_UPDATE<br></td>630 * <td>Unread Routed Messages Boolean<br></td>631 * <td>Update the footer pane with the unread messages boolean.</td>632 * </tr>633 * <tr>634 * <td>CAD_INFO_MESSAGE<br></td>635 * <td>Information message<br></td>636 * <td>Update the footer pane with the new info message.</td>637 96 * </tr> 638 97 * </tbody> … … 654 113 655 114 switch(oMessage.type) { 656 case INCIDENT_INQUIRY:657 IncidentInquiryModel iiModel = (IncidentInquiryModel)oMessage.value;658 659 CADMainPane = new II_IncidentInquiry(iiModel, mainTextPane.getDocument());660 CADMainPane.addObserver(CADFooterPane);661 662 if(!pageLocationSaved)663 pageLocationMap.put(currentScreenNum, CADMainPane.getCurrentPage());664 665 updateViews(iiModel);666 667 break;668 669 case INCIDENT_SUMMARY:670 IncidentSummaryModel isModel = (IncidentSummaryModel)oMessage.value;671 672 CADMainPane = new SA_IncidentSummary(isModel, mainTextPane.getDocument());673 CADMainPane.addObserver(CADFooterPane);674 675 if(!pageLocationSaved)676 pageLocationMap.put(currentScreenNum, CADMainPane.getCurrentPage());677 678 updateViews(isModel);679 break;680 681 case INCIDENT_BOARD:682 IncidentBoardModel ibModel = (IncidentBoardModel)oMessage.value;683 684 CADMainPane = new IB_IncidentBoard(ibModel, mainTextPane.getDocument());685 CADMainPane.addObserver(CADFooterPane);686 687 if(!pageLocationSaved)688 pageLocationMap.put(currentScreenNum, CADMainPane.getCurrentPage());689 690 updateViews(ibModel);691 break;692 693 case ROUTED_MESSAGE:694 RoutedMessageModel rmModel = (RoutedMessageModel)oMessage.value;695 696 CADMainPane = new TO_RoutedMessage(rmModel, mainTextPane.getDocument());697 CADMainPane.addObserver(CADFooterPane);698 699 if(!pageLocationSaved)700 pageLocationMap.put(currentScreenNum, CADMainPane.getCurrentPage());701 702 updateViews(rmModel);703 break;704 705 case BLANK_SCREEN:706 BlankScreenModel bsModel = (BlankScreenModel)oMessage.value;707 708 CADMainPane = new CADMainView(mainTextPane.getDocument());709 CADMainPane.addObserver(CADFooterPane);710 711 if(!pageLocationSaved)712 pageLocationMap.put(currentScreenNum, CADMainPane.getCurrentPage());713 714 updateViews(bsModel);715 break;716 717 case SCREEN_UPDATE:718 CADFooterPane.updateStatus(CADScreenModel.updateStringToMap(719 (String)oMessage.value));720 break;721 722 115 case TIME_UPDATE: 723 CADFooterPane.updateTime((String)oMessage.value); 724 break; 725 726 case ROUTED_MESSAGE_COUNT_UPDATE: 727 CADFooterPane.updateRoutedMessageCount((Integer)oMessage.value); 728 break; 729 730 case ROUTED_MESSAGE_UNREAD_UPDATE: 731 CADFooterPane.updateUnreadMessages((Boolean)oMessage.value); 732 break; 733 734 case CAD_INFO_MESSAGE: 735 CADFooterPane.displayInfoMessage((String)oMessage.value); 116 System.out.println("CAD time is now" + (String)oMessage.value); 736 117 break; 737 118 } 738 119 } 120 121 @Override 122 public void keyTyped(KeyEvent e) 123 { 124 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 125 } 126 127 @Override 128 public void keyPressed(KeyEvent e) 129 { 130 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 131 } 132 133 @Override 134 public void keyReleased(KeyEvent e) 135 { 136 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 137 } 739 138 740 139 741 /**742 * Update the command line and footer pane with model743 * data. Then refresh all of the views to repaint the screen.744 *745 * @param model CADScreenModel shown in main Pane.746 */747 private void updateViews(CADScreenModel model) {748 749 currentScreenNum = model.getScreenNum();750 751 CADCommandLinePane.setCommandLine(model.commandLine);752 753 CADFooterPane.setCADScreenNum(model.getScreenNum());754 CADFooterPane.updateTime(CADScreenModel.theCADTime);755 CADFooterPane.updateDate(CADScreenModel.theCADDate);756 CADFooterPane.updateStatus(model.screenUpdateMap);757 CADFooterPane.updateRoutedMessageCount(model.numberRoutedMessages);758 CADFooterPane.updateUnreadMessages(model.unreadMessages);759 760 CADCommandLinePane.refreshView();761 CADMainPane.refreshView(pageLocationMap.get(currentScreenNum));762 CADFooterPane.refreshView();763 764 }765 766 /* SWING OBJECTS */767 768 private JTextPane cmdLineTextPane = null;769 private JTextPane mainTextPane = null;770 private JTextPane footerTextPane = null;771 772 private JPanel cmdLinePanel = null;773 private JPanel mainPanel = null;774 private JPanel footerPanel = null;775 776 140 777 141 }
Note: See TracChangeset
for help on using the changeset viewer.
