1 #include "CallScilabBridge.hxx"
2 /* Generated by GIWS (version 2.0.2) with command:
3 giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/CallScilabBridge.giws.xml
4 */
5 /*
6 
7 This is generated code.
8 
9 This software is a computer program whose purpose is to hide the complexity
10 of accessing Java objects/methods from C++ code.
11 
12 This software is governed by the CeCILL-B license under French law and
13 abiding by the rules of distribution of free software.  You can  use,
14 modify and/ or redistribute the software under the terms of the CeCILL-B
15 license as circulated by CEA, CNRS and INRIA at the following URL
16 "http://www.cecill.info".
17 
18 As a counterpart to the access to the source code and  rights to copy,
19 modify and redistribute granted by the license, users are provided only
20 with a limited warranty  and the software's author,  the holder of the
21 economic rights,  and the successive licensors  have only  limited
22 liability.
23 
24 In this respect, the user's attention is drawn to the risks associated
25 with loading,  using,  modifying and/or developing or reproducing the
26 software by the user in light of its specific status of free software,
27 that may mean  that it is complicated to manipulate,  and  that  also
28 therefore means  that it is reserved for developers  and  experienced
29 professionals having in-depth computer knowledge. Users are therefore
30 encouraged to load and test the software's suitability as regards their
31 requirements in conditions enabling the security of their systems and/or
32 data to be ensured and,  more generally, to use and operate it in the
33 same conditions as regards security.
34 
35 The fact that you are presently reading this means that you have had
36 knowledge of the CeCILL-B license and that you accept its terms.
37 */
38 
39 namespace org_scilab_modules_gui_bridge {
40 
41                 // Static declarations (if any)
42 
43 // Returns the current env
44 
getCurrentEnv()45 JNIEnv * CallScilabBridge::getCurrentEnv() {
46 JNIEnv * curEnv = NULL;
47 jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
48 if (res != JNI_OK) {
49 throw GiwsException::JniException(getCurrentEnv());
50 }
51 return curEnv;
52 }
53 // Destructor
54 
~CallScilabBridge()55 CallScilabBridge::~CallScilabBridge() {
56 JNIEnv * curEnv = NULL;
57 this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
58 curEnv->DeleteGlobalRef(this->instance);
59 curEnv->DeleteGlobalRef(this->instanceClass);
60 curEnv->DeleteGlobalRef(this->stringArrayClass);}
61 // Constructors
CallScilabBridge(JavaVM * jvm_)62 CallScilabBridge::CallScilabBridge(JavaVM * jvm_) {
63 jmethodID constructObject = NULL ;
64 jobject localInstance ;
65 jclass localClass ;
66 
67 const std::string construct="<init>";
68 const std::string param="()V";
69 jvm=jvm_;
70 
71 JNIEnv * curEnv = getCurrentEnv();
72 
73 localClass = curEnv->FindClass( this->className().c_str() ) ;
74 if (localClass == NULL) {
75   throw GiwsException::JniClassNotFoundException(curEnv, this->className());
76 }
77 
78 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
79 
80 /* localClass is not needed anymore */
81 curEnv->DeleteLocalRef(localClass);
82 
83 if (this->instanceClass == NULL) {
84 throw GiwsException::JniObjectCreationException(curEnv, this->className());
85 }
86 
87 
88 constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
89 if(constructObject == NULL){
90 throw GiwsException::JniObjectCreationException(curEnv, this->className());
91 }
92 
93 localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
94 if(localInstance == NULL){
95 throw GiwsException::JniObjectCreationException(curEnv, this->className());
96 }
97 
98 this->instance = curEnv->NewGlobalRef(localInstance) ;
99 if(this->instance == NULL){
100 throw GiwsException::JniObjectCreationException(curEnv, this->className());
101 }
102 /* localInstance not needed anymore */
103 curEnv->DeleteLocalRef(localInstance);
104 
105                 /* Methods ID set to NULL */
106 voidsetMenuEnabledjintintjstringjava_lang_StringjbooleanbooleanID=NULL;
107 voidsetSubMenuEnabledjintintjstringjava_lang_StringjintintjbooleanbooleanID=NULL;
108 voidremoveMenujintintjstringjava_lang_StringID=NULL;
109 jstringdisplayAndWaitContextMenujintintID=NULL;
110 jintnewMessageBoxID=NULL;
111 voidsetMessageBoxTitlejintintjstringjava_lang_StringID=NULL;
112 voidsetMessageBoxMessagejintintjstringjava_lang_StringID=NULL;
113 voidsetMessageBoxMessagejintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
114 voidmessageBoxDisplayAndWaitjintintID=NULL;
115 jintgetMessageBoxSelectedButtonjintintID=NULL;
116 voidsetMessageBoxDefaultSelectedButtonsjintintjintArray_intintID=NULL;
117 jintArray_getMessageBoxUserSelectedButtonsjintintID=NULL;
118 voidsetMessageBoxButtonsLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
119 voidsetMessageBoxInitialValuejintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
120 jobjectArray_getMessageBoxValuejintintID=NULL;
121 jintgetMessageBoxValueSizejintintID=NULL;
122 voidsetMessageBoxListBoxItemsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
123 jintgetMessageBoxSelectedItemjintintID=NULL;
124 voidsetMessageBoxLineLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
125 voidsetMessageBoxColumnLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
126 voidsetMessageBoxDefaultInputjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
127 voidsetMessageBoxModaljintintjbooleanbooleanID=NULL;
128 voidsetMessageBoxIconjintintjstringjava_lang_StringID=NULL;
129 voidlaunchHelpBrowserjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_StringID=NULL;
130 voidsearchKeywordjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringjbooleanbooleanID=NULL;
131 jintnewExportFileChooserjintintID=NULL;
132 jintnewFontChooserID=NULL;
133 voidfontChooserDisplayAndWaitjintintID=NULL;
134 voidsetFontChooserFontNamejintintjstringjava_lang_StringID=NULL;
135 voidsetFontChooserFontSizejintintjintintID=NULL;
136 voidsetFontChooserBoldjintintjbooleanbooleanID=NULL;
137 voidsetFontChooserItalicjintintjbooleanbooleanID=NULL;
138 jstringgetFontChooserFontNamejintintID=NULL;
139 jintgetFontChooserFontSizejintintID=NULL;
140 jbooleangetFontChooserBoldjintintID=NULL;
141 jbooleangetFontChooserItalicjintintID=NULL;
142 jintnewColorChooserID=NULL;
143 voidcolorChooserDisplayAndWaitjintintID=NULL;
144 voidsetColorChooserDefaultColorjintintjintArray_intintID=NULL;
145 jintArray_getColorChooserSelectedColorjintintID=NULL;
146 voidsetColorChooserTitlejintintjstringjava_lang_StringID=NULL;
147 jstringgetClipboardContentsID=NULL;
148 voidpasteClipboardIntoConsoleID=NULL;
149 voidcopyConsoleSelectionID=NULL;
150 voidemptyClipboardID=NULL;
151 voidsetClipboardContentsjstringjava_lang_StringID=NULL;
152 voidcopyFigureToClipBoardjintintID=NULL;
153 jintgetScreenResolutionID=NULL;
154 jdoublegetScreenWidthID=NULL;
155 jdoublegetScreenHeightID=NULL;
156 jintgetScreenDepthID=NULL;
157 jbooleanprintFigurejintintjbooleanbooleanjbooleanbooleanID=NULL;
158 jbooleanprintFilejstringjava_lang_StringID=NULL;
159 jbooleanprintStringjstringjava_lang_Stringjstringjava_lang_StringID=NULL;
160 jbooleanpageSetupID=NULL;
161 voidrequestFocusjintintID=NULL;
162 voidraiseWindowjintintID=NULL;
163 voiduseCanvasForDisplayjbooleanbooleanID=NULL;
164 jbooleanuseCanvasForDisplayID=NULL;
165 voidscilabAboutBoxID=NULL;
166 voidfireClosingFinishedjintintID=NULL;
167 voidregisterSwingViewID=NULL;
168 
169 
170 }
171 
CallScilabBridge(JavaVM * jvm_,jobject JObj)172 CallScilabBridge::CallScilabBridge(JavaVM * jvm_, jobject JObj) {
173         jvm=jvm_;
174 
175         JNIEnv * curEnv = getCurrentEnv();
176 
177 jclass localClass = curEnv->GetObjectClass(JObj);
178         this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
179         curEnv->DeleteLocalRef(localClass);
180 
181         if (this->instanceClass == NULL) {
182 throw GiwsException::JniObjectCreationException(curEnv, this->className());
183         }
184 
185         this->instance = curEnv->NewGlobalRef(JObj) ;
186         if(this->instance == NULL){
187 throw GiwsException::JniObjectCreationException(curEnv, this->className());
188         }
189         /* Methods ID set to NULL */
190         voidsetMenuEnabledjintintjstringjava_lang_StringjbooleanbooleanID=NULL;
191 voidsetSubMenuEnabledjintintjstringjava_lang_StringjintintjbooleanbooleanID=NULL;
192 voidremoveMenujintintjstringjava_lang_StringID=NULL;
193 jstringdisplayAndWaitContextMenujintintID=NULL;
194 jintnewMessageBoxID=NULL;
195 voidsetMessageBoxTitlejintintjstringjava_lang_StringID=NULL;
196 voidsetMessageBoxMessagejintintjstringjava_lang_StringID=NULL;
197 voidsetMessageBoxMessagejintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
198 voidmessageBoxDisplayAndWaitjintintID=NULL;
199 jintgetMessageBoxSelectedButtonjintintID=NULL;
200 voidsetMessageBoxDefaultSelectedButtonsjintintjintArray_intintID=NULL;
201 jintArray_getMessageBoxUserSelectedButtonsjintintID=NULL;
202 voidsetMessageBoxButtonsLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
203 voidsetMessageBoxInitialValuejintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
204 jobjectArray_getMessageBoxValuejintintID=NULL;
205 jintgetMessageBoxValueSizejintintID=NULL;
206 voidsetMessageBoxListBoxItemsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
207 jintgetMessageBoxSelectedItemjintintID=NULL;
208 voidsetMessageBoxLineLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
209 voidsetMessageBoxColumnLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
210 voidsetMessageBoxDefaultInputjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
211 voidsetMessageBoxModaljintintjbooleanbooleanID=NULL;
212 voidsetMessageBoxIconjintintjstringjava_lang_StringID=NULL;
213 voidlaunchHelpBrowserjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_StringID=NULL;
214 voidsearchKeywordjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringjbooleanbooleanID=NULL;
215 jintnewExportFileChooserjintintID=NULL;
216 jintnewFontChooserID=NULL;
217 voidfontChooserDisplayAndWaitjintintID=NULL;
218 voidsetFontChooserFontNamejintintjstringjava_lang_StringID=NULL;
219 voidsetFontChooserFontSizejintintjintintID=NULL;
220 voidsetFontChooserBoldjintintjbooleanbooleanID=NULL;
221 voidsetFontChooserItalicjintintjbooleanbooleanID=NULL;
222 jstringgetFontChooserFontNamejintintID=NULL;
223 jintgetFontChooserFontSizejintintID=NULL;
224 jbooleangetFontChooserBoldjintintID=NULL;
225 jbooleangetFontChooserItalicjintintID=NULL;
226 jintnewColorChooserID=NULL;
227 voidcolorChooserDisplayAndWaitjintintID=NULL;
228 voidsetColorChooserDefaultColorjintintjintArray_intintID=NULL;
229 jintArray_getColorChooserSelectedColorjintintID=NULL;
230 voidsetColorChooserTitlejintintjstringjava_lang_StringID=NULL;
231 jstringgetClipboardContentsID=NULL;
232 voidpasteClipboardIntoConsoleID=NULL;
233 voidcopyConsoleSelectionID=NULL;
234 voidemptyClipboardID=NULL;
235 voidsetClipboardContentsjstringjava_lang_StringID=NULL;
236 voidcopyFigureToClipBoardjintintID=NULL;
237 jintgetScreenResolutionID=NULL;
238 jdoublegetScreenWidthID=NULL;
239 jdoublegetScreenHeightID=NULL;
240 jintgetScreenDepthID=NULL;
241 jbooleanprintFigurejintintjbooleanbooleanjbooleanbooleanID=NULL;
242 jbooleanprintFilejstringjava_lang_StringID=NULL;
243 jbooleanprintStringjstringjava_lang_Stringjstringjava_lang_StringID=NULL;
244 jbooleanpageSetupID=NULL;
245 voidrequestFocusjintintID=NULL;
246 voidraiseWindowjintintID=NULL;
247 voiduseCanvasForDisplayjbooleanbooleanID=NULL;
248 jbooleanuseCanvasForDisplayID=NULL;
249 voidscilabAboutBoxID=NULL;
250 voidfireClosingFinishedjintintID=NULL;
251 voidregisterSwingViewID=NULL;
252 
253 
254 }
255 
256 // Generic methods
257 
synchronize()258 void CallScilabBridge::synchronize() {
259 if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
260 throw GiwsException::JniMonitorException(getCurrentEnv(), "CallScilabBridge");
261 }
262 }
263 
endSynchronize()264 void CallScilabBridge::endSynchronize() {
265 if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
266 throw GiwsException::JniMonitorException(getCurrentEnv(), "CallScilabBridge");
267 }
268 }
269 // Method(s)
270 
setMenuEnabled(JavaVM * jvm_,int parentUID,char const * menuName,bool status)271 void CallScilabBridge::setMenuEnabled (JavaVM * jvm_, int parentUID, char const* menuName, bool status){
272 
273 JNIEnv * curEnv = NULL;
274 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
275 jclass cls = initClass(curEnv);
276 if ( cls == NULL) {
277 throw GiwsException::JniCallMethodException(curEnv);
278 }
279 
280 static jmethodID voidsetMenuEnabledjintintjstringjava_lang_StringjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "setMenuEnabled", "(ILjava/lang/String;Z)V" ) ;
281 if (voidsetMenuEnabledjintintjstringjava_lang_StringjbooleanbooleanID == NULL) {
282 throw GiwsException::JniMethodNotFoundException(curEnv, "setMenuEnabled");
283 }
284 
285 jstring menuName_ = curEnv->NewStringUTF( menuName );
286 if (menuName != NULL && menuName_ == NULL)
287 {
288 throw GiwsException::JniBadAllocException(curEnv);
289 }
290 
291 
292 jboolean status_ = (static_cast<bool>(status) ? JNI_TRUE : JNI_FALSE);
293 
294                          curEnv->CallStaticVoidMethod(cls, voidsetMenuEnabledjintintjstringjava_lang_StringjbooleanbooleanID ,parentUID, menuName_, status_);
295                         curEnv->DeleteLocalRef(menuName_);
296 if (curEnv->ExceptionCheck()) {
297 throw GiwsException::JniCallMethodException(curEnv);
298 }
299 }
300 
setSubMenuEnabled(JavaVM * jvm_,int parentUID,char const * menuName,int position,bool status)301 void CallScilabBridge::setSubMenuEnabled (JavaVM * jvm_, int parentUID, char const* menuName, int position, bool status){
302 
303 JNIEnv * curEnv = NULL;
304 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
305 jclass cls = initClass(curEnv);
306 if ( cls == NULL) {
307 throw GiwsException::JniCallMethodException(curEnv);
308 }
309 
310 static jmethodID voidsetSubMenuEnabledjintintjstringjava_lang_StringjintintjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "setSubMenuEnabled", "(ILjava/lang/String;IZ)V" ) ;
311 if (voidsetSubMenuEnabledjintintjstringjava_lang_StringjintintjbooleanbooleanID == NULL) {
312 throw GiwsException::JniMethodNotFoundException(curEnv, "setSubMenuEnabled");
313 }
314 
315 jstring menuName_ = curEnv->NewStringUTF( menuName );
316 if (menuName != NULL && menuName_ == NULL)
317 {
318 throw GiwsException::JniBadAllocException(curEnv);
319 }
320 
321 
322 jboolean status_ = (static_cast<bool>(status) ? JNI_TRUE : JNI_FALSE);
323 
324                          curEnv->CallStaticVoidMethod(cls, voidsetSubMenuEnabledjintintjstringjava_lang_StringjintintjbooleanbooleanID ,parentUID, menuName_, position, status_);
325                         curEnv->DeleteLocalRef(menuName_);
326 if (curEnv->ExceptionCheck()) {
327 throw GiwsException::JniCallMethodException(curEnv);
328 }
329 }
330 
removeMenu(JavaVM * jvm_,int parentUID,char const * menuName)331 void CallScilabBridge::removeMenu (JavaVM * jvm_, int parentUID, char const* menuName){
332 
333 JNIEnv * curEnv = NULL;
334 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
335 jclass cls = initClass(curEnv);
336 if ( cls == NULL) {
337 throw GiwsException::JniCallMethodException(curEnv);
338 }
339 
340 static jmethodID voidremoveMenujintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "removeMenu", "(ILjava/lang/String;)V" ) ;
341 if (voidremoveMenujintintjstringjava_lang_StringID == NULL) {
342 throw GiwsException::JniMethodNotFoundException(curEnv, "removeMenu");
343 }
344 
345 jstring menuName_ = curEnv->NewStringUTF( menuName );
346 if (menuName != NULL && menuName_ == NULL)
347 {
348 throw GiwsException::JniBadAllocException(curEnv);
349 }
350 
351 
352                          curEnv->CallStaticVoidMethod(cls, voidremoveMenujintintjstringjava_lang_StringID ,parentUID, menuName_);
353                         curEnv->DeleteLocalRef(menuName_);
354 if (curEnv->ExceptionCheck()) {
355 throw GiwsException::JniCallMethodException(curEnv);
356 }
357 }
358 
displayAndWaitContextMenu(JavaVM * jvm_,int UID)359 char* CallScilabBridge::displayAndWaitContextMenu (JavaVM * jvm_, int UID){
360 
361 JNIEnv * curEnv = NULL;
362 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
363 jclass cls = initClass(curEnv);
364 if ( cls == NULL) {
365 throw GiwsException::JniCallMethodException(curEnv);
366 }
367 
368 static jmethodID jstringdisplayAndWaitContextMenujintintID = curEnv->GetStaticMethodID(cls, "displayAndWaitContextMenu", "(I)Ljava/lang/String;" ) ;
369 if (jstringdisplayAndWaitContextMenujintintID == NULL) {
370 throw GiwsException::JniMethodNotFoundException(curEnv, "displayAndWaitContextMenu");
371 }
372 
373                         jstring res =  static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringdisplayAndWaitContextMenujintintID ,UID));
374                         if (curEnv->ExceptionCheck()) {
375 throw GiwsException::JniCallMethodException(curEnv);
376 }if (res != NULL) {
377 
378 const char *tempString = curEnv->GetStringUTFChars(res, 0);
379 char * myStringBuffer = new char[strlen(tempString) + 1];
380 strcpy(myStringBuffer, tempString);
381 curEnv->ReleaseStringUTFChars(res, tempString);
382 curEnv->DeleteLocalRef(res);
383 if (curEnv->ExceptionCheck()) {
384 delete[] myStringBuffer;
385                                 throw GiwsException::JniCallMethodException(curEnv);
386 }
387 return myStringBuffer;
388  } else {
389 curEnv->DeleteLocalRef(res);
390 return NULL;
391 }
392 }
393 
newMessageBox(JavaVM * jvm_)394 int CallScilabBridge::newMessageBox (JavaVM * jvm_){
395 
396 JNIEnv * curEnv = NULL;
397 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
398 jclass cls = initClass(curEnv);
399 if ( cls == NULL) {
400 throw GiwsException::JniCallMethodException(curEnv);
401 }
402 
403 static jmethodID jintnewMessageBoxID = curEnv->GetStaticMethodID(cls, "newMessageBox", "()I" ) ;
404 if (jintnewMessageBoxID == NULL) {
405 throw GiwsException::JniMethodNotFoundException(curEnv, "newMessageBox");
406 }
407 
408                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewMessageBoxID ));
409                         if (curEnv->ExceptionCheck()) {
410 throw GiwsException::JniCallMethodException(curEnv);
411 }
412 return res;
413 
414 }
415 
setMessageBoxTitle(JavaVM * jvm_,int id,char const * title)416 void CallScilabBridge::setMessageBoxTitle (JavaVM * jvm_, int id, char const* title){
417 
418 JNIEnv * curEnv = NULL;
419 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
420 jclass cls = initClass(curEnv);
421 if ( cls == NULL) {
422 throw GiwsException::JniCallMethodException(curEnv);
423 }
424 
425 static jmethodID voidsetMessageBoxTitlejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxTitle", "(ILjava/lang/String;)V" ) ;
426 if (voidsetMessageBoxTitlejintintjstringjava_lang_StringID == NULL) {
427 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxTitle");
428 }
429 
430 jstring title_ = curEnv->NewStringUTF( title );
431 if (title != NULL && title_ == NULL)
432 {
433 throw GiwsException::JniBadAllocException(curEnv);
434 }
435 
436 
437                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxTitlejintintjstringjava_lang_StringID ,id, title_);
438                         curEnv->DeleteLocalRef(title_);
439 if (curEnv->ExceptionCheck()) {
440 throw GiwsException::JniCallMethodException(curEnv);
441 }
442 }
443 
setMessageBoxMessage(JavaVM * jvm_,int id,char const * message)444 void CallScilabBridge::setMessageBoxMessage (JavaVM * jvm_, int id, char const* message){
445 
446 JNIEnv * curEnv = NULL;
447 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
448 jclass cls = initClass(curEnv);
449 if ( cls == NULL) {
450 throw GiwsException::JniCallMethodException(curEnv);
451 }
452 
453 static jmethodID voidsetMessageBoxMessagejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxMessage", "(ILjava/lang/String;)V" ) ;
454 if (voidsetMessageBoxMessagejintintjstringjava_lang_StringID == NULL) {
455 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxMessage");
456 }
457 
458 jstring message_ = curEnv->NewStringUTF( message );
459 if (message != NULL && message_ == NULL)
460 {
461 throw GiwsException::JniBadAllocException(curEnv);
462 }
463 
464 
465                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxMessagejintintjstringjava_lang_StringID ,id, message_);
466                         curEnv->DeleteLocalRef(message_);
467 if (curEnv->ExceptionCheck()) {
468 throw GiwsException::JniCallMethodException(curEnv);
469 }
470 }
471 
setMessageBoxMessage(JavaVM * jvm_,int id,char const * const * message,int messageSize)472 void CallScilabBridge::setMessageBoxMessage (JavaVM * jvm_, int id, char const* const* message, int messageSize){
473 
474 JNIEnv * curEnv = NULL;
475 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
476 jclass cls = initClass(curEnv);
477 if ( cls == NULL) {
478 throw GiwsException::JniCallMethodException(curEnv);
479 }
480 
481 static jmethodID voidsetMessageBoxMessagejintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxMessage", "(I[Ljava/lang/String;)V" ) ;
482 if (voidsetMessageBoxMessagejintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
483 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxMessage");
484 }
485 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
486 
487 // create java array of strings.
488 jobjectArray message_ = curEnv->NewObjectArray( messageSize, stringArrayClass, NULL);
489 if (message_ == NULL)
490 {
491 throw GiwsException::JniBadAllocException(curEnv);
492 }
493 
494 // convert each char * to java strings and fill the java array.
495 for ( int i = 0; i < messageSize; i++)
496 {
497 jstring TempString = curEnv->NewStringUTF( message[i] );
498 if (TempString == NULL)
499 {
500 throw GiwsException::JniBadAllocException(curEnv);
501 }
502 
503 curEnv->SetObjectArrayElement( message_, i, TempString);
504 
505 // avoid keeping reference on too many strings
506 curEnv->DeleteLocalRef(TempString);
507 }
508                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxMessagejintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, message_);
509                         curEnv->DeleteLocalRef(stringArrayClass);
510 curEnv->DeleteLocalRef(message_);
511 if (curEnv->ExceptionCheck()) {
512 throw GiwsException::JniCallMethodException(curEnv);
513 }
514 }
515 
messageBoxDisplayAndWait(JavaVM * jvm_,int id)516 void CallScilabBridge::messageBoxDisplayAndWait (JavaVM * jvm_, int id){
517 
518 JNIEnv * curEnv = NULL;
519 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
520 jclass cls = initClass(curEnv);
521 if ( cls == NULL) {
522 throw GiwsException::JniCallMethodException(curEnv);
523 }
524 
525 static jmethodID voidmessageBoxDisplayAndWaitjintintID = curEnv->GetStaticMethodID(cls, "messageBoxDisplayAndWait", "(I)V" ) ;
526 if (voidmessageBoxDisplayAndWaitjintintID == NULL) {
527 throw GiwsException::JniMethodNotFoundException(curEnv, "messageBoxDisplayAndWait");
528 }
529 
530                          curEnv->CallStaticVoidMethod(cls, voidmessageBoxDisplayAndWaitjintintID ,id);
531                         if (curEnv->ExceptionCheck()) {
532 throw GiwsException::JniCallMethodException(curEnv);
533 }
534 }
535 
getMessageBoxSelectedButton(JavaVM * jvm_,int id)536 int CallScilabBridge::getMessageBoxSelectedButton (JavaVM * jvm_, int id){
537 
538 JNIEnv * curEnv = NULL;
539 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
540 jclass cls = initClass(curEnv);
541 if ( cls == NULL) {
542 throw GiwsException::JniCallMethodException(curEnv);
543 }
544 
545 static jmethodID jintgetMessageBoxSelectedButtonjintintID = curEnv->GetStaticMethodID(cls, "getMessageBoxSelectedButton", "(I)I" ) ;
546 if (jintgetMessageBoxSelectedButtonjintintID == NULL) {
547 throw GiwsException::JniMethodNotFoundException(curEnv, "getMessageBoxSelectedButton");
548 }
549 
550                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetMessageBoxSelectedButtonjintintID ,id));
551                         if (curEnv->ExceptionCheck()) {
552 throw GiwsException::JniCallMethodException(curEnv);
553 }
554 return res;
555 
556 }
557 
setMessageBoxDefaultSelectedButtons(JavaVM * jvm_,int id,int const * index,int indexSize)558 void CallScilabBridge::setMessageBoxDefaultSelectedButtons (JavaVM * jvm_, int id, int const* index, int indexSize){
559 
560 JNIEnv * curEnv = NULL;
561 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
562 jclass cls = initClass(curEnv);
563 if ( cls == NULL) {
564 throw GiwsException::JniCallMethodException(curEnv);
565 }
566 
567 static jmethodID voidsetMessageBoxDefaultSelectedButtonsjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "setMessageBoxDefaultSelectedButtons", "(I[I)V" ) ;
568 if (voidsetMessageBoxDefaultSelectedButtonsjintintjintArray_intintID == NULL) {
569 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxDefaultSelectedButtons");
570 }
571 
572 jintArray index_ = curEnv->NewIntArray( indexSize ) ;
573 
574 if (index_ == NULL)
575 {
576 // check that allocation succeed
577 throw GiwsException::JniBadAllocException(curEnv);
578 }
579 
580 curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
581 
582 
583                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxDefaultSelectedButtonsjintintjintArray_intintID ,id, index_);
584                         curEnv->DeleteLocalRef(index_);
585 if (curEnv->ExceptionCheck()) {
586 throw GiwsException::JniCallMethodException(curEnv);
587 }
588 }
589 
getMessageBoxUserSelectedButtons(JavaVM * jvm_,int id)590 int* CallScilabBridge::getMessageBoxUserSelectedButtons (JavaVM * jvm_, int id){
591 
592 JNIEnv * curEnv = NULL;
593 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
594 jclass cls = initClass(curEnv);
595 if ( cls == NULL) {
596 throw GiwsException::JniCallMethodException(curEnv);
597 }
598 
599 static jmethodID jintArray_getMessageBoxUserSelectedButtonsjintintID = curEnv->GetStaticMethodID(cls, "getMessageBoxUserSelectedButtons", "(I)[I" ) ;
600 if (jintArray_getMessageBoxUserSelectedButtonsjintintID == NULL) {
601 throw GiwsException::JniMethodNotFoundException(curEnv, "getMessageBoxUserSelectedButtons");
602 }
603 
604                         jintArray res =  static_cast<jintArray>( curEnv->CallStaticObjectMethod(cls, jintArray_getMessageBoxUserSelectedButtonsjintintID ,id));
605                         if (res == NULL) { return NULL; }
606                         if (curEnv->ExceptionCheck()) {
607 throw GiwsException::JniCallMethodException(curEnv);
608 }int lenRow;
609  lenRow = curEnv->GetArrayLength(res);
610 jboolean isCopy = JNI_FALSE;
611 
612 /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
613 jint *resultsArray = static_cast<jint *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
614 int* myArray= new int[ lenRow];
615 
616 for (jsize i = 0; i <  lenRow; i++){
617 myArray[i]=resultsArray[i];
618 }
619 curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
620 
621                         curEnv->DeleteLocalRef(res);
622 if (curEnv->ExceptionCheck()) {
623 delete[] myArray;
624                                 throw GiwsException::JniCallMethodException(curEnv);
625 }
626 return myArray;
627 
628 }
629 
setMessageBoxButtonsLabels(JavaVM * jvm_,int id,char const * const * labels,int labelsSize)630 void CallScilabBridge::setMessageBoxButtonsLabels (JavaVM * jvm_, int id, char const* const* labels, int labelsSize){
631 
632 JNIEnv * curEnv = NULL;
633 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
634 jclass cls = initClass(curEnv);
635 if ( cls == NULL) {
636 throw GiwsException::JniCallMethodException(curEnv);
637 }
638 
639 static jmethodID voidsetMessageBoxButtonsLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxButtonsLabels", "(I[Ljava/lang/String;)V" ) ;
640 if (voidsetMessageBoxButtonsLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
641 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxButtonsLabels");
642 }
643 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
644 
645 // create java array of strings.
646 jobjectArray labels_ = curEnv->NewObjectArray( labelsSize, stringArrayClass, NULL);
647 if (labels_ == NULL)
648 {
649 throw GiwsException::JniBadAllocException(curEnv);
650 }
651 
652 // convert each char * to java strings and fill the java array.
653 for ( int i = 0; i < labelsSize; i++)
654 {
655 jstring TempString = curEnv->NewStringUTF( labels[i] );
656 if (TempString == NULL)
657 {
658 throw GiwsException::JniBadAllocException(curEnv);
659 }
660 
661 curEnv->SetObjectArrayElement( labels_, i, TempString);
662 
663 // avoid keeping reference on too many strings
664 curEnv->DeleteLocalRef(TempString);
665 }
666                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxButtonsLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, labels_);
667                         curEnv->DeleteLocalRef(stringArrayClass);
668 curEnv->DeleteLocalRef(labels_);
669 if (curEnv->ExceptionCheck()) {
670 throw GiwsException::JniCallMethodException(curEnv);
671 }
672 }
673 
setMessageBoxInitialValue(JavaVM * jvm_,int id,char const * const * value,int valueSize)674 void CallScilabBridge::setMessageBoxInitialValue (JavaVM * jvm_, int id, char const* const* value, int valueSize){
675 
676 JNIEnv * curEnv = NULL;
677 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
678 jclass cls = initClass(curEnv);
679 if ( cls == NULL) {
680 throw GiwsException::JniCallMethodException(curEnv);
681 }
682 
683 static jmethodID voidsetMessageBoxInitialValuejintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxInitialValue", "(I[Ljava/lang/String;)V" ) ;
684 if (voidsetMessageBoxInitialValuejintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
685 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxInitialValue");
686 }
687 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
688 
689 // create java array of strings.
690 jobjectArray value_ = curEnv->NewObjectArray( valueSize, stringArrayClass, NULL);
691 if (value_ == NULL)
692 {
693 throw GiwsException::JniBadAllocException(curEnv);
694 }
695 
696 // convert each char * to java strings and fill the java array.
697 for ( int i = 0; i < valueSize; i++)
698 {
699 jstring TempString = curEnv->NewStringUTF( value[i] );
700 if (TempString == NULL)
701 {
702 throw GiwsException::JniBadAllocException(curEnv);
703 }
704 
705 curEnv->SetObjectArrayElement( value_, i, TempString);
706 
707 // avoid keeping reference on too many strings
708 curEnv->DeleteLocalRef(TempString);
709 }
710                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxInitialValuejintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, value_);
711                         curEnv->DeleteLocalRef(stringArrayClass);
712 curEnv->DeleteLocalRef(value_);
713 if (curEnv->ExceptionCheck()) {
714 throw GiwsException::JniCallMethodException(curEnv);
715 }
716 }
717 
getMessageBoxValue(JavaVM * jvm_,int id)718 char** CallScilabBridge::getMessageBoxValue (JavaVM * jvm_, int id){
719 
720 JNIEnv * curEnv = NULL;
721 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
722 jclass cls = initClass(curEnv);
723 if ( cls == NULL) {
724 throw GiwsException::JniCallMethodException(curEnv);
725 }
726 
727 static jmethodID jobjectArray_getMessageBoxValuejintintID = curEnv->GetStaticMethodID(cls, "getMessageBoxValue", "(I)[Ljava/lang/String;" ) ;
728 if (jobjectArray_getMessageBoxValuejintintID == NULL) {
729 throw GiwsException::JniMethodNotFoundException(curEnv, "getMessageBoxValue");
730 }
731 
732                         jobjectArray res =  static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray_getMessageBoxValuejintintID ,id));
733                         if (curEnv->ExceptionCheck()) {
734 throw GiwsException::JniCallMethodException(curEnv);
735 }if (res != NULL) { int lenRow;
736  lenRow = curEnv->GetArrayLength(res);
737 
738 char **arrayOfString;
739 arrayOfString = new char *[lenRow];
740 for (jsize i = 0; i < lenRow; i++){
741 jstring resString = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(res, i));
742 const char *tempString = curEnv->GetStringUTFChars(resString, 0);
743 arrayOfString[i] = new char[strlen(tempString) + 1];
744 
745 strcpy(arrayOfString[i], tempString);
746 curEnv->ReleaseStringUTFChars(resString, tempString);
747 curEnv->DeleteLocalRef(resString);
748 }
749 if (curEnv->ExceptionCheck()) {
750 delete[] arrayOfString;
751                                 throw GiwsException::JniCallMethodException(curEnv);
752 }
753 curEnv->DeleteLocalRef(res);
754 return arrayOfString;
755  } else {
756 curEnv->DeleteLocalRef(res);
757 return NULL;
758 }
759 }
760 
getMessageBoxValueSize(JavaVM * jvm_,int id)761 int CallScilabBridge::getMessageBoxValueSize (JavaVM * jvm_, int id){
762 
763 JNIEnv * curEnv = NULL;
764 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
765 jclass cls = initClass(curEnv);
766 if ( cls == NULL) {
767 throw GiwsException::JniCallMethodException(curEnv);
768 }
769 
770 static jmethodID jintgetMessageBoxValueSizejintintID = curEnv->GetStaticMethodID(cls, "getMessageBoxValueSize", "(I)I" ) ;
771 if (jintgetMessageBoxValueSizejintintID == NULL) {
772 throw GiwsException::JniMethodNotFoundException(curEnv, "getMessageBoxValueSize");
773 }
774 
775                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetMessageBoxValueSizejintintID ,id));
776                         if (curEnv->ExceptionCheck()) {
777 throw GiwsException::JniCallMethodException(curEnv);
778 }
779 return res;
780 
781 }
782 
setMessageBoxListBoxItems(JavaVM * jvm_,int id,char const * const * items,int itemsSize)783 void CallScilabBridge::setMessageBoxListBoxItems (JavaVM * jvm_, int id, char const* const* items, int itemsSize){
784 
785 JNIEnv * curEnv = NULL;
786 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
787 jclass cls = initClass(curEnv);
788 if ( cls == NULL) {
789 throw GiwsException::JniCallMethodException(curEnv);
790 }
791 
792 static jmethodID voidsetMessageBoxListBoxItemsjintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxListBoxItems", "(I[Ljava/lang/String;)V" ) ;
793 if (voidsetMessageBoxListBoxItemsjintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
794 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxListBoxItems");
795 }
796 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
797 
798 // create java array of strings.
799 jobjectArray items_ = curEnv->NewObjectArray( itemsSize, stringArrayClass, NULL);
800 if (items_ == NULL)
801 {
802 throw GiwsException::JniBadAllocException(curEnv);
803 }
804 
805 // convert each char * to java strings and fill the java array.
806 for ( int i = 0; i < itemsSize; i++)
807 {
808 jstring TempString = curEnv->NewStringUTF( items[i] );
809 if (TempString == NULL)
810 {
811 throw GiwsException::JniBadAllocException(curEnv);
812 }
813 
814 curEnv->SetObjectArrayElement( items_, i, TempString);
815 
816 // avoid keeping reference on too many strings
817 curEnv->DeleteLocalRef(TempString);
818 }
819                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxListBoxItemsjintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, items_);
820                         curEnv->DeleteLocalRef(stringArrayClass);
821 curEnv->DeleteLocalRef(items_);
822 if (curEnv->ExceptionCheck()) {
823 throw GiwsException::JniCallMethodException(curEnv);
824 }
825 }
826 
getMessageBoxSelectedItem(JavaVM * jvm_,int id)827 int CallScilabBridge::getMessageBoxSelectedItem (JavaVM * jvm_, int id){
828 
829 JNIEnv * curEnv = NULL;
830 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
831 jclass cls = initClass(curEnv);
832 if ( cls == NULL) {
833 throw GiwsException::JniCallMethodException(curEnv);
834 }
835 
836 static jmethodID jintgetMessageBoxSelectedItemjintintID = curEnv->GetStaticMethodID(cls, "getMessageBoxSelectedItem", "(I)I" ) ;
837 if (jintgetMessageBoxSelectedItemjintintID == NULL) {
838 throw GiwsException::JniMethodNotFoundException(curEnv, "getMessageBoxSelectedItem");
839 }
840 
841                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetMessageBoxSelectedItemjintintID ,id));
842                         if (curEnv->ExceptionCheck()) {
843 throw GiwsException::JniCallMethodException(curEnv);
844 }
845 return res;
846 
847 }
848 
setMessageBoxLineLabels(JavaVM * jvm_,int id,char const * const * labels,int labelsSize)849 void CallScilabBridge::setMessageBoxLineLabels (JavaVM * jvm_, int id, char const* const* labels, int labelsSize){
850 
851 JNIEnv * curEnv = NULL;
852 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
853 jclass cls = initClass(curEnv);
854 if ( cls == NULL) {
855 throw GiwsException::JniCallMethodException(curEnv);
856 }
857 
858 static jmethodID voidsetMessageBoxLineLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxLineLabels", "(I[Ljava/lang/String;)V" ) ;
859 if (voidsetMessageBoxLineLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
860 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxLineLabels");
861 }
862 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
863 
864 // create java array of strings.
865 jobjectArray labels_ = curEnv->NewObjectArray( labelsSize, stringArrayClass, NULL);
866 if (labels_ == NULL)
867 {
868 throw GiwsException::JniBadAllocException(curEnv);
869 }
870 
871 // convert each char * to java strings and fill the java array.
872 for ( int i = 0; i < labelsSize; i++)
873 {
874 jstring TempString = curEnv->NewStringUTF( labels[i] );
875 if (TempString == NULL)
876 {
877 throw GiwsException::JniBadAllocException(curEnv);
878 }
879 
880 curEnv->SetObjectArrayElement( labels_, i, TempString);
881 
882 // avoid keeping reference on too many strings
883 curEnv->DeleteLocalRef(TempString);
884 }
885                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxLineLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, labels_);
886                         curEnv->DeleteLocalRef(stringArrayClass);
887 curEnv->DeleteLocalRef(labels_);
888 if (curEnv->ExceptionCheck()) {
889 throw GiwsException::JniCallMethodException(curEnv);
890 }
891 }
892 
setMessageBoxColumnLabels(JavaVM * jvm_,int id,char const * const * labels,int labelsSize)893 void CallScilabBridge::setMessageBoxColumnLabels (JavaVM * jvm_, int id, char const* const* labels, int labelsSize){
894 
895 JNIEnv * curEnv = NULL;
896 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
897 jclass cls = initClass(curEnv);
898 if ( cls == NULL) {
899 throw GiwsException::JniCallMethodException(curEnv);
900 }
901 
902 static jmethodID voidsetMessageBoxColumnLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxColumnLabels", "(I[Ljava/lang/String;)V" ) ;
903 if (voidsetMessageBoxColumnLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
904 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxColumnLabels");
905 }
906 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
907 
908 // create java array of strings.
909 jobjectArray labels_ = curEnv->NewObjectArray( labelsSize, stringArrayClass, NULL);
910 if (labels_ == NULL)
911 {
912 throw GiwsException::JniBadAllocException(curEnv);
913 }
914 
915 // convert each char * to java strings and fill the java array.
916 for ( int i = 0; i < labelsSize; i++)
917 {
918 jstring TempString = curEnv->NewStringUTF( labels[i] );
919 if (TempString == NULL)
920 {
921 throw GiwsException::JniBadAllocException(curEnv);
922 }
923 
924 curEnv->SetObjectArrayElement( labels_, i, TempString);
925 
926 // avoid keeping reference on too many strings
927 curEnv->DeleteLocalRef(TempString);
928 }
929                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxColumnLabelsjintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, labels_);
930                         curEnv->DeleteLocalRef(stringArrayClass);
931 curEnv->DeleteLocalRef(labels_);
932 if (curEnv->ExceptionCheck()) {
933 throw GiwsException::JniCallMethodException(curEnv);
934 }
935 }
936 
setMessageBoxDefaultInput(JavaVM * jvm_,int id,char const * const * values,int valuesSize)937 void CallScilabBridge::setMessageBoxDefaultInput (JavaVM * jvm_, int id, char const* const* values, int valuesSize){
938 
939 JNIEnv * curEnv = NULL;
940 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
941 jclass cls = initClass(curEnv);
942 if ( cls == NULL) {
943 throw GiwsException::JniCallMethodException(curEnv);
944 }
945 
946 static jmethodID voidsetMessageBoxDefaultInputjintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxDefaultInput", "(I[Ljava/lang/String;)V" ) ;
947 if (voidsetMessageBoxDefaultInputjintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
948 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxDefaultInput");
949 }
950 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
951 
952 // create java array of strings.
953 jobjectArray values_ = curEnv->NewObjectArray( valuesSize, stringArrayClass, NULL);
954 if (values_ == NULL)
955 {
956 throw GiwsException::JniBadAllocException(curEnv);
957 }
958 
959 // convert each char * to java strings and fill the java array.
960 for ( int i = 0; i < valuesSize; i++)
961 {
962 jstring TempString = curEnv->NewStringUTF( values[i] );
963 if (TempString == NULL)
964 {
965 throw GiwsException::JniBadAllocException(curEnv);
966 }
967 
968 curEnv->SetObjectArrayElement( values_, i, TempString);
969 
970 // avoid keeping reference on too many strings
971 curEnv->DeleteLocalRef(TempString);
972 }
973                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxDefaultInputjintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, values_);
974                         curEnv->DeleteLocalRef(stringArrayClass);
975 curEnv->DeleteLocalRef(values_);
976 if (curEnv->ExceptionCheck()) {
977 throw GiwsException::JniCallMethodException(curEnv);
978 }
979 }
980 
setMessageBoxModal(JavaVM * jvm_,int id,bool status)981 void CallScilabBridge::setMessageBoxModal (JavaVM * jvm_, int id, bool status){
982 
983 JNIEnv * curEnv = NULL;
984 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
985 jclass cls = initClass(curEnv);
986 if ( cls == NULL) {
987 throw GiwsException::JniCallMethodException(curEnv);
988 }
989 
990 static jmethodID voidsetMessageBoxModaljintintjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "setMessageBoxModal", "(IZ)V" ) ;
991 if (voidsetMessageBoxModaljintintjbooleanbooleanID == NULL) {
992 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxModal");
993 }
994 
995 jboolean status_ = (static_cast<bool>(status) ? JNI_TRUE : JNI_FALSE);
996 
997                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxModaljintintjbooleanbooleanID ,id, status_);
998                         if (curEnv->ExceptionCheck()) {
999 throw GiwsException::JniCallMethodException(curEnv);
1000 }
1001 }
1002 
setMessageBoxIcon(JavaVM * jvm_,int id,char const * name)1003 void CallScilabBridge::setMessageBoxIcon (JavaVM * jvm_, int id, char const* name){
1004 
1005 JNIEnv * curEnv = NULL;
1006 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1007 jclass cls = initClass(curEnv);
1008 if ( cls == NULL) {
1009 throw GiwsException::JniCallMethodException(curEnv);
1010 }
1011 
1012 static jmethodID voidsetMessageBoxIconjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setMessageBoxIcon", "(ILjava/lang/String;)V" ) ;
1013 if (voidsetMessageBoxIconjintintjstringjava_lang_StringID == NULL) {
1014 throw GiwsException::JniMethodNotFoundException(curEnv, "setMessageBoxIcon");
1015 }
1016 
1017 jstring name_ = curEnv->NewStringUTF( name );
1018 if (name != NULL && name_ == NULL)
1019 {
1020 throw GiwsException::JniBadAllocException(curEnv);
1021 }
1022 
1023 
1024                          curEnv->CallStaticVoidMethod(cls, voidsetMessageBoxIconjintintjstringjava_lang_StringID ,id, name_);
1025                         curEnv->DeleteLocalRef(name_);
1026 if (curEnv->ExceptionCheck()) {
1027 throw GiwsException::JniCallMethodException(curEnv);
1028 }
1029 }
1030 
launchHelpBrowser(JavaVM * jvm_,char const * const * helps,int helpsSize,char const * language)1031 void CallScilabBridge::launchHelpBrowser (JavaVM * jvm_, char const* const* helps, int helpsSize, char const* language){
1032 
1033 JNIEnv * curEnv = NULL;
1034 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1035 jclass cls = initClass(curEnv);
1036 if ( cls == NULL) {
1037 throw GiwsException::JniCallMethodException(curEnv);
1038 }
1039 
1040 static jmethodID voidlaunchHelpBrowserjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "launchHelpBrowser", "([Ljava/lang/String;Ljava/lang/String;)V" ) ;
1041 if (voidlaunchHelpBrowserjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_StringID == NULL) {
1042 throw GiwsException::JniMethodNotFoundException(curEnv, "launchHelpBrowser");
1043 }
1044 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
1045 
1046 // create java array of strings.
1047 jobjectArray helps_ = curEnv->NewObjectArray( helpsSize, stringArrayClass, NULL);
1048 if (helps_ == NULL)
1049 {
1050 throw GiwsException::JniBadAllocException(curEnv);
1051 }
1052 
1053 // convert each char * to java strings and fill the java array.
1054 for ( int i = 0; i < helpsSize; i++)
1055 {
1056 jstring TempString = curEnv->NewStringUTF( helps[i] );
1057 if (TempString == NULL)
1058 {
1059 throw GiwsException::JniBadAllocException(curEnv);
1060 }
1061 
1062 curEnv->SetObjectArrayElement( helps_, i, TempString);
1063 
1064 // avoid keeping reference on too many strings
1065 curEnv->DeleteLocalRef(TempString);
1066 }
1067 jstring language_ = curEnv->NewStringUTF( language );
1068 if (language != NULL && language_ == NULL)
1069 {
1070 throw GiwsException::JniBadAllocException(curEnv);
1071 }
1072 
1073 
1074                          curEnv->CallStaticVoidMethod(cls, voidlaunchHelpBrowserjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_StringID ,helps_, language_);
1075                         curEnv->DeleteLocalRef(stringArrayClass);
1076 curEnv->DeleteLocalRef(helps_);
1077 curEnv->DeleteLocalRef(language_);
1078 if (curEnv->ExceptionCheck()) {
1079 throw GiwsException::JniCallMethodException(curEnv);
1080 }
1081 }
1082 
searchKeyword(JavaVM * jvm_,char const * const * helps,int helpsSize,char const * keyword,char const * language,bool fullText)1083 void CallScilabBridge::searchKeyword (JavaVM * jvm_, char const* const* helps, int helpsSize, char const* keyword, char const* language, bool fullText){
1084 
1085 JNIEnv * curEnv = NULL;
1086 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1087 jclass cls = initClass(curEnv);
1088 if ( cls == NULL) {
1089 throw GiwsException::JniCallMethodException(curEnv);
1090 }
1091 
1092 static jmethodID voidsearchKeywordjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "searchKeyword", "([Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V" ) ;
1093 if (voidsearchKeywordjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringjbooleanbooleanID == NULL) {
1094 throw GiwsException::JniMethodNotFoundException(curEnv, "searchKeyword");
1095 }
1096 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
1097 
1098 // create java array of strings.
1099 jobjectArray helps_ = curEnv->NewObjectArray( helpsSize, stringArrayClass, NULL);
1100 if (helps_ == NULL)
1101 {
1102 throw GiwsException::JniBadAllocException(curEnv);
1103 }
1104 
1105 // convert each char * to java strings and fill the java array.
1106 for ( int i = 0; i < helpsSize; i++)
1107 {
1108 jstring TempString = curEnv->NewStringUTF( helps[i] );
1109 if (TempString == NULL)
1110 {
1111 throw GiwsException::JniBadAllocException(curEnv);
1112 }
1113 
1114 curEnv->SetObjectArrayElement( helps_, i, TempString);
1115 
1116 // avoid keeping reference on too many strings
1117 curEnv->DeleteLocalRef(TempString);
1118 }
1119 jstring keyword_ = curEnv->NewStringUTF( keyword );
1120 if (keyword != NULL && keyword_ == NULL)
1121 {
1122 throw GiwsException::JniBadAllocException(curEnv);
1123 }
1124 
1125 
1126 jstring language_ = curEnv->NewStringUTF( language );
1127 if (language != NULL && language_ == NULL)
1128 {
1129 throw GiwsException::JniBadAllocException(curEnv);
1130 }
1131 
1132 
1133 jboolean fullText_ = (static_cast<bool>(fullText) ? JNI_TRUE : JNI_FALSE);
1134 
1135                          curEnv->CallStaticVoidMethod(cls, voidsearchKeywordjobjectArray_java_lang_Stringjava_lang_Stringjstringjava_lang_Stringjstringjava_lang_StringjbooleanbooleanID ,helps_, keyword_, language_, fullText_);
1136                         curEnv->DeleteLocalRef(stringArrayClass);
1137 curEnv->DeleteLocalRef(helps_);
1138 curEnv->DeleteLocalRef(keyword_);
1139 curEnv->DeleteLocalRef(language_);
1140 if (curEnv->ExceptionCheck()) {
1141 throw GiwsException::JniCallMethodException(curEnv);
1142 }
1143 }
1144 
newExportFileChooser(JavaVM * jvm_,int figureUID)1145 int CallScilabBridge::newExportFileChooser (JavaVM * jvm_, int figureUID){
1146 
1147 JNIEnv * curEnv = NULL;
1148 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1149 jclass cls = initClass(curEnv);
1150 if ( cls == NULL) {
1151 throw GiwsException::JniCallMethodException(curEnv);
1152 }
1153 
1154 static jmethodID jintnewExportFileChooserjintintID = curEnv->GetStaticMethodID(cls, "newExportFileChooser", "(I)I" ) ;
1155 if (jintnewExportFileChooserjintintID == NULL) {
1156 throw GiwsException::JniMethodNotFoundException(curEnv, "newExportFileChooser");
1157 }
1158 
1159                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewExportFileChooserjintintID ,figureUID));
1160                         if (curEnv->ExceptionCheck()) {
1161 throw GiwsException::JniCallMethodException(curEnv);
1162 }
1163 return res;
1164 
1165 }
1166 
newFontChooser(JavaVM * jvm_)1167 int CallScilabBridge::newFontChooser (JavaVM * jvm_){
1168 
1169 JNIEnv * curEnv = NULL;
1170 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1171 jclass cls = initClass(curEnv);
1172 if ( cls == NULL) {
1173 throw GiwsException::JniCallMethodException(curEnv);
1174 }
1175 
1176 static jmethodID jintnewFontChooserID = curEnv->GetStaticMethodID(cls, "newFontChooser", "()I" ) ;
1177 if (jintnewFontChooserID == NULL) {
1178 throw GiwsException::JniMethodNotFoundException(curEnv, "newFontChooser");
1179 }
1180 
1181                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewFontChooserID ));
1182                         if (curEnv->ExceptionCheck()) {
1183 throw GiwsException::JniCallMethodException(curEnv);
1184 }
1185 return res;
1186 
1187 }
1188 
fontChooserDisplayAndWait(JavaVM * jvm_,int objID)1189 void CallScilabBridge::fontChooserDisplayAndWait (JavaVM * jvm_, int objID){
1190 
1191 JNIEnv * curEnv = NULL;
1192 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1193 jclass cls = initClass(curEnv);
1194 if ( cls == NULL) {
1195 throw GiwsException::JniCallMethodException(curEnv);
1196 }
1197 
1198 static jmethodID voidfontChooserDisplayAndWaitjintintID = curEnv->GetStaticMethodID(cls, "fontChooserDisplayAndWait", "(I)V" ) ;
1199 if (voidfontChooserDisplayAndWaitjintintID == NULL) {
1200 throw GiwsException::JniMethodNotFoundException(curEnv, "fontChooserDisplayAndWait");
1201 }
1202 
1203                          curEnv->CallStaticVoidMethod(cls, voidfontChooserDisplayAndWaitjintintID ,objID);
1204                         if (curEnv->ExceptionCheck()) {
1205 throw GiwsException::JniCallMethodException(curEnv);
1206 }
1207 }
1208 
setFontChooserFontName(JavaVM * jvm_,int objID,char const * fontName)1209 void CallScilabBridge::setFontChooserFontName (JavaVM * jvm_, int objID, char const* fontName){
1210 
1211 JNIEnv * curEnv = NULL;
1212 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1213 jclass cls = initClass(curEnv);
1214 if ( cls == NULL) {
1215 throw GiwsException::JniCallMethodException(curEnv);
1216 }
1217 
1218 static jmethodID voidsetFontChooserFontNamejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setFontChooserFontName", "(ILjava/lang/String;)V" ) ;
1219 if (voidsetFontChooserFontNamejintintjstringjava_lang_StringID == NULL) {
1220 throw GiwsException::JniMethodNotFoundException(curEnv, "setFontChooserFontName");
1221 }
1222 
1223 jstring fontName_ = curEnv->NewStringUTF( fontName );
1224 if (fontName != NULL && fontName_ == NULL)
1225 {
1226 throw GiwsException::JniBadAllocException(curEnv);
1227 }
1228 
1229 
1230                          curEnv->CallStaticVoidMethod(cls, voidsetFontChooserFontNamejintintjstringjava_lang_StringID ,objID, fontName_);
1231                         curEnv->DeleteLocalRef(fontName_);
1232 if (curEnv->ExceptionCheck()) {
1233 throw GiwsException::JniCallMethodException(curEnv);
1234 }
1235 }
1236 
setFontChooserFontSize(JavaVM * jvm_,int objID,int fontSize)1237 void CallScilabBridge::setFontChooserFontSize (JavaVM * jvm_, int objID, int fontSize){
1238 
1239 JNIEnv * curEnv = NULL;
1240 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1241 jclass cls = initClass(curEnv);
1242 if ( cls == NULL) {
1243 throw GiwsException::JniCallMethodException(curEnv);
1244 }
1245 
1246 static jmethodID voidsetFontChooserFontSizejintintjintintID = curEnv->GetStaticMethodID(cls, "setFontChooserFontSize", "(II)V" ) ;
1247 if (voidsetFontChooserFontSizejintintjintintID == NULL) {
1248 throw GiwsException::JniMethodNotFoundException(curEnv, "setFontChooserFontSize");
1249 }
1250 
1251                          curEnv->CallStaticVoidMethod(cls, voidsetFontChooserFontSizejintintjintintID ,objID, fontSize);
1252                         if (curEnv->ExceptionCheck()) {
1253 throw GiwsException::JniCallMethodException(curEnv);
1254 }
1255 }
1256 
setFontChooserBold(JavaVM * jvm_,int objID,bool bold)1257 void CallScilabBridge::setFontChooserBold (JavaVM * jvm_, int objID, bool bold){
1258 
1259 JNIEnv * curEnv = NULL;
1260 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1261 jclass cls = initClass(curEnv);
1262 if ( cls == NULL) {
1263 throw GiwsException::JniCallMethodException(curEnv);
1264 }
1265 
1266 static jmethodID voidsetFontChooserBoldjintintjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "setFontChooserBold", "(IZ)V" ) ;
1267 if (voidsetFontChooserBoldjintintjbooleanbooleanID == NULL) {
1268 throw GiwsException::JniMethodNotFoundException(curEnv, "setFontChooserBold");
1269 }
1270 
1271 jboolean bold_ = (static_cast<bool>(bold) ? JNI_TRUE : JNI_FALSE);
1272 
1273                          curEnv->CallStaticVoidMethod(cls, voidsetFontChooserBoldjintintjbooleanbooleanID ,objID, bold_);
1274                         if (curEnv->ExceptionCheck()) {
1275 throw GiwsException::JniCallMethodException(curEnv);
1276 }
1277 }
1278 
setFontChooserItalic(JavaVM * jvm_,int objID,bool italic)1279 void CallScilabBridge::setFontChooserItalic (JavaVM * jvm_, int objID, bool italic){
1280 
1281 JNIEnv * curEnv = NULL;
1282 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1283 jclass cls = initClass(curEnv);
1284 if ( cls == NULL) {
1285 throw GiwsException::JniCallMethodException(curEnv);
1286 }
1287 
1288 static jmethodID voidsetFontChooserItalicjintintjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "setFontChooserItalic", "(IZ)V" ) ;
1289 if (voidsetFontChooserItalicjintintjbooleanbooleanID == NULL) {
1290 throw GiwsException::JniMethodNotFoundException(curEnv, "setFontChooserItalic");
1291 }
1292 
1293 jboolean italic_ = (static_cast<bool>(italic) ? JNI_TRUE : JNI_FALSE);
1294 
1295                          curEnv->CallStaticVoidMethod(cls, voidsetFontChooserItalicjintintjbooleanbooleanID ,objID, italic_);
1296                         if (curEnv->ExceptionCheck()) {
1297 throw GiwsException::JniCallMethodException(curEnv);
1298 }
1299 }
1300 
getFontChooserFontName(JavaVM * jvm_,int objID)1301 char* CallScilabBridge::getFontChooserFontName (JavaVM * jvm_, int objID){
1302 
1303 JNIEnv * curEnv = NULL;
1304 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1305 jclass cls = initClass(curEnv);
1306 if ( cls == NULL) {
1307 throw GiwsException::JniCallMethodException(curEnv);
1308 }
1309 
1310 static jmethodID jstringgetFontChooserFontNamejintintID = curEnv->GetStaticMethodID(cls, "getFontChooserFontName", "(I)Ljava/lang/String;" ) ;
1311 if (jstringgetFontChooserFontNamejintintID == NULL) {
1312 throw GiwsException::JniMethodNotFoundException(curEnv, "getFontChooserFontName");
1313 }
1314 
1315                         jstring res =  static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetFontChooserFontNamejintintID ,objID));
1316                         if (curEnv->ExceptionCheck()) {
1317 throw GiwsException::JniCallMethodException(curEnv);
1318 }if (res != NULL) {
1319 
1320 const char *tempString = curEnv->GetStringUTFChars(res, 0);
1321 char * myStringBuffer = new char[strlen(tempString) + 1];
1322 strcpy(myStringBuffer, tempString);
1323 curEnv->ReleaseStringUTFChars(res, tempString);
1324 curEnv->DeleteLocalRef(res);
1325 if (curEnv->ExceptionCheck()) {
1326 delete[] myStringBuffer;
1327                                 throw GiwsException::JniCallMethodException(curEnv);
1328 }
1329 return myStringBuffer;
1330  } else {
1331 curEnv->DeleteLocalRef(res);
1332 return NULL;
1333 }
1334 }
1335 
getFontChooserFontSize(JavaVM * jvm_,int objID)1336 int CallScilabBridge::getFontChooserFontSize (JavaVM * jvm_, int objID){
1337 
1338 JNIEnv * curEnv = NULL;
1339 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1340 jclass cls = initClass(curEnv);
1341 if ( cls == NULL) {
1342 throw GiwsException::JniCallMethodException(curEnv);
1343 }
1344 
1345 static jmethodID jintgetFontChooserFontSizejintintID = curEnv->GetStaticMethodID(cls, "getFontChooserFontSize", "(I)I" ) ;
1346 if (jintgetFontChooserFontSizejintintID == NULL) {
1347 throw GiwsException::JniMethodNotFoundException(curEnv, "getFontChooserFontSize");
1348 }
1349 
1350                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFontChooserFontSizejintintID ,objID));
1351                         if (curEnv->ExceptionCheck()) {
1352 throw GiwsException::JniCallMethodException(curEnv);
1353 }
1354 return res;
1355 
1356 }
1357 
getFontChooserBold(JavaVM * jvm_,int objID)1358 bool CallScilabBridge::getFontChooserBold (JavaVM * jvm_, int objID){
1359 
1360 JNIEnv * curEnv = NULL;
1361 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1362 jclass cls = initClass(curEnv);
1363 if ( cls == NULL) {
1364 throw GiwsException::JniCallMethodException(curEnv);
1365 }
1366 
1367 static jmethodID jbooleangetFontChooserBoldjintintID = curEnv->GetStaticMethodID(cls, "getFontChooserBold", "(I)Z" ) ;
1368 if (jbooleangetFontChooserBoldjintintID == NULL) {
1369 throw GiwsException::JniMethodNotFoundException(curEnv, "getFontChooserBold");
1370 }
1371 
1372                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleangetFontChooserBoldjintintID ,objID));
1373                         if (curEnv->ExceptionCheck()) {
1374 throw GiwsException::JniCallMethodException(curEnv);
1375 }
1376 return (res == JNI_TRUE);
1377 
1378 }
1379 
getFontChooserItalic(JavaVM * jvm_,int objID)1380 bool CallScilabBridge::getFontChooserItalic (JavaVM * jvm_, int objID){
1381 
1382 JNIEnv * curEnv = NULL;
1383 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1384 jclass cls = initClass(curEnv);
1385 if ( cls == NULL) {
1386 throw GiwsException::JniCallMethodException(curEnv);
1387 }
1388 
1389 static jmethodID jbooleangetFontChooserItalicjintintID = curEnv->GetStaticMethodID(cls, "getFontChooserItalic", "(I)Z" ) ;
1390 if (jbooleangetFontChooserItalicjintintID == NULL) {
1391 throw GiwsException::JniMethodNotFoundException(curEnv, "getFontChooserItalic");
1392 }
1393 
1394                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleangetFontChooserItalicjintintID ,objID));
1395                         if (curEnv->ExceptionCheck()) {
1396 throw GiwsException::JniCallMethodException(curEnv);
1397 }
1398 return (res == JNI_TRUE);
1399 
1400 }
1401 
newColorChooser(JavaVM * jvm_)1402 int CallScilabBridge::newColorChooser (JavaVM * jvm_){
1403 
1404 JNIEnv * curEnv = NULL;
1405 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1406 jclass cls = initClass(curEnv);
1407 if ( cls == NULL) {
1408 throw GiwsException::JniCallMethodException(curEnv);
1409 }
1410 
1411 static jmethodID jintnewColorChooserID = curEnv->GetStaticMethodID(cls, "newColorChooser", "()I" ) ;
1412 if (jintnewColorChooserID == NULL) {
1413 throw GiwsException::JniMethodNotFoundException(curEnv, "newColorChooser");
1414 }
1415 
1416                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintnewColorChooserID ));
1417                         if (curEnv->ExceptionCheck()) {
1418 throw GiwsException::JniCallMethodException(curEnv);
1419 }
1420 return res;
1421 
1422 }
1423 
colorChooserDisplayAndWait(JavaVM * jvm_,int objID)1424 void CallScilabBridge::colorChooserDisplayAndWait (JavaVM * jvm_, int objID){
1425 
1426 JNIEnv * curEnv = NULL;
1427 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1428 jclass cls = initClass(curEnv);
1429 if ( cls == NULL) {
1430 throw GiwsException::JniCallMethodException(curEnv);
1431 }
1432 
1433 static jmethodID voidcolorChooserDisplayAndWaitjintintID = curEnv->GetStaticMethodID(cls, "colorChooserDisplayAndWait", "(I)V" ) ;
1434 if (voidcolorChooserDisplayAndWaitjintintID == NULL) {
1435 throw GiwsException::JniMethodNotFoundException(curEnv, "colorChooserDisplayAndWait");
1436 }
1437 
1438                          curEnv->CallStaticVoidMethod(cls, voidcolorChooserDisplayAndWaitjintintID ,objID);
1439                         if (curEnv->ExceptionCheck()) {
1440 throw GiwsException::JniCallMethodException(curEnv);
1441 }
1442 }
1443 
setColorChooserDefaultColor(JavaVM * jvm_,int objID,int const * rgb,int rgbSize)1444 void CallScilabBridge::setColorChooserDefaultColor (JavaVM * jvm_, int objID, int const* rgb, int rgbSize){
1445 
1446 JNIEnv * curEnv = NULL;
1447 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1448 jclass cls = initClass(curEnv);
1449 if ( cls == NULL) {
1450 throw GiwsException::JniCallMethodException(curEnv);
1451 }
1452 
1453 static jmethodID voidsetColorChooserDefaultColorjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "setColorChooserDefaultColor", "(I[I)V" ) ;
1454 if (voidsetColorChooserDefaultColorjintintjintArray_intintID == NULL) {
1455 throw GiwsException::JniMethodNotFoundException(curEnv, "setColorChooserDefaultColor");
1456 }
1457 
1458 jintArray rgb_ = curEnv->NewIntArray( rgbSize ) ;
1459 
1460 if (rgb_ == NULL)
1461 {
1462 // check that allocation succeed
1463 throw GiwsException::JniBadAllocException(curEnv);
1464 }
1465 
1466 curEnv->SetIntArrayRegion( rgb_, 0, rgbSize, (jint*)(rgb) ) ;
1467 
1468 
1469                          curEnv->CallStaticVoidMethod(cls, voidsetColorChooserDefaultColorjintintjintArray_intintID ,objID, rgb_);
1470                         curEnv->DeleteLocalRef(rgb_);
1471 if (curEnv->ExceptionCheck()) {
1472 throw GiwsException::JniCallMethodException(curEnv);
1473 }
1474 }
1475 
getColorChooserSelectedColor(JavaVM * jvm_,int objID)1476 int* CallScilabBridge::getColorChooserSelectedColor (JavaVM * jvm_, int objID){
1477 
1478 JNIEnv * curEnv = NULL;
1479 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1480 jclass cls = initClass(curEnv);
1481 if ( cls == NULL) {
1482 throw GiwsException::JniCallMethodException(curEnv);
1483 }
1484 
1485 static jmethodID jintArray_getColorChooserSelectedColorjintintID = curEnv->GetStaticMethodID(cls, "getColorChooserSelectedColor", "(I)[I" ) ;
1486 if (jintArray_getColorChooserSelectedColorjintintID == NULL) {
1487 throw GiwsException::JniMethodNotFoundException(curEnv, "getColorChooserSelectedColor");
1488 }
1489 
1490                         jintArray res =  static_cast<jintArray>( curEnv->CallStaticObjectMethod(cls, jintArray_getColorChooserSelectedColorjintintID ,objID));
1491                         if (res == NULL) { return NULL; }
1492                         if (curEnv->ExceptionCheck()) {
1493 throw GiwsException::JniCallMethodException(curEnv);
1494 }int lenRow;
1495  lenRow = curEnv->GetArrayLength(res);
1496 jboolean isCopy = JNI_FALSE;
1497 
1498 /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */
1499 jint *resultsArray = static_cast<jint *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy));
1500 int* myArray= new int[ lenRow];
1501 
1502 for (jsize i = 0; i <  lenRow; i++){
1503 myArray[i]=resultsArray[i];
1504 }
1505 curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT);
1506 
1507                         curEnv->DeleteLocalRef(res);
1508 if (curEnv->ExceptionCheck()) {
1509 delete[] myArray;
1510                                 throw GiwsException::JniCallMethodException(curEnv);
1511 }
1512 return myArray;
1513 
1514 }
1515 
setColorChooserTitle(JavaVM * jvm_,int objID,char const * title)1516 void CallScilabBridge::setColorChooserTitle (JavaVM * jvm_, int objID, char const* title){
1517 
1518 JNIEnv * curEnv = NULL;
1519 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1520 jclass cls = initClass(curEnv);
1521 if ( cls == NULL) {
1522 throw GiwsException::JniCallMethodException(curEnv);
1523 }
1524 
1525 static jmethodID voidsetColorChooserTitlejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setColorChooserTitle", "(ILjava/lang/String;)V" ) ;
1526 if (voidsetColorChooserTitlejintintjstringjava_lang_StringID == NULL) {
1527 throw GiwsException::JniMethodNotFoundException(curEnv, "setColorChooserTitle");
1528 }
1529 
1530 jstring title_ = curEnv->NewStringUTF( title );
1531 if (title != NULL && title_ == NULL)
1532 {
1533 throw GiwsException::JniBadAllocException(curEnv);
1534 }
1535 
1536 
1537                          curEnv->CallStaticVoidMethod(cls, voidsetColorChooserTitlejintintjstringjava_lang_StringID ,objID, title_);
1538                         curEnv->DeleteLocalRef(title_);
1539 if (curEnv->ExceptionCheck()) {
1540 throw GiwsException::JniCallMethodException(curEnv);
1541 }
1542 }
1543 
getClipboardContents(JavaVM * jvm_)1544 char* CallScilabBridge::getClipboardContents (JavaVM * jvm_){
1545 
1546 JNIEnv * curEnv = NULL;
1547 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1548 jclass cls = initClass(curEnv);
1549 if ( cls == NULL) {
1550 throw GiwsException::JniCallMethodException(curEnv);
1551 }
1552 
1553 static jmethodID jstringgetClipboardContentsID = curEnv->GetStaticMethodID(cls, "getClipboardContents", "()Ljava/lang/String;" ) ;
1554 if (jstringgetClipboardContentsID == NULL) {
1555 throw GiwsException::JniMethodNotFoundException(curEnv, "getClipboardContents");
1556 }
1557 
1558                         jstring res =  static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetClipboardContentsID ));
1559                         if (curEnv->ExceptionCheck()) {
1560 throw GiwsException::JniCallMethodException(curEnv);
1561 }if (res != NULL) {
1562 
1563 const char *tempString = curEnv->GetStringUTFChars(res, 0);
1564 char * myStringBuffer = new char[strlen(tempString) + 1];
1565 strcpy(myStringBuffer, tempString);
1566 curEnv->ReleaseStringUTFChars(res, tempString);
1567 curEnv->DeleteLocalRef(res);
1568 if (curEnv->ExceptionCheck()) {
1569 delete[] myStringBuffer;
1570                                 throw GiwsException::JniCallMethodException(curEnv);
1571 }
1572 return myStringBuffer;
1573  } else {
1574 curEnv->DeleteLocalRef(res);
1575 return NULL;
1576 }
1577 }
1578 
pasteClipboardIntoConsole(JavaVM * jvm_)1579 void CallScilabBridge::pasteClipboardIntoConsole (JavaVM * jvm_){
1580 
1581 JNIEnv * curEnv = NULL;
1582 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1583 jclass cls = initClass(curEnv);
1584 if ( cls == NULL) {
1585 throw GiwsException::JniCallMethodException(curEnv);
1586 }
1587 
1588 static jmethodID voidpasteClipboardIntoConsoleID = curEnv->GetStaticMethodID(cls, "pasteClipboardIntoConsole", "()V" ) ;
1589 if (voidpasteClipboardIntoConsoleID == NULL) {
1590 throw GiwsException::JniMethodNotFoundException(curEnv, "pasteClipboardIntoConsole");
1591 }
1592 
1593                          curEnv->CallStaticVoidMethod(cls, voidpasteClipboardIntoConsoleID );
1594                         if (curEnv->ExceptionCheck()) {
1595 throw GiwsException::JniCallMethodException(curEnv);
1596 }
1597 }
1598 
copyConsoleSelection(JavaVM * jvm_)1599 void CallScilabBridge::copyConsoleSelection (JavaVM * jvm_){
1600 
1601 JNIEnv * curEnv = NULL;
1602 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1603 jclass cls = initClass(curEnv);
1604 if ( cls == NULL) {
1605 throw GiwsException::JniCallMethodException(curEnv);
1606 }
1607 
1608 static jmethodID voidcopyConsoleSelectionID = curEnv->GetStaticMethodID(cls, "copyConsoleSelection", "()V" ) ;
1609 if (voidcopyConsoleSelectionID == NULL) {
1610 throw GiwsException::JniMethodNotFoundException(curEnv, "copyConsoleSelection");
1611 }
1612 
1613                          curEnv->CallStaticVoidMethod(cls, voidcopyConsoleSelectionID );
1614                         if (curEnv->ExceptionCheck()) {
1615 throw GiwsException::JniCallMethodException(curEnv);
1616 }
1617 }
1618 
emptyClipboard(JavaVM * jvm_)1619 void CallScilabBridge::emptyClipboard (JavaVM * jvm_){
1620 
1621 JNIEnv * curEnv = NULL;
1622 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1623 jclass cls = initClass(curEnv);
1624 if ( cls == NULL) {
1625 throw GiwsException::JniCallMethodException(curEnv);
1626 }
1627 
1628 static jmethodID voidemptyClipboardID = curEnv->GetStaticMethodID(cls, "emptyClipboard", "()V" ) ;
1629 if (voidemptyClipboardID == NULL) {
1630 throw GiwsException::JniMethodNotFoundException(curEnv, "emptyClipboard");
1631 }
1632 
1633                          curEnv->CallStaticVoidMethod(cls, voidemptyClipboardID );
1634                         if (curEnv->ExceptionCheck()) {
1635 throw GiwsException::JniCallMethodException(curEnv);
1636 }
1637 }
1638 
setClipboardContents(JavaVM * jvm_,char const * text)1639 void CallScilabBridge::setClipboardContents (JavaVM * jvm_, char const* text){
1640 
1641 JNIEnv * curEnv = NULL;
1642 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1643 jclass cls = initClass(curEnv);
1644 if ( cls == NULL) {
1645 throw GiwsException::JniCallMethodException(curEnv);
1646 }
1647 
1648 static jmethodID voidsetClipboardContentsjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setClipboardContents", "(Ljava/lang/String;)V" ) ;
1649 if (voidsetClipboardContentsjstringjava_lang_StringID == NULL) {
1650 throw GiwsException::JniMethodNotFoundException(curEnv, "setClipboardContents");
1651 }
1652 
1653 jstring text_ = curEnv->NewStringUTF( text );
1654 if (text != NULL && text_ == NULL)
1655 {
1656 throw GiwsException::JniBadAllocException(curEnv);
1657 }
1658 
1659 
1660                          curEnv->CallStaticVoidMethod(cls, voidsetClipboardContentsjstringjava_lang_StringID ,text_);
1661                         curEnv->DeleteLocalRef(text_);
1662 if (curEnv->ExceptionCheck()) {
1663 throw GiwsException::JniCallMethodException(curEnv);
1664 }
1665 }
1666 
copyFigureToClipBoard(JavaVM * jvm_,int figID)1667 void CallScilabBridge::copyFigureToClipBoard (JavaVM * jvm_, int figID){
1668 
1669 JNIEnv * curEnv = NULL;
1670 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1671 jclass cls = initClass(curEnv);
1672 if ( cls == NULL) {
1673 throw GiwsException::JniCallMethodException(curEnv);
1674 }
1675 
1676 static jmethodID voidcopyFigureToClipBoardjintintID = curEnv->GetStaticMethodID(cls, "copyFigureToClipBoard", "(I)V" ) ;
1677 if (voidcopyFigureToClipBoardjintintID == NULL) {
1678 throw GiwsException::JniMethodNotFoundException(curEnv, "copyFigureToClipBoard");
1679 }
1680 
1681                          curEnv->CallStaticVoidMethod(cls, voidcopyFigureToClipBoardjintintID ,figID);
1682                         if (curEnv->ExceptionCheck()) {
1683 throw GiwsException::JniCallMethodException(curEnv);
1684 }
1685 }
1686 
getScreenResolution(JavaVM * jvm_)1687 int CallScilabBridge::getScreenResolution (JavaVM * jvm_){
1688 
1689 JNIEnv * curEnv = NULL;
1690 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1691 jclass cls = initClass(curEnv);
1692 if ( cls == NULL) {
1693 throw GiwsException::JniCallMethodException(curEnv);
1694 }
1695 
1696 static jmethodID jintgetScreenResolutionID = curEnv->GetStaticMethodID(cls, "getScreenResolution", "()I" ) ;
1697 if (jintgetScreenResolutionID == NULL) {
1698 throw GiwsException::JniMethodNotFoundException(curEnv, "getScreenResolution");
1699 }
1700 
1701                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetScreenResolutionID ));
1702                         if (curEnv->ExceptionCheck()) {
1703 throw GiwsException::JniCallMethodException(curEnv);
1704 }
1705 return res;
1706 
1707 }
1708 
getScreenWidth(JavaVM * jvm_)1709 double CallScilabBridge::getScreenWidth (JavaVM * jvm_){
1710 
1711 JNIEnv * curEnv = NULL;
1712 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1713 jclass cls = initClass(curEnv);
1714 if ( cls == NULL) {
1715 throw GiwsException::JniCallMethodException(curEnv);
1716 }
1717 
1718 static jmethodID jdoublegetScreenWidthID = curEnv->GetStaticMethodID(cls, "getScreenWidth", "()D" ) ;
1719 if (jdoublegetScreenWidthID == NULL) {
1720 throw GiwsException::JniMethodNotFoundException(curEnv, "getScreenWidth");
1721 }
1722 
1723                         jdouble res =  static_cast<jdouble>( curEnv->CallStaticDoubleMethod(cls, jdoublegetScreenWidthID ));
1724                         if (curEnv->ExceptionCheck()) {
1725 throw GiwsException::JniCallMethodException(curEnv);
1726 }
1727 return res;
1728 
1729 }
1730 
getScreenHeight(JavaVM * jvm_)1731 double CallScilabBridge::getScreenHeight (JavaVM * jvm_){
1732 
1733 JNIEnv * curEnv = NULL;
1734 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1735 jclass cls = initClass(curEnv);
1736 if ( cls == NULL) {
1737 throw GiwsException::JniCallMethodException(curEnv);
1738 }
1739 
1740 static jmethodID jdoublegetScreenHeightID = curEnv->GetStaticMethodID(cls, "getScreenHeight", "()D" ) ;
1741 if (jdoublegetScreenHeightID == NULL) {
1742 throw GiwsException::JniMethodNotFoundException(curEnv, "getScreenHeight");
1743 }
1744 
1745                         jdouble res =  static_cast<jdouble>( curEnv->CallStaticDoubleMethod(cls, jdoublegetScreenHeightID ));
1746                         if (curEnv->ExceptionCheck()) {
1747 throw GiwsException::JniCallMethodException(curEnv);
1748 }
1749 return res;
1750 
1751 }
1752 
getScreenDepth(JavaVM * jvm_)1753 int CallScilabBridge::getScreenDepth (JavaVM * jvm_){
1754 
1755 JNIEnv * curEnv = NULL;
1756 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1757 jclass cls = initClass(curEnv);
1758 if ( cls == NULL) {
1759 throw GiwsException::JniCallMethodException(curEnv);
1760 }
1761 
1762 static jmethodID jintgetScreenDepthID = curEnv->GetStaticMethodID(cls, "getScreenDepth", "()I" ) ;
1763 if (jintgetScreenDepthID == NULL) {
1764 throw GiwsException::JniMethodNotFoundException(curEnv, "getScreenDepth");
1765 }
1766 
1767                         jint res =  static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetScreenDepthID ));
1768                         if (curEnv->ExceptionCheck()) {
1769 throw GiwsException::JniCallMethodException(curEnv);
1770 }
1771 return res;
1772 
1773 }
1774 
printFigure(JavaVM * jvm_,int figID,bool postScript,bool displayDialog)1775 bool CallScilabBridge::printFigure (JavaVM * jvm_, int figID, bool postScript, bool displayDialog){
1776 
1777 JNIEnv * curEnv = NULL;
1778 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1779 jclass cls = initClass(curEnv);
1780 if ( cls == NULL) {
1781 throw GiwsException::JniCallMethodException(curEnv);
1782 }
1783 
1784 static jmethodID jbooleanprintFigurejintintjbooleanbooleanjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "printFigure", "(IZZ)Z" ) ;
1785 if (jbooleanprintFigurejintintjbooleanbooleanjbooleanbooleanID == NULL) {
1786 throw GiwsException::JniMethodNotFoundException(curEnv, "printFigure");
1787 }
1788 
1789 jboolean postScript_ = (static_cast<bool>(postScript) ? JNI_TRUE : JNI_FALSE);
1790 
1791 jboolean displayDialog_ = (static_cast<bool>(displayDialog) ? JNI_TRUE : JNI_FALSE);
1792 
1793                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanprintFigurejintintjbooleanbooleanjbooleanbooleanID ,figID, postScript_, displayDialog_));
1794                         if (curEnv->ExceptionCheck()) {
1795 throw GiwsException::JniCallMethodException(curEnv);
1796 }
1797 return (res == JNI_TRUE);
1798 
1799 }
1800 
printFile(JavaVM * jvm_,char const * fileName)1801 bool CallScilabBridge::printFile (JavaVM * jvm_, char const* fileName){
1802 
1803 JNIEnv * curEnv = NULL;
1804 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1805 jclass cls = initClass(curEnv);
1806 if ( cls == NULL) {
1807 throw GiwsException::JniCallMethodException(curEnv);
1808 }
1809 
1810 static jmethodID jbooleanprintFilejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "printFile", "(Ljava/lang/String;)Z" ) ;
1811 if (jbooleanprintFilejstringjava_lang_StringID == NULL) {
1812 throw GiwsException::JniMethodNotFoundException(curEnv, "printFile");
1813 }
1814 
1815 jstring fileName_ = curEnv->NewStringUTF( fileName );
1816 if (fileName != NULL && fileName_ == NULL)
1817 {
1818 throw GiwsException::JniBadAllocException(curEnv);
1819 }
1820 
1821 
1822                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanprintFilejstringjava_lang_StringID ,fileName_));
1823                         curEnv->DeleteLocalRef(fileName_);
1824 if (curEnv->ExceptionCheck()) {
1825 throw GiwsException::JniCallMethodException(curEnv);
1826 }
1827 return (res == JNI_TRUE);
1828 
1829 }
1830 
printString(JavaVM * jvm_,char const * theString,char const * pageHeader)1831 bool CallScilabBridge::printString (JavaVM * jvm_, char const* theString, char const* pageHeader){
1832 
1833 JNIEnv * curEnv = NULL;
1834 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1835 jclass cls = initClass(curEnv);
1836 if ( cls == NULL) {
1837 throw GiwsException::JniCallMethodException(curEnv);
1838 }
1839 
1840 static jmethodID jbooleanprintStringjstringjava_lang_Stringjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "printString", "(Ljava/lang/String;Ljava/lang/String;)Z" ) ;
1841 if (jbooleanprintStringjstringjava_lang_Stringjstringjava_lang_StringID == NULL) {
1842 throw GiwsException::JniMethodNotFoundException(curEnv, "printString");
1843 }
1844 
1845 jstring theString_ = curEnv->NewStringUTF( theString );
1846 if (theString != NULL && theString_ == NULL)
1847 {
1848 throw GiwsException::JniBadAllocException(curEnv);
1849 }
1850 
1851 
1852 jstring pageHeader_ = curEnv->NewStringUTF( pageHeader );
1853 if (pageHeader != NULL && pageHeader_ == NULL)
1854 {
1855 throw GiwsException::JniBadAllocException(curEnv);
1856 }
1857 
1858 
1859                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanprintStringjstringjava_lang_Stringjstringjava_lang_StringID ,theString_, pageHeader_));
1860                         curEnv->DeleteLocalRef(theString_);
1861 curEnv->DeleteLocalRef(pageHeader_);
1862 if (curEnv->ExceptionCheck()) {
1863 throw GiwsException::JniCallMethodException(curEnv);
1864 }
1865 return (res == JNI_TRUE);
1866 
1867 }
1868 
pageSetup(JavaVM * jvm_)1869 bool CallScilabBridge::pageSetup (JavaVM * jvm_){
1870 
1871 JNIEnv * curEnv = NULL;
1872 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1873 jclass cls = initClass(curEnv);
1874 if ( cls == NULL) {
1875 throw GiwsException::JniCallMethodException(curEnv);
1876 }
1877 
1878 static jmethodID jbooleanpageSetupID = curEnv->GetStaticMethodID(cls, "pageSetup", "()Z" ) ;
1879 if (jbooleanpageSetupID == NULL) {
1880 throw GiwsException::JniMethodNotFoundException(curEnv, "pageSetup");
1881 }
1882 
1883                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanpageSetupID ));
1884                         if (curEnv->ExceptionCheck()) {
1885 throw GiwsException::JniCallMethodException(curEnv);
1886 }
1887 return (res == JNI_TRUE);
1888 
1889 }
1890 
requestFocus(JavaVM * jvm_,int objUID)1891 void CallScilabBridge::requestFocus (JavaVM * jvm_, int objUID){
1892 
1893 JNIEnv * curEnv = NULL;
1894 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1895 jclass cls = initClass(curEnv);
1896 if ( cls == NULL) {
1897 throw GiwsException::JniCallMethodException(curEnv);
1898 }
1899 
1900 static jmethodID voidrequestFocusjintintID = curEnv->GetStaticMethodID(cls, "requestFocus", "(I)V" ) ;
1901 if (voidrequestFocusjintintID == NULL) {
1902 throw GiwsException::JniMethodNotFoundException(curEnv, "requestFocus");
1903 }
1904 
1905                          curEnv->CallStaticVoidMethod(cls, voidrequestFocusjintintID ,objUID);
1906                         if (curEnv->ExceptionCheck()) {
1907 throw GiwsException::JniCallMethodException(curEnv);
1908 }
1909 }
1910 
raiseWindow(JavaVM * jvm_,int objID)1911 void CallScilabBridge::raiseWindow (JavaVM * jvm_, int objID){
1912 
1913 JNIEnv * curEnv = NULL;
1914 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1915 jclass cls = initClass(curEnv);
1916 if ( cls == NULL) {
1917 throw GiwsException::JniCallMethodException(curEnv);
1918 }
1919 
1920 static jmethodID voidraiseWindowjintintID = curEnv->GetStaticMethodID(cls, "raiseWindow", "(I)V" ) ;
1921 if (voidraiseWindowjintintID == NULL) {
1922 throw GiwsException::JniMethodNotFoundException(curEnv, "raiseWindow");
1923 }
1924 
1925                          curEnv->CallStaticVoidMethod(cls, voidraiseWindowjintintID ,objID);
1926                         if (curEnv->ExceptionCheck()) {
1927 throw GiwsException::JniCallMethodException(curEnv);
1928 }
1929 }
1930 
useCanvasForDisplay(JavaVM * jvm_,bool onOrOff)1931 void CallScilabBridge::useCanvasForDisplay (JavaVM * jvm_, bool onOrOff){
1932 
1933 JNIEnv * curEnv = NULL;
1934 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1935 jclass cls = initClass(curEnv);
1936 if ( cls == NULL) {
1937 throw GiwsException::JniCallMethodException(curEnv);
1938 }
1939 
1940 static jmethodID voiduseCanvasForDisplayjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "useCanvasForDisplay", "(Z)V" ) ;
1941 if (voiduseCanvasForDisplayjbooleanbooleanID == NULL) {
1942 throw GiwsException::JniMethodNotFoundException(curEnv, "useCanvasForDisplay");
1943 }
1944 
1945 jboolean onOrOff_ = (static_cast<bool>(onOrOff) ? JNI_TRUE : JNI_FALSE);
1946 
1947                          curEnv->CallStaticVoidMethod(cls, voiduseCanvasForDisplayjbooleanbooleanID ,onOrOff_);
1948                         if (curEnv->ExceptionCheck()) {
1949 throw GiwsException::JniCallMethodException(curEnv);
1950 }
1951 }
1952 
useCanvasForDisplay(JavaVM * jvm_)1953 bool CallScilabBridge::useCanvasForDisplay (JavaVM * jvm_){
1954 
1955 JNIEnv * curEnv = NULL;
1956 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1957 jclass cls = initClass(curEnv);
1958 if ( cls == NULL) {
1959 throw GiwsException::JniCallMethodException(curEnv);
1960 }
1961 
1962 static jmethodID jbooleanuseCanvasForDisplayID = curEnv->GetStaticMethodID(cls, "useCanvasForDisplay", "()Z" ) ;
1963 if (jbooleanuseCanvasForDisplayID == NULL) {
1964 throw GiwsException::JniMethodNotFoundException(curEnv, "useCanvasForDisplay");
1965 }
1966 
1967                         jboolean res =  static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanuseCanvasForDisplayID ));
1968                         if (curEnv->ExceptionCheck()) {
1969 throw GiwsException::JniCallMethodException(curEnv);
1970 }
1971 return (res == JNI_TRUE);
1972 
1973 }
1974 
scilabAboutBox(JavaVM * jvm_)1975 void CallScilabBridge::scilabAboutBox (JavaVM * jvm_){
1976 
1977 JNIEnv * curEnv = NULL;
1978 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1979 jclass cls = initClass(curEnv);
1980 if ( cls == NULL) {
1981 throw GiwsException::JniCallMethodException(curEnv);
1982 }
1983 
1984 static jmethodID voidscilabAboutBoxID = curEnv->GetStaticMethodID(cls, "scilabAboutBox", "()V" ) ;
1985 if (voidscilabAboutBoxID == NULL) {
1986 throw GiwsException::JniMethodNotFoundException(curEnv, "scilabAboutBox");
1987 }
1988 
1989                          curEnv->CallStaticVoidMethod(cls, voidscilabAboutBoxID );
1990                         if (curEnv->ExceptionCheck()) {
1991 throw GiwsException::JniCallMethodException(curEnv);
1992 }
1993 }
1994 
fireClosingFinished(JavaVM * jvm_,int figUID)1995 void CallScilabBridge::fireClosingFinished (JavaVM * jvm_, int figUID){
1996 
1997 JNIEnv * curEnv = NULL;
1998 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1999 jclass cls = initClass(curEnv);
2000 if ( cls == NULL) {
2001 throw GiwsException::JniCallMethodException(curEnv);
2002 }
2003 
2004 static jmethodID voidfireClosingFinishedjintintID = curEnv->GetStaticMethodID(cls, "fireClosingFinished", "(I)V" ) ;
2005 if (voidfireClosingFinishedjintintID == NULL) {
2006 throw GiwsException::JniMethodNotFoundException(curEnv, "fireClosingFinished");
2007 }
2008 
2009                          curEnv->CallStaticVoidMethod(cls, voidfireClosingFinishedjintintID ,figUID);
2010                         if (curEnv->ExceptionCheck()) {
2011 throw GiwsException::JniCallMethodException(curEnv);
2012 }
2013 }
2014 
registerSwingView(JavaVM * jvm_)2015 void CallScilabBridge::registerSwingView (JavaVM * jvm_){
2016 
2017 JNIEnv * curEnv = NULL;
2018 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
2019 jclass cls = initClass(curEnv);
2020 if ( cls == NULL) {
2021 throw GiwsException::JniCallMethodException(curEnv);
2022 }
2023 
2024 static jmethodID voidregisterSwingViewID = curEnv->GetStaticMethodID(cls, "registerSwingView", "()V" ) ;
2025 if (voidregisterSwingViewID == NULL) {
2026 throw GiwsException::JniMethodNotFoundException(curEnv, "registerSwingView");
2027 }
2028 
2029                          curEnv->CallStaticVoidMethod(cls, voidregisterSwingViewID );
2030                         if (curEnv->ExceptionCheck()) {
2031 throw GiwsException::JniCallMethodException(curEnv);
2032 }
2033 }
2034 
2035 }
2036