-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some small changes #52
Conversation
… sync annotationComponents on refresh
@@ -369,13 +369,17 @@ public void updateView(String propertyConstant, Object oldValue, Object newValue | |||
if (PropertyConstants.DOCUMENT_VIEW_ROTATION_CHANGE.equals(propertyConstant) || | |||
PropertyConstants.DOCUMENT_VIEW_ZOOM_CHANGE.equals(propertyConstant)) { | |||
if (annotationComponents != null) { | |||
for (AbstractAnnotationComponent comp : annotationComponents) { | |||
comp.validate(); | |||
synchronized (annotationComponents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting change, I curious what usage scenario you ran into a concurrency issue? This "should" all be happening on the AWT thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must admit, it was while working on some custom extensions involving adding annotations programmatically on startup to the page(s).
I could probably avoid doing that if there is a way to know if a PageViewComponent for a given Page is loading/going to load and when it has finished doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is is the MetricsPageLoadingListener interface but it might not offer the granularity you need. I'll merge this soon but wan't to get your opinion the interface and what you're trying to get done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, to summarize:
I have one or several files of annotations (that I dumped)
In commonNewDocumentHandling
, I go through all the pages and get their annotations (simply to force init them)
After that, I go through all the PageViewComponents
and check if their annotationComponents
is null : if yes, I add the annotations directly to the Page
, otherwise I add it through the documentViewController
(to ensure the annotation component will appear on the view). That's also why I synchronize annotationComponents
, I guess a component got added while the view was being updated.
Now that you mentioned the AWT thread, I imagine that if I force this whole process to go through this thread, I shouldn't have synchronization problems. Although it wouldn't help if there is a concurrent access to initPageAnnotations
(I also marked it synchronized
on my end).
Perhaps a PageLoadingListener could be useful here indeed. Knowing when a page is being inited or painted could save me some trouble I guess.
Basically, what I'm looking for is a way to add "atomically" one or more annotations to a page, and if the PageViewComponent linked to this page is shown on screen, also add the related AnnotationComponents.
If you want to see the exact code I can send it to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I think I've bumped into this problem a couple times over he years as we've had user that are pulling the annotations int from a database to assemble the document. I don't see any performance issue with he locks but it certainly feels like there should be an API that makes this process a lot simpler to the end users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be a great addition indeed. Interesting to know that we are not the only one trying to do this.
Fixes #51