Skip to content

Commit 10e345f

Browse files
committed
Additional fixes and exclusions
1 parent 841668f commit 10e345f

File tree

16 files changed

+74
-111
lines changed

16 files changed

+74
-111
lines changed

.github/scripts/generate-quality-report.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ def main() -> None:
795795
"BC_UNCONFIRMED_CAST_OF_RETURN_VALUE",
796796
"CN_IDIOM_NO_SUPER_CALL",
797797
"DM_BOOLEAN_CTOR",
798-
"DM_CONVERT_CASE",
799798
"DM_EXIT",
800799
"EI_EXPOSE_REP",
801800
"EI_EXPOSE_REP2",

CodenameOne/src/com/codename1/components/ButtonList.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,17 @@ public abstract class ButtonList extends Container implements DataChangedListene
9999
private final java.util.List<Runnable> onReady = new ArrayList<Runnable>();
100100
private String cellUIID;
101101
private java.util.List<Decorator> decorators;
102+
private final boolean allowMultipleSelection;
102103

103104
/**
104105
* Creates a new ButtonList.
105106
*
106107
* @param model The options. Each will be represented by a button.
108+
* @param allowMultipleSelection indicates that multiple selection is allowed or not
107109
*/
108-
public ButtonList(ListModel model) {
109-
if (model instanceof DefaultListModel && isAllowMultipleSelection()) {
110+
protected ButtonList(ListModel model, boolean allowMultipleSelection) {
111+
this.allowMultipleSelection = allowMultipleSelection;
112+
if (model instanceof DefaultListModel && allowMultipleSelection) {
110113
((DefaultListModel) model).setMultiSelectionMode(true);
111114
}
112115
setModel(model);
@@ -182,14 +185,6 @@ public void run() {
182185
}
183186
}
184187

185-
/**
186-
* Returns true for lists that allow multiple selection. {@link CheckBoxList}, and {@link SwitchList} support multiple selection.
187-
* {@link RadioButtonList} does not.
188-
*
189-
* @return
190-
*/
191-
public abstract boolean isAllowMultipleSelection();
192-
193188
/**
194189
* Creates a new button for this list. Should be implemented by subclasses to create the correct kind of button.
195190
*
@@ -237,7 +232,7 @@ public void refresh() {
237232
int len = model.getSize();
238233
for (int i = 0; i < len; i++) {
239234
Component b = createComponent(model.getItemAt(i));
240-
if (isAllowMultipleSelection()) {
235+
if (allowMultipleSelection) {
241236
if (Arrays.binarySearch(selectedIndices, i) >= 0) {
242237
setSelected(b, true);
243238
}
@@ -328,7 +323,7 @@ public void dataChanged(int status, int index) {
328323
// Called when the selection is changed in the model
329324
@Override
330325
public void selectionChanged(int oldSelected, int newSelected) {
331-
if (isAllowMultipleSelection()) {
326+
if (allowMultipleSelection) {
332327
if (oldSelected < 0 && newSelected >= 0) {
333328
Component cmp = newSelected < getComponentCount() ? getComponentAt(newSelected) : null;
334329
if (cmp != null) {

CodenameOne/src/com/codename1/components/CheckBoxList.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,10 @@ public void actionPerformed(ActionEvent evt) {
5757
};
5858

5959
public CheckBoxList(MultipleSelectionListModel model) {
60-
super(model);
60+
super(model, true);
6161
fireReady();
6262
}
63-
64-
@Override
65-
public boolean isAllowMultipleSelection() {
66-
return true;
67-
}
68-
63+
6964
@Override
7065
protected Component createButton(Object model) {
7166
return new CheckBox(String.valueOf(model));

CodenameOne/src/com/codename1/components/ImageViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class ImageViewer extends Component {
118118
public ImageViewer() {
119119
setFocusable(true);
120120
setUIIDFinal("ImageViewer");
121-
$(this).selectAllStyles().setBgTransparency(0x0);
121+
getAllStyles().setBgTransparency(0x0);
122122
}
123123

124124
/**

CodenameOne/src/com/codename1/components/Progress.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*
4444
* @author Shai Almog
4545
*/
46-
public class Progress extends Dialog implements ActionListener {
46+
public class Progress extends Dialog implements ActionListener<NetworkEvent> {
4747
private final ConnectionRequest request;
4848
private boolean disposeOnCompletion;
4949
private boolean autoShow;
@@ -136,18 +136,15 @@ public void setDisposeOnCompletion(boolean disposeOnCompletion) {
136136
/**
137137
* {@inheritDoc}
138138
*/
139-
public void actionPerformed(ActionEvent evt) {
140-
if(evt instanceof NetworkEvent) {
141-
NetworkEvent ev = (NetworkEvent) evt;
142-
if (ev.getConnectionRequest() == request) {
143-
if (disposeOnCompletion && ev.getProgressType() == NetworkEvent.PROGRESS_TYPE_COMPLETED) {
144-
dispose();
145-
return;
146-
}
147-
if (autoShow && !showing) {
148-
showing = true;
149-
showModeless();
150-
}
139+
public void actionPerformed(NetworkEvent ev) {
140+
if (ev.getConnectionRequest() == request) {
141+
if (disposeOnCompletion && ev.getProgressType() == NetworkEvent.PROGRESS_TYPE_COMPLETED) {
142+
dispose();
143+
return;
144+
}
145+
if (autoShow && !showing) {
146+
showing = true;
147+
showModeless();
151148
}
152149
}
153150
}

CodenameOne/src/com/codename1/components/RadioButtonList.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class RadioButtonList extends ButtonList {
4040
/**
4141
* Change listener added to individual radio buttons to keep them in sync with the model.
4242
*/
43-
private final ActionListener changeListener = new ActionListener() {
43+
private final ActionListener<ActionEvent> changeListener = new ActionListener<ActionEvent>() {
4444
@Override
4545
public void actionPerformed(ActionEvent evt) {
4646
if (evt.getSource() instanceof RadioButton && contains((Component) evt.getSource())) {
@@ -61,21 +61,10 @@ public void actionPerformed(ActionEvent evt) {
6161
* @param model The model that defines the options that the user can choose between.
6262
*/
6363
public RadioButtonList(ListModel model) {
64-
super(model);
64+
super(model, false);
6565
fireReady();
6666
}
6767

68-
/**
69-
* Returns false for RadioButtonList since only one radio button can be selected at a time.
70-
*
71-
* @return
72-
*/
73-
@Override
74-
public boolean isAllowMultipleSelection() {
75-
return false;
76-
}
77-
78-
7968
@Override
8069
protected Component createButton(Object model) {
8170
return new RadioButton(String.valueOf(model));

CodenameOne/src/com/codename1/components/SignatureComponent.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
* @author shannah
8686
* @since 3.4
8787
*/
88-
public class SignatureComponent extends Container implements ActionSource {
88+
public class SignatureComponent extends Container implements ActionSource<ActionEvent> {
8989

9090
private final SignaturePanel signaturePanel = new SignaturePanel();
9191
private final Button lead;
@@ -152,7 +152,7 @@ protected void paintBackground(Graphics g) {
152152
};
153153
lead.setText(localize("SignatureComponent.LeadText", "Press to sign"));
154154
lead.setUIID("SignatureButton");
155-
lead.addActionListener(new ActionListener() {
155+
lead.addActionListener(new ActionListener<ActionEvent>() {
156156
public void actionPerformed(ActionEvent evt) {
157157
final Dialog dialog = new Dialog(localize("SignatureComponent.DialogTitle", "Sign Here"));
158158
final SignatureDialogBody sigBody = new SignatureDialogBody() {
@@ -164,7 +164,7 @@ protected void onCancel() {
164164
};
165165
signaturePanel.clear();
166166

167-
sigBody.addActionListener(new ActionListener() {
167+
sigBody.addActionListener(new ActionListener<ActionEvent>() {
168168
public void actionPerformed(ActionEvent sigDoneEvent) {
169169
dialog.dispose();
170170
setSignatureImage(sigBody.getValue());
@@ -179,7 +179,7 @@ public void actionPerformed(ActionEvent sigDoneEvent) {
179179
dialog.show();
180180
}
181181
});
182-
addComponent(BorderLayout.CENTER, lead);
182+
super.addComponent(BorderLayout.CENTER, lead);
183183
}
184184

185185
/**
@@ -208,7 +208,7 @@ protected void onSignatureReset() {
208208
*
209209
* @param l
210210
*/
211-
public void addActionListener(ActionListener l) {
211+
public void addActionListener(ActionListener<ActionEvent> l) {
212212
eventDispatcher.addListener(l);
213213
}
214214

@@ -217,7 +217,7 @@ public void addActionListener(ActionListener l) {
217217
*
218218
* @param l
219219
*/
220-
public void removeActionListener(ActionListener l) {
220+
public void removeActionListener(ActionListener<ActionEvent> l) {
221221
eventDispatcher.removeListener(l);
222222
}
223223

@@ -331,25 +331,22 @@ public void clearSignaturePanel() {
331331
*/
332332
private class SignatureDialogBody extends Container {
333333
private final EventDispatcher eventDispatcher = new EventDispatcher();
334-
private final Button doneButton;
335-
private final Button resetButton;
336-
private final Button cancelButton;
337334
private Image value;
338335

339336
public SignatureDialogBody() {
340337
setLayout(new BorderLayout());
341-
addComponent(BorderLayout.CENTER, signaturePanel);
342-
doneButton = new Button(
338+
super.addComponent(BorderLayout.CENTER, signaturePanel);
339+
Button doneButton = new Button(
343340
localize("SignatureComponent.SaveButtonLabel", "Save"),
344341
getUIManager().getThemeConstant("sigButtonOKUIID", "Button"));
345-
resetButton = new Button(
342+
Button resetButton = new Button(
346343
localize("SignatureComponent.ResetButtonLabel", "Reset"),
347344
getUIManager().getThemeConstant("sigButtonResetUIID", "Button"));
348-
cancelButton = new Button(
345+
Button cancelButton = new Button(
349346
localize("SignatureComponent.CancelButtonLabel", "Cancel"),
350347
getUIManager().getThemeConstant("sigButtonCancelUIID", "Button"));
351348

352-
doneButton.addActionListener(new ActionListener() {
349+
doneButton.addActionListener(new ActionListener<ActionEvent>() {
353350
public void actionPerformed(ActionEvent evt) {
354351
value = signaturePanel.getImage();
355352
if (value == null) {
@@ -366,22 +363,22 @@ public void actionPerformed(ActionEvent evt) {
366363
}
367364
});
368365

369-
resetButton.addActionListener(new ActionListener() {
366+
resetButton.addActionListener(new ActionListener<ActionEvent>() {
370367
public void actionPerformed(ActionEvent evt) {
371368
signaturePanel.clear();
372369
onSignatureReset();
373370
repaint();
374371
}
375372
});
376373

377-
cancelButton.addActionListener(new ActionListener() {
374+
cancelButton.addActionListener(new ActionListener<ActionEvent>() {
378375
public void actionPerformed(ActionEvent evt) {
379376
removeComponent(signaturePanel);
380377
onCancel();
381378
}
382379
});
383380

384-
addComponent(BorderLayout.SOUTH, GridLayout.encloseIn(3, cancelButton, resetButton, doneButton));
381+
super.addComponent(BorderLayout.SOUTH, GridLayout.encloseIn(3, cancelButton, resetButton, doneButton));
385382
}
386383

387384
/**

CodenameOne/src/com/codename1/components/SpanButton.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.codename1.ui.SelectableIconHolder;
3333
import com.codename1.ui.TextArea;
3434
import com.codename1.ui.TextHolder;
35+
import com.codename1.ui.events.ActionEvent;
3536
import com.codename1.ui.events.ActionListener;
3637
import com.codename1.ui.events.ActionSource;
3738
import com.codename1.ui.layouts.BorderLayout;
@@ -53,7 +54,7 @@
5354
*
5455
* @author Shai Almog
5556
*/
56-
public class SpanButton extends Container implements ActionSource, SelectableIconHolder, TextHolder {
57+
public class SpanButton extends Container implements ActionSource<ActionEvent>, SelectableIconHolder, TextHolder {
5758

5859
private int gap = Label.getDefaultGap();
5960
private final Button actualButton;
@@ -84,7 +85,7 @@ public SpanButton(String txt, String textUiid) {
8485
public SpanButton(String txt) {
8586
setUIIDFinal("Button");
8687
setLayout(new BorderLayout());
87-
text = new TextArea(getUIManager().localize(txt, txt));
88+
text = new TextArea(super.getUIManager().localize(txt, txt));
8889
text.setColumns(100);
8990
text.setUIID("Button");
9091
text.setGrowByContent(true);
@@ -98,11 +99,11 @@ public SpanButton(String txt) {
9899
removeBackground(text.getDisabledStyle());
99100
actualButton = new Button();
100101
actualButton.setUIID("icon");
101-
addComponent(BorderLayout.WEST, actualButton);
102+
super.addComponent(BorderLayout.WEST, actualButton);
102103
Container center = BoxLayout.encloseYCenter(text);
103104
center.getStyle().setMargin(0, 0, 0, 0);
104105
center.getStyle().setPadding(0, 0, 0, 0);
105-
addComponent(BorderLayout.CENTER, center);
106+
super.addComponent(BorderLayout.CENTER, center);
106107
setLeadComponent(actualButton);
107108
updateGap();
108109
}
@@ -318,7 +319,7 @@ public void removeLongPressListener(ActionListener l) {
318319
*
319320
* @param l the listener
320321
*/
321-
public void addActionListener(ActionListener l) {
322+
public void addActionListener(ActionListener<ActionEvent> l) {
322323
actualButton.addActionListener(l);
323324
}
324325

@@ -327,7 +328,7 @@ public void addActionListener(ActionListener l) {
327328
*
328329
* @param l the listener
329330
*/
330-
public void removeActionListener(ActionListener l) {
331+
public void removeActionListener(ActionListener<ActionEvent> l) {
331332
actualButton.removeActionListener(l);
332333
}
333334

CodenameOne/src/com/codename1/components/SplitPane.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public SplitPane(Settings settings, Component topOrLeft, Component bottomOrRight
208208
divider = new Divider();
209209
add(this.topOrLeft).add(this.bottomOrRight).add(divider);
210210

211-
LayeredLayout l = (LayeredLayout) getLayout();
211+
LayeredLayout l = (LayeredLayout) super.getLayout();
212212
this.preferredInset = initDividerInset(l.createConstraint(), preferredInset);
213213
this.minInset = initDividerInset(l.createConstraint(), minInset);
214214
this.maxInset = initDividerInset(l.createConstraint(), maxInset);
@@ -217,22 +217,13 @@ public SplitPane(Settings settings, Component topOrLeft, Component bottomOrRight
217217
.setInsets(this.topOrLeft, "0 0 0 0");
218218
this.preferredInset.copyTo(l.getOrCreateConstraint(divider));
219219

220-
switch (orientation) {
221-
case HORIZONTAL_SPLIT: {
222-
l.setReferenceComponentRight(this.topOrLeft, divider, 1f);
223-
l.setReferenceComponentLeft(this.bottomOrRight, divider, 1f);
224-
break;
225-
}
226-
227-
default: {
228-
l.setReferenceComponentBottom(this.topOrLeft, divider, 1f);
229-
l.setReferenceComponentTop(this.bottomOrRight, divider, 1f);
230-
break;
231-
}
232-
220+
if (orientation == HORIZONTAL_SPLIT) {
221+
l.setReferenceComponentRight(this.topOrLeft, divider, 1f);
222+
l.setReferenceComponentLeft(this.bottomOrRight, divider, 1f);
223+
} else {
224+
l.setReferenceComponentBottom(this.topOrLeft, divider, 1f);
225+
l.setReferenceComponentTop(this.bottomOrRight, divider, 1f);
233226
}
234-
235-
236227
}
237228

238229
/**

CodenameOne/src/com/codename1/components/SwitchList.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
public class SwitchList extends ButtonList {
4343

4444

45-
private final ActionListener changeListener = new ActionListener() {
45+
private final ActionListener<ActionEvent> changeListener = new ActionListener<ActionEvent>() {
4646
@Override
4747
public void actionPerformed(ActionEvent evt) {
4848
if (evt.getSource() instanceof Switch && contains((Switch) evt.getSource())) {
@@ -59,15 +59,8 @@ public void actionPerformed(ActionEvent evt) {
5959
};
6060

6161
public SwitchList(MultipleSelectionListModel model) {
62-
super(model);
63-
62+
super(model, true);
6463
fireReady();
65-
66-
}
67-
68-
@Override
69-
public boolean isAllowMultipleSelection() {
70-
return true;
7164
}
7265

7366
@Override

0 commit comments

Comments
 (0)