Skip to content

Commit

Permalink
- fix analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Nov 4, 2024
1 parent 4c72b09 commit 25b7cea
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,6 @@ private void showMenu(MouseEvent evt) {

jPopupMenu.addSeparator();

// URL abspielen
JMenuItem itemPlayer = new JMenuItem("Film (URL) abspielen");
itemPlayer.addActionListener(_ -> {
final int nr1 = tabelle.rowAtPoint(p);
Expand Down Expand Up @@ -1273,7 +1272,6 @@ private void showMenu(MouseEvent evt) {
});
jPopupMenu.add(itemPlayer);

// URL kopieren
JMenuItem itemUrl = new JMenuItem("URL kopieren");
itemUrl.addActionListener(_ -> {
int nr1 = tabelle.rowAtPoint(p);
Expand Down
83 changes: 41 additions & 42 deletions src/main/java/mediathek/gui/tabs/tab_film/GuiFilme.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void setupPsetButtonsTab() {

psetButtonsPanel = new PsetButtonsPanel(this);
psetButtonsPanel.putClientProperty("JTabbedPane.tabClosable", true);
psetButtonsPanel.putClientProperty("JTabbedPane.tabCloseCallback", (IntConsumer) tabIndex -> cbShowButtons.doClick());
psetButtonsPanel.putClientProperty("JTabbedPane.tabCloseCallback", (IntConsumer) _ -> cbShowButtons.doClick());
psetButtonsPanel.install(psetButtonsTab);

makeButtonsTabVisible(initialVisibility);
Expand All @@ -317,7 +317,7 @@ private void setupButtonsMenuItem(boolean initialVisibility) {
if (!SystemUtils.IS_OS_MAC_OSX)
cbShowButtons.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0));
cbShowButtons.setSelected(initialVisibility);
cbShowButtons.addActionListener(l -> {
cbShowButtons.addActionListener(_ -> {
boolean visible = cbShowButtons.isSelected();
makeButtonsTabVisible(visible);
config.setProperty(ApplicationConfiguration.APPLICATION_BUTTONS_PANEL_VISIBLE, visible);
Expand Down Expand Up @@ -651,15 +651,15 @@ private void updateFilmData() {

private void setupDataTransitions() {
//execute on JavaFX thread!
reloadTableDataTransition.setOnFinished(e -> {
reloadTableDataTransition.setOnFinished(_ -> {
try {
SwingUtilities.invokeAndWait(this::loadTable);
} catch (InterruptedException | InvocationTargetException ex) {
logger.error("Table reload failed", ex);
}
});

zeitraumTransition.setOnFinished(evt -> {
zeitraumTransition.setOnFinished(_ -> {
// reset sender filter first
filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().clearChecks();
try {
Expand All @@ -675,8 +675,8 @@ private void setupActionListeners() {
Platform.runLater(() -> {
setupDataTransitions();

final ChangeListener<Boolean> reloadTableListener = (ob, ov, nv) -> reloadTableDataTransition.playFromStart();
final ChangeListener<Boolean> reloadTableListener2 = (ob, ov, newValue) -> {
final ChangeListener<Boolean> reloadTableListener = (_, _, _) -> reloadTableDataTransition.playFromStart();
final ChangeListener<Boolean> reloadTableListener2 = (_, _, newValue) -> {
if (!newValue) {
reloadTableDataTransition.playFromStart();
}
Expand Down Expand Up @@ -712,7 +712,7 @@ protected void setupShowFilmDescriptionMenuItem() {

cbkShowDescription.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0));
cbkShowDescription.setSelected(config.getBoolean(ApplicationConfiguration.FILM_SHOW_DESCRIPTION, true));
cbkShowDescription.addActionListener(l -> {
cbkShowDescription.addActionListener(_ -> {
boolean visible = cbkShowDescription.isSelected();
makeDescriptionTabVisible(visible);
config.setProperty(ApplicationConfiguration.FILM_SHOW_DESCRIPTION, visible);
Expand Down Expand Up @@ -823,7 +823,7 @@ public SearchField() {
putClientProperty("JTextField.clearCallback", (Consumer<JTextComponent>) textField -> clearSearchField());

addKeyListener(new EscapeKeyAdapter());
addActionListener(l -> performSearch());
addActionListener(_ -> performSearch());

createTrailingComponents();

Expand Down Expand Up @@ -887,17 +887,17 @@ public SearchHistoryButton(@Nullable SearchControlFieldMode mode) {
}
}

miClearHistory.addActionListener(l -> {
miClearHistory.addActionListener(_ -> {
historyList.clear();
saveHistory();
});

miEditHistory.addActionListener(l -> {
miEditHistory.addActionListener(_ -> {
EditHistoryDialog dlg = new EditHistoryDialog(mediathekGui , miEditHistory, historyList);
dlg.setVisible(true);
});

addActionListener(l -> {
addActionListener(_ -> {
JPopupMenu popupMenu = new JPopupMenu();
popupMenu.add(miClearHistory);
popupMenu.add(miEditHistory);
Expand All @@ -907,7 +907,7 @@ public SearchHistoryButton(@Nullable SearchControlFieldMode mode) {
popupMenu.addSeparator();
for (var item : historyList) {
JMenuItem historyItem = new JMenuItem(item);
historyItem.addActionListener(li -> {
historyItem.addActionListener(_ -> {
searchField.setText(item);
searchField.fireActionPerformed();
});
Expand All @@ -922,7 +922,7 @@ public SearchHistoryButton(@Nullable SearchControlFieldMode mode) {
});

loadHistory();
historyList.addListEventListener(l -> saveHistory());
historyList.addListEventListener(_ -> saveHistory());
}

public void addHistoryEntry(String text) {
Expand Down Expand Up @@ -991,7 +991,7 @@ protected void createTrailingComponents() {
var luceneBtn = new JButton();
luceneBtn.setIcon(SVGIconUtilities.createSVGIcon("icons/fontawesome/circle-question.svg"));
luceneBtn.setToolTipText("Lucene Query Syntax Hilfe");
luceneBtn.addActionListener(l -> {
luceneBtn.addActionListener(_ -> {
if (Desktop.isDesktopSupported()) {
var desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
Expand Down Expand Up @@ -1031,7 +1031,7 @@ public class RegularSearchField extends SearchField {
private final SearchHistoryButton regularSearchHistoryButton = new SearchHistoryButton(null);

public RegularSearchField() {
addSearchModeChangeListener(evt -> setupHelperTexts());
addSearchModeChangeListener(_ -> setupHelperTexts());
setupPlaceholderText();

putClientProperty(FlatClientProperties.TEXT_FIELD_LEADING_COMPONENT, regularSearchHistoryButton);
Expand Down Expand Up @@ -1136,17 +1136,17 @@ protected void createTrailingComponents() {
class ToggleSearchFieldToggleButton extends JToggleButton {
public ToggleSearchFieldToggleButton() {
FlatSVGIcon selectedIcon = SVGIconUtilities.createSVGIcon("icons/fontawesome/envelope-open-text.svg");
selectedIcon.setColorFilter(new FlatSVGIcon.ColorFilter(color -> MVColor.getSelectedColor()));
selectedIcon.setColorFilter(new FlatSVGIcon.ColorFilter(_ -> MVColor.getSelectedColor()));
FlatSVGIcon normalIcon = SVGIconUtilities.createSVGIcon("icons/fontawesome/envelope-open-text.svg");
normalIcon.setColorFilter(new FlatSVGIcon.ColorFilter(color -> Color.GRAY));
normalIcon.setColorFilter(new FlatSVGIcon.ColorFilter(_ -> Color.GRAY));
setIcon(normalIcon);
setSelectedIcon(selectedIcon);

boolean bSearchThroughDescription = ApplicationConfiguration.getConfiguration().getBoolean(ApplicationConfiguration.SEARCH_USE_FILM_DESCRIPTIONS, false);
setSelected(bSearchThroughDescription);
setupToolTip(bSearchThroughDescription);

addActionListener(l -> {
addActionListener(_ -> {
switch (getSearchMode()) {
case IRGENDWO -> {
setSearchMode(SearchControlFieldMode.THEMA_TITEL);
Expand Down Expand Up @@ -1370,7 +1370,7 @@ private void showMenu(MouseEvent evt) {
JMenuItem item = new JMenuItem(pset.getName());
pset.getForegroundColor().ifPresent(item::setForeground);
if (!pset.getListeProg().isEmpty()) {
item.addActionListener(l -> playerStarten(pset));
item.addActionListener(_ -> playerStarten(pset));
}
submenue.add(item);
}
Expand Down Expand Up @@ -1417,8 +1417,7 @@ private void showMenu(MouseEvent evt) {
res.ifPresent(film -> {
jPopupMenu.addSeparator();
var miCreateInfoFile = new JMenuItem("Infodatei erzeugen...");
miCreateInfoFile.addActionListener(l -> {
System.out.println("INFO FILE");
miCreateInfoFile.addActionListener(_ -> {
var file = FileDialogs.chooseSaveFileLocation(MediathekGui.ui(), "Infodatei speichern", "");
if (file != null) {
MVInfoFile infoFile = new MVInfoFile();
Expand All @@ -1436,7 +1435,7 @@ private void showMenu(MouseEvent evt) {
if (film.isDuplicate()) {
jPopupMenu.addSeparator();
var mi = new JMenuItem("Zusammengehörige Filme anzeigen...");
mi.addActionListener(l -> {
mi.addActionListener(_ -> {
DuplicateFilmDetailsDialog dlg = new DuplicateFilmDetailsDialog(MediathekGui.ui(), film);
dlg.setVisible(true);
});
Expand Down Expand Up @@ -1467,22 +1466,22 @@ private void setupHistoryContextActions(@NotNull JPopupMenu popupMenu, @NotNull
private void setupCopytoClipboardContextMenu(@NotNull DatenFilm film, @NotNull JPopupMenu popupMenu) {
var mCopyToClipboard = new JMenu("In Zwischenablage kopieren");
var miCopyClipboardTitle = new JMenuItem("Titel");
miCopyClipboardTitle.addActionListener(e -> GuiFunktionen.copyToClipboard(film.getTitle()));
miCopyClipboardTitle.addActionListener(_ -> GuiFunktionen.copyToClipboard(film.getTitle()));
mCopyToClipboard.add(miCopyClipboardTitle);

var miCopyClipboardThema = new JMenuItem("Thema");
miCopyClipboardThema.addActionListener(e -> GuiFunktionen.copyToClipboard(film.getThema()));
miCopyClipboardThema.addActionListener(_ -> GuiFunktionen.copyToClipboard(film.getThema()));
mCopyToClipboard.add(miCopyClipboardThema);

var miCopyTitleThemaToClipboard = new JMenuItem("Thema - Titel");
miCopyTitleThemaToClipboard.addActionListener(e -> {
miCopyTitleThemaToClipboard.addActionListener(_ -> {
var text = film.getThema() + " - " + film.getTitle();
GuiFunktionen.copyToClipboard(text);
});
mCopyToClipboard.add(miCopyTitleThemaToClipboard);

var miCopySenderThemaTitelToClipboard = new JMenuItem("Sender - Thema - Titel");
miCopySenderThemaTitelToClipboard.addActionListener(e -> {
miCopySenderThemaTitelToClipboard.addActionListener(_ -> {
var t = String.format("%s - %s - %s", film.getSender(), film.getThema(), film.getTitle());
GuiFunktionen.copyToClipboard(t);
});
Expand Down Expand Up @@ -1511,7 +1510,7 @@ private void setupFilmUrlCopyToClipboardEntries(@NotNull JMenu parentMenu, @NotN
uLow = ""; // dann gibts keine
}
if (!uNormal.isEmpty()) {
final ActionListener copyNormalUrlListener = e -> GuiFunktionen.copyToClipboard(uNormal);
final ActionListener copyNormalUrlListener = _ -> GuiFunktionen.copyToClipboard(uNormal);
if (!uHd.isEmpty() || !uLow.isEmpty()) {
JMenu submenueURL = new JMenu("Film-URL");
// HD
Expand All @@ -1520,7 +1519,7 @@ private void setupFilmUrlCopyToClipboardEntries(@NotNull JMenu parentMenu, @NotN
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, GuiFunktionen.getPlatformControlKey() |
KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
item.addActionListener(
e -> GuiFunktionen.copyToClipboard(film.getUrlFuerAufloesung(FilmResolution.Enum.HIGH_QUALITY)));
_ -> GuiFunktionen.copyToClipboard(film.getUrlFuerAufloesung(FilmResolution.Enum.HIGH_QUALITY)));
submenueURL.add(item);
}

Expand All @@ -1536,7 +1535,7 @@ private void setupFilmUrlCopyToClipboardEntries(@NotNull JMenu parentMenu, @NotN
if (!uLow.isEmpty()) {
item = new JMenuItem("niedrige Qualität");
item.addActionListener(
e -> GuiFunktionen.copyToClipboard(film.getUrlFuerAufloesung(FilmResolution.Enum.LOW)));
_ -> GuiFunktionen.copyToClipboard(film.getUrlFuerAufloesung(FilmResolution.Enum.LOW)));
submenueURL.add(item);
}
parentMenu.add(submenueURL);
Expand All @@ -1550,7 +1549,7 @@ private void setupFilmUrlCopyToClipboardEntries(@NotNull JMenu parentMenu, @NotN
if (!film.getSubtitleUrl().isEmpty()) {

item = new JMenuItem("Untertitel-URL");
item.addActionListener(e -> GuiFunktionen.copyToClipboard(film.getSubtitleUrl()));
item.addActionListener(_ -> GuiFunktionen.copyToClipboard(film.getSubtitleUrl()));
parentMenu.add(item);
}
}
Expand All @@ -1564,24 +1563,16 @@ private void setupSearchEntries(@NotNull JPopupMenu popupMenu, @NotNull DatenFil

for (var item : set) {
var miThema = new JMenuItem(item.toString());
miThema.addActionListener(l -> {
miThema.addActionListener(_ -> {
var url = item.getQueryUrl() + URLEncoder.encode(film.getThema(), StandardCharsets.UTF_8);
try {
UrlHyperlinkAction.openURL(url);
} catch (URISyntaxException ex) {
logger.error("Failed to launch online search for url {}", url);
}
tryLaunchBrowser(url);
});
mThema.add(miThema);

var miTitel = new JMenuItem(item.toString());
miTitel.addActionListener(l -> {
miTitel.addActionListener(_ -> {
var url = item.getQueryUrl() + URLEncoder.encode(film.getTitle(), StandardCharsets.UTF_8);
try {
UrlHyperlinkAction.openURL(url);
} catch (URISyntaxException ex) {
logger.error("Failed to launch online search for url {}", url);
}
tryLaunchBrowser(url);
});
mTitel.add(miTitel);
}
Expand All @@ -1592,6 +1583,14 @@ private void setupSearchEntries(@NotNull JPopupMenu popupMenu, @NotNull DatenFil
popupMenu.addSeparator();
}

private void tryLaunchBrowser(String url) {
try {
UrlHyperlinkAction.openURL(url);
} catch (URISyntaxException ex) {
logger.error("Failed to launch online search for url {}", url);
}
}

private class BeobHistory implements ActionListener {

private final boolean seen;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mediathek/mainwindow/MediathekGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ private void setupTaskbarMenu() {
popupMenu = new PopupMenu();

MenuItem miLoadNewFilmlist = new MenuItem("Neue Filmliste laden");
miLoadNewFilmlist.addActionListener(e -> performFilmListLoadOperation(false));
miLoadNewFilmlist.addActionListener(_ -> performFilmListLoadOperation(false));

popupMenu.addSeparator();
popupMenu.add(miLoadNewFilmlist);
Expand Down Expand Up @@ -1010,7 +1010,7 @@ private void createViewMenu() {
jMenuAnsicht.addSeparator();
jMenuAnsicht.add(showDuplicateStatisticsAction);
var mi = new JMenuItem("Übersicht aller Duplikate anzeigen...");
mi.addActionListener(l -> {
mi.addActionListener(_ -> {
FilmDuplicateOverviewDialog dlg = new FilmDuplicateOverviewDialog(this);
dlg.setVisible(true);
});
Expand Down

0 comments on commit 25b7cea

Please sign in to comment.