Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Frequent Contributor
Posts: 90
Registered: ‎10-13-2015

How to get selected features from legend in JAVA plugin in GMSC

Hi all, 

 

I need to implement own behavior for the sorting of features in the legend and I need to get selected features in legend (e.g. the blue highlighted below). I need to achieve it in Java. Everything works for me now, I have prepared the List<Feature> and I can use it with activeFeature, but I can't find the way, how to fill the List<Feature> with selected feature from legend, just Ids of features or whole Feature objects.

 

 

Thanks for the help.

 

Jakub

Technical Evangelist
Posts: 147
Registered: ‎10-20-2015

Re: How to get selected features from legend in JAVA plugin in GMSC

Hi Jakub,

you can add an action to the legends context and then the given action contains that information.

 

We do something similar in case of the style editor plugin.

 

	@Action(actionLocation = ActionLocation.LEGENDCONTEXT, conditions = { @Condition(actionCondition = StyleEditorActionConditionFactory.class) })
	public void startStyleEditor(RPAction action)
	{
		Objects.requireNonNull(action, "action");
		
		@SuppressWarnings("unchecked")
		final List<Feature> selectedFeatures = (List<Feature>) action.getValue(LegendContextMenu.SELECTED_FEATURES);
		
		if (!Assertion.isValid(selectedFeatures))
			return;
....

Best Regards,

Steve

Frequent Contributor
Posts: 90
Registered: ‎10-13-2015

Re: How to get selected features from legend in JAVA plugin in GMSC

Hi Steve,

 

thanks for your answer. In case that I need this information outside the legendcontext?

 

I try to move actions that change the order of features to the plugintab location instead of legendcontext, everything works fine, I can't just get the selectedFeature list variable somehow to my plugin.

 

I am thinking about the idea to create hidden plugin in legendcontext and call this plugin to get selected features and then use it in the my plugin in plugintab location, but I am not sure if this is a way?

 

Thanks for your help.

 

Regards,

Jakub

Technical Evangelist
Posts: 147
Registered: ‎10-20-2015

Re: How to get selected features from legend in JAVA plugin in GMSC

Hi Jakub,

your workaround wouldn't work. The necessary information (selected features) will be added when the user opens the legend context menu.

 

You need access to the JTree of the used Legend (TreeLegend, FeatureListLegend, VisibleFeatureListLegend, AnalyseableFeatureListLegend) or and therefore we provide no method because as you can imagine, it's a little bit complicated because of the number of different legends.

 

Best Regards,

Steve

Polls
Please register to vote
Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.