se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.HelpText.java Source code

Java tutorial

Introduction

Here is the source code for se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.HelpText.java

Source

/* 
 * 
 * PROJECT
 *     Name
 *         APS User Admin Web
 *     
 *     Code Version
 *         0.10.0
 *     
 *     Description
 *         This is an administration web for aps-simple-user-service that allows editing of roles and users.
 *         
 * COPYRIGHTS
 *     Copyright (C) 2012 by Natusoft AB All rights reserved.
 *     
 * LICENSE
 *     Apache 2.0 (Open Source)
 *     
 *     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.
 *     
 * AUTHORS
 *     Tommy Svensson (tommy@natusoft.se)
 *         Changes:
 *         2012-09-02: Created!
 *         
 */
package se.natusoft.osgi.aps.apsuseradminweb.vaadin.components;

import com.vaadin.ui.Label;

/**
 * This provides a help text that becomes invisible when disabled.
 */
public class HelpText extends Label {
    //
    // Private Members
    //

    /** A cache of our captions so that we can remove and restore it. */
    private String helpText = null;

    //
    // Constructors
    //

    /**
     * Creates a new HelpText.
     *
     * @param helpText The actual help text.
     */
    public HelpText(String helpText) {
        super(helpText);
        this.helpText = helpText;
    }

    //
    // Methods
    //

    /**
     * Sets enabled or disabled state.
     *
     * @param enabled The state to set.
     */
    @Override
    public void setEnabled(boolean enabled) {
        setValue(enabled ? this.helpText : "");
        super.setEnabled(enabled);
    }
}