[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[pde-dev] Simple PDE project: put an action in console view's context menu
|
Hi, I'm an advanced java user, but I'm a newbie in PDE.
I'm trying to do something very very simple: I need to put an Action in the console view's context menu.
Can u give me any help on this?
//mybutton.Activator class
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
TextConsolePage textConsolePage=((TextConsolePage)this.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IConsoleConstants.ID_CONSOLE_VIEW).getSite().getPage());
TextConsoleViewer viewer= textConsolePage.getViewer();
String menuID="#ContextMenu";
MenuManager menuMgr=new MenuManager("satckFinder",menuID);
//menuMgr.add(new SearchStackAction());
Menu menu= menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
textConsolePage.getSite().registerContextMenu(menuID,menuMgr,viewer.getSelectionProvider());
}
//mybutton.MyButtonAction class
public class MyButtonAction implements IObjectActionDelegate {
// The text selected in the console
private String selectedText;
/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
}
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
Shell shell = new Shell();
MessageDialog.openInformation(shell, "MyButton Plug-in","My Button was executed.");
}
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof ITextSelection) {
setSelectedText(((ITextSelection) selection).getText());
}
}
/**
* selectedText setter
*
* @param selectedText
* the text selected in the console
*/
public void setSelectedText(String selectedText) {
this.selectedText = selectedText;
}
}
<!-- plugin.xml file -->
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.ui.console.TextConsolePage"
id="MyButton.contribution1">
<menu
label="My Button Submenu"
path="additions"
id="MyButton.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="My Button"
class="mybutton.popup.actions.MyButtonAction"
menubarPath="MyButton.menu1/group1"
enablesFor="*"
id="MyButton.MyButtonAction">
</action>
</objectContribution>
</extension>
</plugin>
I'm sure that I have more than one problem here, but the first problem I would like to solve is that the mybutton.Activator#start(bundle) method doesn't execute (I executed the plugin in debug mode and put a breakpoint in that method and never stopped)
Thanks in advance
View this message in context:
Simple PDE project: put an action in console view's context menu
Sent from the
Eclipse PDE - General mailing list archive at Nabble.com.