Package com.jbstrap.ui
Class UI
java.lang.Object
com.jbstrap.core.messagebus.MessageBus
com.jbstrap.ui.UI
UI base class
Applications made with the JBStrap framework can have multiple UIs defined, that can be display pages. The UIs function similarly like the pages, but during navigation, if two pages have to be displayed on the same UI, then the UI instance and display does not change. Thus, the components placed on the UI (we recommend using navigation components) do not change either, if the navigation is done within the UI.
In the application, every UI has to extend from this class.
- Since:
- 4.0
- Author:
- JBStrap
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component<?> component) Adds the specified component to the UIaddComponents
(Component<?>... components) Adds the specified components to the UIfinal boolean
Shows the specified question message to the user.final UI
changeLiveFaviconText
(String text) Changes the currently displayed live favicon content.void
draw
(StringWriter writer) final void
Shows the specified error message to the userGets a page from the UI that is specified by the page ID.com.jbstrap.ui.Access
Gets the client, where the UI is currently displayed.Component<?>
Gets a component (specified by the ID) from the UI.Collection<Component<?>>
Gets a collection of every component that is on the UIfinal <T> List<T>
getComponentsByClass
(Class<T> clazz) Gets a list of every component, (specified by the class) from the UI.protected Integer
getComponentSeq
(String typeName) Gets the page that is currently displayed on the UIGets the object containing the data of the currently logged in userfinal String
getId()
Gets the UI's unique IDGets the UI language codegetRoot()
final String
Shows an input window to the userboolean
isAccess()
Removes every component from the UIremoveComponent
(Component<?> component) Removes the specified component from the UIremoveComponent
(Predicate<Component<?>> filter) Removes the component(s), that are specified by the predicate.removeComponents
(Component<?>... components) Removes the specified components from the UIrunJavaScript
(String script) Runs the specified JavaScript on the client, where the UI is currently displayed.void
Shows a message in a popup window.final UI
setLiveFavicon
(LiveFavicon liveFavicon) Sets theLiveFavicon
instance, that will be displayed on the UIvoid
showNotification
(NotificationType notificationType, String title) Displays the specified notification on the interface.void
showNotification
(NotificationType notificationType, String title, String message) Displays the specified notification on the interface.final UI
showProcessIndicator
(boolean show) Shows or hides the Process IndicatorMethods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
-
Field Details
-
root
-
-
Constructor Details
-
UI
Creates a UI- Parameters:
clientId
- The client ID, where the UI will be shown- Throws:
NullPointerException
- If the client is specified asnull
IllegalStateException
- If the component is set to be both Private and Public.
-
-
Method Details
-
getId
Gets the UI's unique ID- Returns:
- The UI's unique ID
-
getComponentById
Gets a component (specified by the ID) from the UI.- Parameters:
id
- The ID of the component- Returns:
- The component instance corresponding to the previously specified ID, or
null
, if not found.
-
getComponents
Gets a collection of every component that is on the UI- Returns:
- A collection of component instances, that are assigned to the UI. If there are none, it will return with an empty list
-
getComponentsByClass
Gets a list of every component, (specified by the class) from the UI.- Type Parameters:
T
- The component type- Parameters:
clazz
- The class of the component(s) that we want to get- Returns:
- A list of component insances of the specified class
- Throws:
NullPointerException
- If the class was specified asnull
-
draw
-
getCurrentPage
Gets the page that is currently displayed on the UI- Returns:
- The instance of the page, or
null
, if no page is currently displayed
-
findPage
Gets a page from the UI that is specified by the page ID.- Parameters:
pageId
- The page ID- Returns:
- The page instance corresponding to the specified ID,or
null
if no page by that ID is currently open on the UI - Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
runJavaScript
Runs the specified JavaScript on the client, where the UI is currently displayed.- Parameters:
script
- The JavaScript- Returns:
- The UI object
-
getClient
Gets the client, where the UI is currently displayed.- Returns:
- The client class, where the UI is currently displayed.
- See Also:
-
getCurrentUser
Gets the object containing the data of the currently logged in user- Returns:
- The object containing the data of the currently logged in user or
null
, if no logged in user is found - See Also:
-
removeComponent
Removes the specified component from the UI- Parameters:
component
- The component instance to be removed- Returns:
- The UI object
-
removeComponent
Removes the component(s), that are specified by the predicate.- Parameters:
filter
- The predicate, that will be used as a filter- Returns:
- The UI object
-
removeComponents
Removes the specified components from the UI- Parameters:
components
- The component instances to be removed- Returns:
- The UI object
-
removeAllComponents
Removes every component from the UI- Returns:
- The UI object
-
showNotification
Displays the specified notification on the interface.- Parameters:
notificationType
- The notification type. See theNotificationType
enum for applicable values.title
- The notification title (header text)
-
showNotification
Displays the specified notification on the interface.- Parameters:
notificationType
- The notification type. See theNotificationType
enum for applicable values.title
- The notification title (header text)message
- The notification message
-
setLiveFavicon
Sets theLiveFavicon
instance, that will be displayed on the UI- Parameters:
liveFavicon
- TheLiveFavicon
instance- Returns:
- The UI object
-
changeLiveFaviconText
Changes the currently displayed live favicon content. This method can only be used, if the UI already has aLiveFavicon
instance assigned.- Parameters:
text
- The favicon text content- Returns:
- The UI object
- Throws:
NullPointerException
- If the UI has noLiveFavicon
instance assigned.
-
error
Shows the specified error message to the user- Parameters:
title
- The error title (header text)message
- The error message
-
say
Shows a message in a popup window.- Parameters:
title
- The message title (header text)message
- The message text
-
ask
Shows the specified question message to the user.- Parameters:
title
- The message title (header text)text
- The message text- Returns:
- The user's answer. Returns
true
, if the user clicked the okButton, otherwisefalse
.
-
input
Shows an input window to the user- Parameters:
title
- The message title (header text)text
- The message text- Returns:
- The text that the user typed in. If the user didn't write anything, or closed the window,
by pressing the cancel button, it will return with
null
.
-
isAccess
public boolean isAccess()- Returns:
true
, if they have access, otherwisefalse
-
getAccess
public com.jbstrap.ui.Access getAccess()- Returns:
- The UI access class
-
showProcessIndicator
Shows or hides the Process Indicator- Parameters:
show
- Iftrue
, the indicator is shown, iffalse
, it is hidden- Returns:
- The UI object
-
addComponent
Adds the specified component to the UI- Parameters:
component
- The instance of the component to be added- Returns:
- The UI object
-
addComponents
Adds the specified components to the UI- Parameters:
components
- The instances of the components to be added- Returns:
- The UI object
-
getRoot
- Returns:
- The root layout
-
getLanguageCode
Gets the UI language code- Returns:
- The UI language code
-
getOpenedPages
- Returns:
- A list of every page that is currently open on the UI
-
getComponentSeq
- Parameters:
typeName
- Component type- Returns:
- Component type sequence number
-