eclipse RCP財務管理程序 發(fā)帖時間: 06-01-02, 02:57 starshus 寫完程序,最大的感想就覺得RCP平臺太優(yōu)秀了,真的是喜歡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功能,以前連斷點都不用,現(xiàn)在想起來不知道浪費了多少時間... 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的大致結(jié)構(gòu),看到這副圖思路挺清楚的.

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

ActionBarAdvisor是用來產(chǎn)生MenuBar和ToolBar的Action的,因為實際程序中Action起碼上百個,它可以把他們方便的分開管理. ActionBarAdvisor.makeActions()是在createWindowContents()之前調(diào)用的,而createWindowContents()是用來創(chuàng)建WorkbenchWindow的組件,所以不能在ActionBarAdvisor里生成的action中調(diào)用任何menu或window.
9. TableTree已經(jīng)不建議使用了,我本來一直不想換,后來還是一狠心換用tree寫成TableTree的樣子 10.制作Product 在工作臺里運行一點問題都沒有,在導出完整的RCP Product時提示缺少插件,但是我花了不少時間,錯誤是eclipse的run configurations那里,在產(chǎn)生plugin.product文件時,要好好檢查Eclipse Application的Configuration.
|