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

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

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

    大夢(mèng)想家

    5年開發(fā)工程師,2年實(shí)施經(jīng)理,X年售前顧問,......
    數(shù)據(jù)加載中……
    如何在ViewPart上添加ViewToolBar

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

    1public void createPartControl(Composite parent) {
                   //SWT Design在生成代碼的時(shí)下面兩句可能會(huì)顛倒,我也不知道為什么,至少我的是位置顛倒了。運(yùn)行起來總報(bào)錯(cuò)!
    2        createActions();
    3        initializeToolBar();
    4}
    先產(chǎn)生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) 評(píng)論(5)  編輯  收藏 所屬分類: Eclipse-RCP

    評(píng)論

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

    用擴(kuò)展點(diǎn)
    org.ecipse.ui.viewactions
    會(huì)更好一些

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

    @笨笨
    用擴(kuò)展點(diǎn)沒有辦法控制權(quán)限啊~

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

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

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

    因?yàn)槭窃趩螜C(jī)上運(yùn)行,甚至可以通過systemProperty屬性來控制,都是可以的!

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

    感謝提醒,學(xué)習(xí)中~

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

    請(qǐng)問toolbar中的按鈕,怎么才能弄到選項(xiàng)卡那一行上
    主站蜘蛛池模板: 久久精品国产亚洲αv忘忧草| 色噜噜AV亚洲色一区二区| 91亚洲精品第一综合不卡播放| 成人免费无码H在线观看不卡| 国产乱子伦精品免费女| 国产亚洲视频在线| 免费a级毛片视频| 一级免费黄色毛片| 亚洲女初尝黑人巨高清| 最近2019中文免费字幕在线观看| 亚洲精品无码不卡在线播放HE| 一个人免费观看日本www视频| 亚洲色偷偷综合亚洲AV伊人| 国产精品美女免费视频观看| 国产亚洲一区二区在线观看| 久久久久久AV无码免费网站| 亚洲国产精品综合福利专区| 成人黄18免费视频| 美女视频黄a视频全免费网站色| 亚洲综合精品网站在线观看| 免费黄色电影在线观看| 亚洲国产日韩在线一区| 国产成人一区二区三区免费视频| 一区二区三区AV高清免费波多| 国产亚洲无线码一区二区 | 亚洲av无码一区二区三区观看| 久久精品无码一区二区三区免费| 亚洲国产AV无码一区二区三区| 亚洲国产小视频精品久久久三级 | 亚洲入口无毒网址你懂的| 日本一道在线日本一道高清不卡免费| 免费无码午夜福利片69| 亚洲av无码一区二区三区不卡 | a毛片在线还看免费网站| 亚洲美女精品视频| 国产成人免费全部网站| 国产精品免费AV片在线观看| 亚洲精品伦理熟女国产一区二区| 亚洲精品老司机在线观看| 在线看片免费人成视久网| 狠狠入ady亚洲精品|