`
snoopy7713
  • 浏览: 1124273 次
  • 性别: Icon_minigender_2
  • 来自: 火星郊区
博客专栏
Group-logo
OSGi
浏览量:0
社区版块
存档分类
最新评论

Eclipse rcp/rap 开发经验总结(10) -Rap不同系统间的差异和处理方式

    博客分类:
  • RAP
阅读更多

平常进行 rap 程序开发一般都是在 win 下面完成 , 然后在 tomcat 下面测试 , 但是程序最终发布一般都是在 linux  aix 上面 , 这个时候就有能会出现一下问题,下面 2 个问题是我们把在开发中真是出现的问题,与大家一起分享下 ;

1、   图片路径

这个是最常用的方法,就是在 rap 中加载图片进行显示,刚开始我们使用的是如下代码

 

Java代码  收藏代码
  1. public   static  String getRoot() {  
  2.         String path = null  ;  
  3.         try  {  
  4.      path = FileLocator.toFileURL (Platform.getBundle (Activator. PLUGIN_ID ).getEntry( ""  )).getPath();  
  5.      path = path.substring(path.indexOf( "/"  ) +  1 , path.length());  
  6.         }  
  7.         catch  (Exception e) {  
  8.            log .error( "getRoot method :"  , e);  
  9.         }  
  10.         return  path;  
  11.     }  

 

来获得系统的跟路径 . 但是当程序在移植到 linux aix 上面的时候发现图片路径全部失效 . 可以使用如下方式进行寻址来获得图片。

Java代码  收藏代码
  1. /**  
  2.      * 获取图片  
  3.      * @param fileName  
  4.      *            图片的名称  
  5.      * @return 先从缓存对象中查找,若有直接返回,若没有,则将图片加载到缓存中,在从缓存中将图片传给调用着  
  6.      */   
  7.   
  8.     public   static  Image getImage(String fileName) {  
  9.         Bundle bundle = Platform.getBundle ( "TelecomUI"  );  
  10.         URL url = bundle.getEntry( "icons"  );  
  11.         try  {  
  12.             url = Platform.asLocalURL (url) ;  
  13.         }  
  14.         catch  (Exception e) {  
  15.         }  
  16.         Image image = registry .get(fileName);  
  17.         if  (  null  != image) {  
  18.             return  image;  
  19.         }  
  20.         else  {  
  21.             URL fullPathString = bundle.getEntry( "icons/"  + fileName);  
  22.             ImageDescriptor des = ImageDescriptor.createFromURL (fullPathString);  
  23.             registry .put(fileName, des);  
  24.             return  ImageDescriptor.createFromURL (fullPathString).createImage();  
  25.         }  
  26.     }   

 

 

 

2、   获得屏幕的分辨率

因为需要把一些弹出的组件居中显示 , 这个时候就需要获得系统的分辨率

刚开始我们使用的方法如下;

Java代码  收藏代码
  1. screenH = Toolkit.getDefaultToolkit().getScreenSize ().height;  
  2.         screenW = Toolkit.getDefaultToolkit().getScreenSize ().width;   

 

 

上面这段代码在 window 下面是没有问题的 , 可是到了 linux aix 下面就报错了 , 找不到

sun.awt.X11.XToolkit

 

可以采用如下方式来获得屏幕的分辨率     

Java代码  收藏代码
  1. DisPlay.getDefault().getClientArea();  

 

 

3、   其他如果有发现不兼容会陆续补充

分享到:
评论

相关推荐

    eclipse-rcp-2022-06-R-linux-gtk-x86_64.tar.gz

    Eclipse IDE for RCP and RAP Developers(eclipse-rcp-2022-06-R-linux-gtk-x86_64.tar.gz) 适用于Linux x86_64: A complete set of tools for developers who want to create Eclipse plug-ins, Rich Client ...

    eclipse-rcp-2022-06-R-win32-x86_64.zip

    Eclipse IDE for RCP and RAP Developers(eclipse-rcp-2022-06-R-win32-x86_64.zip) 适用于Windows x86_64: A complete set of tools for developers who want to create Eclipse plug-ins, Rich Client ...

    eclipse-rcp-2022-06-R-linux-gtk-aarch64.tar.gz

    Eclipse IDE for RCP and RAP Developers(eclipse-rcp-2022-06-R-linux-gtk-aarch64.tar.gz) 适用于Linux aarch64: A complete set of tools for developers who want to create Eclipse plug-ins, Rich Client ...

    eclipse-rcp-2022-06-R-macosx-cocoa-x86_64.dmg

    Eclipse IDE for RCP and RAP Developers(eclipse-rcp-2022-06-R-macosx-cocoa-x86_64.dmg) 适用于macOS x86_64: A complete set of tools for developers who want to create Eclipse plug-ins, Rich Client ...

    eclipse-rcp-2022-06-R-macosx-cocoa-aarch64.dmg

    Eclipse IDE for RCP and RAP Developers(eclipse-rcp-2022-06-R-macosx-cocoa-aarch64.dmg) 适用于macOS aarch64: A complete set of tools for developers who want to create Eclipse plug-ins, Rich Client ...

    eclipse 2020-06 国际化资源包

    Eclipse IDE for RCP and RAP Developers (includes Incubating components) Version: 2020-06 (4.16.0) Build id: 20200615-1200

    eclipse-rcp-2022-06-R-linux-gtk-x86_64.tar

    Eclipse IDE for RCP and RAP linux x86_64 适用于 RCP 和 RAP 开发的工具,需要JDK11及以上运行环境。

    eclipse-rcp-galileo-SR2-win32.zip

    Eclipse For RCP and RAP Developers开发包主要针对开发Eclipse插件,Eclipse RCP(富客户端应用程序),RAP(富客户端ajax应用程序)的程序员,还包含CVS、Mylyn和xml编辑器,EGit分布式版本控制等插件。...

    Instant Eclipse 4 RCP Development How-to.pdf

    Instant Eclipse 4 RCP Development How-to 不错的一本书

    Eclipse RAP2.1部署到Tomcat总结

    本人只会用RCP开发个C/S的程序,最近看到RAP项目想试一下,在百度上看了很多文章关于如何部署RAP到Tomcat,有些文章已经过时的了,还是没能理解清楚,最后弄了2天时间,搞来搞去没办法调试出来,最后都想放弃了。...

    Eclipse Rich Ajax Platform: Bringing Rich Client to the Web

    Eclipse Rich Ajax Platform is the first book on the new Eclipse RAP, and it introduces the required RCP and OSG/i concepts used by Eclipse RAP. This firstPress title demonstrates the functionality ...

    java源码剖析-maracas:Maracas是用Rascal编写的源代码和字节码分析框架,旨在支持JavaAPI和客户端代码的共同发展。

    RCP和RAP。 从其更新站点https://update.rascal-mpl.org/unstable安装不稳定版本的Rascal插件。 单击以获取更多信息。 从其中克隆Rascal项目java-build-manager并将其导入到您的工作空间中。 去! 准备好环境后: 将...

    CodeMirror-Eclipse:CodeMirror-Eclipse

    CodeMirror Eclipse 使您能够在三个上下文中使用 codemirror:Eclipse SWT、RCP 和 RAP。 它在 SWT 浏览器中嵌入了 javascript codemirror 编辑器。 它提供了几个功能: 仅使用带有 SWT/RWT 的 codemirror。 这是...

    archiv-editor

    安装 Eclipse RCP/RAP 发行版。 克隆 git,即从 archiv-editor.git 导入所有项目 转到插件 org.bbaw.pdr.ae.standalone,在 Product-Editor (PDE-Tools) 中打开 Product-Configuration 文件 org.bbaw.pdr.ae....

    packages:构建Enide 2015和AjsIDE软件包

    例如,从Git存储库根目录开始的以下命令将针对同时发布暂存p2存储库构建RCP / RAP软件包: mvn clean verify -Pepp.package.rcp 此版本在两个位置创建输出: tar.gz / zip归档文件,其中的软件包位于archive/和 ...

    java在线安装包.rar

    可以直接安装 官方地址:http://www.eclipse.org/downloads/ ...Eclipse IDE for RCP and RAP Developers Eclipse Modeling Tools Eclipse IDE for Scientific Computing Eclipse IDE for Scout Developers

    eclipse4book:Eclipse 4书

    Eclipse 4书 这是来自vogella GmbH和的Eclipse RCP培训课程的示例代码。运行应用程序克隆项目并将所有项目导入Eclipse IDE。 然后打开目标平台项目的target-platform.target文件,并将此目标定义设置为工作空间的...

Global site tag (gtag.js) - Google Analytics