07-03-2016 06:46 PM
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
07-25-2016 01:19 AM
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
07-28-2016 09:25 PM
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
08-02-2016 05:13 AM
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