Activate the activator class - eclipse

I am using eclipse 3.6. I created one sample plugin application. It is neither a eclipse rcp nor workbench. Now when I run the eclipse I want that plugin also to be loaded. But I dont want to use IStartUp. Because what I have found out is
IStartup will be called after the workbench is loaded. I want to refresh some menu. So Is there any way to activate my plugin while the eclipse loaded?
I tried to use Bundle Activation policy. But that is also not activating my Activator class. I just put one System.out. println("Inside start()"). So that is not called. Now can I make it activate my activator?
EDIT:
what my exact requirement is, I have created one workbench application.It is not eclipse rcp application. Now I want to remove the following menu and menu items from the eclipse before the eclipe is loaded.
1. File Menu
2.) Search Menu
3.)Run Menu
4.)Help->search,Dynamic Help,Key assist,Tips and trick,Report Bug,Cheat Sheet.
These menus are inbuilt menu of eclipse. So that is the reason I have to do in this way.
So I already implemented by using startup extension point. But the early startup is called after the eclipse is started.So I need to do some refreshment on the workbench.Then only the menu item will get removed.So I thought I need startup extension point will not satisfy my requirement as it doesnot refresh the workbench.I need to activate the my plugin and refresh the workbench before it is loaded.
Thanks
Bhanu

You can set the needed start level for your plugin using touch point instruction.

You are just a plugin that expects to run in the Eclipse IDE?
Then the answer is, you cannot do what you want.
If you start before the workbench has finished initializing, most of the services that could be used won't work: The workbench itself, menu service, command service, etc.
For most plugins in eclipse, the plugin.xml should be used to add menus, views, editors, etc to eclipse. When necessary, the framework will instantiate them.
org.eclipse.ui.IStartup is available and as you mentioned it will be called after the workbench has been initialized, but before any windows have been shown. It's not to be used lightly, and not by plugins contributing to the UI as it allows all extension from that plugin to be loaded.
EDIT:
If you are an RCP app, you control the main menu. As an RCP app, you have access to the ActionBarAdvisor, WorkbenchAdvisor, WorkbenchWindowAdvisor, which all have lifecycle methods.
If you are an an eclipse plugin, you can add to the main menu ... you cannot easily remove from the main menu. This is by design. Start levels and org.eclipse.ui.startup are 2 mechanisms that won't do what you want.
You still need to answer these questions:
There might still be a way. The crux of your problem is: "I want to refresh some menu"
What kind of menu (popup, main menu,
compound list of menu items in a
menu, etc)?
Where is the menu contribution coming from?
Which specific menu item is it?
Please edit your question (do not comment) and include the information from the above 3 questions, please.

Related

Eclipse Neon CDT missing manage configurations button

I created a C project in eclipse neon and I am trying to delete some of the build configurations. However I can not get to the manage configurations dialog I am used to. The button seems to be missing. Did it go somewhere else or is my eclipse just buggy?
I think this window is supposed to look more like this. See how there is a manage configurations button next to the dropdown at the top.
I just tried switching workspaces and when I use a clean workspace I can see the button.
While the aforementioned hacks indeed work, such an approach is impossible when one already has many projects and now wishes to target another architecture.
I have found another way.
Right click on the project and select, from the pop-up menu,Build Configurations, and one of the menu items is Manage. This behaves as the disappearing Manage Configurations button.
PS: this is still a problem with Oxygen 3.

Eclipse neon: different behavior for context menus ? Possible bug in eclipse v4.6.0?

JMSToolBox is an eclipse-rcp v4.5.2 based application.
I tried to upgraded to eclipse v4.6.0 but found a problem with popups menu as follows:
A part is defined in the e4 model as a Part Descriptor (PD). A popup menu is defined inside that PD
On a certain action, the PD descriptor is instanciated and the part is added and displayed in a Part Stack. The body of this part is a TabFolder with multiple tabs corresponding to a JMS Q browsed. Each tab body is basically composed of a TableViewer/Table to display JMS messages.
Each time a new tab is created, a new TableViewer/Table is created and the popupmenu is registered on the Table of the TableViewer with the following line of code:
menuService.registerContextMenu(table,<id of the popup menu in the part>);
This works perfectly with eclipse v4.5.2 (Mars) but not with v4.6.0 (Neon) !
With neon, the popup is working only for the first tab: the context menu is visible and #CanExecute methods associated to the handlers/commands of the menu items are called . For subsequent tabs created, no popup is displayed and #CanExecute methods for the menu items are not called
If I register a different menu with a different Id (previously added to the PD) for each tab, it works! So I suspect this may be due to the fact that a menu with the same element id is added to multiple TableViever/Table even if it is coming from a different instance of a PD...
Is it a bug in neon? a regression? or do I benefit of a bug in mars that makes the application is working Ok with this version?
For now I have to downgrade (or not upgrade) to eclipse v4.5.2..
For reference, I pushed some code to correct the problem. It will be in eclipse v4.6.1+ bug #496695

In Eclipse, how can I view which ui class is active?

I know that there is a feature in Eclipse that shows the class name of the active element of the eclipse interface (for example, the class of the element selected with mouse). It is used to debug client plugin extensions, but I don't remember how to call it..
How can I get this feature? Which key combination I can use?
Thanks,
Michele.
You are probably thinking of the Plug-in Spy plug-in. Press Alt+Shift+F1 to see to details about the current selection. Alt+Shift+F2 lets to find out information about menu items.

How to remove a menu itme from menubar in eclipse rcp

I am trying to remove "project" menu from menubar dynamically, means using code. Please help me out. It will be really helpful if someone can provide the exact code.
If you are writing an RCP application you can control what goes into the main menu. If you are adding plugins that you didn't write yourself and they are using extension points to contribute to the main menu, you can use Activities/Capabilities to remove them.
You cannot remove things from the main menu programmatically, unless your code contributed it.

how to access package explorer element in eclipse plugin

i am making an eclipse plugin which make a ui on right clicking a project in eclipse workspce . the ui contains text fields , package explorer for the current project and directory explorer for current project.
i have successfully made a ui which appears on clicking a menu item on right clicking the project but it seems i can't make any jface or swt ui since they are not visible when we are using eclipse command hadlers .so in order to overcome it i made dialog pages but they have limited dialog like directorty dialog and file dialog and that too for entire window directory..... but i want package explorer and directory explorer for the project i just chose like it happens when u try making a new class in a project the browse buttons just show packages and directory struture w.r.t to current selection
am i doin things wrong or is there a way out please suggest .....
It seems a bit unclear to me, what the 'UI' is about. If you plan to embed the package and directory views inside a dialog next to each other, then I think you have to build similar lists on your own, since they are views with their own event logic. But if you plan to use them via the browse buttons as describes, take a look at this page. It gives a good overview of the available selection dialogs in eclipse.
It is also always a good practice to search for code in eclipse that does nearly the same you want to do.
As an example, take a look at the new class wizard from the jdt.ui plug-in (This is the wizard you mentioned in your question): Press Cmd-Shift-T and begin typing 'newclass' and open NewClassWizardPage from org.eclipse.jdt.ui.wizards. This works as expected if you imported all jdt plug-ins as (binary) projects.
Take a look at the createControl method and dive into the createXXXControls methods via F3 and try to find out how JDT is doing the job.
As an alternative, open the desired selection dialog class (again with Cmd-Shift-T) and open the call hierarchy of that class...