Plugin call thru another one

Help
hermock
2011-06-29
2013-04-06
  • hermock
    hermock
    2011-06-29

    Hi,

      I am writting an eclipse plugin that generates C projects. I would like to automatically associate this project with clearcase.
      I tried this :
    project.open(monitor);
    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IHandlerService.class);
    handlerService.executeCommand("net.sourceforge.eclipseccase.ui.actionset.associate", null);

      But I got the exception :
      org.eclipse.core.commands.NotEnabledException: Trying to execute the disabled command net.sourceforge.eclipseccase.ui.actionset.associate
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:469)
    at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:178)
    at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
    at com.alu.mts.eclat.plugin.progen.WorkspaceHelper$1.run(WorkspaceHelper.java:189)
    at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
    at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1408)

    Any idea ?
    thanks for your kind help.

     
  • Hi,

    I guess you have not added the command ( Action) in your plugin.xml

    br,

    //mike

     

  • Anonymous
    2011-06-30

    Thanks for replying Mike. I must admit I am still new to eclipse plugin development.

    You are right I did not add it, I was expecting to use the cleacase plugin declaration.

    This is where I do not have a clear vision of what I should do to call this action.
    Shall I copy the actionset declaration in my plugin.xml or not ?
    The main problem I see is that my plugin will depend from the clearcase plugin.
    Is there a way to programmaticall Call this action when the plugin is present without declaring the dependency.

    Thanks Mathieu

     
  • Hi,

    This can be a way….

        Action myAction = new Action("myAction") {
                @Override
                public void run() {
                    //what you want to call
                }
            };
    

    Where do you store the plugin? I can look at the code if you want?
    //mike

     
  • hermock
    hermock
    2011-07-05

    Unfortunatelly, the code is not open source yet, I hope to manage to convince my managers to make it open source one day.
    But here is an extract of what I tried to do :

                        //Activate clearcase if necessary
                            project.open(monitor);
                            Display.getDefault().syncExec(new Runnable() {
                                @Override
                                public void run() {
                                    try {
                                    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IHandlerService.class);
                                    handlerService.executeCommand("net.sourceforge.eclipseccase.ui.actionset.associate", null);
                                    logger.addInfo("Project [" + projectName
                                            + "] : Clearcase association successful");
                                } catch (Exception e) {
                                    logger.addWarning("Project [" + projectName
                                            + "] : Clearcase association failed", e);
                                }
    
                                }
    
                            });
    

    Just for you to understand clearly. This code is run in my dedicated plugin, and I declared an optionnal dependency to the clearcase plugin (net.sourceforge.eclipseccase.ui;bundle-version="2.2.9") in my plugin.xml.

     
  • Hi,

    What error do you get from this?

    br,

    //mike

     
  • hermock
    hermock
    2011-07-07

    Here is what I get now :

    WARN : Project [ue_call] : Clearcase association failed
    org.eclipse.core.commands.NotHandledException: There is no handler to execute for command net.sourceforge.eclipseccase.ui.actionset.associate
        at org.eclipse.core.commands.Command.executeWithChecks(Command.java:485)
        at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:178)
        at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
        at com.alu.mts.eclat.plugin.progen.WorkspaceHelper$1.run(WorkspaceHelper.java:189)
        at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
        at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
    
     
  • hermock
    hermock
    2011-07-14

    Any idea ?