From 7f537988d31b22ee40fb0ee4b55e5b29708259d4 Mon Sep 17 00:00:00 2001
From: Anna Koskinen
Date: Fri, 23 Jul 2021 15:41:25 +0300
Subject: Checkstyle fixes (#12347)
- Added, completed, and corrected JavaDocs.
- Added an assert to enforce a condition that has always been required.
- Added default sections to switch blocks.
- Added wildcards.
- Deprecated unused methods and variables.
- Removed inner assignments.
- Removed unused private variables and calls that do nothing.
- Updated deprecated calls to use currently recommended versions.
- Updated warning suppressions.
- ...and some auto-formatting.
---
.../client/ui/AbstractComponentConnector.java | 24 +++
.../com/vaadin/client/ui/AbstractConnector.java | 18 ++
.../vaadin/client/ui/AbstractFieldConnector.java | 6 +
.../client/ui/AbstractHasComponentsConnector.java | 5 +
.../vaadin/client/ui/AbstractLayoutConnector.java | 5 +
.../client/ui/JavaScriptComponentConnector.java | 5 +
.../com/vaadin/client/ui/MediaBaseConnector.java | 5 +
.../client/ui/UnknownComponentConnector.java | 22 ++
.../java/com/vaadin/client/ui/VCustomLayout.java | 44 +++-
.../main/java/com/vaadin/client/ui/VEmbedded.java | 20 +-
.../com/vaadin/client/ui/VUnknownComponent.java | 18 ++
.../main/java/com/vaadin/client/ui/VUpload.java | 28 ++-
.../main/java/com/vaadin/client/ui/VWindow.java | 156 +++++++++++---
.../ui/absolutelayout/AbsoluteLayoutConnector.java | 1 +
.../client/ui/accordion/AccordionConnector.java | 5 +
.../com/vaadin/client/ui/audio/AudioConnector.java | 5 +
.../ui/browserframe/BrowserFrameConnector.java | 5 +
.../vaadin/client/ui/button/ButtonConnector.java | 5 +
.../client/ui/checkbox/CheckBoxConnector.java | 2 +-
.../colorpicker/AbstractColorPickerConnector.java | 3 +-
.../ui/colorpicker/VColorPickerGradient.java | 22 +-
.../client/ui/colorpicker/VColorPickerGrid.java | 15 +-
.../client/ui/combobox/ComboBoxConnector.java | 5 +
.../client/ui/composite/CompositeConnector.java | 2 +-
.../client/ui/csslayout/CssLayoutConnector.java | 1 +
.../customcomponent/CustomComponentConnector.java | 5 +
.../ui/customfield/CustomFieldConnector.java | 5 +
.../ui/customlayout/CustomLayoutConnector.java | 6 +
.../ui/datefield/AbstractDateFieldConnector.java | 10 +
.../client/ui/datefield/DateFieldConnector.java | 2 +
.../ui/datefield/DateTimeFieldConnector.java | 1 +
.../ui/datefield/InlineDateTimeFieldConnector.java | 1 +
.../client/ui/datefield/TextualDateConnector.java | 9 +
.../client/ui/embedded/EmbeddedConnector.java | 7 +
.../client/ui/formlayout/FormLayoutConnector.java | 7 +
.../client/ui/gridlayout/GridLayoutConnector.java | 7 +
.../com/vaadin/client/ui/image/ImageConnector.java | 6 +
.../com/vaadin/client/ui/label/LabelConnector.java | 9 +
.../ui/layout/ComponentConnectorLayoutSlot.java | 41 ++++
.../client/ui/layout/ElementResizeEvent.java | 23 ++
.../client/ui/layout/ElementResizeListener.java | 14 +-
.../client/ui/layout/LayoutDependencyTree.java | 239 ++++++++++++++++++++-
.../java/com/vaadin/client/ui/layout/Margins.java | 77 +++++++
.../vaadin/client/ui/layout/MayScrollChildren.java | 6 +
.../com/vaadin/client/ui/layout/VLayoutSlot.java | 215 ++++++++++++++++++
.../com/vaadin/client/ui/link/LinkConnector.java | 5 +
.../client/ui/loginform/LoginFormConnector.java | 10 +-
.../java/com/vaadin/client/ui/menubar/MenuBar.java | 37 ++--
.../vaadin/client/ui/menubar/MenuBarConnector.java | 15 +-
.../ui/nativebutton/NativeButtonConnector.java | 5 +
.../AbstractOrderedLayoutConnector.java | 3 +
.../client/ui/orderedlayout/CaptionPosition.java | 9 +-
.../orderedlayout/HorizontalLayoutConnector.java | 4 +-
.../com/vaadin/client/ui/orderedlayout/Slot.java | 79 ++++++-
.../ui/orderedlayout/VAbstractOrderedLayout.java | 22 +-
.../ui/orderedlayout/VerticalLayoutConnector.java | 4 +-
.../com/vaadin/client/ui/panel/PanelConnector.java | 6 +
.../ui/passwordfield/PasswordFieldConnector.java | 5 +
.../client/ui/popupview/PopupViewConnector.java | 6 +
.../client/ui/popupview/VisibilityChangeEvent.java | 21 ++
.../ui/popupview/VisibilityChangeHandler.java | 11 +
.../ui/progressbar/ProgressBarConnector.java | 3 +
.../client/ui/richtextarea/VRichTextToolbar.java | 152 +++++++++----
.../vaadin/client/ui/slider/SliderConnector.java | 8 +
.../ui/splitpanel/AbstractSplitPanelConnector.java | 10 +-
.../splitpanel/HorizontalSplitPanelConnector.java | 5 +
.../ui/splitpanel/VerticalSplitPanelConnector.java | 5 +
.../client/ui/tabsheet/TabsheetBaseConnector.java | 6 +
.../client/ui/tabsheet/TabsheetConnector.java | 8 +
.../client/ui/textarea/TextAreaConnector.java | 5 +
.../ui/textfield/AbstractTextFieldConnector.java | 5 +
.../client/ui/textfield/TextFieldConnector.java | 4 +-
.../client/ui/treegrid/TreeGridConnector.java | 9 +-
.../java/com/vaadin/client/ui/ui/UIConnector.java | 30 ++-
.../vaadin/client/ui/upload/UploadConnector.java | 9 +
.../ui/upload/UploadIFrameOnloadStrategy.java | 13 ++
.../com/vaadin/client/ui/video/VideoConnector.java | 5 +
.../vaadin/client/ui/window/WindowConnector.java | 15 ++
.../vaadin/client/widget/treegrid/TreeGrid.java | 13 +-
.../widget/treegrid/events/TreeGridClickEvent.java | 1 +
.../treegrid/events/TreeGridDoubleClickEvent.java | 1 +
.../java/com/vaadin/client/widgets/Overlay.java | 111 +++++++++-
server/src/main/java/com/vaadin/ui/Grid.java | 22 ++
server/src/main/java/com/vaadin/ui/TreeGrid.java | 8 +-
.../gridlayout/GridLayoutCaptionAlignment.java | 1 +
85 files changed, 1667 insertions(+), 141 deletions(-)
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
index 3beac5c62e..425fce1a48 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
@@ -62,6 +62,11 @@ import com.vaadin.shared.ui.ComponentStateUtil;
import com.vaadin.shared.ui.TabIndexState;
import com.vaadin.shared.ui.ui.UIState;
+/**
+ * Base class for component connectors.
+ *
+ * @author Vaadin Ltd
+ */
public abstract class AbstractComponentConnector extends AbstractConnector
implements HasErrorIndicator {
@@ -90,6 +95,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector
private int touchStartY;
private boolean preventNextTouchEnd = false;
+ /** Default threshold for determining whether touch move is significant. */
protected int SIGNIFICANT_MOVE_THRESHOLD = 20; // pixels
// long touch event delay
@@ -269,6 +275,12 @@ public abstract class AbstractComponentConnector extends AbstractConnector
}, TouchEndEvent.getType());
}
+ /**
+ * Checks whether a long tap needs handling.
+ *
+ * @return {@code true} if long tap handling is needed, {@code false}
+ * otherwise
+ */
protected boolean shouldHandleLongTap() {
return BrowserInfo.get().isTouchDevice();
}
@@ -314,7 +326,9 @@ public abstract class AbstractComponentConnector extends AbstractConnector
*
* @since 7.6
* @param details
+ * the mouse event details
* @param eventTarget
+ * the target of the event
*/
protected void sendContextClickEvent(MouseEventDetails details,
EventTarget eventTarget) {
@@ -380,6 +394,14 @@ public abstract class AbstractComponentConnector extends AbstractConnector
return widget;
}
+ /**
+ * Checks whether the update is 'real' or contains cached information.
+ *
+ * @param uidl
+ * the UIDL to check
+ * @return {@code true} if doesn't have "cached" attribute, {@code false}
+ * otherwise
+ */
@Deprecated
public static boolean isRealUpdate(UIDL uidl) {
return !uidl.hasAttribute("cached");
@@ -717,6 +739,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector
* {@link com.vaadin.client.ui.datefield.TextualDateConnector#setWidgetStyleNameWithPrefix(String, String, boolean)}
*
*
+ * @param prefix
+ * the prefix for the style name
* @param styleName
* the style name to be added or removed
* @param add
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java
index 0683f864a9..9531de5ac7 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractConnector.java
@@ -186,6 +186,8 @@ public abstract class AbstractConnector
/**
* Unregisters an implementation for a server to client RPC interface.
*
+ * @param
+ * The type of the RPC interface that is being unregistered
* @param rpcInterface
* RPC interface
* @param implementation
@@ -211,6 +213,7 @@ public abstract class AbstractConnector
* @return A proxy object which can be used to invoke the RPC method on the
* server.
*/
+ @SuppressWarnings("unchecked")
protected T getRpcProxy(Class rpcInterface) {
String name = rpcInterface.getName();
if (!rpcProxyMap.containsKey(name)) {
@@ -219,6 +222,7 @@ public abstract class AbstractConnector
return (T) rpcProxyMap.get(name);
}
+ @SuppressWarnings("unchecked")
@Override
public Collection getRpcImplementations(
String rpcInterfaceId) {
@@ -260,6 +264,12 @@ public abstract class AbstractConnector
}
+ /**
+ * Ensure there is a handler manager. If one doesn't exist before this
+ * method is called, it gets created.
+ *
+ * @return the handler manager
+ */
protected HandlerManager ensureHandlerManager() {
if (handlerManager == null) {
handlerManager = new HandlerManager(this);
@@ -402,6 +412,13 @@ public abstract class AbstractConnector
}
+ /**
+ * Find the type of the state for the given connector.
+ *
+ * @param connector
+ * the connector whose state type to find
+ * @return the state type
+ */
public static Type getStateType(ServerConnector connector) {
try {
return TypeData.getType(connector.getClass()).getMethod("getState")
@@ -506,6 +523,7 @@ public abstract class AbstractConnector
}
private static class FullStateChangeEvent extends StateChangeEvent {
+ @SuppressWarnings("deprecation")
public FullStateChangeEvent(ServerConnector connector) {
super(connector, FastStringSet.create());
}
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
index 32bf5588d8..a76333e408 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
@@ -18,6 +18,11 @@ package com.vaadin.client.ui;
import com.vaadin.client.StyleConstants;
import com.vaadin.shared.AbstractFieldState;
+/**
+ * Base class for field connectors.
+ *
+ * @author Vaadin Ltd
+ */
public abstract class AbstractFieldConnector extends AbstractComponentConnector
implements HasRequiredIndicator {
@@ -31,6 +36,7 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector
return getState().required && !isReadOnly();
}
+ @SuppressWarnings("deprecation")
@Override
protected void updateWidgetStyleNames() {
super.updateWidgetStyleNames();
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractHasComponentsConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractHasComponentsConnector.java
index 094fba58db..57a1da689b 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractHasComponentsConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractHasComponentsConnector.java
@@ -24,6 +24,11 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler;
import com.vaadin.client.HasComponentsConnector;
+/**
+ * Base class for component connectors whose widget is a component container.
+ *
+ * @author Vaadin Ltd
+ */
public abstract class AbstractHasComponentsConnector
extends AbstractComponentConnector
implements HasComponentsConnector, ConnectorHierarchyChangeHandler {
diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractLayoutConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractLayoutConnector.java
index f716318d24..8ebd4de3d9 100644
--- a/client/src/main/java/com/vaadin/client/ui/AbstractLayoutConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/AbstractLayoutConnector.java
@@ -17,6 +17,11 @@ package com.vaadin.client.ui;
import com.vaadin.shared.ui.AbstractLayoutState;
+/**
+ * Base class for layout connectors.
+ *
+ * @author Vaadin Ltd
+ */
public abstract class AbstractLayoutConnector
extends AbstractComponentContainerConnector {
diff --git a/client/src/main/java/com/vaadin/client/ui/JavaScriptComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/JavaScriptComponentConnector.java
index 19b0f25c41..13f8b53062 100644
--- a/client/src/main/java/com/vaadin/client/ui/JavaScriptComponentConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/JavaScriptComponentConnector.java
@@ -24,6 +24,11 @@ import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.JavaScriptComponentState;
import com.vaadin.ui.AbstractJavaScriptComponent;
+/**
+ * A connector class for JavaScript components.
+ *
+ * @author Vaadin Ltd
+ */
@Connect(AbstractJavaScriptComponent.class)
public final class JavaScriptComponentConnector extends
AbstractComponentConnector implements HasJavaScriptConnectorHelper {
diff --git a/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java b/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java
index b9474bda9d..1b53b728f4 100644
--- a/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/MediaBaseConnector.java
@@ -22,6 +22,11 @@ import com.vaadin.shared.ui.AbstractMediaState;
import com.vaadin.shared.ui.MediaControl;
import com.vaadin.shared.ui.PreloadMode;
+/**
+ * Base class for media component connectors.
+ *
+ * @author Vaadin Ltd
+ */
public abstract class MediaBaseConnector extends AbstractComponentConnector {
@Override
diff --git a/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java
index 9b1e4b8111..27f6d36054 100644
--- a/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/UnknownComponentConnector.java
@@ -18,6 +18,12 @@ package com.vaadin.client.ui;
import com.google.gwt.core.client.GWT;
+/**
+ * A placeholder connector class for when a component's connector cannot be
+ * determined.
+ *
+ * @author Vaadin Ltd
+ */
public class UnknownComponentConnector extends AbstractComponentConnector {
@Override
@@ -30,10 +36,26 @@ public class UnknownComponentConnector extends AbstractComponentConnector {
return (VUnknownComponent) super.getWidget();
}
+ /**
+ * Updates the placeholder widget's caption to mention the component whose
+ * connector cannot be determined.
+ *
+ * @param serverClassName
+ * the class name of the component
+ */
public void setServerSideClassName(String serverClassName) {
getWidget().setCaption(createMessage(serverClassName));
}
+ /**
+ * Creates a message that warns about the issue with the named component and
+ * gives debugging hints.
+ *
+ * @param serverClassName
+ * the class name of the component whose connector cannot be
+ * determined.
+ * @return the warning message
+ */
public static String createMessage(String serverClassName) {
return "Widgetset '" + GWT.getModuleName()
+ "' does not contain an implementation for " + serverClassName
diff --git a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
index 5022049e48..7f6acbfcd3 100644
--- a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
+++ b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
@@ -48,6 +48,7 @@ import com.vaadin.client.WidgetUtil;
*/
public class VCustomLayout extends ComplexPanel {
+ /** The default classname for this widget. */
public static final String CLASSNAME = "v-customlayout";
/** Location-name to containing element in DOM map */
@@ -84,6 +85,10 @@ public class VCustomLayout extends ComplexPanel {
private String width = "";
+ /**
+ * Constructs a widget for a custom layout.
+ */
+ @SuppressWarnings("deprecation")
public VCustomLayout() {
setElement(DOM.createDiv());
// Clear any unwanted styling
@@ -152,7 +157,14 @@ public class VCustomLayout extends ComplexPanel {
locationToWidget.put(location, widget);
}
- /** Initialize HTML-layout. */
+ /**
+ * Initialize HTML-layout.
+ *
+ * @param template
+ * original HTML-template
+ * @param themeUri
+ * URI to the current theme
+ */
public void initializeHTML(String template, String themeUri) {
// Connect body of the template to DOM
@@ -202,7 +214,11 @@ public class VCustomLayout extends ComplexPanel {
return 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.
+ *
+ * @return {@code true} if has template contents, {@code false} otherwise
+ */
public boolean hasTemplate() {
return htmlInitialized;
}
@@ -229,6 +245,9 @@ public class VCustomLayout extends ComplexPanel {
* Evaluate given script in browser document.
*
* For internal use only. May be removed or replaced in the future.
+ *
+ * @param script
+ * the script to evaluate
*/
public static native void eval(String script)
/*-{
@@ -280,7 +299,8 @@ public class VCustomLayout extends ComplexPanel {
scriptStart = lc.indexOf(">", scriptStart);
final int j = lc.indexOf("", scriptStart);
scripts += html.substring(scriptStart + 1, j) + ";";
- nextPosToCheck = endOfPrevScript = j + "".length();
+ endOfPrevScript = j + "".length();
+ nextPosToCheck = endOfPrevScript;
scriptStart = lc.indexOf("