summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/shared/ui/button/ButtonState.java
blob: c423e18d46a1412c21e009b92e1f78456a045e29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
@VaadinApache2LicenseForJavaFiles@
 */

package com.vaadin.shared.ui.button;

import com.vaadin.shared.ComponentState;
import com.vaadin.shared.ui.TabIndexState;
import com.vaadin.ui.Button;

/**
 * Shared state for Button and NativeButton.
 * 
 * @see ComponentState
 * 
 * @since 7.0
 */
public class ButtonState extends ComponentState implements TabIndexState {
    private boolean disableOnClick = false;
    private int clickShortcutKeyCode = 0;
    /**
     * The tab order number of this field.
     */
    private int tabIndex = 0;
    /**
     * If caption should be rendered in HTML
     */
    private boolean htmlContentAllowed = false;

    /**
     * Checks whether the button should be disabled on the client side on next
     * click.
     * 
     * @return true if the button should be disabled on click
     */
    public boolean isDisableOnClick() {
        return disableOnClick;
    }

    /**
     * Sets whether the button should be disabled on the client side on next
     * click.
     * 
     * @param disableOnClick
     *            true if the button should be disabled on click
     */
    public void setDisableOnClick(boolean disableOnClick) {
        this.disableOnClick = disableOnClick;
    }

    /**
     * Returns the key code for activating the button via a keyboard shortcut.
     * 
     * See {@link Button#setClickShortcut(int, int...)} for more information.
     * 
     * @return key code or 0 for none
     */
    public int getClickShortcutKeyCode() {
        return clickShortcutKeyCode;
    }

    /**
     * Sets the key code for activating the button via a keyboard shortcut.
     * 
     * See {@link Button#setClickShortcut(int, int...)} for more information.
     * 
     * @param clickShortcutKeyCode
     *            key code or 0 for none
     */
    public void setClickShortcutKeyCode(int clickShortcutKeyCode) {
        this.clickShortcutKeyCode = clickShortcutKeyCode;
    }

    /**
     * Set whether the caption text is rendered as HTML or not. You might need
     * to retheme button to allow higher content than the original text style.
     * 
     * If set to true, the captions are passed to the browser as html and the
     * developer is responsible for ensuring no harmful html is used. If set to
     * false, the content is passed to the browser as plain text.
     * 
     * @param htmlContentAllowed
     *            <code>true</code> if caption is rendered as HTML,
     *            <code>false</code> otherwise
     */
    public void setHtmlContentAllowed(boolean htmlContentAllowed) {
        this.htmlContentAllowed = htmlContentAllowed;
    }

    /**
     * Return HTML rendering setting.
     * 
     * @return <code>true</code> if the caption text is to be rendered as HTML,
     *         <code>false</code> otherwise
     */
    public boolean isHtmlContentAllowed() {
        return htmlContentAllowed;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#getTabIndex()
     */
    @Override
    public int getTabIndex() {
        return tabIndex;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int)
     */
    @Override
    public void setTabIndex(int tabIndex) {
        this.tabIndex = tabIndex;
    }

}