View Javadoc
1   /*
2    * Copyright (c) 2011-2024 PrimeFaces Extensions
3    *
4    *  Permission is hereby granted, free of charge, to any person obtaining a copy
5    *  of this software and associated documentation files (the "Software"), to deal
6    *  in the Software without restriction, including without limitation the rights
7    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    *  copies of the Software, and to permit persons to whom the Software is
9    *  furnished to do so, subject to the following conditions:
10   *
11   *  The above copyright notice and this permission notice shall be included in
12   *  all copies or substantial portions of the Software.
13   *
14   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   *  THE SOFTWARE.
21   */
22  package org.primefaces.extensions.component.blockui;
23  
24  import javax.faces.application.ResourceDependency;
25  import javax.faces.component.UIComponentBase;
26  
27  import org.primefaces.component.api.Widget;
28  
29  /**
30   * <code>BlockUI</code> component.
31   *
32   * @author Oleg Varaksin / last modified by $Author$
33   * @version $Revision$
34   * @since 0.2
35   */
36  @ResourceDependency(library = "primefaces", name = "components.css")
37  @ResourceDependency(library = "primefaces", name = "jquery/jquery.js")
38  @ResourceDependency(library = "primefaces", name = "jquery/jquery-plugins.js")
39  @ResourceDependency(library = "primefaces", name = "core.js")
40  @ResourceDependency(library = "primefaces-extensions", name = "primefaces-extensions.js")
41  @ResourceDependency(library = "primefaces-extensions", name = "blockui/blockui.css")
42  @ResourceDependency(library = "primefaces-extensions", name = "blockui/blockui.js")
43  public class BlockUI extends UIComponentBase implements Widget {
44  
45      public static final String COMPONENT_TYPE = "org.primefaces.extensions.component.BlockUI";
46      public static final String COMPONENT_FAMILY = "org.primefaces.extensions.component";
47      private static final String DEFAULT_RENDERER = "org.primefaces.extensions.component.BlockUIRenderer";
48  
49      /**
50       * Properties that are tracked by state saving.
51       *
52       * @author Oleg Varaksin / last modified by $Author$
53       * @version $Revision$
54       */
55      // @formatter:off
56      @SuppressWarnings("java:S115")
57      protected enum PropertyKeys {
58          widgetVar,
59          css,
60          cssOverlay,
61          source,
62          target,
63          content,
64          event,
65          autoShow,
66          timeout,
67          centerX,
68          centerY,
69          fadeIn,
70          fadeOut,
71          showOverlay,
72          focusInput
73  
74      }
75      // @formatter:on
76  
77      public BlockUI() {
78          setRendererType(DEFAULT_RENDERER);
79      }
80  
81      @Override
82      public String getFamily() {
83          return COMPONENT_FAMILY;
84      }
85  
86      public String getWidgetVar() {
87          return (String) getStateHelper().eval(PropertyKeys.widgetVar, null);
88      }
89  
90      public void setWidgetVar(final String widgetVar) {
91          getStateHelper().put(PropertyKeys.widgetVar, widgetVar);
92      }
93  
94      public void setCss(final String css) {
95          getStateHelper().put(PropertyKeys.css, css);
96      }
97  
98      public String getCss() {
99          return (String) getStateHelper().eval(PropertyKeys.css, null);
100     }
101 
102     public void setCssOverlay(final String cssOverlay) {
103         getStateHelper().put(PropertyKeys.cssOverlay, cssOverlay);
104     }
105 
106     public String getCssOverlay() {
107         return (String) getStateHelper().eval(PropertyKeys.cssOverlay, null);
108     }
109 
110     public String getSource() {
111         return (String) getStateHelper().eval(PropertyKeys.source, null);
112     }
113 
114     public void setSource(final String source) {
115         getStateHelper().put(PropertyKeys.source, source);
116     }
117 
118     public String getTarget() {
119         return (String) getStateHelper().eval(PropertyKeys.target, null);
120     }
121 
122     public void setTarget(final String target) {
123         getStateHelper().put(PropertyKeys.target, target);
124     }
125 
126     public String getContent() {
127         return (String) getStateHelper().eval(PropertyKeys.content, null);
128     }
129 
130     public void setContent(final String content) {
131         getStateHelper().put(PropertyKeys.content, content);
132     }
133 
134     public String getEvent() {
135         return (String) getStateHelper().eval(PropertyKeys.event, null);
136     }
137 
138     public void setEvent(final String event) {
139         getStateHelper().put(PropertyKeys.event, event);
140     }
141 
142     public boolean isAutoShow() {
143         return (Boolean) getStateHelper().eval(PropertyKeys.autoShow, false);
144     }
145 
146     public void setAutoShow(final boolean autoShow) {
147         getStateHelper().put(PropertyKeys.autoShow, autoShow);
148     }
149 
150     public int getTimeout() {
151         return (Integer) getStateHelper().eval(PropertyKeys.timeout, 0);
152     }
153 
154     public void setTimeout(final int timeout) {
155         getStateHelper().put(PropertyKeys.timeout, timeout);
156     }
157 
158     public boolean isCenterX() {
159         return (Boolean) getStateHelper().eval(PropertyKeys.centerX, true);
160     }
161 
162     public void setCenterX(final boolean centerX) {
163         getStateHelper().put(PropertyKeys.centerX, centerX);
164     }
165 
166     public boolean isCenterY() {
167         return (Boolean) getStateHelper().eval(PropertyKeys.centerY, true);
168     }
169 
170     public void setCenterY(final boolean centerY) {
171         getStateHelper().put(PropertyKeys.centerY, centerY);
172     }
173 
174     public int getFadeIn() {
175         return (Integer) getStateHelper().eval(PropertyKeys.fadeIn, 200);
176     }
177 
178     public void setFadeIn(final int fadeIn) {
179         getStateHelper().put(PropertyKeys.fadeIn, fadeIn);
180     }
181 
182     public int getFadeOut() {
183         return (Integer) getStateHelper().eval(PropertyKeys.fadeOut, 400);
184     }
185 
186     public void setFadeOut(final int fadeOut) {
187         getStateHelper().put(PropertyKeys.fadeOut, fadeOut);
188     }
189 
190     public void setShowOverlay(final boolean showOverlay) {
191         getStateHelper().put(PropertyKeys.showOverlay, showOverlay);
192     }
193 
194     public boolean isShowOverlay() {
195         return (Boolean) getStateHelper().eval(PropertyKeys.showOverlay, true);
196     }
197 
198     public void setFocusInput(final boolean focusInput) {
199         getStateHelper().put(PropertyKeys.focusInput, focusInput);
200     }
201 
202     public boolean isFocusInput() {
203         return (Boolean) getStateHelper().eval(PropertyKeys.focusInput, true);
204     }
205 
206 }