<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大夢想家

    5年開發工程師,2年實施經理,X年售前顧問,......
    數據加載中……
    如何在ViewPart上添加ViewToolBar

    ViewToolBar其實就是Actions。在ViewPart上添加Action其實是非常簡單的(如果用SWT Design的話)。其實就是幾行代碼的事情:

    1public void createPartControl(Composite parent) {
                   //SWT Design在生成代碼的時下面兩句可能會顛倒,我也不知道為什么,至少我的是位置顛倒了。運行起來總報錯!
    2        createActions();
    3        initializeToolBar();
    4}
    先產生Action,在把Action加入到toolBarManager上:
     1    private void initializeToolBar() {
     2        IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();//取得此View的toolBarManager
     3
     4        toolBarManager.add(partManageAction);
     5
     6        toolBarManager.add(setupCraftworkManage);
     7
     8        toolBarManager.add(baseBOMManage);
     9
    10        toolBarManager.add(standardProductManage);
    11    }

    下面是來自鬼子站的資料,用的都是SWT design做的~有錢??!
    Wizards - RCP - ViewPart

    Subclasses of the Eclipse RCP ViewPart class can be created using the RCP ViewPart wizard. The wizard can be selected from the drop down Designer wizard menu or from the Eclipse New wizard.

    To use the wizard, select the project source folder and package to contain the class. Then enter the class name and view name and hit the Finish button.

     

    The wizard generates the following code.

    import org.eclipse.jface.action.IMenuManager;
    import org.eclipse.jface.action.IToolBarManager;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.ui.part.ViewPart;

    public static final String ID = "sample.rcp.EclipseViewPartTest";

    public class EclipseViewPartTest extends ViewPart {
        public void createPartControl(Composite parent) {
            Composite container = new Composite(parent, SWT.NONE);
            createActions();
            initializeToolBar();
            initializeMenu();
        }
        private void createActions() {
        }
        private void initializeToolBar() {
            IToolBarManager tbm =
                getViewSite().getActionBars().getToolBarManager();
        }
        private void initializeMenu() {
            IMenuManager manager =
               getViewSite().getActionBars().getMenuManager();
        }
        public void setFocus() {
        }
    }

    If the ViewPart is created in an existing plugin project, the plugin.xml file is also updated with the appropriate view declaration.

    When editing ViewParts, Designer presents two tabs in the design area, one for laying out the contents of the view (using any widgets or layout managersr) and a second for defining actions and assigning them to the view's toolbar and menu.

    On the Actions tab, the first column, Actions, is used to define new actions (which are created as inner classes of the current class). New actions may be created using the Add button (plus icon) above the column, existing actions may be added using the Open button (folder icon),  and existing actions may be deleted using the Delete button (minus) icon. Selecting an action allows you to edit its icons, label and tool tip text within the property pane. 

    The second column, Toolbar, is used to define the contents of the view's toolbar. Actions and separators may be dragged from the Actions column and dropped in the Toolbar column. Toolbar actions may be rearranged using the Move Up and Move Down buttons and deleted using the Delete button above the column. The order of individual items may also be rearranged via drag and drop.

    The third column, Menu, is used to define the contents of the view's menu. Actions, separators and menu managers may be dragged from the Actions column and dropped in the Menu column. Menus may be expanded and collapse using the Expand All and Collapse All buttons and deleted using the Delete button above the column. The order of individual items may also be rearranged via drag and drop.

    When the ViewPart itself is selected in the property pane, its icon, category and title may be edited. New categories may also be created.

      



    客戶虐我千百遍,我待客戶如初戀!

    posted on 2007-05-15 17:58 阿南 閱讀(2685) 評論(5)  編輯  收藏 所屬分類: Eclipse-RCP

    評論

    # re: 如何在ViewPart上添加ViewToolBar[未登錄] 2007-05-16 11:50 笨笨

    用擴展點
    org.ecipse.ui.viewactions
    會更好一些
      回復  更多評論    

    # re: 如何在ViewPart上添加ViewToolBar 2007-05-16 14:59 阿南

    @笨笨
    用擴展點沒有辦法控制權限啊~
      回復  更多評論    

    # re: 如何在ViewPart上添加ViewToolBar[未登錄] 2007-05-17 09:13 笨笨

    完全可以在代碼中控制權限
    比如IViewActionDelegate中的init方法,selectionChanged方法

    再比如說你可以通過org.eclipse.ui.IActionFilter可控制Action的權限,方法很多的。

    因為是在單機上運行,甚至可以通過systemProperty屬性來控制,都是可以的!
      回復  更多評論    

    # re: 如何在ViewPart上添加ViewToolBar 2007-05-17 15:41 阿南

    感謝提醒,學習中~
      回復  更多評論    

    # re: 如何在ViewPart上添加ViewToolBar 2015-01-30 15:45 suren

    請問toolbar中的按鈕,怎么才能弄到選項卡那一行上
      回復  更多評論    
    主站蜘蛛池模板: 日本不卡免费新一二三区| 美女内射无套日韩免费播放| 国产亚洲综合一区二区三区| 免费毛片毛片网址| 久久国产精品萌白酱免费| 在线天堂免费观看.WWW| 免费永久在线观看黄网站| 亚洲成在人线av| 亚洲乱码卡三乱码新区| 美女羞羞喷液视频免费| 9420免费高清在线视频| 亚洲高清视频一视频二视频三| 亚洲2022国产成人精品无码区 | 久久亚洲精品成人| 成全在线观看免费观看大全 | 久久午夜羞羞影院免费观看| 久久精品国产亚洲av影院| 亚洲午夜福利在线视频| a级在线观看免费| 国产女高清在线看免费观看| 91亚洲自偷在线观看国产馆| 最近免费中文字幕视频高清在线看 | 色欲A∨无码蜜臀AV免费播| 亚洲国产婷婷综合在线精品| 亚洲AV成人无码天堂| 在线成人精品国产区免费| 亚洲欧洲另类春色校园小说| 成全视频在线观看免费| 亚洲精品视频在线播放| 99re6在线视频精品免费下载 | 看成年女人免费午夜视频| 亚洲人成在线播放网站| 欧洲美女大片免费播放器视频| 久久亚洲国产精品123区| 阿v免费在线观看| 亚洲激情在线视频| 性xxxxx大片免费视频| 亚洲色大成网站www久久九 | 香蕉视频在线观看免费国产婷婷 | 91青青青国产在观免费影视| 亚洲国产精品日韩av不卡在线|