Skip to content

Commit

Permalink
fixing sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth committed May 12, 2021
1 parent e5d5836 commit 9e4dd9c
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 245 deletions.
1 change: 0 additions & 1 deletion src/main/java/de/idrinth/waraddonclient/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.awt.Dimension;
import java.awt.Point;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.prefs.Preferences;
import org.apache.commons.io.IOUtils;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/de/idrinth/waraddonclient/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.xml.parsers.ParserConfigurationException;

Expand Down
11 changes: 3 additions & 8 deletions src/main/java/de/idrinth/waraddonclient/gui/TextCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import de.idrinth.waraddonclient.model.AddonList;
import de.idrinth.waraddonclient.model.ActualAddon;
import java.util.List;
import javax.swing.RowFilter;

public class TextCategory extends javax.swing.RowFilter {
public class TextCategory extends RowFilter<ActualAddon, Integer> {

private final java.util.regex.Pattern textfilter;

Expand All @@ -15,12 +16,6 @@ public TextCategory(String text, AddonList addonList) {
this.addonList = addonList;
}

/**
* apply textfilter tp displayed addon list
*
* @param entry
* @return boolean
*/
@Override
public boolean include(Entry entry) {
ActualAddon addon = addonList.get(entry.getStringValue(1));
Expand All @@ -41,7 +36,7 @@ public boolean include(Entry entry) {
*/
private boolean isInAllowedCategory(ActualAddon addon) {
List<String> tags = addonList.getActiveTags();
return tags.isEmpty() || tags.stream().anyMatch((tag) -> (addon.hasTag(tag)));
return tags.isEmpty() || tags.stream().anyMatch(tag -> (addon.hasTag(tag)));
}

}
2 changes: 1 addition & 1 deletion src/main/java/de/idrinth/waraddonclient/gui/Window.form
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="AddonList">
<Component class="javax.swing.JTable" name="AddonListTable">
<Properties>
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
Expand Down
45 changes: 22 additions & 23 deletions src/main/java/de/idrinth/waraddonclient/gui/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
import java.awt.Desktop;
import java.awt.FileDialog;
import java.awt.Toolkit;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.RowFilter;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

public class Window extends javax.swing.JFrame {
public class Window extends JFrame {

private Addon activeAddon = new de.idrinth.waraddonclient.model.NoAddon();

Expand All @@ -45,10 +44,10 @@ public Window(AddonList addonList, Version version, ThemeManager manager, FileLo
}

private void finishGuiBuilding(Shedule schedule) {
AddonList.getSelectionModel().addListSelectionListener(new TableListener());
AddonListTable.getSelectionModel().addListSelectionListener(new TableListener());
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Images/logo.png")));
AddonList.setRowSorter(new TableRowSorter<>(AddonList.getModel()));
addonList.setModel((DefaultTableModel) AddonList.getModel());
AddonListTable.setRowSorter(new TableRowSorter<>(AddonListTable.getModel()));
addonList.setModel((DefaultTableModel) AddonListTable.getModel());
Description.addHyperlinkListener(new HyperlinkListenerImpl());
localVersion.setText(Config.getVersion());
addonList.setMenu(Tags, (java.awt.event.ActionEvent evt) -> newFilter());
Expand All @@ -58,8 +57,8 @@ private void finishGuiBuilding(Shedule schedule) {

private void newFilter() {
try {
RowFilter<String, ArrayList<String>> rf = new TextCategory(Search.getText(), addonList);
((TableRowSorter) AddonList.getRowSorter()).setRowFilter(rf);
TextCategory rf = new TextCategory(Search.getText(), addonList);
((TableRowSorter) AddonListTable.getRowSorter()).setRowFilter(rf);
} catch (java.util.regex.PatternSyntaxException exception) {
logger.error(exception);
}
Expand All @@ -79,7 +78,7 @@ private void initComponents() {
javax.swing.JPanel leftSide = new javax.swing.JPanel();
Search = new javax.swing.JTextField();
jScrollPane2 = new javax.swing.JScrollPane();
AddonList = new javax.swing.JTable();
AddonListTable = new javax.swing.JTable();
DeleteSearch = new javax.swing.JButton();
UpdateAll = new javax.swing.JButton();
rightSide = new javax.swing.JTabbedPane();
Expand Down Expand Up @@ -143,8 +142,8 @@ public void keyReleased(java.awt.event.KeyEvent evt) {

jScrollPane2.setMaximumSize(null);

AddonList.setAutoCreateRowSorter(true);
AddonList.setModel(new javax.swing.table.DefaultTableModel(
AddonListTable.setAutoCreateRowSorter(true);
AddonListTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {

},
Expand All @@ -167,12 +166,12 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
AddonList.setColumnSelectionAllowed(true);
AddonList.setMaximumSize(null);
AddonList.setName(""); // NOI18N
AddonList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane2.setViewportView(AddonList);
AddonList.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
AddonListTable.setColumnSelectionAllowed(true);
AddonListTable.setMaximumSize(null);
AddonListTable.setName(""); // NOI18N
AddonListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane2.setViewportView(AddonListTable);
AddonListTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

DeleteSearch.setText("X");
DeleteSearch.addMouseListener(new java.awt.event.MouseAdapter() {
Expand Down Expand Up @@ -691,16 +690,16 @@ private void changeLanguageTo(String lang) {
* updates addon list
*/
private void updateList() {
for (int position = 0; position < AddonList.getRowCount(); position++) {
de.idrinth.waraddonclient.model.ActualAddon addon = addonList.get(AddonList.convertRowIndexToModel(position));
AddonList.setValueAt(addon.getInstalled(), position, 3);
AddonList.setValueAt(addon.getStatus(), position, 0);
for (int position = 0; position < AddonListTable.getRowCount(); position++) {
de.idrinth.waraddonclient.model.ActualAddon addon = addonList.get(AddonListTable.convertRowIndexToModel(position));
AddonListTable.setValueAt(addon.getInstalled(), position, 3);
AddonListTable.setValueAt(addon.getStatus(), position, 0);
}
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem About;
private javax.swing.JTable AddonList;
private javax.swing.JTable AddonListTable;
private javax.swing.JMenuItem BuyMeACoffee;
private javax.swing.JMenuItem CreateBackup;
private javax.swing.JLabel CurTags;
Expand Down Expand Up @@ -755,7 +754,7 @@ private class TableListener implements ListSelectionListener {
@Override
public void valueChanged(ListSelectionEvent event) {
try {
activeAddon = addonList.get(AddonList.convertRowIndexToModel(AddonList.getSelectedRow()));
activeAddon = addonList.get(AddonListTable.convertRowIndexToModel(AddonListTable.getSelectedRow()));
} catch (java.lang.ArrayIndexOutOfBoundsException exception) {
logger.error(exception);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
public class IdrinthLookAndFeel extends NimbusLookAndFeel {

private UIDefaults uiDefaults;

private static final String GREY = "grey";

private static final String LIGHT = "light";

private static final String DARK = "dark";

private static final String COLORED = "colored";

@Override
public String getName() {
Expand All @@ -30,49 +38,49 @@ public UIDefaults getDefaults() {
return uiDefaults;
}
uiDefaults = super.getDefaults();
addColor("dark", 25, 20, 20, 255);
addColor("light", 200, 200, 200, 255);
addColor("grey", 100, 100, 100, 255);
addColor("colored", 50, 0, 0, 255);
addColor(DARK, 25, 20, 20, 255);
addColor(LIGHT, 200, 200, 200, 255);
addColor(GREY, 100, 100, 100, 255);
addColor(COLORED, 50, 0, 0, 255);
overwriteNimbus();
return uiDefaults;
}

private void overwriteNimbus() {
//The global style definition
addColor("nimbusBase", "grey");
addColor("nimbusFocus", "colored");
addColor("nimbusSelectionBackground", "colored");
addColor("nimbusDisabledText", "grey");
addColor("info", "dark");
addColor("nimbusOrange", "colored");
addColor("nimbusGreen", "colored");
addColor("nimbusRed", "colored");
addColor("nimbusAlertYellow", "colored");
addColor("nimbusLightBackground", "dark");
addColor("nimbusSelectedText", "dark");
addColor("nimbusInfoBlue", "colored");
addColor("control", "dark");
addColor("text", "light");
addColor("nimbusBase", GREY);
addColor("nimbusFocus", COLORED);
addColor("nimbusSelectionBackground", COLORED);
addColor("nimbusDisabledText", GREY);
addColor("info", DARK);
addColor("nimbusOrange", COLORED);
addColor("nimbusGreen", COLORED);
addColor("nimbusRed", COLORED);
addColor("nimbusAlertYellow", COLORED);
addColor("nimbusLightBackground", DARK);
addColor("nimbusSelectedText", DARK);
addColor("nimbusInfoBlue", COLORED);
addColor("control", DARK);
addColor("text", LIGHT);
addColor("controlText", "text");
addColor("textHighlight", "colored");
addColor("textHighlightText", "dark");
addColor("textInactiveText", "grey");
addColor("menuText", "light");
addColor("menu", "grey");
addColor("nimbusBlueGrey", "colored", -0.1f, -0.1f, -0.1f, 0f);
addColor("scrollbar", "colored");
addColor("textHighlight", COLORED);
addColor("textHighlightText", DARK);
addColor("textInactiveText", GREY);
addColor("menuText", LIGHT);
addColor("menu", GREY);
addColor("nimbusBlueGrey", COLORED, -0.1f, -0.1f, -0.1f, 0f);
addColor("scrollbar", COLORED);
addColor("nimbusBorder", "nimbusBlueGrey", 0.0f, 0.017358616f, 0.11372548f, 0);
addColor("infoText", "light");
addColor("textForeground", "light");
addColor("textBackground", "colored");
addColor("background", "dark");
addColor("nimbusSelection", "grey", 0.010750473f, 0.04875779f, 0.007843137f, 0);
addColor("infoText", LIGHT);
addColor("textForeground", LIGHT);
addColor("textBackground", COLORED);
addColor("background", DARK);
addColor("nimbusSelection", GREY, 0.010750473f, 0.04875779f, 0.007843137f, 0);
addColor("controlHighlight", "nimbusBlueGrey", 0.0f, 0.07333623f, -0.20392156f, 0);
addColor("controlLHighlight", "nimbusBlueGrey", 0.0f, 0.098526314f, -0.2352941f, 0);
addColor("controlShadow", "nimbusBlueGrey", 0.0027777553f, 0.0212406f, -0.13333333f, 0);
addColor("controlDkShadow", "nimbusBlueGrey", 0.0027777553f, 0.0018306673f, 0.02352941f, 0);
addColor("desktop", "dark", 0.009207249f, 0.13984653f, 0.07450983f, 0);
addColor("desktop", DARK, 0.009207249f, 0.13984653f, 0.07450983f, 0);
addColor("activeCaption", "nimbusBlueGrey", 0.0f, 0.049920253f, -0.031372547f, 0);
addColor("inactiveCaption", "nimbusBlueGrey", 0.00505054f, 0.055526316f, -0.039215684f, 0);

Expand All @@ -91,7 +99,7 @@ private void overwriteNimbus() {
addColor("CheckBox[Disabled].textForeground", "nimbusDisabledText");

//Initialize ColorChooser
addColor("ColorChooser.swatchesDefaultRecentColor", "dark");
addColor("ColorChooser.swatchesDefaultRecentColor", DARK);

//Initialize ComboBox
addColor("ComboBox:\"ComboBox.textField\"[Disabled].textForeground", "nimbusDisabledText");
Expand Down Expand Up @@ -123,46 +131,46 @@ private void overwriteNimbus() {
addColor("List:\"List.cellRenderer\"[Disabled].textForeground", "nimbusDisabledText");

//Initialize MenuBar
addColor("MenuBar:Menu.background", "colored");
addColor("MenuBar:Menu.background", COLORED);
addColor("MenuBar:Menu[Disabled].textForeground", "nimbusDisabledText");
addColor("MenuBar:Menu[Enabled].textForeground", "text");
addColor("MenuBar:Menu[Selected].textForeground", "dark");
addColor("MenuBar:Menu[Selected].textForeground", DARK);

//Initialize MenuItem
addColor("MenuItem.background", "colored");
addColor("MenuItem.background", COLORED);
addColor("MenuItem[Disabled].textForeground", "nimbusDisabledText");
addColor("MenuItem[Enabled].textForeground", "dark");
addColor("MenuItem[MouseOver].textForeground", "dark");
addColor("MenuItem[Enabled].textForeground", DARK);
addColor("MenuItem[MouseOver].textForeground", DARK);
addColor("MenuItem:MenuItemAccelerator[Disabled].textForeground", "nimbusDisabledText");
addColor("MenuItem:MenuItemAccelerator[MouseOver].textForeground", "dark");
addColor("MenuItem:MenuItemAccelerator[MouseOver].textForeground", DARK);

//Initialize RadioButtonMenuItem
addColor("RadioButtonMenuItem.background", "colored");
addColor("RadioButtonMenuItem.background", COLORED);
addColor("RadioButtonMenuItem[Disabled].textForeground", "nimbusDisabledText");
addColor("RadioButtonMenuItem[Enabled].textForeground", "dark");
addColor("RadioButtonMenuItem[MouseOver].textForeground", "dark");
addColor("RadioButtonMenuItem[MouseOver+Selected].textForeground", "dark");
addColor("RadioButtonMenuItem:MenuItemAccelerator[MouseOver].textForeground", "dark");
addColor("RadioButtonMenuItem[Enabled].textForeground", DARK);
addColor("RadioButtonMenuItem[MouseOver].textForeground", DARK);
addColor("RadioButtonMenuItem[MouseOver+Selected].textForeground", DARK);
addColor("RadioButtonMenuItem:MenuItemAccelerator[MouseOver].textForeground", DARK);

//Initialize CheckBoxMenuItem
addColor("CheckBoxMenuItem.background", "colored");
addColor("CheckBoxMenuItem[Enabled].textForeground", "dark");
addColor("CheckBoxMenuItem[MouseOver].textForeground", "dark");
addColor("CheckBoxMenuItem[MouseOver+Selected].textForeground", "dark");
addColor("CheckBoxMenuItem:MenuItemAccelerator[MouseOver].textForeground", "dark");
addColor("CheckBoxMenuItem.background", COLORED);
addColor("CheckBoxMenuItem[Enabled].textForeground", DARK);
addColor("CheckBoxMenuItem[MouseOver].textForeground", DARK);
addColor("CheckBoxMenuItem[MouseOver+Selected].textForeground", DARK);
addColor("CheckBoxMenuItem:MenuItemAccelerator[MouseOver].textForeground", DARK);

//Initialize Menu
addColor("Menu.background", "colored");
addColor("Menu.background", COLORED);
addColor("Menu[Disabled].textForeground", "nimbusDisabledText");
addColor("Menu[Enabled].textForeground", "dark");
addColor("Menu[Enabled+Selected].textForeground", "dark");
addColor("Menu:MenuItemAccelerator[MouseOver].textForeground", "dark");
addColor("Menu[Enabled].textForeground", DARK);
addColor("Menu[Enabled+Selected].textForeground", DARK);
addColor("Menu:MenuItemAccelerator[MouseOver].textForeground", DARK);

//Initialize ProgressBar
addColor("ProgressBar[Disabled].textForeground", "nimbusDisabledText");

//Initialize Slider
addColor("Slider.tickColor", "grey");
addColor("Slider.tickColor", GREY);

//Initialize Spinner
addColor("Spinner:Panel:\"Spinner.formattedTextField\"[Disabled].textForeground", "nimbusDisabledText");
Expand All @@ -172,10 +180,10 @@ private void overwriteNimbus() {
//Initialize TabbedPane
addColor("TabbedPane.shadow", "nimbusDisabledText");
addColor("TabbedPane.darkShadow", "text");
addColor("TabbedPane.highlight", "colored");
addColor("TabbedPane.highlight", COLORED);
addColor("TabbedPane:TabbedPaneTab[Disabled].textForeground", "nimbusDisabledText");
addColor("TabbedPane:TabbedPaneTab[Pressed+Selected].textForeground", "dark");
addColor("TabbedPane:TabbedPaneTab[Focused+Pressed+Selected].textForeground", "dark");
addColor("TabbedPane:TabbedPaneTab[Pressed+Selected].textForeground", DARK);
addColor("TabbedPane:TabbedPaneTab[Focused+Pressed+Selected].textForeground", DARK);

//Initialize Table
addColor("Table.textForeground", "text");
Expand Down Expand Up @@ -243,7 +251,7 @@ private void overwriteNimbus() {
addColor("Tree.dropLineColor", "nimbusFocus");
addColor("Tree:TreeCell[Enabled].background", "nimbusLightBackground");
addColor("Tree:TreeCell[Enabled+Focused].background", "nimbusLightBackground");
addColor("Tree:TreeCell[Focused+Selected].textForeground", "dark");
addColor("Tree:TreeCell[Focused+Selected].textForeground", DARK);
addColor("Tree:\"Tree.cellRenderer\"[Disabled].textForeground", "nimbusDisabledText");

//Initialize RootPane
Expand Down
Loading

0 comments on commit 9e4dd9c

Please sign in to comment.