Getting Started with Eclipse RCP development study notes - 04. In Windows, use the Active X control

-------------------------------------------------- -------------------------------------------------


-------------------------------------------------- -------------------------------------------------

1. New OleView:

package hellorcp.ole;

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

public class OleView extends ViewPart {
        public OleFrame frame;

        public static final String ID = "hellorcp.view.OleView"; //$NON-NLS-1$

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


         * Create the actions
        private void createActions() {
                // Create the actions

         * Initialize the toolbar
        private void initializeToolBar() {
                IToolBarManager toolbarManager = getViewSite().getActionBars()

         * Initialize the menu
        private void initializeMenu() {
                IMenuManager menuManager = getViewSite().getActionBars()

        public void setFocus() {
                // Set the focus


2. New OpenFileAction:

package hellorcp.ole;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;

public class OpenFileAction implements IWorkbenchWindowActionDelegate {
        IWorkbenchWindow window;

        public void dispose() {
                // TODO  Automatically generate method stub  

        public void init(IWorkbenchWindow window) {
                this.window = window;

        public void run(IAction action) {
                IViewReference[] vfs = window.getActivePage().getViewReferences();
                IViewPart vw;
                for (int i = 0; i < vfs.length; i++) {
                        vw = vfs[i].getView(false);
                        if (vw.getTitle().equals(" Use the active X control  ")) {
                                OleClientSite client = new OleClientSite(((OleView) vw).frame,
                                                SWT.NONE, "Shell.Explorer.2");
                                OleAutomation oa = new OleAutomation(client);
                                Variant str = new Variant("");
                                oa.invoke(104, new Variant[] { str });

        public void selectionChanged(IAction action, ISelection selection) {
                // TODO  Automatically generate method stub  


3. Modify, revised:

package hellorcp;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory {

        public void createInitialLayout(IPageLayout layout) {
                // FirstView
                String editorArea = layout.getEditorArea();
//              layout.addView("hellorcp.view.FirstView", IPageLayout.RIGHT, 0.2f,
//                              editorArea);

                // SecondView
//              layout.setEditorAreaVisible(false);
//              layout.addView("hellorcp.view.SecondView", IPageLayout.RIGHT, 0.5f,
//                              editorArea);
                // OleView
                layout.addView("hellorcp.ole.OleView", IPageLayout.RIGHT, 0.5f,


4. Configuration plugin.xml:

1) action configuration snippet:

                                class ="hellorcp.ole.OpenFileAction" 
                icon ="icons/alt_window_16.gif" 
                id ="hellorcp.ole.OpenFileAction" 
                    label ="Ole Menu items  " 
                                menubarPath ="hellorcp.firstmenu/additions" 
                style ="push" 
                toolbarPath ="additions" 
                tooltip ="Ole Menu items  " /> 

2) view configuration snippet:

                name=" Use the active X control  " />

5. Save, run (click on Tools first one icon), the effect is as follows:

Getting Started with Eclipse RCP development study notes - 04. In Windows, use the Active X control
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Getting Started with Eclipse RCP development study notes - 04. In Windows, use the Active X control

  • OSGI service must be started

    OSGI must start the service: 0 ACTIVE org.eclipse.osgi_3.4.2.R34x_v20080826-1230 1 ACTIVE org.eclipse.equinox.http.jetty_1.1.0.v20080425 2 ACTIVE org.eclipse.osgi.services_3.1.200.v20071203 3 ACTIVE javax.servlet.jsp_2.0.0.v200806031607 4 ACTIVE org.eclip

  • Getting Started with Eclipse RCP development study notes - 03. View

    -------------------------------------------------- ---------------------------------------------- Study: -------------------------------------------------- --------------------------------- ...

  • Getting Started with Eclipse RCP development study notes - 02. Menus and dialog boxes

    -------------------------------------------------- -------------------------------------------- Study: -------------------------------------------------- ----------------------------------------

  • Getting Started with Eclipse RCP development study notes - 07. Summary

    Follow the "Seaside Momo" series of articles had started studying the development of the RCP has been a general understanding of the increasing interest in this area, of course, if you really want to develop a practical small Dongdong years, Lea

  • Oracle study notes (data dictionary control file rewrite the log file)

    Recent study Oracle, did some study notes, mainly digital dictionary control file and redo log file contents 1. Start iSQL * Plus tool: to ensure the iSQL * Plus application server has started (usually installed by default are automatically activated ...

  • Getting Started with Eclipse RCP Developer Study Notes - 05.2D Drawing

    -------------------------------------------------- -------------------------------------------------- Study: -------------------------------------------------- ----------------------------- ...

  • Getting Started with Eclipse RCP Developer Study Notes - 06.OpenGL

    -------------------------------------------------- ------------------------------------------------- Study: -------------------------------------------------- -----------------------------------

  • Android Study Notes (2) - build Android development platform

    Eclipse + Android SDK First, download the Eclipse Select Eclipse IDE for Java Developers (85 MB) version Second, download the Android SDK I c

  • [Transfer] SAP Study Notes (SAP Portal Study Notes 1)

    SAP Study Notes (SAP Portal Study Notes 1) In general SAP Portal project consultants, including most of the configuration and development issues, development, then very flexible to provide the technology for SAP are WebDynpro (Java and ABAP can be) a

  • Getting Started with Eclipse RCP Developer Study Notes - 01.Hello RCP

    Recent eager to want to learn all aspects of the desktop client development, in addition to work is only beginning to learn a bit of time outside of Delphi, as well as U read a little bit of time VB, VC contacts, in this area can be called super do not qu

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries