-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix: Refactor PushToApplications and split into logic and GUI
#13514
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ee50022
change CAYWEntry.java from class to record
palukku a20d7b2
Merge branch 'JabRef:main' into cayw
palukku 0dcaab6
refactor
palukku 1863499
replace id hash with sharedID
palukku 8dd9c7c
Merge branch 'JabRef:main' into cayw
palukku 0eba897
Merge branch 'JabRef:main' into cayw
palukku 26655cd
Refactor PushToApplications and move the logic part to jablib
palukku 2c66a6d
Merge remote-tracking branch 'origin/cayw' into cayw
palukku 96d79bc
Add Prefix GUI to all gui classes
palukku 02677ef
Merge branch 'JabRef:main' into cayw
palukku 63cf18c
Move Cite Command Preferences from ExternalApplicationsPreferences to…
palukku 7acb3c0
Merge remote-tracking branch 'origin/cayw' into cayw
palukku a13d704
Merge branch 'JabRef:main' into cayw
palukku bfe016f
fix wrong changes
palukku eed07db
Merge remote-tracking branch 'origin/cayw' into cayw
palukku 124abf4
change field name
palukku 7432cd5
checkstyle and rewriterun
palukku e80d7d7
add private constructor
palukku d1cb260
refactor
palukku 881b650
use orElseGet instead of orElse
palukku 19792bf
Merge branch 'main' into cayw
palukku 2b2ad7b
Reduce Gui classes by extending the interfaces with default methods
palukku 566ba96
Add methods for error notification routing and update citation comman…
koppor ba8aa2b
delete
palukku 7372e55
Merge branch 'cayw-2' into cayw
palukku 552206c
rename
palukku 43c632f
Streamline signature for pushEntries
koppor dc5e8db
Merge branch 'JabRef:main' into cayw
palukku ec2bc1e
introduce Applications Enum and change CLI PushToApplications factory.
palukku b78f9b8
Add doc
koppor 12d89f0
refactor
palukku ce96f31
fix tests
palukku b25a985
fix tests2
palukku 282325d
Merge branch 'main' into cayw
palukku 13de083
Merge branch 'main' into cayw
palukku 6be78f2
add ability to cayw to push to other applications
palukku e1a9c52
rename wrong variables
palukku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
jablib/src/main/java/org/jabref/logic/push/Applications.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package org.jabref.logic.push; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public enum Applications { | ||
|
|
||
| EMACS("emacs", "Emacs"), | ||
| LYX("lyx", "LyX/Kile"), | ||
| TEXMAKER("texmaker", "Texmaker"), | ||
| TEXSTUDIO("texstudio", "TeXstudio"), | ||
| TEXWORKS("texworks", "TeXworks"), | ||
| VIM("vim", "Vim"), | ||
| WIN_EDT("winedt", "WinEdt"), | ||
| SUBLIME_TEXT("sublime", "Sublime Text"), | ||
| TEXSHOP("texshop", "TeXShop"), | ||
| VSCODE("vscode", "VScode"); | ||
|
|
||
| private final String id; | ||
| private final String displayName; | ||
|
|
||
| Applications(String id, String displayName) { | ||
| this.id = id; | ||
| this.displayName = displayName; | ||
| } | ||
|
|
||
| public static Optional<Applications> getApplicationByDisplayName(String key) { | ||
| for (Applications application : Applications.values()) { | ||
| if (application.getDisplayName().equalsIgnoreCase(key)) { | ||
| return Optional.of(application); | ||
| } | ||
| } | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| public static Optional<Applications> getApplicationById(String key) { | ||
| for (Applications application : Applications.values()) { | ||
| if (application.getId().equalsIgnoreCase(key)) { | ||
| return Optional.of(application); | ||
| } | ||
| } | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public String getDisplayName() { | ||
| return displayName; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 15 additions & 40 deletions
55
jablib/src/main/java/org/jabref/logic/push/PushToApplications.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,28 @@ | ||
| package org.jabref.logic.push; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| import org.jabref.logic.util.NotificationService; | ||
|
|
||
| public class PushToApplications { | ||
|
|
||
| public static final String EMACS = "Emacs"; | ||
| public static final String LYX = "LyX/Kile"; | ||
| public static final String TEXMAKER = "Texmaker"; | ||
| public static final String TEXSTUDIO = "TeXstudio"; | ||
| public static final String TEXWORKS = "TeXworks"; | ||
| public static final String VIM = "Vim"; | ||
| public static final String WIN_EDT = "WinEdt"; | ||
| public static final String SUBLIME_TEXT = "Sublime Text"; | ||
| public static final String TEXSHOP = "TeXShop"; | ||
| public static final String VSCODE = "VScode"; | ||
|
|
||
| private static final List<PushToApplication> APPLICATIONS = new ArrayList<>(); | ||
|
|
||
| private PushToApplications() { | ||
| } | ||
|
|
||
| public static List<PushToApplication> getAllApplications(NotificationService notificationService, PushToApplicationPreferences preferences) { | ||
| if (!APPLICATIONS.isEmpty()) { | ||
| return Collections.unmodifiableList(APPLICATIONS); | ||
| } | ||
|
|
||
| APPLICATIONS.addAll(List.of( | ||
| new PushToEmacs(notificationService, preferences), | ||
| new PushToLyx(notificationService, preferences), | ||
| new PushToSublimeText(notificationService, preferences), | ||
| new PushToTexmaker(notificationService, preferences), | ||
| new PushToTeXstudio(notificationService, preferences), | ||
| new PushToTeXworks(notificationService, preferences), | ||
| new PushToVim(notificationService, preferences), | ||
| new PushToWinEdt(notificationService, preferences), | ||
| new PushToTexShop(notificationService, preferences), | ||
| new PushToVScode(notificationService, preferences))); | ||
|
|
||
| return APPLICATIONS; | ||
| } | ||
|
|
||
| public static Optional<PushToApplication> getApplicationByName(String applicationName, NotificationService notificationService, PushToApplicationPreferences preferences) { | ||
| return getAllApplications(notificationService, preferences).stream() | ||
| .filter(application -> application.getDisplayName().equals(applicationName)) | ||
| .findAny(); | ||
| /// @param applicationId Used by the CLI to select the application to run. Example: `texstudio` | ||
| public static Optional<PushToApplication> getApplicationById(String applicationId, NotificationService notificationService, PushToApplicationPreferences preferences) { | ||
| return Applications.getApplicationById(applicationId) | ||
| .map(application -> switch (application) { | ||
| case EMACS -> new PushToEmacs(notificationService, preferences); | ||
| case LYX -> new PushToLyx(notificationService, preferences); | ||
| case SUBLIME_TEXT -> new PushToSublimeText(notificationService, preferences); | ||
| case TEXMAKER -> new PushToTexmaker(notificationService, preferences); | ||
| case TEXSTUDIO -> new PushToTeXstudio(notificationService, preferences); | ||
| case TEXWORKS -> new PushToTeXworks(notificationService, preferences); | ||
| case VIM -> new PushToVim(notificationService, preferences); | ||
| case WIN_EDT -> new PushToWinEdt(notificationService, preferences); | ||
| case TEXSHOP -> new PushToTexShop(notificationService, preferences); | ||
| case VSCODE -> new PushToVScode(notificationService, preferences); | ||
| }); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.