All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.v7.ui.AbstractLegacyComponent Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * Copyright (C) 2000-2024 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  for the full
 * license.
 */
package com.vaadin.v7.ui;

import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;

import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.v7.shared.AbstractLegacyComponentState;

/**
 * An abstract base class for compatibility components.
 * 

* Used since immediate and read-only properties has been removed in Vaadin 8 * from {@link AbstractComponent}. * * @author Vaadin Ltd * @since 8.0 * @deprecated only used for Vaadin 7 compatiblity components */ @Deprecated public class AbstractLegacyComponent extends AbstractComponent { private Boolean explicitImmediateValue; /** * Returns the explicitly set immediate value. * * @return the explicitly set immediate value or null if * {@link #setImmediate(boolean)} has not been explicitly invoked */ protected Boolean getExplicitImmediateValue() { return explicitImmediateValue; } /** * Returns the immediate mode of the component. *

* Since Vaadin 8, the default mode is immediate. * * @return true if the component is in immediate mode (explicitly or * implicitly set), false if the component if not in immediate mode */ public boolean isImmediate() { if (explicitImmediateValue != null) { return explicitImmediateValue; } else { return true; } } /** * Sets the component's immediate mode to the specified status. *

* Since Vaadin 8, the default mode is immediate. * * @param immediate * the boolean value specifying if the component should be in the * immediate mode after the call. */ public void setImmediate(boolean immediate) { explicitImmediateValue = immediate; getState().immediate = immediate; } /** * Tests whether the component is in the read-only mode. The user can not * change the value of a read-only component. As only {@code AbstractField} * or {@code LegacyField} components normally have a value that can be input * or changed by the user, this is mostly relevant only to field components, * though not restricted to them. * *

* Notice that the read-only mode only affects whether the user can change * the value of the component; it is possible to, for example, scroll * a read-only table. *

* *

* The method will return {@code true} if the component or any of its * parents is in the read-only mode. *

* * @return true if the component or any of its parents is in * read-only mode, false if not. * @see #setReadOnly(boolean) */ @Override public boolean isReadOnly() { return getState(false).readOnly; } /** * Sets the read-only mode of the component to the specified mode. The user * can not change the value of a read-only component. * *

* As only {@code AbstractField} or {@code LegacyField} components normally * have a value that can be input or changed by the user, this is mostly * relevant only to field components, though not restricted to them. *

* *

* Notice that the read-only mode only affects whether the user can change * the value of the component; it is possible to, for example, scroll * a read-only table. *

* *

* In Vaadin 8 the read-only property is part of {@code HasValue} API. *

* * @param readOnly * a boolean value specifying whether the component is put * read-only mode or not */ @Override public void setReadOnly(boolean readOnly) { getState().readOnly = readOnly; } @Override public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); Attributes attr = design.attributes(); // handle immediate if (attr.hasKey("immediate")) { setImmediate(DesignAttributeHandler.getFormatter() .parse(attr.get("immediate"), Boolean.class)); } } @Override public void writeDesign(Element design, DesignContext designContext) { super.writeDesign(design, designContext); AbstractLegacyComponent def = designContext.getDefaultInstance(this); Attributes attr = design.attributes(); // handle immediate if (explicitImmediateValue != null) { DesignAttributeHandler.writeAttribute("immediate", attr, explicitImmediateValue, def.isImmediate(), Boolean.class, designContext); } } @Override public void beforeClientResponse(boolean initial) { super.beforeClientResponse(initial); getState().immediate = isImmediate(); } @Override protected AbstractLegacyComponentState getState() { return (AbstractLegacyComponentState) super.getState(); } @Override protected AbstractLegacyComponentState getState(boolean markAsDirty) { return (AbstractLegacyComponentState) super.getState(markAsDirty); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy