001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C) Alkacon Software (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.acacia.client.widgets;
029
030import com.google.gwt.dom.client.Element;
031import com.google.gwt.event.dom.client.HasFocusHandlers;
032import com.google.gwt.event.logical.shared.ValueChangeHandler;
033import com.google.gwt.event.shared.HandlerRegistration;
034import com.google.gwt.user.client.ui.HasValue;
035import com.google.gwt.user.client.ui.IsWidget;
036
037/**
038 * The edit widget interface.<p>
039 */
040public interface I_CmsEditWidget extends HasValue<String>, HasFocusHandlers, IsWidget {
041
042    /**
043     * @see com.google.gwt.event.logical.shared.HasValueChangeHandlers#addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
044     */
045    HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler);
046
047    /**
048     * Returns if the widget is active.<p>
049     *
050     * @return <code>true</code> if the widget is active
051     */
052    boolean isActive();
053
054    /**
055     * This method is called when a widget is attached to the browser's document.<p>
056     * It needs to call the {@link com.google.gwt.user.client.ui.Widget#onAttach()} method.<p>
057     */
058    @SuppressWarnings("javadoc")
059    void onAttachWidget();
060
061    /**
062     * Returns true if the element should be logically counted as part of the widget for the purpose of determining whether a mouse click is "outside".
063     *
064     * For example, this is needed if the widget uses a popup.
065     *
066     * @param element the element to check
067     *
068     * @return true if the element counts as part of the widget
069     */
070    boolean owns(Element element);
071
072    /**
073     * Sets the widget active/inactive.<p>
074     *
075     * @param active <code>true</code> to activate the widget
076     */
077    void setActive(boolean active);
078
079    /**
080     * Sets the name of input fields.<p>
081     *
082     * @param name of the input field
083     */
084    void setName(String name);
085
086    /**
087     * @see com.google.gwt.user.client.ui.HasValue#setValue(java.lang.Object, boolean)
088     */
089    void setValue(String value, boolean fireEvent);
090
091    /**
092     * If this returns true, the default value will also be set as the widget value if the widget is inactive (i.e. for optional values which don't exist yet).
093     *
094     * @return true if the default value should be set even if the widget is inactive
095     */
096    default boolean shouldSetDefaultWhenDisabled() {
097
098        return false;
099    }
100}