eclipse RCP財(cái)務(wù)管理程序 發(fā)帖時(shí)間: 06-01-02, 02:57 starshus 寫完程序,最大的感想就覺得RCP平臺(tái)太優(yōu)秀了,真的是喜歡eclipse. 完整Rcp程序下載地址是:http:///files/10185194/FinancePro1.0.zip.html 歡迎大家下載,幫我找找問題:P
中間遇到點(diǎn)小問題,不過都很快就解決了,把幾個(gè)剛弄懂的小知識(shí)點(diǎn)都記下來,方便以后復(fù)習(xí). 1.使用Observer模式時(shí),在某個(gè)UI listener dispose時(shí)把它注銷掉. 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() 添加一個(gè)View,它帶有標(biāo)題,可以關(guān)掉、移動(dòng)、增大、縮小. IPageLayout.addStandaloneView()添加一個(gè)StandalongView,可以關(guān)掉標(biāo)題,所以可以設(shè)定不能關(guān)掉、移動(dòng)、增大、縮小.當(dāng)程序只有一個(gè)view時(shí)這樣做很好. 4.打開關(guān)閉程序時(shí),自動(dòng)保存perspective的views位置: 在自己的WorkbenchAdvisor類里面的initialize()方法里加入這樣一句: configurer.setSaveAndRestore(true); 象下面: public void initialize(IWorkbenchConfigurer configurer) { configurer.setSaveAndRestore(true); } 5.關(guān)于用eclipse Debug的小技巧 這次好好爽了一下eclipse的debug功能,以前連斷點(diǎn)都不用,現(xiàn)在想起來不知道浪費(fèi)了多少時(shí)間... 1)遇到某個(gè)錯(cuò)誤時(shí),設(shè)置eclipse自己找到出錯(cuò)的地方: 比如遇到這種錯(cuò)誤輸出: Unhandled event loop exception Reason: java.lang.NullPointerException 那么 Run > Add Java Exception Breakpoint... 選NullPointerException,再用debug運(yùn)行程序,eclipse會(huì)自己找到為null的變量. 2)設(shè)置斷點(diǎn): 比如上面的情況,找到為null的變量后,在那個(gè)程序第一行旁邊雙擊就可以設(shè)置一個(gè)斷點(diǎn)了.然后,用Debugger Stepping功能一步一步觀察變量到底為什么是null了. 6.在寫程序的時(shí)候我想了一個(gè)如何判斷在當(dāng)前活動(dòng)的workbench下某個(gè)view是否是打開的,可以用這個(gè)方法: 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; } 因?yàn)槭亲约簩懙?,不知道有沒有更簡(jiǎn)單的方法. 7.關(guān)于RCP的大致結(jié)構(gòu),看到這副圖思路挺清楚的.

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

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