jbuilder下swing應用開發移植到eclipse+visual editor的實踐

來源:互聯網
上載者:User
ABC架構項目從JBuilderX遷移到eclipse3.1上過程報告

現在的ABC架構的基金財務系統的開發環境是基於JBuilder的,根據JBuilder的目前水平和以後的發展前景來看,均不樂觀。因此建議將該abcss工程遷移到eclipse上。著手實施此過程:一,使用eclipse匯入Jbuilder的工程,具體做法是建立一個Java工程,然後將jbuilder的檔案匯入到建立的java工程中。有一些檔案jbuilder工程專用的,我們可以將其刪掉,abcss.jpx、abcss.jpx.local等可以都刪除掉。二,匯入eclipse後,build workspace時會提示一堆錯誤,是因為缺少兩個jar包,這兩個jar包在jbuilder下是不報的。一個是crimson.jar,這個是因為有一個java檔案匯入了這個包解析xml但是並沒有使用;還有一個是javaws.jar,這個jar包是使用web start時使用的,這個jar包可以從“D:/Java/jre1.5.0/lib”中找到,在jdk5.0以後,安裝jre並不會建立web start的表徵圖了,但jar包仍然還在。三,在匯入上面的兩個jar包後,程式編譯應該基本上沒有問題了。接下來我們就需要在eclipse中進行java swing程式的編輯了,首推的外掛程式是 visual editor(http://www.eclipse.org/vep/WebContent/main.php)因為這個外掛程式是eclipse項目中的,而且功能強大,可以編輯swing、awt、swt等程式。從上面的網站下載ve後,建議使用ve1.1以上的版本,按照eclipse外掛程式安裝的方法進行安裝即可,需要注意的是需要安裝EMF和GEF架構。安裝後的外觀如所示,開啟類的時候,第一次通過Open With->Visual Editor即可開啟可視化編輯視窗,開啟可視化視窗後,可以通過open view開啟java bean和properties的view來查看視窗的控制項和屬性,並且可以通過托拽調整控制項的順序。具體使用方法請參見VE的使用教程。 四,我們從開啟的視窗中是看不到ABC的組件,我們有兩種方式可以使用,一種是通過浮動畫板上的”Choose bean…”按鈕來選擇要使用的對象,這樣比較麻煩,並且對於新手還需要記對象的名字;另一種方式是可以定製顯示一個浮動面板的分類。在這裡我們使用浮動面板分類並輔以choose bean來實現。五,建立新的浮動面板分類。因為我們已經寫好了bean和beaninfo,這樣我們可以複用這些資源來建立一個外掛程式項目。外掛程式項目中包括plugin.xml、ABC.xmi、ABC20.jar、META-INF、icons等項目,可以見附件(com.abc.ABC.rar)。接下來主要說明外掛程式配置的內容。Plugin.xml<?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><plugin>    <extension         point="org.eclipse.jdt.ui.classpathContainerPage">      <classpathContainerPage            name="ABC Library"            class="org.eclipse.ve.internal.java.wizard.RegisteredClasspathContainerWizardPage"            id="com.abc.ABCContainer"> 類容器頁的名字      </classpathContainerPage>   </extension>       <extension         point="org.eclipse.jdt.core.classpathContainerInitializer">      <classpathContainerInitializer            class="org.eclipse.ve.internal.java.core.RegisteredClasspathContainerInitializer"            id="com.abc.ABCContainer">      </classpathContainerInitializer>   </extension>       <extension         point="org.eclipse.ve.java.core.registrations"> 擴充點,註冊了需要的jar包,這裡可以註冊多個,描述符的名字就是項目的build path 中add library 中的庫的名字,需要在項目中添加library才會出現ABC components的畫板分類      <registration            container="com.abc.ABCContainer"            description="ABC Library">         <library runtime="ABC20.jar"/>      </registration>   </extension>       <extension         point="org.eclipse.ve.java.core.contributors"> 指定了畫板ABC容器使用的分類XMI(分頁檔)      <palette            container="com.abc.ABCContainer"            categories="ABC.xmi"/>   </extension>      <extension         point="org.eclipse.jem.beaninfo.registrations">      <registration            container="com.abc.ABCContainer">      </registration>         </extension> </plugin> ABC.xmi檔案的內容:這是其中一個配置片斷<xmi:XMI xmi:version=”2.0” xmlns:xmi=”http://www.omg.org/XMI” xmlns:ecore=”http://www.eclipse.org/emf/2002/Ecore” xmlns:palette=”http:///org/eclipse/ve/internal/cde/palette.ecore” xmlns:utility=”http:///org/eclipse/ve/internal/cde/utility.ecore”>       <palette:CategoryCmp xmi:id=”swtCat0”>              <categoryLabel xsi:type=”utility:ConstantString” string=”ABC Component” />顯示在面板中的分類的名字              <!--EButton -->              <cmpGroups xsi:type="palette:GroupCmp">              <cmpEntries xsi:type="palette:AnnotatedCreationEntry" xmi:id="entry1"每個項目都要求不一樣的xmi:id icon16Name="platform:/plugin/org.eclipse.ve.jfc/icons/full/clcl16/button_obj.gif">表徵圖的位置/plugin/org.eclipse.ve.jfc指的是外掛程式的plugin的ID,不是路徑,full後面才是路徑,這個可以從協助中的外掛程式明細中看到。可以在ABCPlugin.java中設定圖片路徑                            <objectCreationEntry xsi:type="palette:EMFCreationToolEntry" creationClassURI="java:/com.abc.ermsuite.platform.framework.looks.swing#EButton" />包的路徑和類名,用#分割                            <entryLabel xsi:type="utility:ConstantString" string="EButton" />顯示在面板上的控制項的名字                                                 </cmpEntries>              </cmpGroups>              <!--ETextField -->              <cmpGroups xsi:type="palette:GroupCmp">                     <cmpEntries xsi:type="palette:AnnotatedCreationEntry" xmi:id="entry3" icon16Name="platform:/plugin/org.eclipse.ve.jfc/icons/full/clcl16/textfield_obj.gif">                            <objectCreationEntry xsi:type="palette:EMFCreationToolEntry" creationClassURI="java:/com.abc.ermsuite.platform.framework.looks.swing#ETextField" />                            <entryLabel xsi:type="utility:ConstantString" string="ETextField" />                                             </cmpEntries>              </cmpGroups>                    </palette:CategoryCmp></xmi:XMI> 六,將這些檔案以外掛程式方式放入eclipse目錄,啟動後,在project屬性中設定build path,add library,增加ABC Library即可。   

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.