Browse Source

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.
tags/8.14.0.beta1
Anna Koskinen 2 years ago
parent
commit
f4e16a189a
No account linked to committer's email address

+ 44
- 1
client/src/main/java/com/vaadin/client/ui/VPopupView.java View File

import com.vaadin.client.ui.popupview.VisibilityChangeEvent; import com.vaadin.client.ui.popupview.VisibilityChangeEvent;
import com.vaadin.client.ui.popupview.VisibilityChangeHandler; import com.vaadin.client.ui.popupview.VisibilityChangeHandler;


/**
* Widget class for the PopupView component.
*
* @author Vaadin Ltd
*
*/
public class VPopupView extends HTML public class VPopupView extends HTML
implements HasEnabled, Iterable<Widget>, DeferredWorker { implements HasEnabled, Iterable<Widget>, DeferredWorker {


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


/** /**
popup.setAutoHideOnHistoryEventsEnabled(false); popup.setAutoHideOnHistoryEventsEnabled(false);
} }


/** For internal use only. May be removed or replaced in the future. */
/**
* For internal use only. May be removed or replaced in the future.
*
* @param popup
* the popup that should be shown
*/
public void preparePopup(final CustomPopup popup) { public void preparePopup(final CustomPopup popup) {
popup.setVisible(true); popup.setVisible(true);
popup.setWidget(loading); popup.setWidget(loading);
* Can be overridden to customize the popup position. * Can be overridden to customize the popup position.
* *
* @param popup * @param popup
* the popup whose position should be updated
*/ */
public void showPopup(final CustomPopup popup) { public void showPopup(final CustomPopup popup) {
popup.setPopupPosition(0, 0); popup.setPopupPosition(0, 0);
* (other than it being a VOverlay) is to be considered private and * (other than it being a VOverlay) is to be considered private and
* potentially subject to change. * potentially subject to change.
*/ */
@SuppressWarnings("deprecation")
public class CustomPopup extends VOverlay public class CustomPopup extends VOverlay
implements StateChangeEvent.StateChangeHandler { implements StateChangeEvent.StateChangeHandler {




private ShortcutActionHandler shortcutActionHandler; private ShortcutActionHandler shortcutActionHandler;


/**
* Constructs a popup widget for VPopupView.
*
* @see CustomPopup
*/
public CustomPopup() { public CustomPopup() {
super(true, false); // autoHide, not modal super(true, false); // autoHide, not modal
setOwner(VPopupView.this); setOwner(VPopupView.this);
return super.remove(w); return super.remove(w);
} }


/**
* Sets the connector of the popup content widget. Should not be
* {@code null}.
*
* @param newPopupComponent
* the connector to set
*/
public void setPopupConnector(ComponentConnector newPopupComponent) { public void setPopupConnector(ComponentConnector newPopupComponent) {


if (newPopupComponent != popupComponentConnector) { if (newPopupComponent != popupComponentConnector) {


} }


/**
* Should this popup automatically hide when the user takes the mouse
* cursor out of the popup area? If this is {@code false}, the user must
* click outside the popup to close it. The default is {@code true}.
*
* @param hideOnMouseOut
* {@code true} if this popup should hide when mouse is moved
* away, {@code false} otherwise
*/
public void setHideOnMouseOut(boolean hideOnMouseOut) { public void setHideOnMouseOut(boolean hideOnMouseOut) {
this.hideOnMouseOut = hideOnMouseOut; this.hideOnMouseOut = hideOnMouseOut;
} }
} }
} }


/**
* Adds the given visibility change handler to this widget.
*
* @param visibilityChangeHandler
* the handler that should be triggered when visibility changes
* @return the registration object for removing the given handler when no
* longer needed
*/
public HandlerRegistration addVisibilityChangeHandler( public HandlerRegistration addVisibilityChangeHandler(
final VisibilityChangeHandler visibilityChangeHandler) { final VisibilityChangeHandler visibilityChangeHandler) {
return addHandler(visibilityChangeHandler, return addHandler(visibilityChangeHandler,

+ 37
- 0
client/src/main/java/com/vaadin/client/ui/VProgressBar.java View File

*/ */
public class VProgressBar extends Widget implements HasEnabled { public class VProgressBar extends Widget implements HasEnabled {


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


Element wrapper = DOM.createDiv(); Element wrapper = DOM.createDiv();
private float state = 0.0f; private float state = 0.0f;
private boolean enabled; private boolean enabled;


/**
* Constructs a widget for the ProgressBar component or renderer.
*/
@SuppressWarnings("deprecation")
public VProgressBar() { public VProgressBar() {
setElement(DOM.createDiv()); setElement(DOM.createDiv());
getElement().appendChild(wrapper); getElement().appendChild(wrapper);


} }


/**
* Sets whether or not this progress indicator is indeterminate. In
* indeterminate mode there is an animation indicating that the task is
* running but without providing any information about the current progress.
*
* @param indeterminate
* {@code true} to set to indeterminate mode, {@code false}
* otherwise
*/
public void setIndeterminate(boolean indeterminate) { public void setIndeterminate(boolean indeterminate) {
this.indeterminate = indeterminate; this.indeterminate = indeterminate;
setStyleName(getStylePrimaryName() + "-indeterminate", indeterminate); setStyleName(getStylePrimaryName() + "-indeterminate", indeterminate);
} }


/**
* Sets the value of this progress bar. The value is a {@code float} between
* 0 and 1 where 0 represents no progress at all and 1 represents fully
* completed.
*
* @param state
* the new progress value
*/
public void setState(float state) { public void setState(float state) {
final int size = Math.round(100 * state); final int size = Math.round(100 * state);
indicator.getStyle().setWidth(size, Unit.PCT); indicator.getStyle().setWidth(size, Unit.PCT);
} }


/**
* Gets whether or not this progress indicator is indeterminate. In
* indeterminate mode there is an animation indicating that the task is
* running but without providing any information about the current progress.
*
* @return {@code true} if set to indeterminate mode, {@code false}
* otherwise
*/
public boolean isIndeterminate() { public boolean isIndeterminate() {
return indeterminate; return indeterminate;
} }


/**
* Returns the current value of this progress bar. The value is a
* {@code float} between 0 and 1 where 0 represents no progress at all and 1
* represents fully completed.
*
* @return the current progress value
*/
public float getState() { public float getState() {
return state; return state;
} }

+ 67
- 4
client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java View File

public class VRadioButtonGroup extends FocusableFlowPanelComposite public class VRadioButtonGroup extends FocusableFlowPanelComposite
implements Field, ClickHandler, HasEnabled { implements Field, ClickHandler, HasEnabled {


/** Default classname for this widget. */
public static final String CLASSNAME = "v-select-optiongroup"; public static final String CLASSNAME = "v-select-optiongroup";
/** Default classname for all radio buttons within this widget. */
public static final String CLASSNAME_OPTION = "v-select-option"; public static final String CLASSNAME_OPTION = "v-select-option";
/** Default classname for the selected radio button within this widget. */
public static final String CLASSNAME_OPTION_SELECTED = "v-select-option-selected"; public static final String CLASSNAME_OPTION_SELECTED = "v-select-option-selected";


private final Map<RadioButton, JsonObject> optionsToItems; private final Map<RadioButton, JsonObject> optionsToItems;
private final String groupId; private final String groupId;
private List<Consumer<JsonObject>> selectionChangeListeners; private List<Consumer<JsonObject>> selectionChangeListeners;


/**
* Constructs a widget for the RadioButtonGroup component.
*/
public VRadioButtonGroup() { public VRadioButtonGroup() {
groupId = DOM.createUniqueId(); groupId = DOM.createUniqueId();
getWidget().setStyleName(CLASSNAME); getWidget().setStyleName(CLASSNAME);
selectionChangeListeners = new ArrayList<>(); selectionChangeListeners = new ArrayList<>();
} }


/*
* Build all the options
/**
* Build all the options.
*
* @param items
* the list of options
*/ */
public void buildOptions(List<JsonObject> items) { public void buildOptions(List<JsonObject> items) {
Roles.getRadiogroupRole().set(getElement()); Roles.getRadiogroupRole().set(getElement());
} }
} }


/**
* Sets the tabulator index for the container element that holds the radio
* buttons. It represents the entire radio button group within the browser's
* focus cycle.
*
* @param tabIndex
* tabulator index for the radio button group
*/
public void setTabIndex(int tabIndex) { public void setTabIndex(int tabIndex) {
for (Widget anOptionsContainer : getWidget()) { for (Widget anOptionsContainer : getWidget()) {
FocusWidget widget = (FocusWidget) anOptionsContainer; FocusWidget widget = (FocusWidget) anOptionsContainer;
} }
} }


/**
* Sets radio buttons enabled according to this widget's enabled and
* read-only status, as well as each option's own enabled status.
*/
protected void updateEnabledState() { protected void updateEnabledState() {
// sets options enabled according to the widget's enabled,
// readonly and each options own enabled
for (Map.Entry<RadioButton, JsonObject> entry : optionsToItems for (Map.Entry<RadioButton, JsonObject> entry : optionsToItems
.entrySet()) { .entrySet()) {
RadioButton radioButton = entry.getKey(); RadioButton radioButton = entry.getKey();
} }
} }


/**
* Returns whether HTML is allowed in the item captions.
*
* @return {@code true} if the captions are used as HTML, {@code false} if
* used as plain text
*/
public boolean isHtmlContentAllowed() { public boolean isHtmlContentAllowed() {
return htmlContentAllowed; return htmlContentAllowed;
} }


/**
* Sets whether HTML is allowed in the item captions. If set to
* {@code true}, the captions are displayed as HTML and the developer is
* responsible for ensuring no harmful HTML is used. If set to
* {@code false}, the content is displayed as plain text.
* <p>
* This value is delegated from the RadioButtonGroupState.
*
* @param htmlContentAllowed
* {@code true} if the captions are used as HTML, {@code false}
* if used as plain text
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) { public void setHtmlContentAllowed(boolean htmlContentAllowed) {
this.htmlContentAllowed = htmlContentAllowed; this.htmlContentAllowed = htmlContentAllowed;
} }
return enabled; return enabled;
} }


/**
* Returns whether this radio button group is read-only or not.
*
* @return {@code true} if this widget is read-only, {@code false} otherwise
*/
public boolean isReadonly() { public boolean isReadonly() {
return readonly; return readonly;
} }


/**
* Sets the read-only status of this radio button group.
*
* @param readonly
* {@code true} if this widget should be read-only, {@code false}
* otherwise
*/
public void setReadonly(boolean readonly) { public void setReadonly(boolean readonly) {
if (this.readonly != readonly) { if (this.readonly != readonly) {
this.readonly = readonly; this.readonly = readonly;
} }
} }


/**
* Adds the given selection change handler to this widget.
*
* @param selectionChanged
* the handler that should be triggered when selection changes
* @return the registration object for removing the given handler when no
* longer needed
*/
public Registration addSelectionChangeHandler( public Registration addSelectionChangeHandler(
Consumer<JsonObject> selectionChanged) { Consumer<JsonObject> selectionChanged) {
selectionChangeListeners.add(selectionChanged); selectionChangeListeners.add(selectionChanged);
.remove(selectionChanged); .remove(selectionChanged);
} }


/**
* Removes previous selection and adds new selection.
*
* @param selectedItemKey
* the key of the selected radio button
*/
public void selectItemKey(String selectedItemKey) { public void selectItemKey(String selectedItemKey) {
// At most one item could be selected so reset all radio buttons // At most one item could be selected so reset all radio buttons
// before applying current selection // before applying current selection

+ 121
- 10
client/src/main/java/com/vaadin/client/ui/VSlider.java View File

*/ */
private static final int MIN_SIZE = 50; private static final int MIN_SIZE = 50;


/**
* Current client-side communication engine.
*
* @deprecated this field is no longer used by the framework
*/
@Deprecated
protected ApplicationConnection client; protected ApplicationConnection client;


/**
* Current connector id.
*
* @deprecated this field is no longer used by the framework
*/
@Deprecated
protected String id; protected String id;


/** Is this widget disabled. */
protected boolean disabled; protected boolean disabled;
/** Is this widget read-only. */
protected boolean readonly; protected boolean readonly;


private int acceleration = 1; private int acceleration = 1;
/** Minimum value of slider. */
protected double min; protected double min;
/** Maximum value of slider. */
protected double max; protected double max;
/** Resolution (precision level) of slider. */
protected int resolution; protected int resolution;
/** Current value of slider. */
protected Double value; protected Double value;


private boolean updateValueOnClick; private boolean updateValueOnClick;
/** Current orientation (vertical/horizontal) of slider. */
protected SliderOrientation orientation = SliderOrientation.HORIZONTAL; protected SliderOrientation orientation = SliderOrientation.HORIZONTAL;


private final HTML feedback = new HTML("", false); private final HTML feedback = new HTML("", false);
@SuppressWarnings("deprecation")
private final VOverlay feedbackPopup = new VOverlay(true, false) { private final VOverlay feedbackPopup = new VOverlay(true, false) {
{ {
setOwner(VSlider.this); setOwner(VSlider.this);
} }
}; };


/* DOM element for slider's base */
/** DOM element for slider's base. */
private final Element base; private final Element base;
private static final int BASE_BORDER_WIDTH = 1; private static final int BASE_BORDER_WIDTH = 1;


/* DOM element for slider's handle */
/** DOM element for slider's handle. */
private final Element handle; private final Element handle;


/* DOM element for decrement arrow */
/** DOM element for decrement arrow. */
private final Element smaller; private final Element smaller;


/* DOM element for increment arrow */
/** DOM element for increment arrow. */
private final Element bigger; private final Element bigger;


/* Temporary dragging/animation variables */
/** Temporary dragging/animation variables. */
private boolean dragging = false; private boolean dragging = false;


private VLazyExecutor delayedValueUpdater = new VLazyExecutor(100, () -> { private VLazyExecutor delayedValueUpdater = new VLazyExecutor(100, () -> {
acceleration = 1; acceleration = 1;
}); });


/**
* Constructs a widget for the Slider component.
*/
public VSlider() { public VSlider() {
super(); super();


updateStyleNames(style, true); updateStyleNames(style, true);
} }


/**
* Updates the style names for this widget and the child elements.
*
* @param styleName
* the new style name
* @param isPrimaryStyleName
* {@code true} if the new style name is primary, {@code false}
* otherwise
*/
protected void updateStyleNames(String styleName, protected void updateStyleNames(String styleName,
boolean isPrimaryStyleName) { boolean isPrimaryStyleName) {


} }
} }


/**
* Updates the value shown in the feedback pop-up when the slider is moved.
* The value should match the current value of this widget.
*
* @param value
* the new value to show
*/
public void setFeedbackValue(double value) { public void setFeedbackValue(double value) {
feedback.setText(String.valueOf(value)); feedback.setText(String.valueOf(value));
} }


delayedValueUpdater.trigger(); delayedValueUpdater.trigger();


DOM.eventPreventDefault(event);
event.preventDefault();
DOM.eventCancelBubble(event, true); DOM.eventCancelBubble(event, true);
} }
} else if (targ.equals(getElement()) } else if (targ.equals(getElement())
} }


private void processMouseWheelEvent(final Event event) { private void processMouseWheelEvent(final Event event) {
final int dir = DOM.eventGetMouseWheelVelocityY(event);
final int dir = event.getMouseWheelVelocityY();


if (dir < 0) { if (dir < 0) {
increaseValue(false); increaseValue(false);


delayedValueUpdater.trigger(); delayedValueUpdater.trigger();


DOM.eventPreventDefault(event);
event.preventDefault();
DOM.eventCancelBubble(event, true); DOM.eventCancelBubble(event, true);
} }


handle.addClassName(getStylePrimaryName() + "-handle-active"); handle.addClassName(getStylePrimaryName() + "-handle-active");


DOM.setCapture(getElement()); DOM.setCapture(getElement());
DOM.eventPreventDefault(event); // prevent selecting text
event.preventDefault(); // prevent selecting text
DOM.eventCancelBubble(event, true); DOM.eventCancelBubble(event, true);
event.stopPropagation(); event.stopPropagation();
} }
* webkit (only browser that really supports touches). * webkit (only browser that really supports touches).
* *
* @param event * @param event
* @return
* the event whose position to check
* @return the client position
*/ */
protected int getEventPosition(Event event) { protected int getEventPosition(Event event) {
if (isVertical()) { if (isVertical()) {
} }
} }


/**
* Run internal layouting.
*/
public void iLayout() { public void iLayout() {
if (isVertical()) { if (isVertical()) {
setHeight(); setHeight();
return KeyCodes.KEY_RIGHT; return KeyCodes.KEY_RIGHT;
} }


/**
* Sets the current client-side communication engine.
*
* @param client
* the application connection that manages this component
* @deprecated the updated field is no longer used by the framework
*/
@Deprecated
public void setConnection(ApplicationConnection client) { public void setConnection(ApplicationConnection client) {
this.client = client; this.client = client;
} }


/**
* Sets the id of this component's connector.
*
* @param id
* the connector id
* @deprecated the updated field is no longer used by the framework
*/
@Deprecated
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }


/**
* Disables or enables this slider. Users cannot interact with a disabled
* widget, and the default styles show it as grayed out (via opacity). The
* slider is enabled by default.
*
* @param disabled
* a boolean value specifying whether the slider should be
* disabled or not
* @see #setReadOnly(boolean)
*/
public void setDisabled(boolean disabled) { public void setDisabled(boolean disabled) {
this.disabled = disabled; this.disabled = disabled;
} }


/**
* Sets the read-only status of this slider. Users cannot interact with a
* read-only widget, but the default styles don't show it grayed out unless
* it's also disabled. The slider is not read-only by default.
*
* @param readonly
* a boolean value specifying whether the slider should be in
* read-only mode or not
* @see #setDisabled(boolean)
*/
public void setReadOnly(boolean readonly) { public void setReadOnly(boolean readonly) {
this.readonly = readonly; this.readonly = readonly;
} }
return orientation == SliderOrientation.VERTICAL; return orientation == SliderOrientation.VERTICAL;
} }


/**
* Sets the slider orientation. Updates the style names if the given
* orientation differs from previously set orientation.
*
* @param orientation
* the orientation to use
*/
public void setOrientation(SliderOrientation orientation) { public void setOrientation(SliderOrientation orientation) {
if (this.orientation != orientation) { if (this.orientation != orientation) {
this.orientation = orientation; this.orientation = orientation;
} }
} }


/**
* Sets the minimum value for slider.
*
* @param value
* the minimum value to use
*/
public void setMinValue(double value) { public void setMinValue(double value) {
min = value; min = value;
} }


/**
* Sets the maximum value for slider.
*
* @param value
* the maximum value to use
*/
public void setMaxValue(double value) { public void setMaxValue(double value) {
max = value; max = value;
} }


/**
* Sets the resolution (precision level) for slider as the number of
* fractional digits that are considered significant. Determines how big
* change is used when increasing or decreasing the value, and where more
* precise values get rounded.
*
* @param resolution
* the number of digits after the decimal point
*/
public void setResolution(int resolution) { public void setResolution(int resolution) {
this.resolution = resolution; this.resolution = resolution;
} }
} }
} }


@SuppressWarnings("deprecation")
@Override @Override
public com.google.gwt.user.client.Element getSubPartElement( public com.google.gwt.user.client.Element getSubPartElement(
String subPart) { String subPart) {
return null; return null;
} }


@SuppressWarnings("deprecation")
@Override @Override
public String getSubPartName( public String getSubPartName(
com.google.gwt.user.client.Element subElement) { com.google.gwt.user.client.Element subElement) {
* Specifies whether or not click event should update the Slider's value. * Specifies whether or not click event should update the Slider's value.
* *
* @param updateValueOnClick * @param updateValueOnClick
* {@code true} if a click should update slider's value,
* {@code false} otherwise
*/ */
public void setUpdateValueOnClick(boolean updateValueOnClick) { public void setUpdateValueOnClick(boolean updateValueOnClick) {
this.updateValueOnClick = updateValueOnClick; this.updateValueOnClick = updateValueOnClick;

+ 6
- 0
client/src/main/java/com/vaadin/client/ui/slider/SliderConnector.java View File

private final ElementResizeListener resizeListener = event -> getWidget() private final ElementResizeListener resizeListener = event -> getWidget()
.iLayout(); .iLayout();


@SuppressWarnings("deprecation")
@Override @Override
public void init() { public void init() {
super.init(); super.init();
// The widget no longer uses the connection, but the value is still set
// to ensure backwards compatibility.
getWidget().setConnection(getConnection()); getWidget().setConnection(getConnection());
getWidget().addValueChangeHandler(this); getWidget().addValueChangeHandler(this);


rpc.valueChanged(event.getValue()); rpc.valueChanged(event.getValue());
} }


@SuppressWarnings("deprecation")
@Override @Override
public void onStateChanged(StateChangeEvent stateChangeEvent) { public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent); super.onStateChanged(stateChangeEvent);


// The widget no longer uses the connector id, but the value is still
// set to ensure backwards compatibility.
getWidget().setId(getConnectorId()); getWidget().setId(getConnectorId());
getWidget().setDisabled(!isEnabled()); getWidget().setDisabled(!isEnabled());
getWidget().setReadOnly(isReadOnly()); getWidget().setReadOnly(isReadOnly());

+ 1
- 0
shared/src/main/java/com/vaadin/shared/ui/optiongroup/RadioButtonGroupState.java View File

primaryStyleName = "v-select-optiongroup"; primaryStyleName = "v-select-optiongroup";
} }


/** Is HTML allowed in the item captions. */
@DelegateToWidget @DelegateToWidget
public boolean htmlContentAllowed = false; public boolean htmlContentAllowed = false;
} }

Loading…
Cancel
Save