Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] [CDT Platform] Add a button to the debug toolbar

I haven't looked deeply at the code you posted but I didn't notice the use of the menu.ui extension point.  When I use the command framework I use the extension points:
Command
Handler
Menu

I recommend you mimic the connect button which is added by CDT to the Debug toolbar. That should be the closest example you can find to what you seem to want.

BR,
Marc

From: Christelle BURGUERA <Christelle.BURGUERA@xxxxxx>
Sent: Nov 26, 2015 03:11
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] [CDT Platform] Add a button to the debug toolbar

Hi,

 

I develop plugins installed on a CDT Eclipse to do C/C++ application.

I would like to add a button to the debug toolbar next to “Resume” button for example or not so far ….

To do that I was inspired by the button “Resume”. I did the same things, I just changed the id and name but for the moment my button should have the same behavior that Resume button !

But no L !

 

By default it’s enabled when no debug is launched and more annoying it’s visible in the others perspectives !

 

I put breakpoints on “init” function of ResumeCommandActionDelegate and ResetCommandActionDelegate (my commandActionDelegate). When I open the debug perspective, the breakpoint on “init” function of ResumeCommandActionDelegate is detected but not in my commandActionDelegate, the breakpoint is detected only when I click on the button … but too late !

I think my action isn’t register !

But I don’t know why ….

 

See the sources code :

plugin.xml:

[CODE]

// actionSets

<extension

         point="org.eclipse.ui.actionSets">

      <actionSet

            id="blabla.debug.reset.actionset"

            label="Reset"

            visible="true">

         <action

               class="blabla.debug.actions.ResetCommandActionDelegate"

               definitionId="blabla.debug.commands.Reset"

               disabledIcon="icons/unselected_restart.gif"

               hoverIcon="icons/selected_restart.gif"

               icon="icons/selected_restart.gif"

               id="blabla.debug.action.reset"

               label="Reset"

               menubarPath="org.eclipse.ui.run/stepGroup"

               toolbarPath="org.eclipse.debug.ui.main.toolbar/additions"

               tooltip="Reset the chip to restart the process">

         </action>

      </actionSet>

   </extension>

// Command

<command

            categoryId="org.eclipse.debug.ui.category.run"

            defaultHandler="blabla.debug.commands.ResetHandler"

            description="Reset the chip to restart the process"

            id="blabla.debug.commands.Reset"

            name="Reset">

      </command>

[/CODE]

 

Associated sources:

[CODE]

package blabla.debug.commands;

 

import org.eclipse.debug.core.commands.IRestartHandler;

import org.eclipse.debug.core.commands.IResumeHandler;

import org.eclipse.debug.ui.actions.DebugCommandHandler;

 

 

 

public class ResetHandler extends DebugCommandHandler {

 

            @Override

                        protected Class<IResumeHandler> getCommandType() {

                    return IResumeHandler.class;

                }

 

}

[/CODE]

 

[CODE]

package blabla.debug.actions;

 

import org.eclipse.debug.ui.actions.DebugCommandAction;

import org.eclipse.jface.action.IAction;

import org.eclipse.jface.viewers.ISelection;

import org.eclipse.swt.widgets.Event;

import org.eclipse.ui.IActionDelegate2;

import org.eclipse.ui.IWorkbenchWindow;

import org.eclipse.ui.IWorkbenchWindowActionDelegate;

 

public class ResetCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 {

 

           

            private DebugCommandActionfDebugAction = new ResetCommandAction();

   

    @Override

            public void dispose() {

        fDebugAction.dispose();

    }

 

    @Override

            public void init(IWorkbenchWindow window) {

        fDebugAction.init(window);

    }

 

    @Override

            public void run(IAction action) {

        fDebugAction.run();

    }

 

    @Override

            public void selectionChanged(IAction action, ISelection selection) {

        // do nothing

    }

 

    @Override

            public void init(IAction action) {

        fDebugAction.setActionProxy(action);

       

    }

 

    @Override

            public void runWithEvent(IAction action, Event event) {

        run(action);

    }

}

[/CODE]

 

[CODE]

package blabla.debug.actions;

 

import org.eclipse.debug.core.commands.IRestartHandler;

import org.eclipse.debug.core.commands.IResumeHandler;

import org.eclipse.debug.internal.ui.DebugPluginImages;

import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;

import org.eclipse.debug.internal.ui.actions.ActionMessages;

import org.eclipse.debug.ui.actions.DebugCommandAction;

import org.eclipse.jface.resource.ImageDescriptor;

import org.eclipse.ui.plugin.AbstractUIPlugin;

 

import blabla.debug.MCUDebugPlugin;

 

public class ResetCommandAction extends DebugCommandAction {

 

           

            public ResetCommandAction() {

                        setActionDefinitionId("org.eclipse.debug.ui.commands.Resume"); //$NON-NLS-1$

            }

 

    @Override

            public String getText() {

        return ActionMessages.ResumeAction_0;

    }

 

    @Override

            public String getHelpContextId() {

        return "org.eclipse.debug.ui.resume_action_context"; //$NON-NLS-1$

    }

 

    @Override

            public String getId() {

        return "org.eclipse.debug.ui.debugview.toolbar.resume"; //$NON-NLS-1$

    }

 

    @Override

            public String getToolTipText() {

        return ActionMessages.ResumeAction_3;

    }

 

    @Override

            public ImageDescriptor getDisabledImageDescriptor() {

        return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESUME);

    }

 

    @Override

            public ImageDescriptor getHoverImageDescriptor() {

        return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME);

    }

 

    @Override

            public ImageDescriptor getImageDescriptor() {

        return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME);

    }

 

            @Override

            protected Class<IResumeHandler> getCommandType() {

                        return IResumeHandler.class;

            }

 

}

[/CODE]

 

If you have any idea ….

Many thanks !!!

 

Chris


Back to the top