Skip to content

Commit f4e16a1

Browse files
authored
Some Checkstyle fixes. (#12379)
- Added and updated JavaDocs. - Deprecated unused fields and methods that update them. - Suppressed unavoidable deprecated calls. - Switched other deprecated calls to use currently recommended calls.
1 parent 4f6f3ae commit f4e16a1

File tree

6 files changed

+276
-15
lines changed

6 files changed

+276
-15
lines changed

client/src/main/java/com/vaadin/client/ui/VPopupView.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@
4646
import com.vaadin.client.ui.popupview.VisibilityChangeEvent;
4747
import com.vaadin.client.ui.popupview.VisibilityChangeHandler;
4848

49+
/**
50+
* Widget class for the PopupView component.
51+
*
52+
* @author Vaadin Ltd
53+
*
54+
*/
4955
public class VPopupView extends HTML
5056
implements HasEnabled, Iterable<Widget>, DeferredWorker {
5157

58+
/** Default classname for this widget. */
5259
public static final String CLASSNAME = "v-popupview";
5360

5461
/**
@@ -113,7 +120,12 @@ public void onClose(CloseEvent<PopupPanel> event) {
113120
popup.setAutoHideOnHistoryEventsEnabled(false);
114121
}
115122

116-
/** For internal use only. May be removed or replaced in the future. */
123+
/**
124+
* For internal use only. May be removed or replaced in the future.
125+
*
126+
* @param popup
127+
* the popup that should be shown
128+
*/
117129
public void preparePopup(final CustomPopup popup) {
118130
popup.setVisible(true);
119131
popup.setWidget(loading);
@@ -130,6 +142,7 @@ public void preparePopup(final CustomPopup popup) {
130142
* Can be overridden to customize the popup position.
131143
*
132144
* @param popup
145+
* the popup whose position should be updated
133146
*/
134147
public void showPopup(final CustomPopup popup) {
135148
popup.setPopupPosition(0, 0);
@@ -220,6 +233,7 @@ public void setEnabled(boolean enabled) {
220233
* (other than it being a VOverlay) is to be considered private and
221234
* potentially subject to change.
222235
*/
236+
@SuppressWarnings("deprecation")
223237
public class CustomPopup extends VOverlay
224238
implements StateChangeEvent.StateChangeHandler {
225239

@@ -237,6 +251,11 @@ public class CustomPopup extends VOverlay
237251

238252
private ShortcutActionHandler shortcutActionHandler;
239253

254+
/**
255+
* Constructs a popup widget for VPopupView.
256+
*
257+
* @see CustomPopup
258+
*/
240259
public CustomPopup() {
241260
super(true, false); // autoHide, not modal
242261
setOwner(VPopupView.this);
@@ -361,6 +380,13 @@ public boolean remove(Widget w) {
361380
return super.remove(w);
362381
}
363382

383+
/**
384+
* Sets the connector of the popup content widget. Should not be
385+
* {@code null}.
386+
*
387+
* @param newPopupComponent
388+
* the connector to set
389+
*/
364390
public void setPopupConnector(ComponentConnector newPopupComponent) {
365391

366392
if (newPopupComponent != popupComponentConnector) {
@@ -377,6 +403,15 @@ public void setPopupConnector(ComponentConnector newPopupComponent) {
377403

378404
}
379405

406+
/**
407+
* Should this popup automatically hide when the user takes the mouse
408+
* cursor out of the popup area? If this is {@code false}, the user must
409+
* click outside the popup to close it. The default is {@code true}.
410+
*
411+
* @param hideOnMouseOut
412+
* {@code true} if this popup should hide when mouse is moved
413+
* away, {@code false} otherwise
414+
*/
380415
public void setHideOnMouseOut(boolean hideOnMouseOut) {
381416
this.hideOnMouseOut = hideOnMouseOut;
382417
}
@@ -405,6 +440,14 @@ private ShortcutActionHandler findShortcutActionHandler() {
405440
}
406441
}
407442

443+
/**
444+
* Adds the given visibility change handler to this widget.
445+
*
446+
* @param visibilityChangeHandler
447+
* the handler that should be triggered when visibility changes
448+
* @return the registration object for removing the given handler when no
449+
* longer needed
450+
*/
408451
public HandlerRegistration addVisibilityChangeHandler(
409452
final VisibilityChangeHandler visibilityChangeHandler) {
410453
return addHandler(visibilityChangeHandler,

client/src/main/java/com/vaadin/client/ui/VProgressBar.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
*/
3737
public class VProgressBar extends Widget implements HasEnabled {
3838

39+
/** Default classname for this widget. */
3940
public static final String PRIMARY_STYLE_NAME = "v-progressbar";
4041

4142
Element wrapper = DOM.createDiv();
@@ -45,6 +46,10 @@ public class VProgressBar extends Widget implements HasEnabled {
4546
private float state = 0.0f;
4647
private boolean enabled;
4748

49+
/**
50+
* Constructs a widget for the ProgressBar component or renderer.
51+
*/
52+
@SuppressWarnings("deprecation")
4853
public VProgressBar() {
4954
setElement(DOM.createDiv());
5055
getElement().appendChild(wrapper);
@@ -68,20 +73,52 @@ public void setStylePrimaryName(String style) {
6873

6974
}
7075

76+
/**
77+
* Sets whether or not this progress indicator is indeterminate. In
78+
* indeterminate mode there is an animation indicating that the task is
79+
* running but without providing any information about the current progress.
80+
*
81+
* @param indeterminate
82+
* {@code true} to set to indeterminate mode, {@code false}
83+
* otherwise
84+
*/
7185
public void setIndeterminate(boolean indeterminate) {
7286
this.indeterminate = indeterminate;
7387
setStyleName(getStylePrimaryName() + "-indeterminate", indeterminate);
7488
}
7589

90+
/**
91+
* Sets the value of this progress bar. The value is a {@code float} between
92+
* 0 and 1 where 0 represents no progress at all and 1 represents fully
93+
* completed.
94+
*
95+
* @param state
96+
* the new progress value
97+
*/
7698
public void setState(float state) {
7799
final int size = Math.round(100 * state);
78100
indicator.getStyle().setWidth(size, Unit.PCT);
79101
}
80102

103+
/**
104+
* Gets whether or not this progress indicator is indeterminate. In
105+
* indeterminate mode there is an animation indicating that the task is
106+
* running but without providing any information about the current progress.
107+
*
108+
* @return {@code true} if set to indeterminate mode, {@code false}
109+
* otherwise
110+
*/
81111
public boolean isIndeterminate() {
82112
return indeterminate;
83113
}
84114

115+
/**
116+
* Returns the current value of this progress bar. The value is a
117+
* {@code float} between 0 and 1 where 0 represents no progress at all and 1
118+
* represents fully completed.
119+
*
120+
* @return the current progress value
121+
*/
85122
public float getState() {
86123
return state;
87124
}

client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@
5353
public class VRadioButtonGroup extends FocusableFlowPanelComposite
5454
implements Field, ClickHandler, HasEnabled {
5555

56+
/** Default classname for this widget. */
5657
public static final String CLASSNAME = "v-select-optiongroup";
58+
/** Default classname for all radio buttons within this widget. */
5759
public static final String CLASSNAME_OPTION = "v-select-option";
60+
/** Default classname for the selected radio button within this widget. */
5861
public static final String CLASSNAME_OPTION_SELECTED = "v-select-option-selected";
5962

6063
private final Map<RadioButton, JsonObject> optionsToItems;
@@ -72,6 +75,9 @@ public class VRadioButtonGroup extends FocusableFlowPanelComposite
7275
private final String groupId;
7376
private List<Consumer<JsonObject>> selectionChangeListeners;
7477

78+
/**
79+
* Constructs a widget for the RadioButtonGroup component.
80+
*/
7581
public VRadioButtonGroup() {
7682
groupId = DOM.createUniqueId();
7783
getWidget().setStyleName(CLASSNAME);
@@ -80,8 +86,11 @@ public VRadioButtonGroup() {
8086
selectionChangeListeners = new ArrayList<>();
8187
}
8288

83-
/*
84-
* Build all the options
89+
/**
90+
* Build all the options.
91+
*
92+
* @param items
93+
* the list of options
8594
*/
8695
public void buildOptions(List<JsonObject> items) {
8796
Roles.getRadiogroupRole().set(getElement());
@@ -194,16 +203,26 @@ public void onClick(ClickEvent event) {
194203
}
195204
}
196205

206+
/**
207+
* Sets the tabulator index for the container element that holds the radio
208+
* buttons. It represents the entire radio button group within the browser's
209+
* focus cycle.
210+
*
211+
* @param tabIndex
212+
* tabulator index for the radio button group
213+
*/
197214
public void setTabIndex(int tabIndex) {
198215
for (Widget anOptionsContainer : getWidget()) {
199216
FocusWidget widget = (FocusWidget) anOptionsContainer;
200217
widget.setTabIndex(tabIndex);
201218
}
202219
}
203220

221+
/**
222+
* Sets radio buttons enabled according to this widget's enabled and
223+
* read-only status, as well as each option's own enabled status.
224+
*/
204225
protected void updateEnabledState() {
205-
// sets options enabled according to the widget's enabled,
206-
// readonly and each options own enabled
207226
for (Map.Entry<RadioButton, JsonObject> entry : optionsToItems
208227
.entrySet()) {
209228
RadioButton radioButton = entry.getKey();
@@ -214,10 +233,28 @@ protected void updateEnabledState() {
214233
}
215234
}
216235

236+
/**
237+
* Returns whether HTML is allowed in the item captions.
238+
*
239+
* @return {@code true} if the captions are used as HTML, {@code false} if
240+
* used as plain text
241+
*/
217242
public boolean isHtmlContentAllowed() {
218243
return htmlContentAllowed;
219244
}
220245

246+
/**
247+
* Sets whether HTML is allowed in the item captions. If set to
248+
* {@code true}, the captions are displayed as HTML and the developer is
249+
* responsible for ensuring no harmful HTML is used. If set to
250+
* {@code false}, the content is displayed as plain text.
251+
* <p>
252+
* This value is delegated from the RadioButtonGroupState.
253+
*
254+
* @param htmlContentAllowed
255+
* {@code true} if the captions are used as HTML, {@code false}
256+
* if used as plain text
257+
*/
221258
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
222259
this.htmlContentAllowed = htmlContentAllowed;
223260
}
@@ -227,10 +264,22 @@ public boolean isEnabled() {
227264
return enabled;
228265
}
229266

267+
/**
268+
* Returns whether this radio button group is read-only or not.
269+
*
270+
* @return {@code true} if this widget is read-only, {@code false} otherwise
271+
*/
230272
public boolean isReadonly() {
231273
return readonly;
232274
}
233275

276+
/**
277+
* Sets the read-only status of this radio button group.
278+
*
279+
* @param readonly
280+
* {@code true} if this widget should be read-only, {@code false}
281+
* otherwise
282+
*/
234283
public void setReadonly(boolean readonly) {
235284
if (this.readonly != readonly) {
236285
this.readonly = readonly;
@@ -246,13 +295,27 @@ public void setEnabled(boolean enabled) {
246295
}
247296
}
248297

298+
/**
299+
* Adds the given selection change handler to this widget.
300+
*
301+
* @param selectionChanged
302+
* the handler that should be triggered when selection changes
303+
* @return the registration object for removing the given handler when no
304+
* longer needed
305+
*/
249306
public Registration addSelectionChangeHandler(
250307
Consumer<JsonObject> selectionChanged) {
251308
selectionChangeListeners.add(selectionChanged);
252309
return (Registration) () -> selectionChangeListeners
253310
.remove(selectionChanged);
254311
}
255312

313+
/**
314+
* Removes previous selection and adds new selection.
315+
*
316+
* @param selectedItemKey
317+
* the key of the selected radio button
318+
*/
256319
public void selectItemKey(String selectedItemKey) {
257320
// At most one item could be selected so reset all radio buttons
258321
// before applying current selection

0 commit comments

Comments
 (0)