Note: Eclipse rap rich client Development Summary-a series of articles are transplanted from my iteye blog. Later will directly update the http://jlins.iteye.com/
Normally, rap program development is generally completed under win, and then tested under tomcat, but the final release of the program is generally on Linux Aix. At this time, problems may occur, the following two problems are the problems we have encountered during development. Let's share them with you;
1. Image path
This is the most common method, that is, loading images in rap for display. At first we used the following code:
public static String getRoot() { String path = null ; try { path = FileLocator.toFileURL (Platform.getBundle (Activator. PLUGIN_ID ).getEntry( "" )).getPath(); path = path.substring(path.indexOf( "/" ) + 1, path.length()); } catch (Exception e) { log .error( "getRoot method :" , e); } return path; }
To obtain the path of the system. But when the program is transplanted to Linux and Aix, it finds that all the image paths are invalid. You can use the following method for addressing to obtain the image.
/*** Get image ** @ Param filename * image name * @ return first searches for the cached object. If yes, the image is directly returned. If no, the image is loaded into the cache, transmit the image from the cache to call */public static image getimage (string filename) {bundle = platform. getbundle ("telecomui"); Url url = bundle. getentry ("icons"); try {url = platform. aslocalurl (URL);} catch (exception e) {} image = registry. get (filename); If (null! = Image) {return image;} else {URL fullpathstring = bundle. getentry ("icons/" + filename); imagedescriptor des = imagedescriptor. createfromurl (fullpathstring); registry. put (filename, des); Return imagedescriptor. createfromurl (fullpathstring ). createimage ();}}
2. Obtain the screen resolution
This is because you need to center some pop-up components and obtain the system resolution.
At the beginning, we used the following method;
screenH = Toolkit.getDefaultToolkit().getScreenSize ().height; screenW = Toolkit.getDefaultToolkit().getScreenSize ().width;
The above code is correct under the window, but an error is reported under Linux and Aix and cannot be found.
Sun. AWT. x11.xtoolkit class
You can use the following method to obtain the screen resolution:
DisPlay.getDefault().getClientArea();
3. Others will be added if any incompatibility is found