-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[WIP] Convert entry preview panel to JavaFX #3504
Conversation
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 have tested it locally and it works except for the printing and the display bug you mentioned. These things should still be fixed or addressed in some way before this is merged.
I also have a few code comments, mainly addressing code duplication with the JFXPanel
.
@halirutan has done some more analysis regarding the citation styles since you opened this PR. Maybe you can use this information to improve performance now?
} | ||
|
||
private JFXPanel setupPreviewContainer(PreviewPanel preview) { | ||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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 don't like the fact this chunk of three lines is duplicated all over the place. Maybe add a new factory class that provides a method to build a JFXPanel
but hides the OS aspect.
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.
Good remark! Fixed.
copyPreview.setOnAction(event -> copyPreviewToClipBoard()); | ||
MenuItem printEntryPreview = new MenuItem(Localization.lang("Print entry preview"), IconTheme.JabRefIcon.PRINTED.getGraphicNode()); | ||
printEntryPreview.setOnAction(event -> print()); | ||
MenuItem previousPreviewLayout = new MenuItem(Localization.menuTitle("Previous preview layout")); |
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.
On my machine, the localization string appears prefixed with an &
. Even if that's not nicely solvable here, could you at least implement a quick hack to remove the preceeding &
?
Also, in the Swing version the context menu text also listed the shortcuts for the menu item. This should be the case here as well.
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 removed the & and added the display of the shortcut.
printEntryPreview.setOnAction(event -> print()); | ||
MenuItem previousPreviewLayout = new MenuItem(Localization.menuTitle("Previous preview layout")); | ||
previousPreviewLayout.setOnAction(event -> basePanel.ifPresent(BasePanel::previousPreviewStyle)); | ||
MenuItem nextPreviewLayout = new MenuItem(Localization.menuTitle("Next preview layout")); |
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.
Same here with the display bug.
} | ||
}); | ||
} | ||
public void print() { |
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 method does not work on my machine. In the swing version a dialog would appear. Here, the printer icon pops up in the taskbar, but no documents are added.
EDIT: I take it back, the method does seem to work. When I just logged into the printer I found a document waiting for me. However, this should be less of a surprise. In the old version a dialog popped up where you could configure the printer a little. We don't need the exact same thing here, but could at least have a dialog displayed for like two seconds, saying: "Printing..." or something similar.
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.
ohh gosh. By default, I print to PDF and thus the PDF print dialog poped up and everything seemed to work just fine. But, of course, in general you want to have a confirmation dialog and a possibility to change the printer. Luckily, javafx provides a default dialog for printing, so this was easy to implement.
b.add(new JScrollPane(pp)).xy(3, row); | ||
PreviewPanel previewPanel = new PreviewPanel(null, null); | ||
previewPanel.setEntry(entry); | ||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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.
Again the construction of the panel should be outsourced somewhere.
@@ -230,7 +234,9 @@ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String undoNam | |||
centerPan.setLayout(new BorderLayout()); | |||
|
|||
contentPane.setTopComponent(new JScrollPane(glTable)); | |||
contentPane.setBottomComponent(preview); | |||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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.
Again outsource as above.
mainPanel.add(entryPreview, CELL_CONSTRAINTS.xyw(1, 8, 6)); | ||
entryPreview = new PreviewPanel(null, null); | ||
entryPreview.setEntry(mergedEntry); | ||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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.
Again outsource as above.
@@ -154,7 +158,9 @@ private void init() { | |||
builder.add(new JScrollPane(table)).xyw(1, 3, 5); | |||
builder.add(addButton).xy(3, 5); | |||
builder.add(removeButton).xy(5, 5); | |||
builder.add(preview).xyw(1, 7, 5); | |||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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.
Again outsource as above.
PreviewPanel testPane = new PreviewPanel(null, null); | ||
testPane.setFixedLayout(layout.getText()); | ||
testPane.setEntry(TestEntry.getTestEntry()); | ||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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.
Again outsource as above.
@@ -149,7 +154,10 @@ private void init(String title) { | |||
entryTable.addMouseListener(new TableClickListener()); | |||
|
|||
contentPane.setTopComponent(sp); | |||
contentPane.setBottomComponent(preview); | |||
|
|||
JFXPanel container = OS.LINUX ? new CustomJFXPanel() : new JFXPanel(); |
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.
Again outsource as above.
@tobiasdiez @lenhard I hacked a version of the Remarks: The current behavior is that the first Preview takes as long as it took and until the style or the output format is changed, all follow-up calls are cheap, fast and don't use much memory. In numbers this means that while before one call to create the preview text needed 70.000 ms under profiling, it now takes on average about 800ms. The memory is better as well. Before we had about 85MB per preview and now 100 previews need 125MB (including the first expensive call). Btw: Don't be confused when I say it needs over 500MB and it needs 85MB. The profiler does not count all objects and makes certain estimates. So the profiling memory will usually be smaller than what you see in your memory monitor. |
@halirutan From my point of view, we could just scrap the CSLs again and remove them from JabRef completely. But I think @koppor has a strong opinion on it. Maybe the right way to go is to have them improve their implementation and I've seen that you've already opened an issue for that michel-kraemer/citeproc-java#40 Let's hope they react. |
Yeah, CSL was wished by many users and is a strong selling point 😇
To improve speed, we added the CSL cache. Think, with JavaScript V8, it
also can get much better. Maybe, we should put energy in that...
Reimplementing csl-proc in Java is also possible, but much effort...
|
I checked out this branch and I would have included my fix in here, but we still have the big problem, that UTF8 fonts are not displayed correctly. This might be related to this question I asked recently although now it's for JavaFX and I'm on Linux. Anyway, in the old preview, if an entry contains e.g. In the JavaFX preview from this branch, the same entry displays like this If you like to try this out, here is the shortened entry
My PR for the CSL performance should be almost unrelated to this here and can later easily be merged if we find it works acceptably. |
Thanks for the feedback. I revised the code accordingly. @halirutan I couldn't replicate the problem with |
Everything wrong above. There is only one italics H. I totally misunderstood the comment at https://stackoverflow.com/q/46954858/873282: --cut - emphasize is mine -- |
From what I read, the mathematic area is the only font which provides italics. And I am unsure whether we really should support that. |
Question: If there was a mystical For the Mathematica plugin, I had to transform the doc of built-in function to html. Fortunately, I could even use MathML and now the function docs contain everything from italics, simple formulas, and integrals. |
@halirutan There is a latex2html converter. But not all cases should be handled by this, for example you typically want names with accents or other weird characters to be displayed as Unicode. |
I propose the following which may make our life a lot easier:
So why don't we use the latex2html converter on both of them? |
@Siedlerchr That was the reason behind my question. I ran several times into this issue on both Linux and OS X and it was the reason for the question on SO. There, it was also suggested to use HTML and I'm also confident, that it would make life easier. In addition to "it is rendered at all" we hopefully get a better quality. On Linux the italics look so ugly that it is almost not bearable. Therefore, if easily possible, I vote for using HTML for rendering LaTeX. |
One reason for using latex2unicode was that our own custom conversion was relatively incomplete and partly broken. I am not sure on the state of the html conversion, but I wouldn't presume that it's perfect. So if we go for displaying html everywhere (which is perfectly fine in my point of view), it would also be cool if we had a robust Java library that does the LaTeX to html conversion. I am not sure if such a library exists, though, and then we will have to make do with the current conversion. The main reason for latex2unicode was to enable a proper search of entries independent of LaTeX commands. As far as I understand, this shouldn't conflict with displaying html and can be kept as is. |
So how do we want to proceed with this PR? The discussion concerning latex2unicode/html is a bit decoupled from the actual purpose of this PR (which is just to move forward with the migration to JavaFX). Maybe it also makes sense to extract our latex2html code and merge it into the latex2unicode library we use. |
@tobiasdiez I really would like to concentrate on the JavaFX part of this PR as well, but until the unicode issue is resolved, this breaks preview for entries that contain any LaTeX on my machine. As long as I'm not the only one where this happens, I see no way we could merge this PR without annoying a lot of users. Therefore, we need to discuss the latex2XXX issue somewhere first. Do you have a suggestion how we should proceed? |
+1 for switchting to latex2html in this case (entry preview). Thus, moved to v4.2 and not for v4.1 release. |
I now used latex2html for the preview and it seems to work fine. I also implemented the citation style provider as discussed with @halirutan in his recent PR. Sadly, I made some mistakes with while checking out my code and now cannot push to this branch anymore (git claims "everything is up-to-date" - well it isn't). So continued at #3574. |
@tobiasdiez in that case you have to do a force push, e.g. when amending your last commit. |
@tobiasdiez Only regarding the
When you merge updates into this branch and you use rebase, then you cannot push it again. If you are sure no one else has used your branch, you have to make a force push and everything is fine. Rebasing your (local) branch looks nicer because you don't get a cluttered history wich merge commits, but it should only be used you are working on a local branch. |
Thanks for the help but the problem was not about the rebase/force pushed. I created the branch on another pc and used the github gui tool to check it out on a new one. For some reason git now thinks the remote branch associated to my local code is |
You can edit .git/config directly for changing branch config. You can also
use gitk --all to check, what's going on.
Finally, git push -f origin HEAD:BranchNameAtOrigin always works;
regardless of your local branch name. No need to create a new PR then...
Am 23.12.2017 22:22 schrieb "Tobias Diez" <[email protected]>:
… Thanks for the help but the problem was not about the rebase/force pushed.
I created the branch on another pc and used the github gui tool to check it
out on a new one. For some reason git now thinks the remote branch
associated to my local code is JabRef/javafxPreview instead of just
javafxPreview. I could probably remove/readd the remote branch but it was
easier to just create a new PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3504 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABTafhu0cSaLVRCdGZVkQx8EhjmoDjIpks5tDW8dgaJpZM4Q7wk4>
.
|
I migrated the entry preview to JavaFX. My hope was to resolve the memory issues #2533, but this was sadly not successful (thus the issues really come from the citation style cache and not from the display).
Notable differences:
lang.menuTitle
to get the text but menu titles contain the acceleration key binding. Probably one needs to convert the main toolbar to JavaFX as well in order to fix this problem.gradle localizationUpdate
?