Skip to content

Commit 2abfdf6

Browse files
committed
More cleanup
1 parent c8373d3 commit 2abfdf6

File tree

126 files changed

+985
-1474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+985
-1474
lines changed

ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ This is a minor release.
2424
* `net.sourceforge.pmd.eclipse.runtime.cmd.BaseVisitor.isUseTaskMarker()`
2525
* `net.sourceforge.pmd.eclipse.runtime.cmd.BaseVisitor.setUseTaskMarker(boolean)`
2626
* `net.sourceforge.pmd.eclipse.ui.preferences.br.FilterManager`
27+
* `net.sourceforge.pmd.eclipse.util.IOUtil`
28+
* All classes that couldn't be instantiated because they had a private constructor only
29+
are now also `final`.
2730

2831
### External Contributions
2932

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractEditorFactory.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public abstract class AbstractEditorFactory<T> implements EditorFactory<T> {
2626
// protected static Color overriddenColour;
2727

2828
protected AbstractEditorFactory() {
29+
// protected default constructor for subclassing
2930
}
3031

3132
// private static ColourManager colourManager() {
@@ -50,6 +51,7 @@ protected AbstractEditorFactory() {
5051
* necessary but must be able to extract the values held by them when the
5152
* property is created.
5253
*/
54+
@Override
5355
public Control[] createOtherControlsOn(Composite parent, PropertyDescriptor<T> desc, PropertySource source,
5456
ValueChangeListener listener, SizeChangeListener sizeListener) {
5557
return new Control[] { newLabel(parent, "Default"), newEditorOn(parent, desc, source, listener, sizeListener) };
@@ -68,18 +70,8 @@ protected T valueFor(PropertySource source, PropertyDescriptor<T> desc) {
6870
return source.hasDescriptor(desc) ? source.getProperty(desc) : desc.defaultValue();
6971
}
7072

71-
/**
72-
* Method addLabel.
73-
*
74-
* @param parent
75-
* Composite
76-
* @param desc
77-
* PropertyDescriptor
78-
*
79-
* @return Label
80-
*/
73+
@Override
8174
public Label addLabel(Composite parent, PropertyDescriptor<T> desc) {
82-
8375
Label label = new Label(parent, SWT.NONE);
8476
label.setText(desc.description());
8577
GridData data = new GridData();
@@ -109,7 +101,7 @@ public Label addLabel(Composite parent, PropertyDescriptor<T> desc) {
109101
// }
110102
protected void adjustRendering(PropertySource source, PropertyDescriptor<?> desc, Control control) {
111103

112-
return; // don't do it...kinda irritating
104+
// return; // don't do it...kinda irritating
113105

114106
// if (!(rule instanceof RuleReference)) return;
115107
//

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
* held in the event handlers and passed onto any new handlers created to manage values newly created
3333
* by the user - hence the monster method calls with umpteen arguments.
3434
*
35-
* Concrete subclasses are responsible for instantiating the type-appropriate edit widgets, retrieving
35+
* <p>Concrete subclasses are responsible for instantiating the type-appropriate edit widgets, retrieving
3636
* their values, and updating the rule property. Provided you have widget capable of displaying/editing
3737
* your value type you can use this class as a base to bring up the appropriate widgets for the
3838
* individual values.
3939
*
40-
* The editor is held in a composite divided into three columns. In the collapsed mode, a text field
40+
* <p>The editor is held in a composite divided into three columns. In the collapsed mode, a text field
4141
* displaying the value collection occupies the first two cells with an expand/collapse button in the
4242
* last cell. When the user clicks the button the row beneath is given a label, a type-specific edit
4343
* widget, and a control button for every value in the collection. The last row is empty and serves as
4444
* a place the user can enter additional values. When the user enters a value and clicks the control
4545
* button that row becomes read-only and a new empty row is added to the bottom.
4646
*
47-
* Note inclusion of the size and value changed callbacks used to let the parent composite resize itself
47+
* <p>Note inclusion of the size and value changed callbacks used to let the parent composite resize itself
4848
* and update the values in the rule listings respectively.
4949
*
5050
* @author Brian Remedios
@@ -57,6 +57,7 @@ public abstract class AbstractMultiValueEditorFactory<T> extends AbstractEditorF
5757

5858

5959
protected AbstractMultiValueEditorFactory() {
60+
// protected default constructor for subclassing
6061
}
6162

6263

@@ -75,6 +76,7 @@ protected AbstractMultiValueEditorFactory() {
7576
protected abstract Control addWidget(Composite parent, T value, PropertyDescriptor<List<T>> desc, PropertySource source);
7677

7778

79+
@Override
7880
public Control newEditorOn(final Composite parent, final PropertyDescriptor<List<T>> desc,
7981
final PropertySource source, final ValueChangeListener changeListener, final SizeChangeListener sizeListener) {
8082

@@ -92,7 +94,7 @@ public Control newEditorOn(final Composite parent, final PropertyDescriptor<List
9294
boolean itemsVisible = false;
9395
List<Control> items = new ArrayList<Control>();
9496

95-
97+
@Override
9698
public void handleEvent(Event event) {
9799
if (itemsVisible) {
98100
hideCollection(items);
@@ -137,7 +139,7 @@ private void delete(Control number, Control widget, Control button, List<Control
137139
renumberLabelsIn(controlList);
138140

139141
List<T> values = valueFor(source, desc);
140-
List<T> newValues = new ArrayList<T>(values.size() - 1);
142+
List<T> newValues = new ArrayList<>(values.size() - 1);
141143
for (T value : values) {
142144
if (value.equals(deleteValue)) {
143145
continue;
@@ -153,7 +155,7 @@ private List<Control> openCollection(final Composite parent, final PropertyDescr
153155
final PropertySource source, final Text textWidget, final ValueChangeListener changeListener,
154156
final SizeChangeListener sizeListener) {
155157

156-
final List<Control> newControls = new ArrayList<Control>();
158+
final List<Control> newControls = new ArrayList<>();
157159

158160
int i;
159161
List<T> values = valueFor(source, desc);
@@ -167,6 +169,7 @@ private List<Control> openCollection(final Composite parent, final PropertyDescr
167169
butt.setText("-"); // TODO use icon for consistent width
168170
final T value = values.get(i);
169171
butt.addListener(SWT.Selection, new Listener() { // remove value handler
172+
@Override
170173
public void handleEvent(Event event) {
171174
delete(number, widget, butt, newControls, value, desc, source);
172175
fillWidget(textWidget, desc, source); // j
@@ -218,6 +221,7 @@ private void addNewValueRow(final Composite parent, final PropertyDescriptor<Lis
218221
butt.setText("+"); // TODO use icon for consistent width
219222
newControls.add(butt);
220223
Listener addListener = new Listener() {
224+
@Override
221225
public void handleEvent(Event event) { // add new value handler
222226
// add the new value to the property set
223227
// set the value in the widget to the cleaned up one, disable it
@@ -255,6 +259,7 @@ private void convertToDelete(final Button button, final T toDeleteValue, final C
255259
button.setText("-");
256260
Util.removeListeners(button, SWT.Selection);
257261
button.addListener(SWT.Selection, new Listener() {
262+
@Override
258263
public void handleEvent(Event event) {
259264
delete(number, widget, button, newControls, toDeleteValue, desc, source);
260265
fillWidget(parentWidget, desc, source);
@@ -282,7 +287,7 @@ protected List<String> textWidgetValues(Text textWidget) {
282287
}
283288

284289
String[] valueSet = values.split(DELIMITER);
285-
List<String> valueList = new ArrayList<String>(valueSet.length);
290+
List<String> valueList = new ArrayList<>(valueSet.length);
286291

287292
for (String value : valueSet) {
288293
String str = value.trim();

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractNumericEditorFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public abstract class AbstractNumericEditorFactory<T> extends AbstractEditorFact
2828

2929

3030
protected AbstractNumericEditorFactory() {
31+
// protected default constructor for subclassing
3132
}
3233

3334

@@ -67,18 +68,21 @@ protected int digitPrecision() {
6768

6869
private void linkup(final Spinner minWidget, final Spinner valueWidget, final Spinner maxWidget) {
6970
minWidget.addListener(SWT.Selection, new Listener() {
71+
@Override
7072
public void handleEvent(Event event) {
7173
adjustForMin(minWidget, valueWidget, maxWidget);
7274
}
7375
});
7476

7577
valueWidget.addListener(SWT.Selection, new Listener() {
78+
@Override
7679
public void handleEvent(Event event) {
7780
adjustForValue(minWidget, valueWidget, maxWidget);
7881
}
7982
});
8083

8184
maxWidget.addListener(SWT.Selection, new Listener() {
85+
@Override
8286
public void handleEvent(Event event) {
8387
adjustForMax(minWidget, valueWidget, maxWidget);
8488
}

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractRealNumberEditor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public abstract class AbstractRealNumberEditor<T extends Number> extends Abstrac
2121

2222

2323
protected AbstractRealNumberEditor() {
24+
// protected default constructor for subclassing
2425
}
2526

2627

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/BooleanEditorFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,29 @@
2020
/**
2121
* @author Brian Remedios
2222
*/
23-
public class BooleanEditorFactory extends AbstractEditorFactory<Boolean> {
23+
public final class BooleanEditorFactory extends AbstractEditorFactory<Boolean> {
2424

2525
public static final BooleanEditorFactory INSTANCE = new BooleanEditorFactory();
2626

2727

2828
private BooleanEditorFactory() { }
2929

3030

31+
@Override
3132
public PropertyDescriptor<Boolean> createDescriptor(String name, String description, Control[] otherData) {
3233
return PropertyFactory.booleanProperty(name).desc(description)
33-
.defaultValue(otherData == null ? false : valueFrom(otherData[1]))
34+
.defaultValue(otherData != null && valueFrom(otherData[1]))
3435
.build();
3536
}
3637

3738

39+
@Override
3840
protected Boolean valueFrom(Control valueControl) {
3941
return ((Button) valueControl).getSelection();
4042
}
4143

4244

45+
@Override
4346
public Control newEditorOn(Composite parent, final PropertyDescriptor<Boolean> desc, final PropertySource source,
4447
final ValueChangeListener listener, SizeChangeListener sizeListener) {
4548

@@ -50,6 +53,7 @@ public Control newEditorOn(Composite parent, final PropertyDescriptor<Boolean> d
5053
butt.setSelection(set);
5154

5255
SelectionAdapter sa = new SelectionAdapter() {
56+
@Override
5357
public void widgetSelected(SelectionEvent event) {
5458
boolean selected = butt.getSelection();
5559
if (selected == valueFor(source, desc)) {

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/CharacterEditorFactory.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,31 @@
2121
/**
2222
* @author Brian Remedios
2323
*/
24-
public class CharacterEditorFactory extends AbstractEditorFactory<Character> {
24+
public final class CharacterEditorFactory extends AbstractEditorFactory<Character> {
2525

2626
public static final CharacterEditorFactory INSTANCE = new CharacterEditorFactory();
2727

2828

2929
private CharacterEditorFactory() { }
3030

3131

32+
@Override
3233
public PropertyDescriptor<Character> createDescriptor(String name, String description, Control[] otherData) {
3334
return PropertyFactory.charProperty(name).desc(description)
3435
.defaultValue('a').build();
3536
}
3637

3738

39+
@Override
3840
protected Character valueFrom(Control valueControl) {
39-
4041
String value = ((Text) valueControl).getText().trim();
4142

42-
return (StringUtils.isBlank(value) || value.length() > 1) ? null
43-
: value.charAt(0);
43+
return StringUtils.isBlank(value) || value.length() > 1 ? null
44+
: value.charAt(0);
4445
}
4546

4647

48+
@Override
4749
public Control newEditorOn(Composite parent, final PropertyDescriptor<Character> desc, final PropertySource
4850
source, final ValueChangeListener listener, SizeChangeListener sizeListener) {
4951

@@ -52,6 +54,7 @@ public Control newEditorOn(Composite parent, final PropertyDescriptor<Character>
5254
fillWidget(text, desc, source);
5355

5456
text.addListener(SWT.FocusOut, new Listener() {
57+
@Override
5558
public void handleEvent(Event event) {
5659
Character newValue = charValueIn(text);
5760
Character existingValue = valueFor(source, desc);
@@ -69,12 +72,6 @@ public void handleEvent(Event event) {
6972
}
7073

7174

72-
/**
73-
* Method fillWidget.
74-
*
75-
* @param textWidget Text
76-
* @param desc PropertyDescriptor<?>
77-
*/
7875
protected void fillWidget(Text textWidget, PropertyDescriptor<Character> desc, PropertySource source) {
7976
Character val = valueFor(source, desc);
8077
textWidget.setText(val == null ? "" : val.toString());

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/DoubleEditorFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
/**
2121
* @author Brian Remedios
2222
*/
23-
public class DoubleEditorFactory extends AbstractRealNumberEditor<Double> {
23+
public final class DoubleEditorFactory extends AbstractRealNumberEditor<Double> {
2424

2525
public static final DoubleEditorFactory INSTANCE = new DoubleEditorFactory();
2626

2727

2828
private DoubleEditorFactory() { }
2929

3030

31+
@Override
3132
public PropertyDescriptor<Double> createDescriptor(String name, String description, Control[] otherData) {
3233
return PropertyFactory.doubleProperty(name).desc(description)
3334
.defaultValue(defaultIn(otherData).doubleValue())
@@ -36,18 +37,20 @@ public PropertyDescriptor<Double> createDescriptor(String name, String descripti
3637
}
3738

3839

40+
@Override
3941
protected Double valueFrom(Control valueControl) {
40-
4142
return ((Spinner) valueControl).getSelection() / SCALE;
4243
}
4344

4445

46+
@Override
4547
public Control newEditorOn(Composite parent, final PropertyDescriptor<Double> desc, final PropertySource source,
4648
final ValueChangeListener listener, SizeChangeListener sizeListener) {
4749

4850
final Spinner spinner = newSpinnerFor(parent, source, desc);
4951

5052
spinner.addModifyListener(new ModifyListener() {
53+
@Override
5154
public void modifyText(ModifyEvent event) {
5255
Double newValue = spinner.getSelection() / SCALE;
5356
if (newValue.equals(valueFor(source, desc))) {

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/EnumerationEditorFactory.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,28 @@
2222
/**
2323
* @author Brian Remedios
2424
*/
25-
public class EnumerationEditorFactory extends AbstractEditorFactory<Object> {
25+
public final class EnumerationEditorFactory extends AbstractEditorFactory<Object> {
2626

2727
public static final EnumerationEditorFactory INSTANCE = new EnumerationEditorFactory();
2828

2929

3030
private EnumerationEditorFactory() { }
3131

3232

33+
@Override
3334
protected Object valueFrom(Control valueControl) {
34-
35-
int index = ((Combo) valueControl).getSelectionIndex();
35+
// TODO int index = ((Combo) valueControl).getSelectionIndex();
3636
return null; // TODO ???
3737
}
3838

3939

40+
@Override
4041
public PropertyDescriptor<Object> createDescriptor(String name, String optionalDescription, Control[] otherData) {
4142
return PropertyFactory.enumProperty(name, new HashMap<String, Object>()).desc("Value set " + name).build();
4243
}
4344

4445

46+
@Override
4547
public Control newEditorOn(Composite parent, final PropertyDescriptor<Object> desc, final PropertySource source,
4648
final ValueChangeListener listener, SizeChangeListener sizeListener) {
4749

@@ -67,6 +69,7 @@ public Control newEditorOn(Composite parent, final PropertyDescriptor<Object> de
6769
}
6870

6971
combo.addSelectionListener(new SelectionAdapter() {
72+
@Override
7073
public void widgetSelected(SelectionEvent e) {
7174
int selectionIdx = combo.getSelectionIndex();
7275
Object[][] choices = (Object[][]) combo.getData();
@@ -86,7 +89,7 @@ public void widgetSelected(SelectionEvent e) {
8689

8790

8891
/**
89-
* Search through both columns if necessary
92+
* Search through both columns if necessary.
9093
*/
9194
public static int indexOf(Object item, Object[][] items) {
9295
int index = indexOf(item, items, 0);
@@ -104,8 +107,7 @@ public static int indexOf(Object item, Object[][] items, int testColumnIndex) {
104107
}
105108

106109
public static <T> Object[][] choices(PropertyDescriptor<T> prop) {
107-
Object[][] res = new Object[0][2];
108110
// TODO: prop.mapping() would be needed to get the valid choices....
109-
return res;
111+
return new Object[0][2];
110112
}
111113
}

0 commit comments

Comments
 (0)