1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.test.vcl.client;
25 
26 import java.util.Properties;
27 import java.util.regex.Matcher;
28 import java.util.regex.Pattern;
29 
30 /**
31  * The exception during executing the remote method.
32  *
33  */
34 public class VclHookException extends RuntimeException {
35 	/**
36 	 *
37 	 */
38 	private static final long serialVersionUID = 1L;
39 
40 	/**
41 	 * The messages are from basic\source\app\svtmsg.src
42 	 */
43 	/***ERROR****/
44 	public static final int SVT_START = 22000;
45 
46 	public static final int S_GPF_ABORT									=( SVT_START +   0 );
47 	public static final int S_APP_SHUTDOWN								=( SVT_START +   1 );
48 	public static final int S_SID_EXECUTE_FAILED_NO_DISPATCHER			=( SVT_START +   2 );
49 	public static final int S_SID_EXECUTE_FAILED						=( SVT_START +   3 );
50 	public static final int S_UNO_PROPERTY_NITIALIZE_FAILED				=( SVT_START +   4 );
51 	public static final int S_RESETAPPLICATION_FAILED_COMPLEX			=( SVT_START +   5 );
52 	public static final int S_RESETAPPLICATION_FAILED_UNKNOWN			=( SVT_START +   6 );
53 	public static final int S_NO_ACTIVE_WINDOW							=( SVT_START +   7 );
54 	public static final int S_NO_DIALOG_IN_GETACTIVE					=( SVT_START +   8 );
55 	public static final int S_NO_POPUP									=( SVT_START +   9 );
56 	public static final int S_NO_SUBMENU								=( SVT_START +  10 );
57 	public static final int S_CONTROLTYPE_NOT_SUPPORTED					=( SVT_START +  11 );
58 	public static final int S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES	=( SVT_START +  12 );
59 	public static final int S_NO_MORE_FILES								=( SVT_START +  13 );
60 	public static final int S_UNKNOWN_METHOD							=( SVT_START +  14 );
61 	public static final int S_INVALID_PARAMETERS						=( SVT_START +  15 );
62 	public static final int S_POINTER_OUTSIDE_APPWIN					=( SVT_START +  16 );
63 	public static final int S_UNKNOWN_COMMAND							=( SVT_START +  17 );
64 	public static final int S_WIN_NOT_FOUND								=( SVT_START +  18 );
65 	public static final int S_WIN_INVISIBLE								=( SVT_START +  19 );
66 	public static final int S_WIN_DISABLED								=( SVT_START +  20 );
67 	public static final int S_NUMBER_TOO_BIG							=( SVT_START +  21 );
68 	public static final int S_NUMBER_TOO_SMALL							=( SVT_START +  22 );
69 	public static final int S_WINDOW_DISAPPEARED						=( SVT_START +  23 );
70 	public static final int S_ERROR_SAVING_IMAGE						=( SVT_START +  24 );
71 	public static final int S_INVALID_POSITION							=( SVT_START +  25 );
72 	public static final int S_SPLITWIN_NOT_FOUND						=( SVT_START +  26 );
73 	public static final int S_INTERNAL_ERROR							=( SVT_START +  27 );
74 	public static final int S_NO_STATUSBAR								=( SVT_START +  28 );
75 	public static final int S_ITEMS_INVISIBLE							=( SVT_START +  29 );
76 	public static final int S_TABPAGE_NOT_FOUND							=( SVT_START +  30 );
77 	public static final int S_TRISTATE_NOT_ALLOWED						=( SVT_START +  31 );
78 	public static final int S_ERROR_IN_SET_TEXT							=( SVT_START +  32 );
79 	public static final int S_ATTEMPT_TO_WRITE_READONLY					=( SVT_START +  33 );
80 	public static final int S_NO_SELECT_FALSE							=( SVT_START +  34 );
81 	public static final int S_ENTRY_NOT_FOUND							=( SVT_START +  35 );
82 	public static final int S_METHOD_FAILED								=( SVT_START +  36 );
83 	public static final int S_HELPID_ON_TOOLBOX_NOT_FOUND				=( SVT_START +  37 );
84 	public static final int S_BUTTON_DISABLED_ON_TOOLBOX				=( SVT_START +  38 );
85 	public static final int S_BUTTON_HIDDEN_ON_TOOLBOX					=( SVT_START +  39 );
86 	public static final int S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX		=( SVT_START +  40 );
87 	public static final int S_TEAROFF_FAILED							=( SVT_START +  41 );
88 	public static final int S_NO_SELECTED_ENTRY_DEPRECATED				=( SVT_START +  42 ); // Has to stay in for old res files
89 	public static final int S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED =( SVT_START +  43 );
90 	public static final int S_ALLOWED_ONLY_IN_FLOATING_MODE				=( SVT_START +  44 );
91 	public static final int S_ALLOWED_ONLY_IN_DOCKING_MODE				=( SVT_START +  45 );
92 	public static final int S_SIZE_NOT_CHANGEABLE						=( SVT_START +  46 );
93 	public static final int S_NO_OK_BUTTON								=( SVT_START +  47 );
94 	public static final int S_NO_CANCEL_BUTTON							=( SVT_START +  48 );
95 	public static final int S_NO_YES_BUTTON								=( SVT_START +  49 );
96 	public static final int S_NO_NO_BUTTON								=( SVT_START +  50 );
97 	public static final int S_NO_RETRY_BUTTON							=( SVT_START +  51 );
98 	public static final int S_NO_HELP_BUTTON							=( SVT_START +  52 );
99 	public static final int S_NO_DEFAULT_BUTTON							=( SVT_START +  53 );
100 	public static final int S_BUTTON_ID_NOT_THERE						=( SVT_START +  54 );
101 	public static final int S_BUTTONID_REQUIRED							=( SVT_START +  55 );
102 	public static final int S_UNKNOWN_TYPE								=( SVT_START +  56 );
103 	public static final int	S_UNPACKING_STORAGE_FAILED					=( SVT_START +  57 );
104 	public static final int	S_NO_LIST_BOX_BUTTON						=( SVT_START +  58 );
105 	public static final int S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER      =( SVT_START +  59 );
106 	public static final int S_UNO_URL_EXECUTE_FAILED_NO_FRAME           =( SVT_START +  60 );
107 	public static final int S_NO_MENU									=( SVT_START +  61 );
108 	public static final int S_NO_SELECTED_ENTRY 						=( SVT_START +  62 );
109 	public static final int S_UNO_URL_EXECUTE_FAILED_DISABLED           =( SVT_START +  63 );
110 	public static final int S_NO_SCROLLBAR                              =( SVT_START +  64 );
111 	public static final int S_NO_SAX_PARSER                             =( SVT_START +  65 );
112 	public static final int S_CANNOT_CREATE_DIRECTORY                   =( SVT_START +  66 );
113 	public static final int S_DIRECTORY_NOT_EMPTY                       =( SVT_START +  67 );
114 	public static final int S_DEPRECATED                                =( SVT_START +  68 );
115 	public static final int S_SIZE_BELOW_MINIMUM						=( SVT_START +  69 );
116 	public static final int S_CANNOT_FIND_FLOATING_WIN					=( SVT_START +  70 );
117 	public static final int S_NO_LIST_BOX_STRING                        =( SVT_START +  71 );
118 	public static final int S_SLOT_IN_EXECUTE                           =( SVT_START +  72 );
119 
120 	public static Properties MESSAGES = new Properties();
121 
122 	static {
MESSAGES.put(new Integer(S_GPF_ABORT), R)123 		MESSAGES.put(new Integer(S_GPF_ABORT), "Program aborted with GPF");
MESSAGES.put(new Integer(S_APP_SHUTDOWN), R)124 		MESSAGES.put(new Integer(S_APP_SHUTDOWN), "Application has been shut down");
MESSAGES.put(new Integer(S_SID_EXECUTE_FAILED_NO_DISPATCHER), R)125 		MESSAGES.put(new Integer(S_SID_EXECUTE_FAILED_NO_DISPATCHER), "Slot ID cannot be executed. No ActiveDispatcher");
MESSAGES.put(new Integer(S_SID_EXECUTE_FAILED), R)126 		MESSAGES.put(new Integer(S_SID_EXECUTE_FAILED), "Slot ID could not be executed");
MESSAGES.put(new Integer(S_UNO_PROPERTY_NITIALIZE_FAILED), R)127 		MESSAGES.put(new Integer(S_UNO_PROPERTY_NITIALIZE_FAILED), "UnoSlot: Properties could not be initialized");
MESSAGES.put(new Integer(S_RESETAPPLICATION_FAILED_COMPLEX), R)128 		MESSAGES.put(new Integer(S_RESETAPPLICATION_FAILED_COMPLEX),
129 				"ResetApplication failed: too complex");
MESSAGES.put(new Integer(S_RESETAPPLICATION_FAILED_UNKNOWN), R)130 		MESSAGES.put(new Integer(S_RESETAPPLICATION_FAILED_UNKNOWN),
131 				"ResetApplication failed: unknown window type");
MESSAGES.put(new Integer(S_NO_ACTIVE_WINDOW), R)132 		MESSAGES.put(new Integer(S_NO_ACTIVE_WINDOW),
133 				"No active window found (GetNextCloseWindow)");
MESSAGES.put(new Integer(S_NO_DIALOG_IN_GETACTIVE), R)134 		MESSAGES.put(new Integer(S_NO_DIALOG_IN_GETACTIVE),
135 				"GetActive does not return a dialog! Inform development");
MESSAGES.put(new Integer(S_NO_POPUP), R)136 		MESSAGES.put(new Integer(S_NO_POPUP), "Pop-up menu not open");
MESSAGES.put(new Integer(S_NO_SUBMENU), R)137 		MESSAGES.put(new Integer(S_NO_SUBMENU), "Submenu does not exist");
MESSAGES.put(new Integer(S_CONTROLTYPE_NOT_SUPPORTED), R)138 		MESSAGES.put(new Integer(S_CONTROLTYPE_NOT_SUPPORTED),
139 				"ControlType ($Arg1) is not supported");
MESSAGES.put(new Integer(S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES), R)140 		MESSAGES.put(new Integer(S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES),
141 				"Selection by attributes only possible for directories");
MESSAGES.put(new Integer(S_NO_MORE_FILES), R)142 		MESSAGES.put(new Integer(S_NO_MORE_FILES), "No more files");
MESSAGES.put(new Integer(S_UNKNOWN_METHOD), R)143 		MESSAGES.put(new Integer(S_UNKNOWN_METHOD),
144 				"Unknown method '($Arg1)' on ($Arg2)");
MESSAGES.put(new Integer(S_INVALID_PARAMETERS), R)145 		MESSAGES.put(new Integer(S_INVALID_PARAMETERS), "Invalid Parameters");
MESSAGES.put(new Integer(S_POINTER_OUTSIDE_APPWIN), R)146 		MESSAGES.put(new Integer(S_POINTER_OUTSIDE_APPWIN),
147 				"Pointer not inside application window at '($Arg1)'");
MESSAGES.put(new Integer(S_UNKNOWN_COMMAND), R)148 		MESSAGES.put(new Integer(S_UNKNOWN_COMMAND),
149 				"Unknown command '($Arg1)'");
MESSAGES.put(new Integer(S_WIN_NOT_FOUND), R)150 		MESSAGES.put(new Integer(S_WIN_NOT_FOUND), "($Arg1) could not be found");
MESSAGES.put(new Integer(S_WIN_INVISIBLE), R)151 		MESSAGES.put(new Integer(S_WIN_INVISIBLE), "($Arg1) is not visible");
MESSAGES.put(new Integer(S_WIN_DISABLED), R)152 		MESSAGES.put(new Integer(S_WIN_DISABLED), "($Arg1) could not be accessed. Disabled");
MESSAGES.put(new Integer(S_NUMBER_TOO_BIG), R)153 		MESSAGES.put(new Integer(S_NUMBER_TOO_BIG),
154 						"Entry number ($Arg2) is too large in ($Arg1). Max. allowed is ($Arg3)");
MESSAGES.put(new Integer(S_NUMBER_TOO_SMALL), R)155 		MESSAGES.put(new Integer(S_NUMBER_TOO_SMALL),
156 						"The entry number ($Arg2) is too small in ($Arg1). Min allowed is ($Arg3)");
MESSAGES.put(new Integer(S_WINDOW_DISAPPEARED), R)157 		MESSAGES.put(new Integer(S_WINDOW_DISAPPEARED), "Window disappeared in the meantime at ($Arg1)");
MESSAGES.put(new Integer(S_ERROR_SAVING_IMAGE), R)158 		MESSAGES.put(new Integer(S_ERROR_SAVING_IMAGE), "Error #($Arg1) when saving the image");
MESSAGES.put(new Integer(S_INVALID_POSITION), R)159 		MESSAGES.put(new Integer(S_INVALID_POSITION),
160 				"Invalid position at ($Arg1)");
MESSAGES.put(new Integer(S_SPLITWIN_NOT_FOUND), R)161 		MESSAGES.put(new Integer(S_SPLITWIN_NOT_FOUND),
162 				"SplitWindow not found at ($Arg1)");
163 		MESSAGES
put(new Integer(S_INTERNAL_ERROR), R)164 				.put(new Integer(S_INTERNAL_ERROR), "Internal error at ($Arg1)");
MESSAGES.put(new Integer(S_NO_STATUSBAR), R)165 		MESSAGES.put(new Integer(S_NO_STATUSBAR), "No status bar at ($Arg1)");
MESSAGES.put(new Integer(S_ITEMS_INVISIBLE), R)166 		MESSAGES.put(new Integer(S_ITEMS_INVISIBLE),
167 				"The items are hidden at ($Arg1)");
MESSAGES.put(new Integer(S_TABPAGE_NOT_FOUND), R)168 		MESSAGES.put(new Integer(S_TABPAGE_NOT_FOUND),
169 				"Tab page not found at ($Arg1)");
MESSAGES.put(new Integer(S_TRISTATE_NOT_ALLOWED), R)170 		MESSAGES.put(new Integer(S_TRISTATE_NOT_ALLOWED),
171 				"Tristate cannot be set at ($Arg1)");
MESSAGES.put(new Integer(S_ERROR_IN_SET_TEXT), R)172 		MESSAGES.put(new Integer(S_ERROR_IN_SET_TEXT),
173 				"Set text did not function");
MESSAGES.put(new Integer(S_ATTEMPT_TO_WRITE_READONLY), R)174 		MESSAGES.put(new Integer(S_ATTEMPT_TO_WRITE_READONLY),
175 				"Attempt to write on read-only ($Arg1)");
MESSAGES.put(new Integer(S_NO_SELECT_FALSE), R)176 		MESSAGES.put(new Integer(S_NO_SELECT_FALSE),
177 				"Select FALSE not allowed. Use MultiSelect at ($Arg1)");
MESSAGES.put(new Integer(S_ENTRY_NOT_FOUND), R)178 		MESSAGES.put(new Integer(S_ENTRY_NOT_FOUND),
179 				"\"($Arg2)\" entry at ($Arg1) not found");
MESSAGES.put(new Integer(S_METHOD_FAILED), R)180 		MESSAGES.put(new Integer(S_METHOD_FAILED),
181 				"($Arg1) of entry \"($Arg2)\" failed");
MESSAGES.put(new Integer(S_HELPID_ON_TOOLBOX_NOT_FOUND), R)182 		MESSAGES.put(new Integer(S_HELPID_ON_TOOLBOX_NOT_FOUND),
183 				"HelpID in ToolBox not found at ($Arg1)");
184 
MESSAGES.put(new Integer(S_BUTTON_DISABLED_ON_TOOLBOX), R)185 		MESSAGES.put(new Integer(S_BUTTON_DISABLED_ON_TOOLBOX),
186 				"The button is disabled in ToolBox at ($Arg1)");
187 
MESSAGES.put(new Integer(S_BUTTON_HIDDEN_ON_TOOLBOX), R)188 		MESSAGES.put(new Integer(S_BUTTON_HIDDEN_ON_TOOLBOX),
189 				"The button is hidden in ToolBox at ($Arg1)");
190 
MESSAGES.put(new Integer(S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX), R)191 		MESSAGES.put(new Integer(S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX),
192 				"Button cannot be made visible in ToolBox at ($Arg1)");
193 
MESSAGES.put(new Integer(S_TEAROFF_FAILED), R)194 		MESSAGES.put(new Integer(S_TEAROFF_FAILED),
195 				"TearOff failed in ToolBox at ($Arg1)");
196 
197 		// Has to stay in for old res files
MESSAGES.put(new Integer(S_NO_SELECTED_ENTRY_DEPRECATED), R)198 		MESSAGES.put(new Integer(S_NO_SELECTED_ENTRY_DEPRECATED),
199 				"No entry is selected in TreeListBox at ($Arg1)");
200 
MESSAGES.put(new Integer(S_NO_SELECTED_ENTRY), R)201 		MESSAGES.put(new Integer(S_NO_SELECTED_ENTRY),
202 				"No entry is selected in ($Arg2) at ($Arg1)");
203 
204 		MESSAGES
put(new Integer(S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED), R)205 				.put(new Integer(S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED),
206 						"Select/Deselect with MESSAGES.put(new Integer(not implemented at ($Arg1)");
207 
MESSAGES.put(new Integer(S_ALLOWED_ONLY_IN_FLOATING_MODE), R)208 		MESSAGES.put(new Integer(S_ALLOWED_ONLY_IN_FLOATING_MODE),
209 				"Method only allowed in floating mode at ($Arg1)");
210 
MESSAGES.put(new Integer(S_ALLOWED_ONLY_IN_DOCKING_MODE), R)211 		MESSAGES.put(new Integer(S_ALLOWED_ONLY_IN_DOCKING_MODE),
212 				"Method only allowed in docking mode at ($Arg1)");
213 
MESSAGES.put(new Integer(S_SIZE_NOT_CHANGEABLE), R)214 		MESSAGES.put(new Integer(S_SIZE_NOT_CHANGEABLE),
215 				"Size cannot be altered at ($Arg1)");
216 
MESSAGES.put(new Integer(S_NO_OK_BUTTON), R)217 		MESSAGES.put(new Integer(S_NO_OK_BUTTON),
218 				"There is no OK button at ($Arg1)");
219 
MESSAGES.put(new Integer(S_NO_CANCEL_BUTTON), R)220 		MESSAGES.put(new Integer(S_NO_CANCEL_BUTTON),
221 				"There is no Cancel button at ($Arg1)");
222 
MESSAGES.put(new Integer(S_NO_YES_BUTTON), R)223 		MESSAGES.put(new Integer(S_NO_YES_BUTTON),
224 				"There is no Yes button at ($Arg1)");
225 
MESSAGES.put(new Integer(S_NO_NO_BUTTON), R)226 		MESSAGES.put(new Integer(S_NO_NO_BUTTON),
227 				"There is no No button at ($Arg1)");
228 
MESSAGES.put(new Integer(S_NO_RETRY_BUTTON), R)229 		MESSAGES.put(new Integer(S_NO_RETRY_BUTTON),
230 				"There is no Repeat button at ($Arg1)");
231 
MESSAGES.put(new Integer(S_NO_HELP_BUTTON), R)232 		MESSAGES.put(new Integer(S_NO_HELP_BUTTON),
233 				"There is no Help button at ($Arg1)");
234 
MESSAGES.put(new Integer(S_NO_DEFAULT_BUTTON), R)235 		MESSAGES.put(new Integer(S_NO_DEFAULT_BUTTON),
236 				"There is no Default button defined at ($Arg1)");
237 
MESSAGES.put(new Integer(S_BUTTON_ID_NOT_THERE), R)238 		MESSAGES.put(new Integer(S_BUTTON_ID_NOT_THERE),
239 				"There is no button with ID ($Arg1) at ($Arg2)");
240 
MESSAGES.put(new Integer(S_BUTTONID_REQUIRED), R)241 		MESSAGES.put(new Integer(S_BUTTONID_REQUIRED),
242 				"A button ID needs to be given at ($Arg1)");
243 
244 		MESSAGES
put(new Integer(S_UNKNOWN_TYPE), R)245 				.put(new Integer(S_UNKNOWN_TYPE),
246 						"Unknown object type ($Arg1) from UId or method '($Arg2)' not supported");
247 
MESSAGES.put(new Integer(S_UNPACKING_STORAGE_FAILED), R)248 		MESSAGES.put(new Integer(S_UNPACKING_STORAGE_FAILED),
249 				"Unpacking storage \"($Arg1)\" to \"($Arg2)\" failed");
250 
MESSAGES.put(new Integer(S_NO_LIST_BOX_BUTTON), R)251 		MESSAGES.put(new Integer(S_NO_LIST_BOX_BUTTON),
252 				"ListBoxButton does not exist in ($Arg1)");
253 
254 		MESSAGES
put(new Integer(S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER), R)255 				.put(new Integer(S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER),
256 						"UNO URL \"($Arg1)\" could not be executed: No dispatcher was found.");
257 
258 		MESSAGES
put(new Integer(S_UNO_URL_EXECUTE_FAILED_NO_FRAME), R)259 				.put(new Integer(S_UNO_URL_EXECUTE_FAILED_NO_FRAME),
260 						"UNO URL \"($Arg1)\" could not be executed: No ActiveFrame on desktop.");
261 
MESSAGES.put(new Integer(S_NO_MENU), R)262 		MESSAGES.put(new Integer(S_NO_MENU), "There is no menu at ($Arg1)");
263 
MESSAGES.put(new Integer(S_UNO_URL_EXECUTE_FAILED_DISABLED), R)264 		MESSAGES.put(new Integer(S_UNO_URL_EXECUTE_FAILED_DISABLED),
265 				"UNO URL \"($Arg1)\" could not be run: Disabled");
266 
MESSAGES.put(new Integer(S_NO_SCROLLBAR), R)267 		MESSAGES.put(new Integer(S_NO_SCROLLBAR), "No scroll bar at ($Arg1)");
268 
269 		MESSAGES
put(new Integer(S_NO_SAX_PARSER), R)270 				.put(new Integer(S_NO_SAX_PARSER),
271 						"No SAX Parser when using ($Arg1). Initialize with 'SAXReadFile' first.");
272 
MESSAGES.put(new Integer(S_CANNOT_CREATE_DIRECTORY), R)273 		MESSAGES.put(new Integer(S_CANNOT_CREATE_DIRECTORY),
274 				"Cannot create Directory: \"($Arg1)\"");
275 
276 		MESSAGES
put(new Integer(S_DIRECTORY_NOT_EMPTY), R)277 				.put(new Integer(S_DIRECTORY_NOT_EMPTY),
278 						"Directory has to be Empty to unpack to. Directory: \"($Arg1)\"");
279 
MESSAGES.put(new Integer(S_DEPRECATED), R)280 		MESSAGES.put(new Integer(S_DEPRECATED),
281 				"Deprecated! Please change the script.");
282 
MESSAGES.put(new Integer(S_SIZE_BELOW_MINIMUM), R)283 		MESSAGES.put(new Integer(S_SIZE_BELOW_MINIMUM),
284 				"The Size is below the minimum. x=($Arg1) ,y=($Arg2)");
285 
286 		MESSAGES
put(new Integer(S_CANNOT_FIND_FLOATING_WIN), R)287 				.put(new Integer(S_CANNOT_FIND_FLOATING_WIN),
288 						"Cannot find FloatingWindow for floating DockingWindow at ($Arg1).");
289 
MESSAGES.put(new Integer(S_NO_LIST_BOX_STRING), R)290 		MESSAGES.put(new Integer(S_NO_LIST_BOX_STRING),
291 				"String does not exist in ($Arg1)");
292 
MESSAGES.put(new Integer(S_SLOT_IN_EXECUTE), R)293 		MESSAGES.put(new Integer(S_SLOT_IN_EXECUTE),
294 				"Another Slot is being executed already.");
295 
296 	}
297 
298 	private SmartId id = null;
299 
300 	private String message = null;
301 
302 	private int code = -1;
303 
304 	private Properties properties = new Properties();
305 
VclHookException(String message)306 	public VclHookException(String message) {
307 		this(null, message);
308 	}
309 
VclHookException(SmartId id, String message)310 	public VclHookException(SmartId id, String message) {
311 		this.id = id;
312 		this.message = message;
313 		if (id != null)
314 			parse();
315 	}
316 
317 
getMessage()318 	public String getMessage() {
319 		return this.message;
320 	}
321 
322 
parse()323 	private void parse() {
324 		if (message == null)
325 			return;
326 
327 		//Replace some key
328 		message = message.replaceAll("%Method=([^%]*)%", "$1");
329 		message = message.replaceAll("%RType=([^%]*)%", "$1");
330 		message = message.replaceAll("%RCommand=([^%]*)%", "$1");
331 		message = message.replaceAll("%UId=([^%]*)%", "$1");
332 
333 		// Parse String into Properties
334 		int start = -1, sep = -1, end =-1, pos = 0;
335 		String key = null;
336 		String value= null;
337 		while( (start = message.indexOf('%', pos)) != -1
338 				&& (sep = message.indexOf('=', start + 1)) != -1
339 				&& (end = message.indexOf('%', sep + 1)) != -1) {
340 			key = message.substring(start + 1, sep);
341 			value = message.substring(sep + 1, end);
342 			pos = end + 1;
343 			properties.put(key, value);
344 		}
345 
346 		String resId = properties.getProperty("ResId");
347 		if (resId == null)
348 			return;
349 		this.code = Integer.parseInt(resId);
350 		String originalMsg = (String) MESSAGES.get(this.code);
351 		if (originalMsg == null)
352 			return;
353 
354 		Pattern pattern = Pattern.compile("\\(\\$([^\\)]*)\\)");
355 		Matcher matcher = pattern.matcher(originalMsg);
356 		StringBuffer result = new StringBuffer();
357 		while (matcher.find()) {
358 			String rep = properties.getProperty(matcher.group(1), matcher.group()).replace("$", "\\$");
359 			matcher.appendReplacement(result, rep);
360 		}
361 		matcher.appendTail(result);
362 		message =  "ID:" + id + " - " + result.toString();
363 	}
364 
365 
getCode()366 	public int getCode() {
367 		return this.code;
368 	}
369 }
370