Commit 1f5f391e9b93ca251803ff48c62260f7c5866118
1 parent
0c2eb328
Exists in
master
and in
5 other branches
Implementando teste de proteção em java
Showing
5 changed files
with
79 additions
and
3 deletions
Show diff stats
src/java/field.cc
| @@ -91,3 +91,42 @@ JNIEXPORT jint JNICALL Java_pw3270_terminal_get_1next_1unprotected(JNIEnv *env, | @@ -91,3 +91,42 @@ JNIEXPORT jint JNICALL Java_pw3270_terminal_get_1next_1unprotected(JNIEnv *env, | ||
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | } | 93 | } |
| 94 | + | ||
| 95 | +JNIEXPORT jint JNICALL Java_pw3270_terminal_get_1is_1protected(JNIEnv *env, jobject obj, jint baddr) { | ||
| 96 | + | ||
| 97 | + jint rc = -1; | ||
| 98 | + | ||
| 99 | + try { | ||
| 100 | + | ||
| 101 | + rc = java::getHandle(env,obj)->get_is_protected((int) baddr); | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + } catch(std::exception &e) { | ||
| 105 | + | ||
| 106 | + env->ThrowNew(env->FindClass("java/lang/Exception"), e.what()); | ||
| 107 | + | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + return rc; | ||
| 111 | + | ||
| 112 | + | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +JNIEXPORT jint JNICALL Java_pw3270_terminal_get_1is_1protected_1at(JNIEnv *env, jobject obj, jint row, jint col) { | ||
| 116 | + | ||
| 117 | + jint rc = -1; | ||
| 118 | + | ||
| 119 | + try { | ||
| 120 | + | ||
| 121 | + rc = java::getHandle(env,obj)->get_is_protected_at((int) row, (int) col); | ||
| 122 | + | ||
| 123 | + } catch(std::exception &e) { | ||
| 124 | + | ||
| 125 | + env->ThrowNew(env->FindClass("java/lang/Exception"), e.what()); | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + return rc; | ||
| 130 | + | ||
| 131 | + | ||
| 132 | +} |
src/java/plugin.cc
| @@ -235,11 +235,11 @@ | @@ -235,11 +235,11 @@ | ||
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | int get_is_protected(int baddr = -1) { | 237 | int get_is_protected(int baddr = -1) { |
| 238 | - return lib3270_is_protected(hSession,baddr); | 238 | + return lib3270_get_is_protected(hSession,baddr); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | int get_is_protected_at(int row, int col) { | 241 | int get_is_protected_at(int row, int col) { |
| 242 | - return lib3270_is_protected_at(hSession,row,col); | 242 | + return lib3270_get_is_protected_at(hSession,row,col); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | int set_copy(const char *text) { | 245 | int set_copy(const char *text) { |
| @@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
| 1 | + | ||
| 2 | +import pw3270.*; | ||
| 3 | + | ||
| 4 | +public class prot | ||
| 5 | +{ | ||
| 6 | + public static void main (String[] args) | ||
| 7 | + { | ||
| 8 | + System.out.println("Begin"); | ||
| 9 | + | ||
| 10 | + try { | ||
| 11 | + | ||
| 12 | + terminal host = new terminal(); | ||
| 13 | + | ||
| 14 | + host.popup_dialog(0,"19,39","Testing","Position 19,39 is " + (host.get_is_protected_at(19,39) == 0 ? "un" : "") + "protected"); | ||
| 15 | + host.popup_dialog(0,"20,39","Testing","Position 19,39 is " + (host.get_is_protected_at(20,39) == 0 ? "un" : "") + "protected"); | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + } catch( Exception e ) { | ||
| 19 | + | ||
| 20 | + System.out.println("Error: " + e); | ||
| 21 | + | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + System.out.println("End"); | ||
| 25 | + } | ||
| 26 | +}; |
src/java/terminal.java
| @@ -316,6 +316,17 @@ public class terminal | @@ -316,6 +316,17 @@ public class terminal | ||
| 316 | public native int get_is_protected(int baddr); | 316 | public native int get_is_protected(int baddr); |
| 317 | 317 | ||
| 318 | /** | 318 | /** |
| 319 | + * Check if the address is protected. | ||
| 320 | + * | ||
| 321 | + * @param row Screen row. | ||
| 322 | + * @param col Screen col. | ||
| 323 | + * | ||
| 324 | + * @return Protect state. | ||
| 325 | + * | ||
| 326 | + */ | ||
| 327 | + public native int get_is_protected_at(int row, int col); | ||
| 328 | + | ||
| 329 | + /** | ||
| 319 | * Get next field address. | 330 | * Get next field address. |
| 320 | * | 331 | * |
| 321 | * @return Address of the next field. | 332 | * @return Address of the next field. |
ui/80javasamples.xml
| @@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
| 38 | <menuitem name='java_except' action='java' label='Exception test' src='except'/> | 38 | <menuitem name='java_except' action='java' label='Exception test' src='except'/> |
| 39 | <menuitem name='java_output' action='java' label='Output test' src='out'/> | 39 | <menuitem name='java_output' action='java' label='Output test' src='out'/> |
| 40 | <menuitem name='java_popup' action='java' label='Popup test' src='popup'/> | 40 | <menuitem name='java_popup' action='java' label='Popup test' src='popup'/> |
| 41 | + <menuitem name='java_protect' action='java' label='Protection test' src='prot'/> | ||
| 41 | </menu> | 42 | </menu> |
| 42 | </menubar> | 43 | </menubar> |
| 43 | </ui> | 44 | </ui> |
| 44 | - |