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.widgets;
25 
26 import org.openoffice.test.vcl.client.Constant;
27 import org.openoffice.test.vcl.client.VclHookException;
28 
29 /**
30  * VCL message box proxy.
31  *
32  */
33 public class VclMessageBox extends VclControl {
34 
35 	private String message = null;
36 
VclMessageBox(VclApp app)37 	public VclMessageBox(VclApp app) {
38 		super(app, Constant.UID_ACTIVE);
39 	}
40 
VclMessageBox(VclApp app, String id)41 	public VclMessageBox(VclApp app, String id) {
42 		super(app, id);
43 	}
44 
VclMessageBox(VclApp app, String id, String msg)45 	public VclMessageBox(VclApp app, String id, String msg) {
46 		super(app, id);
47 		this.message = msg;
48 	}
49 
50 
51 	/**
52 	 * Get the message on the message box
53 	 * @return
54 	 */
getMessage()55 	public String getMessage() {
56 		return (String) invoke(Constant.M_GetText);
57 	}
58 
exists()59 	public boolean exists() {
60 		try {
61 			boolean exists = super.exists();
62 			if (!exists)
63 				return false;
64 
65 			if (Constant.WINDOW_MESSBOX != getType())
66 				return false;
67 
68 			if (message != null) {
69 				String msg = getMessage();
70 				return msg.contains(message);
71 			}
72 
73 			return true;
74 		} catch (VclHookException e) {
75 			return false;
76 		}
77 	}
78 
79 	/**
80 	 * Click the yes button on the message box
81 	 *
82 	 */
yes()83 	public void yes(){
84 		invoke(Constant.M_Yes);
85 	}
86 
87 	/**
88 	 * Click the no button on the message box
89 	 *
90 	 */
no()91 	public void no(){
92 		invoke(Constant.M_No);
93 	}
94 
95 
96 	/**
97 	 * Closes a dialog by pressing the Cancel button.
98 	 */
cancel()99 	public void cancel() {
100 		invoke(Constant.M_Cancel);
101 	}
102 
103 	/**
104 	 * Closes a dialog with the Close button.
105 	 */
close()106 	public void close() {
107 		invoke(Constant.M_Close);
108 	}
109 
110 	/**
111 	 * Closes a dialog with the Default button.
112 	 */
doDefault()113 	public void doDefault()  {
114 		invoke(Constant.M_Default);
115 	}
116 
117 	/**
118 	 * Presses the Help button to open the help topic for the dialog.
119 	 *
120 	 */
help()121 	public void help()  {
122 		invoke(Constant.M_Help);
123 	}
124 
125 	/**
126 	 * Closes a dialog with the OK button.
127 	 */
ok()128 	public void ok()  {
129 		invoke(Constant.M_OK);
130 	}
131 
132 
133 	/**
134 	 * Closes a dialog with the OK button.
135 	 */
repeat()136 	public void repeat()  {
137 		invoke(Constant.M_Repeat);
138 	}
139 
140 	/**
141 	 * Get the check box text if it exists
142 	 *
143 	 * @return the check box text
144 	 */
getCheckBoxText()145 	public String getCheckBoxText() {
146 		return (String) invoke(Constant.M_GetCheckBoxText);
147 	}
148 
149 	/**
150 	 * Get the status of check box on the message box
151 	 * @return
152 	 */
isChecked()153 	public boolean isChecked() {
154 		return (Boolean) invoke(Constant.M_IsChecked);
155 	}
156 
157 	/**
158 	 * Check the check box on the message box
159 	 *
160 	 */
check()161 	public void check() {
162 		invoke(Constant.M_Check);
163 	}
164 
165 	/**
166 	 * Uncheck the check box on the message box
167 	 *
168 	 */
uncheck()169 	public void uncheck() {
170 		invoke(Constant.M_UnCheck);
171 	}
172 
173 }
174