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

Fix Codacy Unused Params, Fields #3753

Merged
merged 20 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1963,8 +1963,6 @@ private class RedoAction implements BaseAction {
@Override
public void action() {
try {

JComponent focused = Globals.getFocusListener().getFocused();
getUndoManager().redo();
markBaseChanged();
frame.output(Localization.lang("Redo"));
Expand Down
14 changes: 2 additions & 12 deletions src/main/java/org/jabref/gui/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,9 @@ public class IconTheme {
private static final Map<String, String> KEY_TO_ICON = readIconThemeFile(
IconTheme.class.getResource("/images/Icons.properties"), "/images/external/");

// Christmas edition
//public static final Color DEFAULT_COLOR = new Color(0x155115);
//public static final Color DEFAULT_DISABLED_COLOR = new Color(0x990000);
private static Font FONT_16;
private static javafx.scene.text.Font FX_FONT;

static {
try (InputStream stream = getMaterialDesignIconsStream()) {
FONT = Font.createFont(Font.TRUETYPE_FONT, stream);
FONT_16 = FONT.deriveFont(Font.PLAIN, 16f);
try (InputStream stream2 = getMaterialDesignIconsStream()) {
FX_FONT = javafx.scene.text.Font.loadFont(stream2, JabRefPreferences.getInstance().getInt(JabRefPreferences.ICON_SIZE_LARGE));
}
} catch (FontFormatException | IOException e) {
LOGGER.warn("Error loading font", e);
}
Expand Down Expand Up @@ -92,14 +82,14 @@ public static Image getJabRefImageFX() {
return getImageFX("jabrefIcon48");
}

/**
/*
* Constructs an {@link Image} for the image representing the given function, in the resource
* file listing images.
*
* @param name The name of the icon, such as "open", "save", "saveAs" etc.
* @return The {@link Image} for the function.
*/
public static Image getImageFX(String name) {
private static Image getImageFX(String name) {
return new Image(getIconUrl(name).toString());
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/jabref/gui/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexString;
import org.jabref.model.metadata.MetaData;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -43,7 +42,6 @@ public class ChangeScanner implements Runnable {
private final File file;
private final Path tempFile;
private final BibDatabaseContext databaseInMemory;
private final MetaData metadataInMemory;

private final BasePanel panel;
private final JabRefFrame frame;
Expand All @@ -62,7 +60,6 @@ public ChangeScanner(JabRefFrame frame, BasePanel bp, File file, Path tempFile)
this.panel = bp;
this.frame = frame;
this.databaseInMemory = bp.getDatabaseContext();
this.metadataInMemory = bp.getBibDatabaseContext().getMetaData();
this.file = file;
this.tempFile = tempFile;
}
Expand Down Expand Up @@ -132,7 +129,7 @@ public void run() {
// Start looking at changes.
BibDatabaseDiff differences = BibDatabaseDiff.compare(databaseInTemp, databaseOnDisk);
differences.getMetaDataDifferences().ifPresent(diff -> {
changes.add(new MetaDataChangeViewModel(metadataInMemory, diff));
changes.add(new MetaDataChangeViewModel(diff));
diff.getGroupDifferences().ifPresent(groupDiff -> changes.add(new GroupChangeViewModel(groupDiff)));
});
differences.getPreambleDifferences().ifPresent(diff -> changes.add(new PreambleChangeViewModel(databaseInMemory.getDatabase().getPreamble().orElse(""), diff)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@
import org.jabref.model.database.BibDatabase;
import org.jabref.model.metadata.MetaData;

/**
*
*/
class MetaDataChangeViewModel extends ChangeViewModel {

private final InfoPane infoPane = new InfoPane();
private final JScrollPane sp = new JScrollPane(infoPane);
private final MetaData originalMetaData;
private final MetaData newMetaData;

public MetaDataChangeViewModel(MetaData originalMetaData, MetaDataDiff metaDataDiff) {
public MetaDataChangeViewModel(MetaDataDiff metaDataDiff) {
super(Localization.lang("Metadata change"));
this.originalMetaData = originalMetaData;
this.newMetaData = metaDataDiff.getNewMetaData();

infoPane.setText("<html>" + Localization.lang("Metadata change") + "</html>");
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.jabref.gui.fieldeditors;

import java.util.Optional;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Parent;
Expand All @@ -18,9 +16,10 @@

public class JournalEditor extends HBox implements FieldEditorFX {

@FXML private JournalEditorViewModel viewModel;
@FXML private EditorTextArea textArea;
private Optional<BibEntry> entry;
@FXML
private JournalEditorViewModel viewModel;
@FXML
private EditorTextArea textArea;

public JournalEditor(String fieldName, JournalAbbreviationLoader journalAbbreviationLoader, JabRefPreferences preferences, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers) {
this.viewModel = new JournalEditorViewModel(fieldName, suggestionProvider, journalAbbreviationLoader, preferences.getJournalAbbreviationPreferences(), fieldCheckers);
Expand All @@ -41,7 +40,6 @@ public JournalEditorViewModel getViewModel() {

@Override
public void bindToEntry(BibEntry entry) {
this.entry = Optional.of(entry);
viewModel.bindToEntry(entry);
}

Expand All @@ -51,7 +49,7 @@ public Parent getNode() {
}

@FXML
private void toggleAbbreviation(ActionEvent event) {
private void toggleAbbreviation(ActionEvent unused) {
viewModel.toggleAbbreviation();
}
}
26 changes: 13 additions & 13 deletions src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class FileListEntryEditor {
private final JComboBox<ExternalFileType> types;
private final JProgressBar prog = new JProgressBar(SwingConstants.HORIZONTAL);
private final JLabel downloadLabel = new JLabel(Localization.lang("Downloading..."));
private JDialog diag;
private JDialog dialog;
//Do not make this variable final, as then the lambda action listener will fail on compile
private JabRefFrame frame;
private boolean showSaveDialog;
Expand Down Expand Up @@ -142,7 +142,7 @@ public FileListEntryEditor(LinkedFile entry, boolean showProgressBar, boolean sh
return;
}
}
diag.dispose();
dialog.dispose();
storeSettings(FileListEntryEditor.this.entry);
okPressed = true;
};
Expand Down Expand Up @@ -198,7 +198,7 @@ public FileListEntryEditor(LinkedFile entry, boolean showProgressBar, boolean sh

@Override
public void actionPerformed(ActionEvent e) {
diag.dispose();
dialog.dispose();
}
};
cancel.addActionListener(cancelAction);
Expand Down Expand Up @@ -228,13 +228,13 @@ public void changedUpdate(DocumentEvent documentEvent) {

});

diag = new JDialog();
diag.setTitle(Localization.lang("Select files"));
diag.setModal(true);
diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
diag.pack();
diag.addWindowListener(new WindowAdapter() {
dialog = new JDialog();
dialog.setTitle(Localization.lang("Select files"));
dialog.setModal(true);
dialog.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
dialog.pack();
dialog.addWindowListener(new WindowAdapter() {

@Override
public void windowActivated(WindowEvent event) {
Expand Down Expand Up @@ -314,12 +314,12 @@ public void setVisible(boolean visible, boolean openBrowse) {
} else {
title = Localization.lang("Select files");
}
diag.setTitle(title);
diag.setVisible(visible);
dialog.setTitle(title);
dialog.setVisible(visible);
}

public boolean isVisible() {
return (diag != null) && diag.isVisible();
return (dialog != null) && dialog.isVisible();
}

private void setValues(LinkedFile entry) {
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.jabref.gui.StateManager;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.FieldChange;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.groups.AbstractGroup;
Expand Down Expand Up @@ -136,7 +135,7 @@ public void addNewSubgroup(GroupNodeViewModel parent) {
SwingUtilities.invokeLater(() -> {
Optional<AbstractGroup> newGroup = dialogService.showCustomDialogAndWait(new GroupDialog());
newGroup.ifPresent(group -> {
GroupTreeNode newGroupNode = parent.addSubgroup(group);
parent.addSubgroup(group);

// TODO: Add undo
//UndoableAddOrRemoveGroup undo = new UndoableAddOrRemoveGroup(parent, new GroupTreeNodeViewModel(newGroupNode), UndoableAddOrRemoveGroup.ADD_NODE);
Expand Down Expand Up @@ -173,7 +172,7 @@ public void editGroup(GroupNodeViewModel oldGroup) {
boolean removePreviousAssignents = (oldGroup.getGroupNode().getGroup() instanceof ExplicitGroup)
&& (group instanceof ExplicitGroup);

List<FieldChange> addChange = oldGroup.getGroupNode().setGroup(
oldGroup.getGroupNode().setGroup(
group,
keepPreviousAssignments,
removePreviousAssignents,
Expand Down Expand Up @@ -259,7 +258,7 @@ public void removeGroupAndSubgroups(GroupNodeViewModel group) {
}

void removeGroupsAndSubGroupsFromEntries(GroupNodeViewModel group) {
for (GroupNodeViewModel child: group.getChildren()) {
for (GroupNodeViewModel child : group.getChildren()) {
removeGroupsAndSubGroupsFromEntries(child);
}

Expand All @@ -275,7 +274,7 @@ public void addSelectedEntries(GroupNodeViewModel group) {
// if (!WarnAssignmentSideEffects.warnAssignmentSideEffects(node.getNode().getGroup(), panel.frame())) {
// return; // user aborted operation

List<FieldChange> addChange = group.getGroupNode().addEntriesToGroup(stateManager.getSelectedEntries());
group.getGroupNode().addEntriesToGroup(stateManager.getSelectedEntries());

// TODO: Add undo
// NamedCompound undoAll = new NamedCompound(Localization.lang("change assignment of entries"));
Expand Down Expand Up @@ -303,7 +302,7 @@ public void removeSelectedEntries(GroupNodeViewModel group) {
// if (!WarnAssignmentSideEffects.warnAssignmentSideEffects(mNode.getNode().getGroup(), mPanel.frame())) {
// return; // user aborted operation

List<FieldChange> removeChange = group.getGroupNode().removeEntriesFromGroup(stateManager.getSelectedEntries());
group.getGroupNode().removeEntriesFromGroup(stateManager.getSelectedEntries());

// TODO: Add undo
// if (!undo.isEmpty()) {
Expand All @@ -312,6 +311,5 @@ public void removeSelectedEntries(GroupNodeViewModel group) {

public void sortAlphabeticallyRecursive(GroupNodeViewModel group) {
group.getGroupNode().sortChildren(compAlphabetIgnoreCase, true);

}
}
54 changes: 0 additions & 54 deletions src/main/java/org/jabref/gui/groups/UndoableModifyGroup.java

This file was deleted.

Loading