Skip to content
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

Xml editor demo #164

Merged
merged 3 commits into from
Aug 7, 2015
Merged

Xml editor demo #164

merged 3 commits into from
Aug 7, 2015

Conversation

cemartins
Copy link
Contributor

Hi Tomas,

I closed the previous pull request because I found a bug in my demo. This one is working ok, now.

Here is my pull request with an XMLEditor demo. I thought the poor man's regex parsing method was still the best (I tried with stax, but found it difficult to get the cursor positions on attributes).

I think it might not be very performant with large xml files, since it calls for a full text parsing on every keystroke. Any ideas how I can make this better?

Kind regards
Carlos

TomasMikula added a commit that referenced this pull request Aug 7, 2015
@TomasMikula TomasMikula merged commit 73384d2 into FXMisc:master Aug 7, 2015
@TomasMikula
Copy link
Member

Thanks for the contribution, looks good to me.

As to your question, you can

  • a) use a really fast parser and don't mind re-parsing the whole file;
  • b) trigger parsing only when the user paused typing, plus run the parser in a background thread so that it does not slow down the UI. This is implemented in the JavaKeywordsAsync demo and you can read about the mechanism in this blog post;
  • c) use an incremental parser that does not have to re-parse the whole file on every edit. I know about PapaCarlo, but I don't know how good/mature it is.

@cemartins
Copy link
Contributor Author

Thanks for accepting my contribution :)

I looked into your JavaKeywordsAsync demo and saw that you are using Java8 streams to handle the change events more efficiently. It is really great, but I still need some more time to study it.

Also, if the text is changing because the user is typing, then I can check if the change was made inside an xml tag ( < .... > ) and recalculate the syntax highlighting only in this case and only for the affected xml tag.

This is just an idea. I don't quite know how to go about it yet.

@TomasMikula
Copy link
Member

They are ReactFX EventStreams, not Java 8 Streams. Java 8 Streams are not suitable for the task, because they are pull-based (demand driven), but UI events don't occur on demand. We need reactive (push-based) kind of streams.

@cemartins
Copy link
Contributor Author

Right. Thank you Tomas.
I must study about ReactFX as well.

On 08 Aug 2015, at 17:05, Tomas Mikula notifications@github.com wrote:

They are ReactFX https://github.com/TomasMikula/ReactFX EventStreams, not Java 8 Streams. Java 8 Streams are not suitable for the task because they are pull-based (demand driven), but UI events don't occur on demand. We need reactive (push-based) kind of streams.


Reply to this email directly or view it on GitHub #164 (comment).

@JordanMartinez
Copy link
Contributor

@cemartins If you're unfamiliar with Reactive Programming, this article (The introduction to Reactive Programming you've been missing) helped me understand the fundamental ideas behind it. That might help you better understand the ReactFX library.

@cemartins
Copy link
Contributor Author

Thank you so much Jordan. I will definetely read this article. I also found the course on reactive programming that Tomas mentioned (https://www.coursera.org/course/reactive https://www.coursera.org/course/reactive). Looks like I’m going to be busy learning new tricks for the next few weeks :)

Thank you again for your care and support.

Kind regards
Carlos

On 08 Aug 2015, at 22:02, JordanMartinez notifications@github.com wrote:

@cemartins https://github.com/cemartins If you're unfamiliar with Reactive Programming, this article (The introduction to Reactive Programming you've been missing https://gist.github.com/staltz/868e7e9bc2a7b8c1f754) helped me understand the fundamental ideas behind it. That might help you better understand the ReactFX library.


Reply to this email directly or view it on GitHub #164 (comment).

@JordanMartinez
Copy link
Contributor

Yes, you'll be busy learning some new tricks, but those tricks will save you hours of headaches. :-)
I would take that class, but it's for Scala; I use Groovy. Still, I might do it just to get a deeper understanding of the ideas and get an idea for how Scala works.

@cemartins
Copy link
Contributor Author

Yep. I work in java, but am quite curious about scala, so this course is a bonus! I'm in! :)

On 09/08/2015, at 20:42, JordanMartinez notifications@github.com wrote:

Yes, you'll be busy learning some new tricks, but those tricks will save you hours of headaches. :-)
I would take that class, but it's for Scala; I use Groovy. Still, I might do it just to get a deeper understanding of the ideas and get an idea for how Scala works.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants