Skip to content

Commit

Permalink
Moved preference constants to JabRefPreferences and renamed (JabRef#1786
Browse files Browse the repository at this point in the history
)
  • Loading branch information
oscargus authored and ayanai1 committed Sep 5, 2016
1 parent c327a36 commit b0ecaa3
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.logic.util.Version;
import net.sf.jabref.logic.util.VersionPreferences;
import net.sf.jabref.migrations.PreferencesMigrations;
import net.sf.jabref.preferences.JabRefPreferences;
import net.sf.jabref.preferences.VersionPreferences;

import com.jgoodies.looks.plastic.Plastic3DLookAndFeel;
import com.jgoodies.looks.plastic.theme.SkyBluer;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static void start(String[] args) {

// Update handling of special fields based on preferences
InternalBibtexFields
.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.PREF_SERIALIZESPECIALFIELDS));
.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS));
// Update name of the time stamp field based on preferences
InternalBibtexFields.updateTimeStampField(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FIELD));
// Update which fields should be treated as numeric, based on preferences:
Expand Down
22 changes: 9 additions & 13 deletions src/main/java/net/sf/jabref/external/DroppedFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;
import net.sf.jabref.model.entry.IdGenerator;
import net.sf.jabref.preferences.JabRefPreferences;

import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
Expand All @@ -70,11 +71,6 @@ public class DroppedFileHandler {

private static final Log LOGGER = LogFactory.getLog(DroppedFileHandler.class);

public static final String DFH_LEAVE = "DroppedFileHandler_LeaveFileInDir";
public static final String DFH_COPY = "DroppedFileHandler_CopyFile";
public static final String DFH_MOVE = "DroppedFileHandler_MoveFile";
public static final String DFH_RENAME = "DroppedFileHandler_RenameFile";

private final JabRefFrame frame;

private final BasePanel panel;
Expand Down Expand Up @@ -358,10 +354,10 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy

renameToTextBox.setText(targetName.concat(".").concat(fileType.getExtension()));

linkInPlace.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_LEAVE));
copyRadioButton.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_COPY));
moveRadioButton.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_MOVE));
renameCheckBox.setSelected(frame.prefs().getBoolean(DroppedFileHandler.DFH_RENAME));
linkInPlace.setSelected(frame.prefs().getBoolean(JabRefPreferences.DROPPEDFILEHANDLER_LEAVE));
copyRadioButton.setSelected(frame.prefs().getBoolean(JabRefPreferences.DROPPEDFILEHANDLER_COPY));
moveRadioButton.setSelected(frame.prefs().getBoolean(JabRefPreferences.DROPPEDFILEHANDLER_MOVE));
renameCheckBox.setSelected(frame.prefs().getBoolean(JabRefPreferences.DROPPEDFILEHANDLER_RENAME));

linkInPlace.addChangeListener(cl);
cl.stateChanged(new ChangeEvent(linkInPlace));
Expand All @@ -373,10 +369,10 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (reply == JOptionPane.OK_OPTION) {
// store user's choice
frame.prefs().putBoolean(DroppedFileHandler.DFH_LEAVE, linkInPlace.isSelected());
frame.prefs().putBoolean(DroppedFileHandler.DFH_COPY, copyRadioButton.isSelected());
frame.prefs().putBoolean(DroppedFileHandler.DFH_MOVE, moveRadioButton.isSelected());
frame.prefs().putBoolean(DroppedFileHandler.DFH_RENAME, renameCheckBox.isSelected());
frame.prefs().putBoolean(JabRefPreferences.DROPPEDFILEHANDLER_LEAVE, linkInPlace.isSelected());
frame.prefs().putBoolean(JabRefPreferences.DROPPEDFILEHANDLER_COPY, copyRadioButton.isSelected());
frame.prefs().putBoolean(JabRefPreferences.DROPPEDFILEHANDLER_MOVE, moveRadioButton.isSelected());
frame.prefs().putBoolean(JabRefPreferences.DROPPEDFILEHANDLER_RENAME, renameCheckBox.isSelected());
return true;
} else {
return false;
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/net/sf/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
import net.sf.jabref.logic.importer.ParserResult;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.logging.GuiAppender;
import net.sf.jabref.logic.preferences.LastFocusedTabPreferences;
import net.sf.jabref.logic.undo.AddUndoableActionEvent;
import net.sf.jabref.logic.undo.UndoChangeEvent;
import net.sf.jabref.logic.undo.UndoRedoEvent;
Expand All @@ -138,6 +137,7 @@
import net.sf.jabref.model.entry.EntryType;
import net.sf.jabref.preferences.HighlightMatchingGroupPreferences;
import net.sf.jabref.preferences.JabRefPreferences;
import net.sf.jabref.preferences.LastFocusedTabPreferences;
import net.sf.jabref.specialfields.Printed;
import net.sf.jabref.specialfields.Priority;
import net.sf.jabref.specialfields.Quality;
Expand Down Expand Up @@ -1210,28 +1210,28 @@ private void fillMenu() {
edit.add(unmark);
edit.add(unmarkAll);
edit.addSeparator();
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
JMenu m;
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RANKING)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RANKING)) {
m = new JMenu();
RightClickMenu.populateSpecialFieldMenu(m, Rank.getInstance(), this);
edit.add(m);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RELEVANCE)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RELEVANCE)) {
edit.add(toggleRelevance);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_QUALITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_QUALITY)) {
edit.add(toggleQualityAssured);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRIORITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRIORITY)) {
m = new JMenu();
RightClickMenu.populateSpecialFieldMenu(m, Priority.getInstance(), this);
edit.add(m);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRINTED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRINTED)) {
edit.add(togglePrinted);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_READ)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_READ)) {
m = new JMenu();
RightClickMenu.populateSpecialFieldMenu(m, ReadStatus.getInstance(), this);
edit.add(m);
Expand Down Expand Up @@ -1456,29 +1456,29 @@ private void createToolBar() {
tlb.addSeparator();
tlb.addAction(mark);
tlb.addAction(unmark);
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RANKING)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RANKING)) {
JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown
.generateSpecialFieldButtonWithDropDown(Rank.getInstance(), this);
tlb.add(button);
specialFieldButtons.add(button);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RELEVANCE)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RELEVANCE)) {
tlb.addAction(toggleRelevance);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_QUALITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_QUALITY)) {
tlb.addAction(toggleQualityAssured);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRIORITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRIORITY)) {
JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown
.generateSpecialFieldButtonWithDropDown(Priority.getInstance(), this);
tlb.add(button);
specialFieldButtons.add(button);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRINTED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRINTED)) {
tlb.addAction(togglePrinted);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_READ)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_READ)) {
JButton button = net.sf.jabref.specialfields.SpecialFieldDropDown
.generateSpecialFieldButtonWithDropDown(ReadStatus.getInstance(), this);
tlb.add(button);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/gui/actions/CleanupAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ public void run() {
CleanupPreset cleanupPreset = presetPanel.getCleanupPreset();
cleanupPreset.storeInPreferences(preferences);

if (cleanupPreset.isRenamePDF() && Globals.prefs.getBoolean(JabRefPreferences.AKS_AUTO_NAMING_PDFS_AGAIN)) {
if (cleanupPreset.isRenamePDF() && Globals.prefs.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) {
CheckBoxMessage cbm = new CheckBoxMessage(
Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"),
Localization.lang("Disable this confirmation dialog"), false);
int answer = JOptionPane.showConfirmDialog(frame, cbm, Localization.lang("Autogenerate PDF Names"),
JOptionPane.YES_NO_OPTION);
if (cbm.isSelected()) {
Globals.prefs.putBoolean(JabRefPreferences.AKS_AUTO_NAMING_PDFS_AGAIN, false);
Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, false);
}
if (answer == JOptionPane.NO_OPTION) {
canceled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void init() {
builder.add(cleanUpMakePathsRelative).xyw(1, 4, 2);
builder.add(cleanUpRenamePDF).xyw(1, 5, 2);
String currentPattern = Localization.lang("Filename format pattern").concat(": ")
.concat(Globals.prefs.get(JabRefPreferences.PREF_IMPORT_FILENAMEPATTERN));
.concat(Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN));
builder.add(new JLabel(currentPattern)).xy(2, 6);
builder.add(cleanUpRenamePDFonlyRelativePaths).xy(2, 7);
builder.add(cleanUpBibLatex).xyw(1, 8, 2);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/gui/help/NewVersionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import net.sf.jabref.gui.desktop.JabRefDesktop;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.Version;
import net.sf.jabref.logic.util.VersionPreferences;
import net.sf.jabref.preferences.VersionPreferences;

public class NewVersionDialog extends JDialog {

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/sf/jabref/gui/maintable/MainTableFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,23 @@ public void updateTableFormat() {


// Add the "special" icon columns (e.g., ranking, file, ...) that are enabled in preferences.
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RANKING)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RANKING)) {
tableColumns.add(SpecialMainTableColumns.RANKING_COLUMN);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RELEVANCE)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RELEVANCE)) {
tableColumns.add(SpecialMainTableColumns.RELEVANCE_COLUMN);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_QUALITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_QUALITY)) {
tableColumns.add(SpecialMainTableColumns.QUALITY_COLUMN);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRIORITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRIORITY)) {
tableColumns.add(SpecialMainTableColumns.PRIORITY_COLUMN);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRINTED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRINTED)) {
tableColumns.add(SpecialMainTableColumns.PRINTED_COLUMN);
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_READ)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_READ)) {
tableColumns.add(SpecialMainTableColumns.READ_STATUS_COLUMN);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/sf/jabref/gui/menus/RightClickMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
}
}

if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RANKING)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RANKING)) {
JMenu rankingMenu = new JMenu();
RightClickMenu.populateSpecialFieldMenu(rankingMenu, Rank.getInstance(), frame);
add(rankingMenu);
Expand All @@ -132,23 +132,23 @@ public RightClickMenu(JabRefFrame frame, BasePanel panel) {
// TODO: multiple handling for relevance and quality-assurance
// if multiple values are selected ("if (multiple)"), two options (set / clear) should be offered
// if one value is selected either set or clear should be offered
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_RELEVANCE)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_RELEVANCE)) {
add(Relevance.getInstance().getValues().get(0).getMenuAction(frame));
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_QUALITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_QUALITY)) {
add(Quality.getInstance().getValues().get(0).getMenuAction(frame));
}
if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRINTED)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRINTED)) {
add(Printed.getInstance().getValues().get(0).getMenuAction(frame));
}

if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_PRIORITY)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_PRIORITY)) {
JMenu priorityMenu = new JMenu();
RightClickMenu.populateSpecialFieldMenu(priorityMenu, Priority.getInstance(), frame);
add(priorityMenu);
}

if (Globals.prefs.getBoolean(JabRefPreferences.PREF_SHOWCOLUMN_READ)) {
if (Globals.prefs.getBoolean(JabRefPreferences.SHOWCOLUMN_READ)) {
JMenu readStatusMenu = new JMenu();
RightClickMenu.populateSpecialFieldMenu(readStatusMenu, ReadStatus.getInstance(), frame);
add(readStatusMenu);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/sf/jabref/gui/preftabs/ImportSettingsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public ImportSettingsTab(JabRefPreferences prefs) {

@Override
public void setValues() {
useDefaultPDFImportStyle.setSelected(prefs.getBoolean(JabRefPreferences.PREF_IMPORT_ALWAYSUSE));
int style = prefs.getInt(JabRefPreferences.PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE);
useDefaultPDFImportStyle.setSelected(prefs.getBoolean(JabRefPreferences.IMPORT_ALWAYSUSE));
int style = prefs.getInt(JabRefPreferences.IMPORT_DEFAULT_PDF_IMPORT_STYLE);
switch (style) {
case ImportDialog.NOMETA:
radioButtonNoMeta.setSelected(true);
Expand All @@ -139,12 +139,12 @@ public void setValues() {
radioButtonPDFcontent.setSelected(true);
break;
}
fileNamePattern.setText(prefs.get(JabRefPreferences.PREF_IMPORT_FILENAMEPATTERN));
fileNamePattern.setText(prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN));
}

@Override
public void storeSettings() {
prefs.putBoolean(JabRefPreferences.PREF_IMPORT_ALWAYSUSE, useDefaultPDFImportStyle.isSelected());
prefs.putBoolean(JabRefPreferences.IMPORT_ALWAYSUSE, useDefaultPDFImportStyle.isSelected());
int style = ImportSettingsTab.DEFAULT_STYLE;
if (radioButtonNoMeta.isSelected()) {
style = ImportDialog.NOMETA;
Expand All @@ -155,8 +155,8 @@ public void storeSettings() {
} else if (radioButtononlyAttachPDF.isSelected()) {
style = ImportDialog.ONLYATTACH;
}
prefs.putInt(JabRefPreferences.PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE, style);
prefs.put(JabRefPreferences.PREF_IMPORT_FILENAMEPATTERN, fileNamePattern.getText());
prefs.putInt(JabRefPreferences.IMPORT_DEFAULT_PDF_IMPORT_STYLE, style);
prefs.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, fileNamePattern.getText());
}

@Override
Expand Down
Loading

0 comments on commit b0ecaa3

Please sign in to comment.