How to remove or set help content to the Help menu available in WizardDialog in eclipse plugin - eclipse

I am calling WizardDialog dialog = new WizardDialog and a new window is opening with a help icon in the bottom button tray in extreme left corner. I don't need that button.
How to remove that or is there any way to add help content to it.

According to bug 330206:
To hide the "?" you need to call setHelpAvailable(false) on your WizardDialog.
If you don't control/create the dialog, you can add the following method to
your wizard:
public void setContainer(IWizardContainer wizardContainer) {
super.setContainer(wizardContainer);
if (getContainer() instanceof TrayDialog)
((TrayDialog)getContainer()).setHelpAvailable(false);
}
To add Help, you can see the general idea in this thread, but take into account bug 3827:
if you are opening the wizard in a WizardDialog you create, you have to set help on the dialog's shell: ex.
dialog.create();
WorkbenchHelp.setHelp(dialog.getShell(), new Object[]{IHelpContextIds.NEW_WIZARD});
dialog.open();

Related

How to create context menu or right click menu on button

when i right click on button open a context menu. how i will do it. i try this code also
MenuManager menuManager = new MenuManager();
Menu menu = menuManager.createContextMenu(btn.getText());
btn.getText().setMenu(menu);
getSite().registerContextMenu(menuManager, btn);
getSite().setSelectionProvider(btn);
I got problem in createContextMenu. Please Help me
createContextMenu requires a Control as its argument, you are passing the button text String. The setMenu method also belongs to Control. So:
MenuManager menuManager = new MenuManager();
Menu menu = menuManager.createContextMenu(btn);
btn.setMenu(menu);
getSite().registerContextMenu(menuManager, btn);
Button does not implement ISelectionProvider so you will have to write one if you want to use the button as the selection provider.
Note that a part can only register one context menu like this and there can only be one selection provider for a part.
If you want context menu contributions from other parts of Eclipe to be added to the menu you must add the line:
menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

Add text next to UI Form action icon in toolbar?

Is there a way to add text next to the action icon in the toolbar of an eclipse RCP UI Form? If you do not assign the Action an ImageDescriptor, the action will be displayed containing only text. If you do give it an ImageDescriptor, it displays only the image. I want to display both side by side, within one button - is there a way to do this?
This will have only the text "Description" in the button on the toolbar:
myAction = new Action("Description", SWT.PUSH) {
#Override
public void run() {}
};
myForm.getToolBarManager().add(myAction);
But adding an image will cause the the text to be replaced:
myAction.setImageDescriptor(newImage);
I was eventually able to find an answer to my issue, hopefully it's helpful to anyone else who runs into this problem. I found this in the Eclipse Rich Client Platform (2nd Ed.) book.
The Action must be converted to an ActionContributionItem with its mode set to MODE_FORCE_TEXT. This will display both the text and the image in the toolbar.
ActionContributionItem aCI = new ActionContributionItem(myAction);
aCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
myForm.getToolBarManager().add(aCI);

Eclipse RCP 4.x show view

I'm working for a short time on the libraries of eclipse 4.x someone could tell me how can I open a view through from the context menu? Thank you in advance.
To show a part anywhere you should define a command in the application model and a handler for the command. To show a part in the handler use:
#Execute
public void execute(EPartService partService)
{
MPart mpart = partService.showPart(part id, PartState.ACTIVATE);
}
In the application Part definition for your part add a Popup Menu to the Menus section. In the popup menu define a HandledMenuItem for your command.
To register the popup menu as the context menu for a control (tree, table etc) use:
#Inject
private EMenuService;
...
menuService.registerContextMenu(control, menu id);

Need to add 'popping up help window' function to About Dialog

I've designed my own help content for my RCP. And the pop up help window works properly for other common dialog, except the Help->About Dialog.
My purpose is once the user clicked the help button, the help window should be popped up successfully just like what eclipse does.
I set an help listener for the aboutAction in my code. Unfortunately it does not work.
aboutAction = ActionFactory.ABOUT.create(getWindow());
WorkbenchHelpSystem.getInstance().setHelp(aboutAction, IWorkbenchHelpContextIds.HELP_CONTENTS_ACTION);
aboutAction.setImageDescriptor(IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_OBJS_DEFAULT_PROD));
aboutAction.setHelpListener(new HelpListener()
{
public void helpRequested(HelpEvent event)
{
getWindow().getWorkbench().getHelpSystem().displayHelp();
}
});
menu.add(aboutAction);
menu.add(new GroupMarker("group.about.ext"));
I am just a beginner in eclipse rcps. Could anyone give me some suggestions?
If you want to know how something is implemented in Eclipse (in your case the about dialog) you could use the Plug-in Spy. Look in this stackoverflow answer for further details on how to use the plug-in spy.

Refreshing the workbench

HI,
I am facing some problem.. I want to hide the menu when eclipse workbench starts.
But the problem is menu is not hiding when the eclipse workbench starts. It is hiding only
when some refresh is happened. for example: when I change the default perspective to some other perspective, I am getting the desired out put. That means menu is hiding.
But when the eclipse workbench is loaded it is not hiding the menu. Below is my code.
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
try {
IWorkbenchWindow window = Workbench.getInstance().getActiveWorkbenchWindow()
if(window instanceof WorkbenchWindow) {
MenuManager menuManager = ((WorkbenchWindow)window).getMenuManager();
IContributionItem[] items = menuManager.getItems();
for(IContributionItem item:items){
System.out.println("item.getId()::: "+item.getId());
menuManager.remove("org.eclipse.ui.run");
menuManager.remove("help");
menuManager.remove("project");
}
}
}`
}
};
Given that you are looking to hide some features, I don't think that this is the best approach. (Not I am using the term feature here in the colloquial way, not as an Eclipse feature.
I would recommend one of two avenues:
Perspectives: See the extension point org.eclipse.ui.perspectives. This allows you to create a new perspective like the debug perspective or the Java perspective. Using a perspective, you can select exactly what menu items and views are shown and which ones are hidden.
Capabilities (aka activites): See the extension point org.eclipse.ui.activities. This allows you to have some fairly fine-grained control over what features are available in the workspace. See more info here: http://wiki.eclipse.org/Galileo_Capabilities
Put Your code in org.eclipse.ui.startup extention point. Make a Startup class after implementing the interface IStartup. For Details follow this link:-
Eclipse plugin : disable/enable dynamically an action from main menubar