`
longgangbai
  • 浏览: 7375573 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

RCP系统的菜单功能的使用

阅读更多
              在项目RCP 应用程序中添加系统菜单的在ApplicationActionBarAdvisor 中创建相关的Action,并注册之后使用。

RCP系统提供的reflesh,save的功能均在ActionFactory类中使用时调用。如果想重新启动:
采用以下代码:

 PlatformUI.getWorkbench().restart(); 

看下面的源代码如下:

package com.unutrip.plugin.dev;


import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
/**
 * 
 * @author longgangbai
 *
 */
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    // Actions - important to allocate these only in makeActions, and then use them
    // in the fill methods.  This ensures that the actions aren't recreated
    // when fillActionBars is called with FILL_PROXY.
    private IWorkbenchAction exitAction;
    private IWorkbenchAction aboutAction;
    private IWorkbenchAction newWindowAction;
    private OpenViewAction openViewAction;
    private Action messagePopupAction;
    

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }
    //如果是继承自Jface 中Action的Action类,不需要注册飞,否则出现错误
    protected void makeActions(final IWorkbenchWindow window) {
        // Creates the actions and registers them.
        // Registering is needed to ensure that key bindings work.
        // The corresponding commands keybindings are defined in the plugin.xml file.
        // Registering also provides automatic disposal of the actions when
        // the window is closed.

        exitAction = ActionFactory.QUIT.create(window);
        register(exitAction);
        
        aboutAction = ActionFactory.ABOUT.create(window);
        register(aboutAction);
        
        newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
        register(newWindowAction);
        
        openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID);
        register(openViewAction);
        
        messagePopupAction = new MessagePopupAction("Open Message", window);
        register(messagePopupAction);
    }
    
    protected void fillMenuBar(IMenuManager menuBar) {
       //MenuManger 必须绑定到一个菜单上
        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
        MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
        
        menuBar.add(fileMenu);
        // Add a group marker indicating where action set menus will appear.
        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        menuBar.add(helpMenu);
        
        // File
        fileMenu.add(newWindowAction);
        fileMenu.add(new Separator());
        fileMenu.add(messagePopupAction);
        fileMenu.add(openViewAction);
        fileMenu.add(new Separator());
        fileMenu.add(exitAction);
        
        // Help
        helpMenu.add(aboutAction);
    }
    
    protected void fillCoolBar(ICoolBarManager coolBar) {
        IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
        coolBar.add(new ToolBarContributionItem(toolbar, "main"));   
        toolbar.add(openViewAction);
        toolbar.add(messagePopupAction);
    }
}
分享到:
评论

相关推荐

    plugin2_RCP菜单_teamcenter_

    总的来说,"plugin2_RCP菜单_teamcenter_"涉及的知识点主要包括了Eclipse RCP的原理,`plugin.xml`配置文件的使用,以及如何在Teamcenter环境中定制和集成菜单与工具栏。开发者需要具备扎实的Java编程基础,熟悉...

    RCP系统开发

    - **图片缓冲处理**:为了提高性能,RCP系统常使用图片缓冲技术,减少图像加载时间。 - **品牌化应用程序**:通过定制外观和行为,使应用程序符合企业品牌形象。 #### 重构功能 重构是RCP开发中的一个重要工具,...

    RCP 菜单与工具栏小结

    通过深入理解RCP的贡献系统和菜单工具栏的实现机制,开发者可以构建出既强大又易于使用的桌面应用程序。在实际开发过程中,应充分利用RCP提供的框架和工具,同时结合具体的应用需求进行定制,以达到最佳的用户界面...

    eclipse rcp应用系统开发方法与实战

    Eclipse Rich Client Platform (RCP) 是一个强大的框架,用于构建桌面应用程序,它基于Java语言,利用了Eclipse IDE的强大功能。本项目“Eclipse RCP应用系统开发方法与实战”旨在深入探讨如何利用Eclipse RCP进行...

    plugin1_RCP菜单_teamcenter_

    本文将深入探讨“plugin1_RCP菜单_teamcenter_”这一主题,重点讲解如何在Teamcenter的RCP(Rich Client Platform)环境中开发一级和二级主菜单,并通过配置plugin.xml文件来实现这一功能。 首先,让我们理解什么是...

    eclipse rcp 菜单小例子

    在Eclipse RCP中,我们可以使用`IMenuService`来管理这些菜单。 菜单项的创建通常在`ActionBarAdvisor`类中完成,它是负责初始化和配置应用动作栏的。在`fillMenuBar`方法中,我们会定义`MenuBarManager`,并添加...

    RCP-1500中文操作手册.pdf

    在操作和维护方面,RCP-1500系列遥控面板提供了一个详细的菜单系统,包括菜单操作、状态画面、着色菜单、文件菜单、维护菜单和配置菜单等。用户可以通过这些菜单来进行高级的配置和设置,以确保设备的性能达到最佳。...

    Eclipse RCP 应用系统开发方法与实战 源代码

    Eclipse RCP的命令模型使得功能的实现与UI解耦,增强了可复用性和可扩展性。而服务机制则允许组件之间进行通信。"第8章.rar"可能涵盖了如何创建和使用命令,以及如何注册和使用服务的示例。 6. **首选项...

    RCP系统托盘实现方法

    通过以上步骤,可以实现一个完整的RCP应用程序的系统托盘功能,使得程序在不占用桌面空间的情况下,仍然可以方便地被用户访问和控制。同时,通过右键菜单可以提供更多的操作选项,增强了用户体验。

    RCP弹出日期控件

    在RCP系统中,弹出式日期控件通常是为了简化用户在日期输入时的操作。这种控件不仅允许用户通过点击按钮弹出一个日历视图,还可以在该视图中轻松切换至上一月、下一月,向前或向后滚动一年。这种设计考虑到了用户的...

    RCP程序设计自学RCP的教程

    Eclipse RCP的设计理念围绕着插件、扩展和扩展点,这意味着应用可以通过增加新的插件来实现功能的扩展和定制,从而满足不同的需求场景。 #### 二、构建你的第一个RCP程序 ##### 1. 创建一个RCP程序 在Eclipse IDE...

    Eclipse RCP开发教程

    Eclipse Rich Client Platform (RCP) 是一个用于构建桌面应用程序的框架,它基于 Eclipse IDE 平台,允许开发者利用 Eclipse 的强大功能和丰富的插件系统来创建自定义的、可扩展的应用程序。Eclipse RCP 的核心理念...

    rcp-1500.pdf

    这份英文说明书详细介绍了RCP-1500的操作方式,包括菜单设置、状态显示、文件管理、系统维护以及用户自定义功能等。 首先,文档描述了RCP-1500的硬件部分,包括操作面板和连接面板的具体组件及其功能。操作面板上...

    rcp学习好资料

    RCP允许开发者使用插件系统构建可扩展的应用程序,具有强大的功能和用户界面。 **标签解析** "rcp学习好资料"标签进一步确认了这些文件的主要内容,即关于RCP的学习资料,可能是教程、案例研究或者是开发实践的...

    Eclipse Rcp

    最后,Eclipse RCP的发展带来了Java桌面应用程序开发的新希望,它允许开发者利用Eclipse的强大功能和成熟的插件生态,来构建功能丰富、外观一致的客户端应用,同时避免了大量重复的界面开发工作。Eclipse RCP的应用...

    一个RCP的简单例子

    RCP允许开发者利用Eclipse的强大功能,如插件系统、工作台管理、视图和编辑器,来创建自定义的、模块化的用户界面。在本例子中,我们看到的是一个基于RCP实现的**客户关系管理(CRM)**系统。 CRM系统主要用于企业...

    Eclipse的RCP开发的入门教程

    "使用Eclipse RCP进行桌面程序开发(二):菜单、工具栏和对话框 .doc"则专注于用户界面(UI)元素的创建和管理,包括如何定义菜单、工具栏,以及创建自定义对话框。这些组件是用户与应用程序交互的关键部分,开发者...

    Eclipse RCP应用系统开发方法与实战(第四章)

    4. 实现命令:Eclipse RCP的命令模型允许我们定义和绑定用户操作,比如菜单项和工具栏按钮,这样可以统一处理用户交互。 5. 集成数据服务:利用Eclipse的模型服务(如EMF或GMF)来管理和展示复杂的数据结构。 在这...

    使用RCP进行程序开发(学习篇)

    在本文中,我们将深入探讨如何使用RCP(Rich Client Platform)进行程序开发,这是一种基于Eclipse的框架,用于构建强大的桌面应用程序。RCP利用插件化的系统架构,提供了模块化和动态化的应用开发能力,同时也简化...

Global site tag (gtag.js) - Google Analytics