邋遢居

          我的Java天堂

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            61 Posts :: 2 Stories :: 90 Comments :: 0 Trackbacks

          開始學(xué)習(xí)RCP編程

          很早很早就聽說RCP了。也很想來玩玩,但是一直沒有找到好的點(diǎn)子來練手。不過近段時(shí)間有個(gè)老朋友要求幫他做個(gè)小東西。他現(xiàn)在的需求很簡(jiǎn)單。我怕他以后有要加什么內(nèi)容。所以就想用RCP來做。剛好用他來好好學(xué)習(xí)一下,要不都不好意思在bbs.rcp.cn混了。

          找了本書(《Eclipse Rich Client Platform Designing Coding and Packaging Java Applications》)按照書中的例子看了起來。

          了解基本的:

          AbstractUIPlugin

          WorkbenchWindowAdvisor

          WorkbenchAdvisor

          ActionBarAdvisor

          IperspectiveFactoryViewPart幾個(gè)類。

          收獲最大的就是看到yipsilonbbs.rcp.cn中關(guān)于布局的帖子。

          http://www.eclipseworld.org/bbs/read.php?tid=1312&page=e#a

          public class MGRPerspective implements IPerspectiveFactory {

          public void createInitialLayout(IPageLayout layout) {

            Plugin plugin 
          = Plugin.getDefault();

            LSEmployee employee 
          = plugin.getEmployee();

            
          //只有在用戶登陸后才能畫界面
            if (employee != null) {
              
              String editorArea 
          = layout.getEditorArea();
              
              layout.setEditorAreaVisible(
          false);
              
              
          // 主要界面
              IFolderLayout main = layout.createFolder("main", IPageLayout.TOP, 0.95f, editorArea);
              
          // 屬性界面
              IFolderLayout property = layout.createFolder("property", IPageLayout.RIGHT, 0.75f"main");
              
          // 字典界面
              IFolderLayout dictionary = layout.createFolder("dictionary", IPageLayout.BOTTOM, 0.95f"property");

              LSPosition position 
          = employee.getPosition();

              
          boolean isManager = position.getManager().booleanValue();

              
          if (isManager) {
              main.addView(EmployeeTableView.
          class.getName());
              property.addView(PositionPropertyView.
          class.getName());
              property.addView(EmployeePropertyView.
          class.getName());
              }

              
          if (position.getBuyer().booleanValue() || isManager) {
              main.addView(ProviderTableView.
          class.getName());
              main.addView(JHInvoiceTableView.
          class.getName());
              property.addView(ProviderPropertyView.
          class.getName());
              property.addView(JHInvoicePropertyView.
          class.getName());
              }

              
          if (position.getKeeper().booleanValue() || isManager) {
              dictionary.addView(DDRepositoryView.
          class.getName());
              main.addView(DBInvoiceTableView.
          class.getName());
              property.addView(DBInvoicePropertyView.
          class.getName());
              }

              
          if (position.getSeller().booleanValue() || isManager) {
              main.addView(MemberTableView.
          class.getName());
              main.addView(YDInvoiceTableView.
          class.getName());
              main.addView(XSInvoiceTableView.
          class.getName());
              property.addView(MemberPropertyView.
          class.getName());
              property.addView(YDInvoicePropertyView.
          class.getName());
              property.addView(XSInvoicePropertyView.
          class.getName());
              }

              
          if (position.getMaintainer().booleanValue() || isManager) {
              dictionary.addView(DDAreaView.
          class.getName());
              dictionary.addView(DDBrandView.
          class.getName());
              dictionary.addView(DDColorView.
          class.getName());
              dictionary.addView(DDCompView.
          class.getName());
              dictionary.addView(DDLevelView.
          class.getName());
              dictionary.addView(DDSizeView.
          class.getName());
              dictionary.addView(DDSortView.
          class.getName());
              dictionary.addView(DDDescriptionView.
          class.getName());
              }
            }
          }
          }

          根據(jù)這段代碼做出如下界面:

          rcp ui.bmp
          很簡(jiǎn)單。大家見笑了。呵呵。
          我的代碼就不貼了。看
          yipsilon的代碼就可以搞定布局了。再次感謝yipsilon。
          今天就寫到這兒了。爭(zhēng)取周末能把ui全部畫好。
          posted on 2006-02-23 23:06 Jet Geng 閱讀(2404) 評(píng)論(0)  編輯  收藏 所屬分類: Eclipse
          主站蜘蛛池模板: 阿鲁科尔沁旗| 海宁市| 郎溪县| 靖远县| 根河市| 汨罗市| 昭平县| 寿光市| 青州市| 五原县| 手游| 松潘县| 隆回县| 朔州市| 泽库县| 曲阜市| 高邮市| 大埔区| 浙江省| 遵义县| 洮南市| 海阳市| 广平县| 定南县| 靖边县| 鄂尔多斯市| 玉门市| 林口县| 乐陵市| 柳州市| 南溪县| 得荣县| 曲靖市| 华蓥市| 许昌市| 东丰县| 玉田县| 西昌市| 襄城县| 潞城市| 腾冲县|