Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:01:36+00:00 2026-06-08T22:01:36+00:00

I have an eclipse plugin and I want to perform certain action inside this

  • 0

I have an eclipse plugin and I want to perform certain action inside this plugin but after eclipse application is opened.

I tried to do it through overriding


public void postWindowCreate()

but it seems that I can’t get inside this function when launching the application

Any ideas ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:01:38+00:00Added an answer on June 8, 2026 at 10:01 pm

    Do you use e4? Then maybe the following link may help: http://www.eclipse.org/forums/index.php/m/886197/

    Edit:

    OK, do you define your own application?

    Are the methods provided by org.eclipse.ui.application.WorkbenchWindowAdvisor the ones you need? (e.g. preWindowOpen(), preWindowShellClose(), postWindowRestore(), postWindowCreate(), …)

    I also needed that functionality, so here’s how I do it:

    You need 3 classes, one implementing org.eclipse.equinox.app.IApplication e.g. MyApp, one which extends org.eclipse.ui.application.WorkbenchAdvisor e.g. MyAdvisor, and one which extends org.eclipse.ui.application.WorkbenchWindowAdvisor e.g. MyWindowAdvisor.

    Then in MyApp you will probably call something like

    PlatformUI.createAndRunWorkbench(display, new MyAdvisor());
    

    where you actually start the workbench and provide your own WorkbenchWindowAdvisor. In MyAdvisor you have to overwrite:

    @Override    
    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        return new MyWindowAdvisor(configurer);
    }
    

    in which you provide your WorkbenchWindowAdvisor. In class MyWindowAdvisor you can finally override the appropriate functions, e.g.

    @Override
    public void postWindowOpen() {
        //TODO
    }
    

    Of course you have to run the appropriate application for this to work 😉
    OK, now, to provide arbitrary plug-ins to deal with these events, you could define an extension point.

    First you need an interface which defines the “events” you want to listen to, e.g.:

    public interface IWorkbenchWindowAdvisorHook
    {
        /**
         * Performs arbitrary actions before the window is opened.
         * <p>
         * This method is called before the window's controls have been created.
         * Clients must not call this method directly (although super calls are okay).
         * The default implementation does nothing. Subclasses may override.
         * Typical clients will use the window configurer to tweak the
         * workbench window in an application-specific way; however, filling the
         * window's menu bar, tool bar, and status line must be done in 
         * {@link ActionBarAdvisor#fillActionBars}, which is called immediately
         * after this method is called.
         * </p>
         */
        void preWindowOpen();
    
        /**
         * Performs arbitrary actions as the window's shell is being closed
         * directly, and possibly veto the close.
         * <p>
         * This method is called from a ShellListener associated with the window,
         * for example when the user clicks the window's close button. It is not
         * called when the window is being closed for other reasons, such as if the
         * user exits the workbench via the {@link ActionFactory#QUIT} action.
         * Clients must not call this method directly (although super calls are
         * okay). If this method returns <code>false</code>, then the user's
         * request to close the shell is ignored. This gives the workbench advisor
         * an opportunity to query the user and/or veto the closing of a window
         * under some circumstances.
         * </p>
         * 
         * @return <code>true</code> to allow the window to close, and
         *         <code>false</code> to prevent the window from closing
         * @see org.eclipse.ui.IWorkbenchWindow#close
         * @see WorkbenchAdvisor#preShutdown()
         */
        public boolean preWindowShellClose();
    
        /**
         * Performs arbitrary actions after the window has been restored, 
         * but before it is opened.
         * <p>
         * This method is called after a previously-saved window has been
         * recreated. This method is not called when a new window is created from
         * scratch. This method is never called when a workbench is started for the
         * very first time, or when workbench state is not saved or restored.
         * Clients must not call this method directly (although super calls are okay).
         * The default implementation does nothing. Subclasses may override.
         * It is okay to call <code>IWorkbench.close()</code> from this method.
         * </p>
         * 
         * @exception WorkbenchException thrown if there are any errors to report
         *   from post-restoration of the window
         */
        void postWindowRestore() throws WorkbenchException;
    
        /**
         * Performs arbitrary actions after the window has been created (possibly 
         * after being restored), but has not yet been opened.
         * <p>
         * This method is called after the window has been created from scratch, 
         * or when it has been restored from a previously-saved window.  In the latter case,
         * this method is called after <code>postWindowRestore</code>.
         * Clients must not call this method directly (although super calls are okay).
         * The default implementation does nothing. Subclasses may override.
         * </p>
         */
        void postWindowCreate();
    
        /**
         * Performs arbitrary actions after the window has been opened (possibly 
         * after being restored).
         * <p>
         * This method is called after the window has been opened. This method is 
         * called after the window has been created from scratch, or when
         * it has been restored from a previously-saved window.
         * Clients must not call this method directly (although super calls are okay).
         * The default implementation does nothing. Subclasses may override.
         * </p>
         */
        void postWindowOpen();
    
        /**
         * Performs arbitrary actions after the window is closed.
         * <p>
         * This method is called after the window's controls have been disposed.
         * Clients must not call this method directly (although super calls are
         * okay). The default implementation does nothing. Subclasses may override.
         * </p>
         */
        void postWindowClose();
    }
    

    Then the extension point schema (replace all “YOUR-xxx” with your own package/plug-in names, and namespace):

    <?xml version='1.0' encoding='UTF-8'?>
    <!-- Schema file written by PDE -->
    <schema targetNamespace="***YOUR-NAMESPACE***" xmlns="http://www.w3.org/2001/XMLSchema">
    <annotation>
          <appInfo>
             <meta.schema plugin="***YOUR-PLUGIN***" id="workbenchWindowHook" name="***YOUR-PACKAGE***.workbenchWindowHook"/>
          </appInfo>
          <documentation>
             An extension to actively hook into the WorkbenchWindowAdvisor&apos;s pre/post methods from other plug-ins.
    This is primarily intended for plug-ins that are optional or restricted to some specific products.
          </documentation>
       </annotation>
    
       <element name="extension">
          <annotation>
             <appInfo>
                <meta.element />
             </appInfo>
          </annotation>
          <complexType>
             <sequence>
                <element ref="class" minOccurs="1" maxOccurs="unbounded"/>
             </sequence>
             <attribute name="point" type="string" use="required">
                <annotation>
                   <documentation>
    
                   </documentation>
                </annotation>
             </attribute>
             <attribute name="id" type="string">
                <annotation>
                   <documentation>
    
                   </documentation>
                </annotation>
             </attribute>
             <attribute name="name" type="string">
                <annotation>
                   <documentation>
    
                   </documentation>
                   <appInfo>
                      <meta.attribute translatable="true"/>
                   </appInfo>
                </annotation>
             </attribute>
          </complexType>
       </element>
    
       <element name="class">
          <annotation>
             <documentation>
                The hook class implementing IWorkbenchWindowAdvisorHook.
             </documentation>
          </annotation>
          <complexType>
             <attribute name="name" type="string" use="required">
                <annotation>
                   <documentation>
                      The hook class implementing IWorkbenchWindowAdvisorHook.
                   </documentation>
                   <appInfo>
                      <meta.attribute kind="java" basedOn=":***YOUR-PACKAGE***.IWorkbenchWindowAdvisorHook"/>
                   </appInfo>
                </annotation>
             </attribute>
          </complexType>
       </element>
    
       <annotation>
          <appInfo>
             <meta.section type="since"/>
          </appInfo>
          <documentation>
          </documentation>
       </annotation>
    </schema>
    

    Then, in your MyWindowAdvisor you need to keep a reference to the extensions

    // the reference list
    private List<IWorkbenchWindowAdvisorHook> hooks = new ArrayList<IWorkbenchWindowAdvisorHook>();
    

    load/initialize the extensions

    //code for initializing the extensions, must be called in the constructor
    private void initExtensions()
    {
        IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
                IWorkbenchWindowAdvisorHook.ID);
        for(IConfigurationElement element : config)
        {
            try
            {
                final Object o = element.createExecutableExtension("name"); //$NON-NLS-1$
                if(o instanceof IWorkbenchWindowAdvisorHook)
                {
                    hooks.add((IWorkbenchWindowAdvisorHook)o);
                }
            }
            catch(CoreException e)
            {
                e.printStackTrace();
            }
        }
    }
    

    and in each “event” function call the extensions’ methods:

    // example method preWindowOpen()
    public void preWindowOpen()
    {
        for(IWorkbenchWindowAdvisorHook hook : hooks)
        {
            try
            {
                hook.preWindowOpen();
            }
            catch(Throwable t)
            {
                CorePlugin.logDefaultError(t);
            }
        }
    }
    

    The final step is to provide an extension and class in each plug-in you need to listen to these workbench window events.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a Google Closure Compiler plugin for Eclipse. I already have
I have Eclipse with m2 plugin and want to make new project with Spring.
I have a ListViewer in my eclipse-plugin, I want to do some work when
I'm using CVS through the eclipse plugin. I have a .fla and a .swf
I have eclipse Galileo 3.5 with maven plugin installed. I want to know if
I'm developing a Eclipse plugin. From this plugin I want to instantiate classes from
For my Eclipse plugin I have created a new perspective. This perspective consists of
I have maven eclipse plugin and I want to use a jar file in
I want to install the Eclipse plugin for Symfony 2. But I'm stuck at
I want to bind source to eclipse plugin. I have created custom target from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.