嘟嘟

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            26 Posts :: 0 Stories :: 6 Comments :: 0 Trackbacks

          1:建立一個視圖類需要擴展org.eclipse.ui.part.ViewPart
                public class FirstView extends ViewPart {
                }

          2:在視圖中添加控件
             主要在方法中createPartControl加入控件,(建議使用designer工具)
                public class FirstView extends ViewPart {
           

                 private Text text;
                 public static final String ID = "rcpdemo.views.FirstView"; //$NON-NLS-1$

                 /**
                  * Create contents of the view part
                  * @param parent
                  */
                 public void createPartControl(Composite parent) {
                  Composite container = new Composite(parent, SWT.NONE);

                  final Label label = new Label(container, SWT.NONE);
                  label.setAlignment(SWT.CENTER);
                  label.setText("姓名:");
                  label.setBounds(84, 65, 58, 24);

                  text = new Text(container, SWT.BORDER);
                  text.setBounds(144, 62, 80, 25);

                  //
                  createActions();
                  initializeToolBar();
                  initializeMenu();
                  }


          3:配置plugin.xml文件
              <extension
                   id="rcpdemo.views.FirstView"
                   name="first view"
                   point="org.eclipse.ui.views">
                <view
                      class="rcpdemo.views.FirstView"
                      id="rcpdemo.views.FirstView"
                      name="New ViewPart"/>
              </extension>

          4:修改透視圖的代碼
             public class Perspective implements IPerspectiveFactory {

              public void createInitialLayout(IPageLayout layout) {
               //顯示視圖
               String editorArea = layout.getEditorArea();
               layout.addView("rcpdemo.views.FirstView", IPageLayout.RIGHT, 0.2f, editorArea);
              }
             }
          createInitialLayou中,我們可以通過以下幾個方法向透視圖中添加視圖、編輯器和菜單:
          addView   ——
          添加視圖
          addActionSet ——
          添加菜單和工具欄
          createFolder ——
          創建一個IForderLayou,可以讓多個視圖重疊在同一個位置

          posted on 2007-06-13 19:52 fyp1210 閱讀(847) 評論(0)  編輯  收藏 所屬分類: RCP&SWT&JFACE
          主站蜘蛛池模板: 曲阳县| 金门县| 华容县| 手游| 姜堰市| 汉川市| 普宁市| 东明县| 龙南县| 辽宁省| 奎屯市| 诸暨市| 松阳县| 巴里| 民勤县| 柳江县| 灵寿县| 太仓市| 加查县| 天全县| 南安市| 永福县| 民丰县| 凌海市| 辉县市| 荆州市| 金沙县| 马龙县| 金川县| 广西| 迁安市| 林口县| 大厂| 洪洞县| 枣强县| 千阳县| 台山市| 平阳县| 武邑县| 广宁县| 乌兰察布市|