Get notified when user jumps to a marker (annotation) in Eclipse - eclipse

I'm currently writing a plugin for the Eclipse IDE. In this plugin, I defined my own type of resource marker (IMarker). Using the standard Eclipse means like the "Next annotation"/"Previous annotation" buttons, the user has the possibility to navigate between these markers. I also wrote a view which shows some detail information for a single marker. This view shall be updated when the user navigates to a marker. Can I register some kind of listener/observer that will be notified when the user selects/jumps to a marker? If so, how? If not, what are my alternatives?

The Next Annotation action ends up calling the ITextEditorExtension4.gotAnnotation method. The usually implementation for this is in AbstractTextEditor. This just calls finds the annotation and calls the selectAndReveal method.
So there does not seem to be any special listener you can use for this. Normal selection events should be generated so you could use the ISelectionService selection listener but you will have to work out if the selection is for your marker.

Related

How can I make use of Event Delegation in a parent Svelte Component

In this example, if I click the Tutorial NavItem I get to the Tutorial
section. Here I forward an custom click event on every Nav Item, where I set the segment which has been clicked. In the app.svelte I pull in the NavItem component and set the segment to current, which tells the Nav Component (through Props), which segment is current and needs to be active.
My question is how Can i Make use of event Delegation, so the Nav Component listen for the click Event, so it doesn't feel so repetitiv
The minimal Example goes like that, I want the parent to handle the event?:
https://svelte.dev/repl/691e82ee168549c782b61c355e78cf9b?version=3.12.1
Here is a complex Ex. the Repl:
https://svelte.dev/repl/691e82ee168549c782b61c355e78cf9b?version=3.12.1
I see you already use the getContext and setContext functionality. Instead of firing the event you can simply update that context:
in NavItem.svelte
function setSegment(){
current.set(segment);
}

ImgButton : How to tell SmartGWT to not concatene state on the name of file source?

private ImgButton button = new ImgButton();
...
button.setSrc("iconName.jpg");
GWT or SmartGWT, I cannot tell exactly, generate state word to concatene it on the name of file.
Example to clarify :
On focus, iconName.jpg become iconName_Focus.jpg
On mouse down click, iconName.jpg become iconName_Down.jpg
On over, iconName.jpg become iconName_Over.jpg
Because these images are custom images, I want to tell GWT to take a default image when I didn't provide the corresponding image.
For example, when over event is fire and iconName_Over.jpg does not exist then use iconName.jpg.
Use the setShow{State} or setShow{State}Icon methods accordingly. For example for disabling the mouse down state, use setShowDown(Boolean.FALSE). For not showing a different icon when the mouse goes down on the button, use the setShowDownIcon(Boolean.FALSE). The rest of the actions have accordingly named methods you can look up at the ImgButton's javadoc page.

Update Eclipse menu item enabled state

I created the menu item in the "File" menu as a command. For this command there is a handler implementing the IHandler interface. This handler contains the isEnabled method. I am trying to use this method to enable/disable my menu item, but that method is called only once when I click on the "File" menu. When clicked for the second, third etc. times, the isEnabled method is not called again even if I changed the state of page (open/close editors) before.
What should I do? Maybe this method is not intended for control menu items?
Are you subclassing org.eclipse.core.commands.AbstractHandler? You should use setBaseEnabled(boolean) to update the state of your handler (which would update your command).
It's only valid to change enabled state in your handler as long as you also fire the HandlerEvent. It's usually easier to call setBaseEnabled(boolean) which will fire the event for you.
If you're trying to enable/disable the menu, than you should use core expressions.
I've already explained how to do that in this answer:
Eclipse RCP menus & actions: Configure or code?
The part that you're interested in starts with:
For activating/deactivating a menu[...]
I hope this is what you're looking for.

Windows Phone 7 - Bing Maps MVVM Pushpin initialization

Does anyone have a good guideline on how to initialize a pushpin on the Bing Maps control?
My current scenario works, but is not 100% correct... let me explain the details:
When I open the page with the Bing Maps control on it, I want the user to be able to push a small button that will show his current location.
To show the current location, I'm using a Pushpin. I'm already adding the Pushpin on the control in the XAML file like this:
<map:Pushpin> x:Name="currentLocation" Location="{Binding CurrentLocation}" Content="Me" ManipulationStarted="CurrentLocationPin_ManipulationStarted" </map:Pushpin>
Now with this scenario there a some problems!
One, the pushpin is always visible! So how do I go about this? ( I know I can bind the Visibility also to a property and use a bool to visibility converter, but is this the best way to do this? )
Secondly, now I don't initialize the Location in the viewmodel... but for semantic reasons I would love to initialize the default value to Geocoordinate.Unkown ( that way I can use this to do checks when the user tries to do some manipulation before a currentlocation is set ). But when I initialize the pushpin on startup I get following error: "UIElement.Arrange(finalRect) cannot be called with Infinite or NaN values in finalRect.". So my question again :) what is a good guideline to setting up a currentlocation pushpin? ( but do mind that the users has to push a small application bar button before the currentlocation is set )
The initialization problem is due to the visibility of the Pushpin. If the initial visibility of the Pushpin is Collapsed, then it won't take part in the arrange pass, so you won't get the error.
If you're using a view model to back this view, then I don't see a problem with exposing a property from the view model that determines whether the Pushpin should be visibile or not. Yes you could use a boolean to visibility converter, but you could save some processing by actually exposing a Visibility property (which is the approach I've used).
If you're using a command to initiate showing the Pushpin from the button push (the Silverlight Windows Phone Toolkit has a behavior to enable hooking up application bar buttons to commands).

Eclipse Plug-in / View Question

I have a plugin which contains class A that brings up a view defined in class B via the following line of code:
(VideoLogView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("Videolog.VideoLogView");
What I need to do in the createPartControl() method of the view (class B object) is access a method in the class A object.
How can this be done?
Thanks.
Look like you are facing the classic issue of "how do I pass arguments to my view" ?
This thread illustrates it best:
I was facing the same problem at the beggining of my RCP project. I was getting weird about the fact that there was no way to pass an argument to a view as the viewed model.
Why? Because (emphasis mine):
You are on an opened, pluggable platform.
You contribute to existing developments, others should be able to contribute to yours.
Therefore you will not "pass" arguments to a view, this would lock the whole thing into a non-opened design.
Instead, your view will ask the platform (or will listen to the platform) to determine which information to manage.
Other views (from other plugins that don't yet exist) might also want to manage the same information on the same event.
What you should do then is to ask the workbench for the current selection. I guess your view is opening on a double click action or simple selection so the object you want to manage in your view will be currently selected.
This is how you could retrieve the workbench selection from your view :
ISelection s = this.getSite().getWorkbenchWindow().getSelectionService().getSelection();
where "this" is a ViewPart.
Then you have to make your initial view (the one initiating the view creation from a given event like DoubleClick) a selection provider. A JFace viewer is a selection provider, so you can use it if you're using jface, or you can implement the ISelectionProvider interface when you're using custom SWT controls (that was my case).
The article "Eclipse Workbench: Using the Selection Service" can also give you some pointers.