PL-8250 Change typing bounds for WebAbstractComponent and WebAbstractField

This commit is contained in:
Daniil Tsarev 2016-11-24 14:51:54 +04:00
parent c6c38e7fa8
commit 392d586f91
25 changed files with 66 additions and 373 deletions

View File

@ -40,7 +40,7 @@ import static com.haulmont.cuba.gui.ComponentsHelper.findActionById;
/**
* Base class for action holders with shortcuts support
*/
public abstract class WebAbstractActionsHolderComponent<T extends com.vaadin.ui.Component & com.vaadin.event.Action.ShortcutNotifier>
public abstract class WebAbstractActionsHolderComponent<T extends com.vaadin.ui.AbstractComponent & com.vaadin.event.Action.ShortcutNotifier>
extends WebAbstractComponent<T> implements com.haulmont.cuba.gui.components.Component.SecuredActionsHolder {
protected final List<Action> actionList = new ArrayList<>();

View File

@ -36,9 +36,9 @@ import java.util.List;
/**
* @param <T>
*/
public abstract class WebAbstractComponent<T extends com.vaadin.ui.Component>
public abstract class WebAbstractComponent<T extends com.vaadin.ui.AbstractComponent>
implements
Component, Component.Wrapper, Component.HasXmlDescriptor, Component.BelongToFrame, Component.HasIcon {
Component, Component.Wrapper, Component.HasXmlDescriptor, Component.BelongToFrame, Component.HasIcon, Component.HasCaption {
public static final List<Sizeable.Unit> UNIT_SYMBOLS = Collections.unmodifiableList(Arrays.asList(
Sizeable.Unit.PIXELS, Sizeable.Unit.POINTS, Sizeable.Unit.PICAS,
@ -194,6 +194,26 @@ public abstract class WebAbstractComponent<T extends com.vaadin.ui.Component>
return icon;
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public void setIcon(String icon) {
this.icon = icon;

View File

@ -32,8 +32,6 @@ import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.ValueListener;
import com.haulmont.cuba.gui.data.impl.WeakItemChangeListener;
import com.haulmont.cuba.web.gui.data.ItemWrapper;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
@ -47,7 +45,7 @@ import static com.haulmont.cuba.gui.ComponentsHelper.handleFilteredAttributes;
/**
* @param <T>
*/
public abstract class WebAbstractField<T extends com.vaadin.ui.Field> extends WebAbstractComponent<T> implements Field {
public abstract class WebAbstractField<T extends com.vaadin.ui.AbstractField> extends WebAbstractComponent<T> implements Field {
protected Datasource<Entity> datasource;
protected MetaProperty metaProperty;
@ -183,37 +181,8 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.Field> extends We
@Override
public void setValue(Object value) {
if (component instanceof AbstractField) {
//noinspection unchecked
((AbstractField) component).setValueIgnoreReadOnly(value);
} else {
//noinspection unchecked
component.setValue(value);
}
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
if (component instanceof AbstractComponent) {
((AbstractComponent) component).setDescription(description);
} else {
throw new UnsupportedOperationException("Unable to set description for " + component.getClass().getName());
}
//noinspection unchecked
component.setValueIgnoreReadOnly(value);
}
@Override

View File

@ -25,7 +25,7 @@ import com.haulmont.cuba.gui.components.UploadField;
import java.util.Set;
public abstract class WebAbstractUploadComponent<T extends com.vaadin.ui.Component>
public abstract class WebAbstractUploadComponent<T extends com.vaadin.ui.AbstractComponent>
extends WebAbstractComponent<T>
implements UploadField {

View File

@ -26,7 +26,7 @@ import com.haulmont.cuba.gui.components.UploadField;
import java.util.Set;
public abstract class WebAbstractUploadField<T extends com.vaadin.ui.Field>
public abstract class WebAbstractUploadField<T extends com.vaadin.ui.AbstractField>
extends WebAbstractField<T>
implements UploadField {

View File

@ -52,26 +52,6 @@ public class WebButton extends WebAbstractComponent<CubaButton> implements Butto
protected void afterActionPerformed() {
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public Action getAction() {
return action;

View File

@ -32,7 +32,10 @@ import com.haulmont.cuba.web.gui.components.calendar.CalendarEventWrapper;
import com.haulmont.cuba.web.toolkit.ui.CubaCalendar;
import com.vaadin.ui.components.calendar.CalendarComponentEvents;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
public class WebCalendar extends WebAbstractComponent<CubaCalendar> implements Calendar {
private CollectionDatasource datasource;
@ -472,24 +475,4 @@ public class WebCalendar extends WebAbstractComponent<CubaCalendar> implements C
public CalendarEventProvider getEventProvider() {
return ((CalendarEventProviderWrapper) component.getEventProvider()).getCalendarEventProvider();
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -220,26 +220,6 @@ public class WebEmbedded extends WebAbstractComponent<com.vaadin.ui.Embedded> im
}
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
protected static class EmptyStreamSource implements StreamResource.StreamSource {
public static final String EMPTY_IMAGE_PATH = "/com/haulmont/cuba/web/gui/components/resources/empty.png";

View File

@ -22,8 +22,6 @@ import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.gui.TestIdManager;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.Field;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.DsContext;
@ -34,7 +32,7 @@ import com.haulmont.cuba.web.toolkit.ui.CubaCheckBox;
import com.haulmont.cuba.web.toolkit.ui.CubaFieldGroup;
import com.haulmont.cuba.web.toolkit.ui.CubaFieldGroupLayout;
import com.haulmont.cuba.web.toolkit.ui.CubaFieldWrapper;
import com.vaadin.ui.*;
import com.vaadin.ui.AbstractComponent;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
@ -542,7 +540,11 @@ public class WebFieldGroup extends WebAbstractComponent<CubaFieldGroupLayout> im
@Override
public String getCaption() {
return component.getCaption();
if (wrapperAttached) {
return wrapper.getCaption();
} else {
return component.getCaption();
}
}
@Override
@ -554,16 +556,6 @@ public class WebFieldGroup extends WebAbstractComponent<CubaFieldGroupLayout> im
}
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public boolean isEditable() {
return !component.isReadOnly();

View File

@ -33,9 +33,9 @@ import com.haulmont.cuba.web.WebConfig;
import com.haulmont.cuba.web.WebWindowManager;
import com.haulmont.cuba.web.toolkit.FileUploadTypesHelper;
import com.haulmont.cuba.web.toolkit.VersionedThemeResource;
import com.haulmont.cuba.web.toolkit.ui.CubaAbstractUploadComponent;
import com.haulmont.cuba.web.toolkit.ui.CubaFileUpload;
import com.haulmont.cuba.web.toolkit.ui.CubaMultiUpload;
import com.haulmont.cuba.web.toolkit.ui.UploadComponent;
import com.vaadin.server.Page;
import com.vaadin.server.WebBrowser;
import com.vaadin.ui.Component;
@ -49,7 +49,7 @@ import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
public class WebFileMultiUploadField extends WebAbstractUploadComponent<UploadComponent> implements FileMultiUploadField {
public class WebFileMultiUploadField extends WebAbstractUploadComponent<CubaAbstractUploadComponent> implements FileMultiUploadField {
private final Logger log = LoggerFactory.getLogger(WebFileMultiUploadField.class);
@ -281,26 +281,6 @@ public class WebFileMultiUploadField extends WebAbstractUploadComponent<UploadCo
return new CubaMultiUpload();
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Deprecated
public int getButtonWidth() {
return ((CubaMultiUpload) component).getButtonWidth();

View File

@ -230,24 +230,4 @@ public class WebGridLayout extends WebAbstractComponent<CubaGridLayout> implemen
public void setSpacing(boolean enabled) {
component.setSpacing(enabled);
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -381,24 +381,4 @@ public class WebGroupBox extends WebAbstractComponent<CubaGroupBox> implements G
public boolean isShowAsPanel() {
return component.isShowAsPanel();
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -145,24 +145,4 @@ public class WebHtmlBoxLayout extends WebAbstractComponent<CustomLayout> impleme
public Collection<Component> getComponents() {
return ComponentsHelper.getComponents(this);
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -278,16 +278,6 @@ public class WebLabel extends WebAbstractComponent<com.vaadin.ui.Label> implemen
// do nothing
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public void setIcon(String icon) {
super.setIcon(icon);

View File

@ -19,7 +19,6 @@ package com.haulmont.cuba.web.gui.components;
import com.haulmont.cuba.gui.components.Link;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.Resource;
import org.apache.commons.lang.StringUtils;
public class WebLink extends WebAbstractComponent<com.vaadin.ui.Link> implements Link {
@ -51,24 +50,4 @@ public class WebLink extends WebAbstractComponent<com.vaadin.ui.Link> implements
public String getTarget() {
return component.getTargetName();
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -81,26 +81,6 @@ public class WebPopupButton extends WebAbstractComponent<CubaPopupButton>
return false;
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public boolean isFocusable() {
return __isFocusable();

View File

@ -90,26 +90,6 @@ public class WebPopupView extends WebAbstractComponent<com.vaadin.ui.PopupView>
return minimizedValue;
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public void setCaptionAsHtml(boolean value) {
component.setCaptionAsHtml(value);

View File

@ -296,24 +296,4 @@ public class WebScrollBoxLayout extends WebAbstractComponent<CubaScrollBoxPanel>
public void setSpacing(boolean enabled) {
getContent().setSpacing(enabled);
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -353,24 +353,4 @@ public class WebSplitPanel extends WebAbstractComponent<AbstractSplitPanel> impl
return Sizeable.Unit.PIXELS;
}
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -479,26 +479,6 @@ public class WebTabSheet extends WebAbstractComponent<CubaTabSheet> implements T
}
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
protected class LazyTabChangeListener implements com.vaadin.ui.TabSheet.SelectedTabChangeListener {
protected BoxLayout tabContent;
protected Element descriptor;

View File

@ -60,24 +60,4 @@ public class WebLogoutButton extends WebAbstractComponent<CubaButton> implements
component.addStyleName(LOGOUT_BUTTON_STYLENAME);
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getDescription() {
return component.getDescription();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
}

View File

@ -58,24 +58,4 @@ public class WebNewWindowButton extends WebAbstractComponent<CubaButton> impleme
component.addStyleName(NEWWINDOW_BUTTON_STYLENAME);
}
@Override
public void setCaption(String caption) {
component.setCaption(caption);
}
@Override
public String getCaption() {
return component.getCaption();
}
@Override
public void setDescription(String description) {
component.setDescription(description);
}
@Override
public String getDescription() {
return component.getDescription();
}
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2008-2016 Haulmont.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.haulmont.cuba.web.toolkit.ui;
import com.vaadin.ui.AbstractComponent;
public abstract class CubaAbstractUploadComponent extends AbstractComponent implements UploadComponent {
}

View File

@ -23,7 +23,6 @@ import com.haulmont.cuba.web.toolkit.ui.client.fileupload.CubaFileUploadState;
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.*;
import com.vaadin.server.communication.FileUploadHandler;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.util.ReflectTools;
@ -45,8 +44,8 @@ import java.util.Set;
"vaadin://resources/jqueryfileupload/jquery.iframe-transport-9.12.1.min.js",
"vaadin://resources/jqueryfileupload/jquery.fileupload-9.12.1.min.js"
})
public class CubaFileUpload extends AbstractComponent
implements Component.Focusable, LegacyComponent, UploadComponent {
public class CubaFileUpload extends CubaAbstractUploadComponent
implements Component.Focusable, LegacyComponent {
/**
* The output of the upload is redirected to this receiver.

View File

@ -25,7 +25,6 @@ import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
import com.vaadin.server.ThemeResource;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.LegacyComponent;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
@ -40,8 +39,8 @@ import java.util.*;
*/
@JavaScript(value = "vaadin://resources/swfobject/swfobject-2.2.js")
@Deprecated
public class CubaMultiUpload extends AbstractComponent
implements LegacyComponent, UploadComponent {
public class CubaMultiUpload extends CubaAbstractUploadComponent
implements LegacyComponent {
private List<UploadListener> uploadListeners = new ArrayList<>();