Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Get and add an action for Eclipse main toolbar's items in code
Get and add an action for Eclipse main toolbar's items in code [message #1810247] Tue, 06 August 2019 03:38 Go to next message
Kien Minh Quan is currently offline Kien Minh QuanFriend
Messages: 7
Registered: July 2019
Junior Member
Hi folks,

Recently, I have been managing how to get Eclipse main toolbar's items and simulate a click action on these items in code. I successfully retrieved the id of toolbar's item, but after that I don't know to use it to simulate a click action.

Below is the code that I have tried to find the solution:

wb = jvm.PlatformUI.getWorkbench()

if (wb.getWorkbenchWindowCount() == 1):
toolbar = wb.getWorkbenchWindows()[0].getCoolBarManager2()
for item in toolbar.getItems():
print(item.getId())

So appreciate your help.

Many thanks!
Re: Get and add an action for Eclipse main toolbar's items in code [message #1810363 is a reply to message #1810247] Thu, 08 August 2019 18:25 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3513
Registered: July 2009
Senior Member

You're asking about plug-in development, not exactly "newcomer" material. You want to ask in either the Eclipse 4 group (https://www.eclipse.org/forums/index.php/f/12/) or
the underlying Eclipse Platform group (https://www.eclipse.org/forums/index.php/f/11/).

What is jvm.PlatformUI? Are you in some other language?


Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Thu, 08 August 2019 18:27]

Report message to a moderator

Re: Get and add an action for Eclipse main toolbar's items in code [message #1810434 is a reply to message #1810363] Mon, 12 August 2019 01:07 Go to previous messageGo to next message
Kien Minh Quan is currently offline Kien Minh QuanFriend
Messages: 7
Registered: July 2019
Junior Member
Hi Nitin Dahyabhai,

I'm really grateful for your reply and recommendation.

Because I have been working this quite different project that I need to use Python script to control Eclipse IDE (Execute some actions with Eclipse IDE in runtime), I just tried using Py4J plugin to create a communication bridge between Python and Java, so as to I can invoke and use some packages that are included in Eclipse IDE runtime instance.

Thus, what you see "jvm.PlatformUI" that I was using PlatformUI package of Eclipse in Python side.

Do you have any more apposite solutions for me in my project?

So appreciate your reply.
Re: Get and add an action for Eclipse main toolbar's items in code [message #1810438 is a reply to message #1810434] Mon, 12 August 2019 04:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Your question seems to be about the "Eclipse in Python" libraries, but those are not provided by Eclipse.org. You should try to track down the people who provide that.

However, if you have an actually tool item, in Java I would use toolItem.notifyListeners(org.eclipse.swt.SWT.Selection, new org.eclipse.swt.widgets.Event.Event()) to make it look like the user clicked (selected) the button.
Re: Get and add an action for Eclipse main toolbar's items in code [message #1810463 is a reply to message #1810434] Mon, 12 August 2019 12:56 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3513
Registered: July 2009
Senior Member

Would the EASE project be a possibility?

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Get and add an action for Eclipse main toolbar's items in code [message #1810512 is a reply to message #1810463] Tue, 13 August 2019 04:34 Go to previous message
Kien Minh Quan is currently offline Kien Minh QuanFriend
Messages: 7
Registered: July 2019
Junior Member
Yes, I have been also trying using EASE project to control Eclipse IDE in runtime, but I have two more considerable problems after starting my first demo with EASE:

1) When I used getShell(), it returned Shell {*Wrong Thread*}, so this is an obstacle for me to get main toolbar from this running Shell.

2) Suppose I have a scripting file (js, py, etc.), is it feasible to run this file from command line console and it still can control Eclipse IDE?

If you have an experience in my headachy issues, please kindly share your resolution.

Many thanks!


Previous Topic:Eclipse suddenly cannot find gcc with correctly configured path.
Next Topic:Socket error on client<unknown>,disconnecting.
Goto Forum:
  


Current Time: Mon Oct 21 04:42:29 GMT 2019

Powered by FUDForum. Page generated in 0.02942 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top