eclipse RCP财务管理程序 发帖时间: 06-01-02, 02:57 starshus 写完程序,最大的感想就觉得RCP平台太优秀了,真的是喜欢eclipse. 完整Rcp程序下载地址是:http:///files/10185194/FinancePro1.0.zip.html 欢迎大家下载,帮我找找问题:P
中间遇到点小问题,不过都很快就解决了,把几个刚弄懂的小知识点都记下来,方便以后复习. 1.使用Observer模式时,在某个UI listener dispose时把它注销掉. 2.WorkbenchAdvisor和WorkbenchWindowAdvisor的功能: As the name implies, a WorkbenchAdvisor tells the Workbench how to behavehow to draw, what to draw, etc. Window advisors are consulted at various points in the lifecycle of a window (e.g., preWindowOpen() and postWindowCreate()) and have the opportunity to control the creation of the window's contents. 3.IPageLayout.addView() 添加一个View,它带有标题,可以关掉、移动、增大、缩小. IPageLayout.addStandaloneView()添加一个StandalongView,可以关掉标题,所以可以设定不能关掉、移动、增大、缩小.当程序只有一个view时这样做很好. 4.打开关闭程序时,自动保存perspective的views位置: 在自己的WorkbenchAdvisor类里面的initialize()方法里加入这样一句: configurer.setSaveAndRestore(true); 象下面: public void initialize(IWorkbenchConfigurer configurer) { configurer.setSaveAndRestore(true); } 5.关于用eclipse Debug的小技巧 这次好好爽了一下eclipse的debug功能,以前连断点都不用,现在想起来不知道浪费了多少时间... 1)遇到某个错误时,设置eclipse自己找到出错的地方: 比如遇到这种错误输出: Unhandled event loop exception Reason: java.lang.NullPointerException 那么 Run > Add Java Exception Breakpoint... 选NullPointerException,再用debug运行程序,eclipse会自己找到为null的变量. 2)设置断点: 比如上面的情况,找到为null的变量后,在那个程序第一行旁边双击就可以设置一个断点了.然后,用Debugger Stepping功能一步一步观察变量到底为什么是null了. 6.在写程序的时候我想了一个如何判断在当前活动的workbench下某个view是否是打开的,可以用这个方法: private boolean isViewOpened(String viewID){ IViewReference[] viewReference = FinancePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences(); //IViewReference[] viewReference = //getSite().getWorkbenchWindow().getActivePage().getViewReferences(); for (int i = 0; i<viewReference.length; i++){ String vp = viewReference[i].getId(); if (vp.equals("starshus.csdn.blog.finance.views.ProjectTableView")){ return true; } } return false; } 因为是自己写的,不知道有没有更简单的方法. 7.关于RCP的大致结构,看到这副图思路挺清楚的.

8.WorkbenchWindow, the WorkbenchWindowAdvisor, and the ActionBarAdvisor的UML顺序图,如下所示:

ActionBarAdvisor是用来产生MenuBar和ToolBar的Action的,因为实际程序中Action起码上百个,它可以把他们方便的分开管理. ActionBarAdvisor.makeActions()是在createWindowContents()之前调用的,而createWindowContents()是用来创建WorkbenchWindow的组件,所以不能在ActionBarAdvisor里生成的action中调用任何menu或window.
9. TableTree已经不建议使用了,我本来一直不想换,后来还是一狠心换用tree写成TableTree的样子 10.制作Product 在工作台里运行一点问题都没有,在导出完整的RCP Product时提示缺少插件,但是我花了不少时间,错误是eclipse的run configurations那里,在产生plugin.product文件时,要好好检查Eclipse Application的Configuration.
|