Skip to content

Commit

Permalink
Fixes Sonar complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
fathzer committed May 21, 2024
1 parent 3e4948d commit 75e1fd3
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 19 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/fathzer/soft/ajlib/swing/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ private Browser() {
public static void show(URI uri, Component parent, String errorDialogTitle) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e) {
error(uri, parent, errorDialogTitle);
} catch (UnsupportedOperationException e) {
} catch (IOException | UnsupportedOperationException e) {
error(uri, parent, errorDialogTitle);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ButtonGroup extends Observable {
*/
public ButtonGroup() {
this.autoDeselect = false;
this.buttons = new ArrayList<AbstractButton>();
this.buttons = new ArrayList<>();
this.selected = null;
this.listener = new ItemListener() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fathzer/soft/ajlib/swing/FontUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private FontUtils() {
* @return The list of fonts that are available and able to display text in the specified locale.
*/
public static List<Font> getAvailableTextFonts(Locale locale) {
ArrayList<Font> result = new ArrayList<Font>();
ArrayList<Font> result = new ArrayList<>();
Font[] allfonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (Font font : allfonts) {
if (font.canDisplayUpTo(font.getFontName(locale)) == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void search() {
text = normalize(text);

// 3) Search for the searched text
List<Integer> indexes = new LinkedList<Integer>();
List<Integer> indexes = new LinkedList<>();
int lastIndex = 0;
int size = 0;
searchedNormalizedLength = text.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class AbstractDialog<T,V> extends JDialog {
* @param title Dialog's title
* @param data optional data (will be transfered to createContentPane)
*/
public AbstractDialog(Window owner, String title, T data) {
protected AbstractDialog(Window owner, String title, T data) {
super(owner, title, ModalityType.APPLICATION_MODAL);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.data = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class AbstractTableRowMover extends JPanel {
* Creates the panel.
* @param table The table that contains the moveable rows.
*/
public AbstractTableRowMover(JTable table) {
protected AbstractTableRowMover(JTable table) {
this.table = table;
initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void toggleSortOrder(int column) {
return;
}
List<? extends SortKey> sortKeys = getSortKeys();
ArrayList<SortKey> futureKeys = new ArrayList<SortKey>();
ArrayList<SortKey> futureKeys = new ArrayList<>();
SortKey theKey = null;
for (SortKey sortKey : sortKeys) {
if (sortKey.getColumn()==column) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class AbstractSelector<T,V> extends JPanel {
* Constructor.
* @param parameters The init parameters of the selector (that object will be used to populate the combo).
*/
public AbstractSelector(V parameters) {
protected AbstractSelector(V parameters) {
this.parameters = parameters;
initialize();
internalPopulate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AbstractTitledPanel<T> extends JPanel {
* @param headerIcon The header icon (null for no icon)
* @param data The center component's data
*/
public AbstractTitledPanel(String headerMessage, Icon headerIcon, T data) {
protected AbstractTitledPanel(String headerMessage, Icon headerIcon, T data) {
super();
this.data = data;
initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ private void showPopup() {

private void fillModel(String text) {
TextMatcher matcher = new TextMatcher(TextMatcher.Kind.CONTAINS, text, false, false); //TODO Must match "starts with" ... to be implemented in TextMatcher
ArrayList<String> okProbaSort = new ArrayList<String>();
TreeSet<String> okAlphabeticSort = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
ArrayList<String> okProbaSort = new ArrayList<>();
TreeSet<String> okAlphabeticSort = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (String value : this.proposals) {
if (matcher.matches(value)) {
if (okProbaSort.size()<=unsortedMax) {
Expand All @@ -267,7 +267,7 @@ private void fillModel(String text) {
}
}

private final static class PopupListModel extends AbstractListModel {
private static final class PopupListModel extends AbstractListModel {
private static final long serialVersionUID = 1L;
String[] values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class Worker<T,V> extends SwingWorker<T,V> {
/** Constructor.
* <br>The phase is initialize to null and the length is set to -1 (indeterminate length).
*/
public Worker() {
protected Worker() {
super();
this.phase = null;
this.phaseLength = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public static Locale getSystemLocale() {
* @see #add(String)
*/
public LocalizationData(String bundlePath) {
this.bundleNames = new ArrayList<String>();
this.bundleNames = new ArrayList<>();
this.bundleNames.add(bundlePath);
this.bundles = new HashMap<Locale, List<ResourceBundle>>();
this.bundles = new HashMap<>();
this.translatorMode = false;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public String getString(String key) {
private List<ResourceBundle> getBundle(Locale locale) {
List<ResourceBundle> result = bundles.get(locale);
if (result==null) {
result = new ArrayList<ResourceBundle>();
result = new ArrayList<>();
for (String bundleName : this.bundleNames) {
ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
result.add(bundle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private StringUtils() {
* @return an array of Strings.
*/
public static String[] split(String string, char separator) {
List<String> result = new LinkedList<String>();
List<String> result = new LinkedList<>();
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < string.length(); i++) {
if (string.charAt(i)==separator) {
Expand Down

0 comments on commit 75e1fd3

Please sign in to comment.