1 11 package org.eclipse.equinox.launcher; 12 13 14 20 public class JNIBridge { 21 private native void _set_exit_data(String sharedId, String data); 23 private native void _update_splash(); 24 private native long _get_splash_handle(); 25 private native void _show_splash(String bitmap); 26 private native void _takedown_splash(); 27 28 private native int OleInitialize(int reserved); 29 private native void OleUninitialize(); 30 31 private String library; 32 private boolean libraryLoaded = false; 33 public JNIBridge(String library) { 34 this.library = library; 35 } 36 37 private void loadLibrary() { 38 if (library != null) { 39 try { 40 if (library.indexOf("wpf") != -1) { int idx = library.indexOf("eclipse_"); if (idx != -1) { 43 String comLibrary = library.substring(0, idx) + "com_"; comLibrary += library.substring(idx + 8, library.length()); 45 Runtime.getRuntime().load(comLibrary); 46 OleInitialize(0); 47 } 48 } 49 Runtime.getRuntime().load(library); 50 } catch (UnsatisfiedLinkError e) { 51 } 53 } 54 libraryLoaded = true; 55 } 56 57 public boolean setExitData(String sharedId, String data) { 58 try { 59 _set_exit_data(sharedId, data); 60 return true; 61 } catch (UnsatisfiedLinkError e) { 62 if(!libraryLoaded){ 63 loadLibrary(); 64 return setExitData(sharedId, data); 65 } 66 return false; 67 } 68 } 69 70 public boolean showSplash(String bitmap) { 71 try { 72 _show_splash(bitmap); 73 return true; 74 } catch (UnsatisfiedLinkError e) { 75 if(!libraryLoaded){ 76 loadLibrary(); 77 return showSplash(bitmap); 78 } 79 return false; 80 } 81 } 82 83 public boolean updateSplash() { 84 try { 85 _update_splash(); 86 return true; 87 } catch (UnsatisfiedLinkError e) { 88 if(!libraryLoaded){ 89 loadLibrary(); 90 return updateSplash(); 91 } 92 return false; 93 } 94 } 95 96 public long getSplashHandle() { 97 try { 98 return _get_splash_handle(); 99 } catch (UnsatisfiedLinkError e) { 100 if(!libraryLoaded){ 101 loadLibrary(); 102 return getSplashHandle(); 103 } 104 return -1; 105 } 106 } 107 108 public boolean takeDownSplash() { 109 try { 110 _takedown_splash(); 111 return true; 112 } catch (UnsatisfiedLinkError e) { 113 if(!libraryLoaded){ 114 loadLibrary(); 115 return takeDownSplash(); 116 } 117 return false; 118 } 119 } 120 121 public boolean uninitialize() { 122 if (libraryLoaded && library != null) { 123 if (library.indexOf("wpf") != -1) { try { 125 OleUninitialize(); 126 } catch (UnsatisfiedLinkError e) { 127 return false; 129 } 130 } 131 } 132 return true; 133 } 134 } 135 | Popular Tags |