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

Refactor BaseAction in RightClickMenu #5958

Merged
merged 25 commits into from
Mar 6, 2020

Conversation

calixtus
Copy link
Member

@calixtus calixtus commented Feb 18, 2020

I started by bugfixing some missing executablebindings. It totally escalated. Sorry.
I believe this could be the beginning of an approach to get rid of the deprecated BaseAction and OldCommandWrapper stuff.

I stop here, because this PR is becoming quite complex even though I tried to keep my modifications short and simple (e.g. I did not extract BasePanel or Globals.prefs, if I did not had to). This PR is theoretically mergable, but we should talk about it first.

I tested everything by hand, it should all work like before.

L10n yet missing, I'm doing this in the very end.

  • Change in CHANGELOG.md described (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for bigger UI changes)
  • Checked documentation: Is the information available and up to date? If not: Issue created at https://github.com/JabRef/user-documentation/issues.

@Siedlerchr
Copy link
Member

Wow, thanks for your huge work! So far I could not see anything which is breaking

@koppor
Copy link
Member

koppor commented Feb 19, 2020

Wow 🤩. Good to see that the GUI code gets better. That always causes much changes. I am really happy that you accepted the challange to do so.

You can also start working on bigger refactorings. We need to reduce Globals.prefs. This will cause a huge diff. Similar to the entry editor refactorings.

So, I would propose that Could not open link, External viewer called, No URL defined is added to the localization and we merge.

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 19, 2020
@koppor koppor changed the title [WIP] Refactor BaseAction in RightClickMenu Refactor BaseAction in RightClickMenu Feb 19, 2020
@calixtus
Copy link
Member Author

Made some final corrections. Should be mergeable now, but I'm not sure if it's best to merge this PR before the next major release. Maybe there are some bugs I did not spot and there would be not much time for the latest dev users to test the changes...

@koppor
Copy link
Member

koppor commented Feb 19, 2020

@tobiasdiez If possible, could you have a quick look?

We would merge it to use the current energy of @calixtus and to avoid huge merge conflicts.

@calixtus
Copy link
Member Author

calixtus commented Feb 19, 2020

Just to be clear, there is still a long way to go with the BaseActions, I could not yet take all of them out of the RightClickMenu. Especially the SpecialFields and the EditActions are closely interlinked with the BaseActions.

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work! I haven't found any major issues and as usual the code quality is really good.

I echo the concern of @calixtus and would recommend waiting with the merge after the release this weekend. There is no need to risk that half of the menu is not working (although the risk for this is really low).

src/main/java/org/jabref/gui/BasePanel.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/JabRefFrame.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/OpenConsoleAction.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/actions/ActionHelper.java Outdated Show resolved Hide resolved
src/main/java/org/jabref/gui/maintable/OpenUrlAction.java Outdated Show resolved Hide resolved
@koppor koppor added this to the v5.1 milestone Feb 20, 2020
@calixtus
Copy link
Member Author

Sorry, wrong commit title.

@calixtus
Copy link
Member Author

calixtus commented Feb 23, 2020

You can also start working on bigger refactorings. We need to reduce Globals.prefs. This will cause a huge diff. Similar to the entry editor refactorings.

I think the most sensible way to proceed is, after completely extracting BaseAction, to untangle BasePanel and BibDatabaseContext a bit. At the same time, the remaining Globals.prefs calls can be broken down a bit into individual preferences classes. When this is done, it should not be a big problem anymore to reduce the unnecessary references to JabRefFrame and BasePanel.

But what will need some discussion is how to proceed with the UndoManager (Partly it doesn't work, because some actions are commented out). If I understand it correctly, it can be distinguished whether it should create an 'UndoStream' for each library or unify it for all libraries.

@tobiasdiez
Copy link
Member

Sounds like a reasonable program. 👍

The undo manager needs to be completely rewritten (we are still using the Swing one). My idea was that one needs to only register what action is performed and the undo manager automatically listens to all changes in the open databases.
Thus in pseudo-code:

// Somewhere global
UndoManager.listenForChanges(currently open database);

// If an action is performed
try (UndoManager.newOperation("Action name")) {
   entry.setField(blaba);
}

In this way, the logic package can be completely independent of the undo manager and does not need to care to return change information (e.g. as it's done right now in the setField method).

Some links that might be helpful:
§ https://github.com/TomasMikula/UndoFX
§ https://github.com/FXMisc/UndoFX
§ http://torgen-engineering.blogspot.de/2016/05/how-to-bring-undoredo-features-to-your.html
§ https://stackoverflow.com/questions/42841258/how-to-undo-redo-a-command-with-javafx
https://stackoverflow.com/questions/40638845/implementing-undo-redo-in-javafx

@calixtus
Copy link
Member Author

The RightClickMenu should now be completely clean of any BaseAction stuff. No more hidden BaseAction in SpecialFields or so. Next step (definitely in another PR) will be to extract BaseAction out of JabRefFrame (main menu and toolbar). But that shouldn't be a big deal anymore (except maybe SaveAction), but most of the funny stuff is already done.

@calixtus calixtus mentioned this pull request Feb 25, 2020
6 tasks
@koppor
Copy link
Member

koppor commented Feb 25, 2020

The ADR on using the Swing Undomanager was in short: Why reimplementing things already industry proven only because the package name is wrong.

Maybe with the new module system, we can skip shipping the swing module so we reduce the binary size when reimplementing the UndoManager.

@JabRef JabRef deleted a comment from sonarcloud bot Feb 25, 2020
stevensdavid added a commit to stevensdavid/jabref that referenced this pull request Feb 26, 2020
The new context menu style that is proposed in JabRef#5958 is now used for
the ShortScience integration.
@koppor koppor force-pushed the master branch 5 times, most recently from b8ef7b7 to 21c6e5e Compare March 4, 2020 17:02
@koppor koppor merged commit c0abdce into JabRef:master Mar 6, 2020
@koppor koppor deleted the replace_deprecated branch March 6, 2020 10:19
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 6, 2020
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.

4 participants