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

Extract PushTo names into model #8005

Merged
merged 3 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/push/PushToEmacs.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.model.JabRefStringConstants;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;
Expand All @@ -22,7 +23,7 @@

public class PushToEmacs extends AbstractPushToApplication implements PushToApplication {

public static final String NAME = "Emacs";
public static final String NAME = JabRefStringConstants.EMACS;

private static final Logger LOGGER = LoggerFactory.getLogger(PushToEmacs.class);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/push/PushToLyx.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.JabRefStringConstants;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;
Expand All @@ -23,7 +24,7 @@

public class PushToLyx extends AbstractPushToApplication implements PushToApplication {

public static final String NAME = "LyX/Kile";
public static final String NAME = JabRefStringConstants.LYX;

private static final Logger LOGGER = LoggerFactory.getLogger(PushToLyx.class);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/push/PushToTeXstudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.model.JabRefStringConstants;
import org.jabref.preferences.PreferencesService;

public class PushToTeXstudio extends AbstractPushToApplication implements PushToApplication {

public static final String NAME = "TeXstudio";
public static final String NAME = JabRefStringConstants.TEXSTUDIO;

public PushToTeXstudio(DialogService dialogService, PreferencesService preferencesService) {
super(dialogService, preferencesService);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/push/PushToVim.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.JabRefStringConstants;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;
Expand All @@ -21,7 +22,7 @@

public class PushToVim extends AbstractPushToApplication implements PushToApplication {

public static final String NAME = "Vim";
public static final String NAME = JabRefStringConstants.VIM;

private static final Logger LOGGER = LoggerFactory.getLogger(PushToVim.class);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/push/PushToWinEdt.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.model.JabRefStringConstants;
import org.jabref.preferences.PreferencesService;

public class PushToWinEdt extends AbstractPushToApplication implements PushToApplication {

public static final String NAME = "WinEdt";
public static final String NAME = JabRefStringConstants.WIN_EDT;

public PushToWinEdt(DialogService dialogService, PreferencesService preferencesService) {
super(dialogService, preferencesService);
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/jabref/model/JabRefStringConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.jabref.model;

public class JabRefStringConstants {
Copy link
Member

@calixtus calixtus Aug 20, 2021

Choose a reason for hiding this comment

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

Maybe missing a private empty constructor, so this class can't be instantiated.
Codewise LGTM, although I really don't know if this is good practice. But to move forward and calm @koppor s temper...

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @calixtus not sure either. I would at least rename the class to PushToApplicationConstants and would have expected them in a supackge model/push/

Copy link
Member

Choose a reason for hiding this comment

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

Name of the class came up yesterday as we were thinking about collecting all the commonly used constant strings in jabref in that class.

Please add the private constructor, then we should merge, to start with the little things.


// PushTo name constants
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 VIM = "Vim";
public static final String WIN_EDT = "WinEdt";
}
31 changes: 13 additions & 18 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@
import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle;
import org.jabref.gui.maintable.MainTablePreferences;
import org.jabref.gui.mergeentries.MergeEntries;
import org.jabref.gui.push.PushToEmacs;
import org.jabref.gui.push.PushToLyx;
import org.jabref.gui.push.PushToTeXstudio;
import org.jabref.gui.push.PushToTexmaker;
import org.jabref.gui.push.PushToVim;
import org.jabref.gui.push.PushToWinEdt;
import org.jabref.gui.search.SearchDisplayMode;
import org.jabref.gui.specialfields.SpecialFieldsPreferences;
import org.jabref.gui.util.Theme;
Expand Down Expand Up @@ -101,6 +95,7 @@
import org.jabref.logic.util.io.AutoLinkPreferences;
import org.jabref.logic.util.io.FileHistory;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.JabRefStringConstants;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.BibEntryTypesManager;
Expand Down Expand Up @@ -1746,12 +1741,12 @@ public void storeCitationKeyPatternPreferences(CitationKeyPatternPreferences pre
@Override
public PushToApplicationPreferences getPushToApplicationPreferences() {
Map<String, String> applicationCommands = new HashMap<>();
applicationCommands.put(PushToEmacs.NAME, get(PUSH_EMACS_PATH));
applicationCommands.put(PushToLyx.NAME, get(PUSH_LYXPIPE));
applicationCommands.put(PushToTexmaker.NAME, get(PUSH_TEXMAKER_PATH));
applicationCommands.put(PushToTeXstudio.NAME, get(PUSH_TEXSTUDIO_PATH));
applicationCommands.put(PushToVim.NAME, get(PUSH_VIM));
applicationCommands.put(PushToWinEdt.NAME, get(PUSH_WINEDT_PATH));
applicationCommands.put(JabRefStringConstants.EMACS, get(PUSH_EMACS_PATH));
applicationCommands.put(JabRefStringConstants.LYX, get(PUSH_LYXPIPE));
applicationCommands.put(JabRefStringConstants.TEXMAKER, get(PUSH_TEXMAKER_PATH));
applicationCommands.put(JabRefStringConstants.TEXSTUDIO, get(PUSH_TEXSTUDIO_PATH));
applicationCommands.put(JabRefStringConstants.VIM, get(PUSH_VIM));
applicationCommands.put(JabRefStringConstants.WIN_EDT, get(PUSH_WINEDT_PATH));

return new PushToApplicationPreferences(
applicationCommands,
Expand All @@ -1762,12 +1757,12 @@ public PushToApplicationPreferences getPushToApplicationPreferences() {

@Override
public void storePushToApplicationPreferences(PushToApplicationPreferences preferences) {
put(PUSH_EMACS_PATH, preferences.getPushToApplicationCommandPaths().get(PushToEmacs.NAME));
put(PUSH_LYXPIPE, preferences.getPushToApplicationCommandPaths().get(PushToLyx.NAME));
put(PUSH_TEXMAKER_PATH, preferences.getPushToApplicationCommandPaths().get(PushToTexmaker.NAME));
put(PUSH_TEXSTUDIO_PATH, preferences.getPushToApplicationCommandPaths().get(PushToTeXstudio.NAME));
put(PUSH_VIM, preferences.getPushToApplicationCommandPaths().get(PushToVim.NAME));
put(PUSH_WINEDT_PATH, preferences.getPushToApplicationCommandPaths().get(PushToWinEdt.NAME));
put(PUSH_EMACS_PATH, preferences.getPushToApplicationCommandPaths().get(JabRefStringConstants.EMACS));
put(PUSH_LYXPIPE, preferences.getPushToApplicationCommandPaths().get(JabRefStringConstants.LYX));
put(PUSH_TEXMAKER_PATH, preferences.getPushToApplicationCommandPaths().get(JabRefStringConstants.TEXMAKER));
put(PUSH_TEXSTUDIO_PATH, preferences.getPushToApplicationCommandPaths().get(JabRefStringConstants.TEXSTUDIO));
put(PUSH_VIM, preferences.getPushToApplicationCommandPaths().get(JabRefStringConstants.VIM));
put(PUSH_WINEDT_PATH, preferences.getPushToApplicationCommandPaths().get(JabRefStringConstants.WIN_EDT));

put(PUSH_EMACS_ADDITIONAL_PARAMETERS, preferences.getEmacsArguments());
put(PUSH_VIM_SERVER, preferences.getVimServer());
Expand Down