Skip to content

Commit d4a6a77

Browse files
author
Joe Wegner
committed
Address Codacy errors
1 parent df15e84 commit d4a6a77

File tree

2 files changed

+38
-45
lines changed

2 files changed

+38
-45
lines changed

app/src/cc/arduino/contributions/ContributionsSelfCheck.java

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import cc.arduino.contributions.packages.ContributionInstaller;
3636
import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
3737
import cc.arduino.view.NotificationPopup;
38-
import com.sun.javafx.binding.Logging;
3938
import org.apache.logging.log4j.LogManager;
39+
import org.apache.logging.log4j.Logger;
4040
import processing.app.*;
4141

4242
import javax.swing.*;
@@ -84,56 +84,41 @@ public void run() {
8484
return;
8585
}
8686

87+
boolean setAccessible = PreferencesData.getBoolean("ide.accessible");
8788
final String text;
8889
final String button1Name;
8990
final String button2Name;
90-
final String boardsButtonName = tr("Boards");
91-
final String librariesButtonName = tr("Libraries");
92-
93-
// default to no anchors
94-
String openAnchor1 = "";
95-
String closeAnchor1 = "";
96-
String openAnchor2 = "";
97-
String closeAnchor2 = "";
98-
boolean setAccessible = PreferencesData.getBoolean("ide.accessible");
91+
String openAnchorBoards = "<a href=\"" + boardsManagerURL + "\">";
92+
String closeAnchorBoards = "</a>";
93+
String openAnchorLibraries = "<a href=\"" + libraryManagerURL + "\">";
94+
String closeAnchorLibraries = "</a>";
95+
96+
// if accessibility mode and board updates are available set the button name and clear the anchors
97+
if(setAccessible && updatablePlatforms) {
98+
button1Name = tr("Boards");
99+
openAnchorBoards = "";
100+
closeAnchorBoards = "";
101+
}
102+
else { // when not accessibility mode or no boards to update no button is needed
103+
button1Name = null;
104+
}
105+
106+
// if accessibility mode and libraries updates are available set the button name and clear the anchors
107+
if (setAccessible && updatableLibraries) {
108+
button2Name = tr("Libraries");
109+
openAnchorLibraries = "";
110+
closeAnchorLibraries = "";
111+
}
112+
else { // when not accessibility mode or no libraries to update no button is needed
113+
button2Name = null;
114+
}
115+
99116
if (updatableLibraries && !updatablePlatforms) {
100-
if (setAccessible) {
101-
button1Name = null;
102-
button2Name = librariesButtonName;
103-
}
104-
else {
105-
button1Name = null;
106-
button2Name = null;
107-
openAnchor1 = "<a href=\"" + libraryManagerURL + "\">";
108-
closeAnchor1 = "</a>";
109-
}
110-
text = I18n.format(tr("Updates available for some of your {0}libraries{1}"), openAnchor1, closeAnchor1);
117+
text = I18n.format(tr("Updates available for some of your {0}libraries{1}"), openAnchorLibraries, closeAnchorLibraries);
111118
} else if (!updatableLibraries && updatablePlatforms) {
112-
if (setAccessible) {
113-
button1Name = boardsButtonName;
114-
button2Name = null;
115-
}
116-
else {
117-
button1Name = null;
118-
button2Name = null;
119-
openAnchor1 = "<a href=\"" + boardsManagerURL + "\">";
120-
closeAnchor1 = "</a>";
121-
}
122-
text = I18n.format(tr("Updates available for some of your {0}boards{1}"), openAnchor1, closeAnchor1);
119+
text = I18n.format(tr("Updates available for some of your {0}boards{1}"), openAnchorBoards, closeAnchorBoards);
123120
} else {
124-
if (setAccessible) {
125-
button1Name = boardsButtonName;
126-
button2Name = librariesButtonName;
127-
}
128-
else {
129-
button1Name = null;
130-
button2Name = null;
131-
openAnchor1 = "<a href=\"" + boardsManagerURL + "\">";
132-
closeAnchor1 = "</a>";
133-
openAnchor2 = "<a href=\"" + libraryManagerURL + "\">";
134-
closeAnchor2 = "</a>";
135-
}
136-
text = I18n.format(tr("Updates available for some of your {0}libraries{1} and {2}libraries{3}"), openAnchor1, closeAnchor1, openAnchor2, closeAnchor2);
121+
text = I18n.format(tr("Updates available for some of your {0}libraries{1} and {2}libraries{3}"), openAnchorBoards, closeAnchorBoards, openAnchorLibraries, closeAnchorLibraries);
137122
}
138123

139124
if (cancelled) {

app/src/cc/arduino/view/NotificationPopup.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
import javax.swing.event.HyperlinkListener;
5151

5252
import cc.arduino.Constants;
53+
import org.apache.logging.log4j.LogManager;
54+
import org.apache.logging.log4j.Logger;
5355
import processing.app.PreferencesData;
5456
import processing.app.Theme;
5557

@@ -152,10 +154,12 @@ public void mouseClicked(MouseEvent e) {
152154
optionalButton2.addMouseListener(button2Action);
153155

154156
KeyListener button2Key = new KeyListener() {
157+
// Ignore when the key is typed - only act once the key is released
155158
public void keyTyped(KeyEvent e) {
156159
// do nothing here, wait until the key is released
157160
}
158161

162+
// Ignore when the key is pressed - only act once the key is released
159163
public void keyPressed(KeyEvent e) {
160164
// do nothing here, wait until the key is released
161165
}
@@ -180,10 +184,14 @@ public void keyReleased(KeyEvent e) {
180184
closeButton.setBackground(new Color(0, 0, 0, 0));
181185
closeButton.getAccessibleContext().setAccessibleDescription(tr("Close"));
182186
KeyListener closeKey = new KeyListener() {
187+
// Ignore when the key is typed - only act once the key is released
183188
public void keyTyped(KeyEvent e) {
189+
// do nothing here, wait until the key is released
184190
}
185191

192+
// Ignore when the key is pressed - only act once the key is released
186193
public void keyPressed(KeyEvent e) {
194+
// do nothing here, wait until the key is released
187195
}
188196

189197
public void keyReleased(KeyEvent e) {

0 commit comments

Comments
 (0)