-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Watch main css file for change and reapply automatically #3847
Conversation
I generated a structure-diff below from pulling |
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.
So this code wacthes for CSS file changes all the time in production code? I'm ok with adding this for the dev version but imho something like this shouldn't be inside the release code.
@stefan-kolb The idea was actually that external css files are also supported so that the user can edit them directly (in the hope that we can get one or two designers interested, which create a nice theme for us - similar to the dozen of different color schemes for IDEs). The overhead of the change listener should be almost non-existing (and we don't have a method to test for production code, do we?) |
We could still use external css files without polling for changes all the time. I don't think its valuable except for debugging/designing purposes. A simple restart of the app if one wants a new CSS theme would totally be standard behavior. |
When you use ScenicView it has the ability to hook into the css files and you can then achieve the same effect. |
I also think polling all the time for CSS changes is too much and I would not expose this feature directly to the user (at least not all the time). However, wouldn't it be possible to merge it anyway, but make the polling turned on by e.g. a command-line switch or a Java environment variable? This would have no impact on the performance of the release version and it would help us and possibly non-existent godlike UI designers with too much time :) @Siedlerchr Have you actually tried this with JabRef and ScenicView? For inspecting the tree-nodes, it is OK, but changing the style is a pain. It is much more convenient to work in the CSS files, at least with my current experience. I would really like to see this happen and as long as we only do polling on demand, it should not have a performance impact. @tobiasdiez Do you agree that there is no performance drop without polling? |
The file monitor is now only activated if the css file exists as a direct physical file, i.e. is not bundled in the jar. You guys are of course right that there is no need to monitor a css file in the bundled jar archive. By the way, if I understand it correctly, then the Watcher does not poll the file for changes but actually registers listeners that fire upon changes (at least for modern OSs). Thus it is very performative and scales to thousands of active file listeners (and the limit lies more in the IOPS needed for registering the listeners). There shouldn't be any noticeable overhead for a few files. |
The "live reloading" has now to be turned on by defining -Djabref.main.css Additionally, the location of the Main.css file can be given as parameter to this property. This makes it way more convenient when working on the code, because usually the location of the Main.css is in the build folder. Now, you can use the Main.css from the source directly.
I tested the live reloading from IDEA and it was inconvenient because the watched I wanted it to be as convenient for me as possible and I would like to change the source
lets them turn on live styling. I have tested this version both from the IDE and from command-line and it seems to work as expected. Can we merge this into the maintable-beta so that I can pull it into my other branch? |
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 like your changes @halirutan! +1 for merge.
If you fix the checkstyle issue (constant names must be uppercase with underscore), we can merge |
Co-authored-by: Tobias Diez <[email protected]> Co-authored-by: Patrick Scheibe <[email protected]>
de555c4
to
cb069ef
Compare
@Siedlerchr Thanks! I usually use this format as well, but Tobi used CamelCase and I wasn't sure anymore how we handle this. |
…esDlg * upstream/maintable-beta: Get rid of journal abbrev loader in linkedFiles (#3862) fix build, remove layout prefs, pass journal abbrev loader and prefs where necessary Watch main css file for change and reapply automatically (#3847) Provides download option in context menu and fixes #3614 (#3824) Minor refactoring # Conflicts: # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
With this PR, working on styling and css files should be easier. Css files are now watched for changes and automatically reloaded. Thus JabRef does not have to be restarted in order to apply a new design. In IntellJ you can now start debugging, edit the css and apply the changes by
Build > Build project
orRun > Reload Changed Classes
.The idea of the
ThemeLoader
class is to support external css files (next to the jar file) in the future so that users could change the theme on their own.I'll add a short note documenting this feature to the wiki after this PR gets merged.