How to call my handler instead of ResetPerspectiveHandler when clicked on ResetPerspective? - eclipse-rcp

When I click on ResetPerspective in my RCP application, execute() method of ResetPerspectiveHandler is getting called and its a predefined handler.
I need to perform some task before so I created a handler which extends ResetPerspectiveHandler. So now the flow should be like when I click on ResetPerspective first my handler should get called from there ResetPerspectiveHandler will be called (super.execute()).
How can I call my handler instead of ResetPerspectiveHandler?

Related

UE5 Create Event issues

I am having issues creating an event inside a function.
My function calls a “Bind Event to On Destroyed”. When dragging out the Event node, I call Create Event. After dragging the output of my bind event actor into the Create Event “Object” input, I select “Create a matching event” from the dropdown.
Afterwards, a new custom event appears inside my function, let’s call it “RespawnEvent”:
Now, when I search for the event in my “Create Event” dropdown, it just doesn’t appear:
Is this a bug or am I doing something wrong here?
Thanks in advance!

GWT - How to handle multiple handlers for the same event

I'm currently working on a GWT project. I have a common block shared between multiple pages. I have some action buttons on that common block and the pages have a handler for the event launched on the click of those action buttons.
The problem I'm facing is that when I click on one of those action buttons on Page A, the handler from Page B previsouly registered would be called too.
So the solution I thought of was to remove the handler from a page when we leave it so there would be only one page at once with a registered handler to the same action button event.
First, I register to the action button click events and save the HandlerRegistration object returned from the addHandler method:
HandlerRegistration actionButtonClickEventHandlerRegistration=eventBus.addHandler(CommonBlockActionButtonClickedEvent.TYPE, someHandler);
And then, on page change event, I call removeHandler from the previously saved HandlerRegistration object
eventBus.addHandler(PageChangeEvent.TYPE, new PageChangeEventHandler() {
#Override
public void onMainPageChange(PageChangeEvent event) {
actionButtonClickEventHandlerRegistration.removeHandler();
}
});
So I do that on every pages, except that when I lauch my app and go to two of those pages, I get this error:
Caused by: java.lang.AssertionError: redundant remove call
Do you guys have any idea of why I'm getting this error or another way to solve my issue ?
Thanks a lot !
I would set the handler to null after removing it and I would check if it is actually null before removing it.
Like this:
eventBus.addHandler(PageChangeEvent.TYPE, new PageChangeEventHandler() {
#Override
public void onMainPageChange(PageChangeEvent event) {
if(actionButtonClickEventHandlerRegistration != null ) {
actionButtonClickEventHandlerRegistration.removeHandler();
actionButtonClickEventHandlerRegistration = null;
}
}
});
Nevertheless you seem to remove the handler at least twice and should check your program logic for that.
A good approach to do that is to set a breakpoint in the debugger (of your browser) on the line removing the handler. If you look at the call stack for every call to it, you should be able to spot the duplicate call and fix it.

Eclipse calling IWorkbenchWindowActionDelegate

I have written an eclipse plugin in 3.7 and in my Action delegate which gets called when user chooses a menu option I would like to call another Action Delegate.
To be more specific, I have an action delegate and I would like to call the equivalent of Team -> Refresh action (Specifically Perforce).
The relevant action class is com.perforce.team.ui.p4java.actions.RefreshAction however how can I construct, init and call a method?
Can someone tell me how I can achieve this?

How do I access the toolbar item (org.eclipse.swt.widgets.ToolItem) from within the Activator?

I'm implementing a simple eclipse notification plugin that is supposed to change an icon in the toolbar if something of some nature happens. I made an extension to org.eclipse.ui.menus and the icon shows up nicely.
I thought of starting a poller thread in the Activator and have it poll every couple minutes and changing the icon accordingly.
The thread must have access to the ToolItem in order to call setImage(). How do I access the ToolItem to pass it on to the Thread?
Your handler must implement org.eclipse.ui.commands.IElementUpdater. It can call org.eclipse.ui.menus.UIElement.setIcon(ImageDescriptor). When you need to update the image, you call org.eclipse.ui.commands.ICommandService.refreshElements(String, Map) to trigger the refresh and the call to your handler.

glade aboutDialog doesn't close

I have an AboutDialog box made in glade, but the Close button doesn't work. I don't know how to connect this button to a separate function, since it sits in a widget called dialog-action_area.
Another problem is if I use the close button created by the window manager, I can't open it again because it has been destroyed.
How can I change this so it just hides?
As any other Dialog window, they require you to
Make use of the run method.
Make use of the "reponse" signal
The first will block the main loop and will return as soon as the dialog receives a response, this may be, click on any button in the action area or press Esc, or call the dialog's response method or "destroy" the window, the last don't mean that the window wil be destroyed, this means that the run() method will exit and return a response. like this:
response = dialog.run()
If you use a debugger, you will notice that the main loop stays there until you click on a button or try to close the dialog. Once you have received yout response, then you can useit as you want.
response = dialog.run()
if response == gtk.RESPONSE_OK:
#do something here if the user hit the OK button
dialog.destroy()
The second allow you to use the dialog in a non-blocking stuff, then you have to connect your dialog to the "response" signal.
def do_response(dialog, response):
if response == gtk.RESPONSE_OK:
#do something here if the user hit the OK button
dialog.destroy()
dialog.connect('response', do_response)
Now, you notice that you have to destroy your dialog
You need to call the widget's hide() method when you receive delete or cancel signals:
response = self.wTree.get_widget("aboutdialog1").run() # or however you run it
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
self.wTree.get_widget("aboutdialog1").hide()
You can find the Response Type constants in the GTK documentation