Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for selection changes in views #84

Closed
steghoja opened this issue Feb 12, 2019 · 6 comments
Closed

Support for selection changes in views #84

steghoja opened this issue Feb 12, 2019 · 6 comments

Comments

@steghoja
Copy link

I have a use case in which I want to regenerate the diagram when the selection in the project explorer changes. Since the project explorer is not an editor, changes in this view are not captured by PlantUmlView out of the box.

I have managed to implement a very hacky way of achieving what I want by extending PlantUmlView and overwriting updateDiagramText(boolean, IWorkbenchPart, ISelection) and exposing the list of DiagramTextProviders via PlantUmlUtil. However, this hardly feels like the best way to do it and I wonder if there is a more elegant solution.

I imagine other use cases such as creating a class diagram on selecting a package in the package explorer.

Any ideas for how to achieve this?

@hallvard
Copy link
Owner

The current design allows diagramTextProviders to say they support a specific editor and optionally its selection. It sounds easy to extend this to also cover views (IWorkbenchPart in general), but I haven't looked at the details. The relevant code is in net.sourceforge.plantuml.eclipse.views.AbstractDiagramSourceView, where an IPartListener triggers updating the diagram text. There's several place where the code checks that the workbench part is an editor, it may just work removing the checks and changing some types from IEditorPart to IWorkbenchPart.

I'm not sure if parts contribute selection providers to the site, so the selection listener logic may need to be extended.

@steghoja
Copy link
Author

Thanks for the quick answer! I suspected as much. This would be a pretty deep change and will probably require extensive testing. I'll see what I can do and send a pull request if I come up with something.

@hallvard
Copy link
Owner

https://www.eclipse.org/articles/Article-WorkbenchSelections/article.html suggests views also contribute selections through the site's selection service, so that part of the current design should just work.

@steghoja
Copy link
Author

steghoja commented Feb 13, 2019

I have made some progress on this and you can see my WIP here. When I activate a view (such as the Project Explorer or the Package Explorer), the generation of diagrams is now triggered. I have not yet managed to get changes in the selections to work. The listener is triggered, but the change is not reflected in the diagram. However, if I leave the view and return, the update happens. I suspect that this has to do with pinnedTo, but I need to investigate further.

At this point, I'd be happy if you could have a look at the changes, maybe test them with your test rig, and let me know what you think.

@anb0s
Copy link

anb0s commented Mar 25, 2019

We have also PlantUML output generated in views e.g. in console view from some tool. How can we help with testing? Do you have a plugin build for install and test? Thanks!

hallvard added a commit that referenced this issue Apr 3, 2019
text consoles. Preference page for diagram text provider enablement.
@hallvard
Copy link
Owner

hallvard commented Apr 4, 2019

Close, should be fixed in release 1.1.23

@hallvard hallvard closed this as completed Apr 4, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants