Package de.hybris.platform.cockpit.util
Class UITools
- java.lang.Object
-
- de.hybris.platform.cockpit.util.UITools
-
public final class UITools extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ON_DRAG_HOVER_CLICKED
static java.lang.String
TEST_ID_BUILDER_REGISTRY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addBusyListener(org.zkoss.zk.ui.Component component, java.lang.String evtnm, org.zkoss.zk.ui.event.EventListener listener, java.lang.String data, java.lang.String i3BusyMessage)
Adds a event listener to a component.static void
addDragHoverClickEventListener(org.zkoss.zul.impl.XulElement component, org.zkoss.zk.ui.event.EventListener eventListener, int timeout, java.lang.String dragID)
Add "drag hover click" feature to a component, i.e.static void
addMacCommandClickListener(org.zkoss.zul.impl.XulElement component)
static void
applyLazyload(org.zkoss.zk.ui.HtmlBasedComponent component)
Converts a component with appended children into a lazyload component, i.e.static void
applyTestID(org.zkoss.zk.ui.Component component, TestIdContext ctx)
Applies a test id to aComponent
according to the specifiedTestIdContext
if test id mechanism is enabled.static void
applyTestID(org.zkoss.zk.ui.Component component, java.lang.String id)
static void
cleanupFCKEditorIframeGhosts()
static void
clearBrowserTextSelection()
static org.zkoss.zul.Grid
createGridSkeleton(int columnsnumber)
static void
detachChildren(org.zkoss.zk.ui.Component parent)
static boolean
different(java.lang.Object object1, java.lang.Object object2)
static void
forceRenderCombobox(org.zkoss.zul.Combobox comboBox, org.zkoss.zul.ComboitemRenderer renderer, java.util.Collection<? extends java.lang.Object> model)
Combobox
es usually aren't rendered until ZK's event processing phase.static java.lang.String
getAdjustedUrl(java.lang.String url)
static java.lang.String
getCockpitParameter(java.lang.String key, org.zkoss.zk.ui.Desktop desktop)
Returns a config parameter for the current cockpit.static java.lang.String
getCockpitParameter(java.lang.String key, org.zkoss.zk.ui.Execution execution)
Returns a config parameter for the current cockpit.static org.zkoss.zk.ui.Component
getCurrentZKRoot()
static java.lang.String
getLocalDate(java.util.Date date)
static java.lang.String
getLocalDateTime(java.util.Date date)
static <T extends org.zkoss.zk.ui.Component>
TgetNextParentOfType(java.lang.Class clazz, org.zkoss.zk.ui.Component child, int maxDepth)
static java.lang.String
getWebAppName(org.zkoss.zk.ui.Desktop desktop)
static java.lang.String
getWebAppName(org.zkoss.zk.ui.Execution execution)
static java.lang.String
getZKPreference(java.lang.String key)
Get a preference value set in zk.xml.static void
invalidateAllPortallayouts()
static void
invalidateGroupbox(org.zkoss.zk.ui.Component child)
static void
invalidateNextLayoutregion(org.zkoss.zk.ui.Component comp)
static boolean
isFromOtherDesktop(org.zkoss.zk.ui.Component comp)
static boolean
isParent(org.zkoss.zk.ui.Component parent, org.zkoss.zk.ui.Component child)
static boolean
isUrlAbsolute(java.lang.String url)
static void
maximize(org.zkoss.zk.ui.HtmlBasedComponent component)
static void
modifySClass(org.zkoss.zhtml.impl.AbstractTag component, java.lang.String className, boolean add)
static void
modifySClass(org.zkoss.zk.ui.HtmlBasedComponent component, java.lang.String className, boolean add)
Adds or removes a style class to the components style classes.static void
modifyStyle(org.zkoss.zhtml.impl.AbstractTag component, java.lang.String key, java.lang.String value)
static void
modifyStyle(org.zkoss.zk.ui.HtmlBasedComponent component, java.lang.String key, java.lang.String value)
static void
performDoubleClickDelay(org.zkoss.zk.ui.WebApp webApp)
static void
removeEventListenersForComponent(java.lang.String eventType, org.zkoss.zk.ui.Component component)
static java.lang.String
removeHtml(java.lang.String html)
static void
resizeBorderLayout(org.zkoss.zk.ui.Component comp, boolean allParents)
static void
scrollIntoViewIfNeeded(org.zkoss.zk.ui.Component component, org.zkoss.zk.ui.Component scrollContainer)
Same asscrollIntoViewIfNeeded(Component, Component, int)
with '0' as last argument.static void
scrollIntoViewIfNeeded(org.zkoss.zk.ui.Component component, org.zkoss.zk.ui.Component scrollContainer, int childDepth)
Checks if the component is outside the scrollcontainers parent (i.e.static java.util.List<java.lang.String>
searchForLabel(java.lang.Object obj, java.lang.reflect.Method method, java.util.Collection<LanguageModel> firstPrioLanguages)
static boolean
searchRestrictionsDisabledInCockpit()
static void
setComponentWidths(java.lang.String[] widths, org.zkoss.zk.ui.HtmlBasedComponent... comps)
static boolean
setManagedEventListener(org.zkoss.zk.ui.Component component, java.lang.String evtnm, org.zkoss.zk.ui.event.EventListener listener)
Adds and replaces anEventListener
at aComponent
.static boolean
setTooltipText(org.zkoss.zk.ui.Component component, java.lang.String text)
static void
showNoPermissionMessage()
static java.util.Collection<java.lang.Object>
toColl(java.lang.Object object)
static void
updateMediaModel(MediaModel currentMediaModel, org.zkoss.util.media.Media mediaContent, MediaService mediaService)
-
-
-
Field Detail
-
TEST_ID_BUILDER_REGISTRY
public static final java.lang.String TEST_ID_BUILDER_REGISTRY
- See Also:
- Constant Field Values
-
ON_DRAG_HOVER_CLICKED
public static final java.lang.String ON_DRAG_HOVER_CLICKED
- See Also:
- Constant Field Values
-
-
Method Detail
-
setTooltipText
public static boolean setTooltipText(org.zkoss.zk.ui.Component component, java.lang.String text)
-
applyLazyload
public static void applyLazyload(org.zkoss.zk.ui.HtmlBasedComponent component)
Converts a component with appended children into a lazyload component, i.e. the children will be added successively later.- Parameters:
component
- the component
-
getCurrentZKRoot
public static org.zkoss.zk.ui.Component getCurrentZKRoot()
-
addDragHoverClickEventListener
public static void addDragHoverClickEventListener(org.zkoss.zul.impl.XulElement component, org.zkoss.zk.ui.event.EventListener eventListener, int timeout, java.lang.String dragID)
Add "drag hover click" feature to a component, i.e. the component will receive an event with nameON_DRAG_HOVER_CLICKED
if the mouse cursor stays over component for a specified time while dragging a component with the specified dragID.- Parameters:
component
- the componenteventListener
- you can specify anEventListener
which reacts on theON_DRAG_HOVER_CLICKED
event or leave it null, if you want to add it later.timeout
- the time the cursor has to stay over component, in millisecondsdragID
- the drag id of the component, which triggers the event
-
getZKPreference
public static java.lang.String getZKPreference(java.lang.String key)
Get a preference value set in zk.xml. Can be overwritten by entries in project.properties/local.properties.- Parameters:
key
- the preference key- Returns:
- the preference value
-
cleanupFCKEditorIframeGhosts
public static void cleanupFCKEditorIframeGhosts()
-
clearBrowserTextSelection
public static void clearBrowserTextSelection()
-
applyTestID
public static void applyTestID(org.zkoss.zk.ui.Component component, java.lang.String id)
-
applyTestID
public static void applyTestID(org.zkoss.zk.ui.Component component, TestIdContext ctx)
Applies a test id to aComponent
according to the specifiedTestIdContext
if test id mechanism is enabled.- Parameters:
component
- The ZK component on which the id should be applied.ctx
- A context which usually specifies the environment of the component
-
resizeBorderLayout
public static void resizeBorderLayout(org.zkoss.zk.ui.Component comp, boolean allParents)
-
invalidateNextLayoutregion
public static void invalidateNextLayoutregion(org.zkoss.zk.ui.Component comp)
-
maximize
public static void maximize(org.zkoss.zk.ui.HtmlBasedComponent component)
-
detachChildren
public static void detachChildren(org.zkoss.zk.ui.Component parent)
-
getNextParentOfType
public static <T extends org.zkoss.zk.ui.Component> T getNextParentOfType(java.lang.Class clazz, org.zkoss.zk.ui.Component child, int maxDepth)
-
invalidateGroupbox
public static void invalidateGroupbox(org.zkoss.zk.ui.Component child)
-
different
public static boolean different(java.lang.Object object1, java.lang.Object object2)
-
createGridSkeleton
public static org.zkoss.zul.Grid createGridSkeleton(int columnsnumber)
-
modifySClass
public static void modifySClass(org.zkoss.zk.ui.HtmlBasedComponent component, java.lang.String className, boolean add)
Adds or removes a style class to the components style classes.- Parameters:
component
- the component to change style classesclassName
- the class nameadd
- adding or removing the class
-
modifySClass
public static void modifySClass(org.zkoss.zhtml.impl.AbstractTag component, java.lang.String className, boolean add)
-
modifyStyle
public static void modifyStyle(org.zkoss.zk.ui.HtmlBasedComponent component, java.lang.String key, java.lang.String value)
-
modifyStyle
public static void modifyStyle(org.zkoss.zhtml.impl.AbstractTag component, java.lang.String key, java.lang.String value)
-
isFromOtherDesktop
public static boolean isFromOtherDesktop(org.zkoss.zk.ui.Component comp)
-
toColl
public static java.util.Collection<java.lang.Object> toColl(java.lang.Object object)
-
isParent
public static boolean isParent(org.zkoss.zk.ui.Component parent, org.zkoss.zk.ui.Component child)
-
getAdjustedUrl
public static java.lang.String getAdjustedUrl(java.lang.String url)
-
isUrlAbsolute
public static boolean isUrlAbsolute(java.lang.String url)
-
showNoPermissionMessage
public static void showNoPermissionMessage()
-
searchForLabel
public static java.util.List<java.lang.String> searchForLabel(java.lang.Object obj, java.lang.reflect.Method method, java.util.Collection<LanguageModel> firstPrioLanguages) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException
- Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
-
forceRenderCombobox
public static void forceRenderCombobox(org.zkoss.zul.Combobox comboBox, org.zkoss.zul.ComboitemRenderer renderer, java.util.Collection<? extends java.lang.Object> model)
Combobox
es usually aren't rendered until ZK's event processing phase. However, it might be necessary to be able to access the children in an earlier stage of the life cycle. This method forces the addition and rendering of aCombobox
' children.- Parameters:
comboBox
- the combobox which children are to be renderedrenderer
- the renderer to use for rendering the childrenmodel
- the the data to be rendered
-
getLocalDate
public static java.lang.String getLocalDate(java.util.Date date)
-
getLocalDateTime
public static java.lang.String getLocalDateTime(java.util.Date date)
-
addBusyListener
public static void addBusyListener(org.zkoss.zk.ui.Component component, java.lang.String evtnm, org.zkoss.zk.ui.event.EventListener listener, java.lang.String data, java.lang.String i3BusyMessage)
Adds a event listener to a component. A busy user message is shown while the event callback is processed.- Parameters:
component
- the zk component to which the event listener should be addedevtnm
- the event namelistener
- the event listenerdata
- additional datai3BusyMessage
- the i3 label code or null for default busy message
-
performDoubleClickDelay
public static void performDoubleClickDelay(org.zkoss.zk.ui.WebApp webApp)
-
getWebAppName
public static java.lang.String getWebAppName(org.zkoss.zk.ui.Execution execution)
-
getWebAppName
public static java.lang.String getWebAppName(org.zkoss.zk.ui.Desktop desktop)
-
getCockpitParameter
public static java.lang.String getCockpitParameter(java.lang.String key, org.zkoss.zk.ui.Desktop desktop)
Returns a config parameter for the current cockpit. If it doesn't exist, this method tries to get the default cockpit parameter. Example: For wysiwyg editors toolbar configuration you can specify the key "default.fckToolbarConfig". If you are in cmscockpit, this method looks for the key "cmscockpit.default.fckToolbarConfig". If it doesn't find it, it returns the value for "cockpit.default.fckToolbarConfig".- Parameters:
key
- the key without cockpit prefixdesktop
- the current desktop- Returns:
- the value, can be null
-
getCockpitParameter
public static java.lang.String getCockpitParameter(java.lang.String key, org.zkoss.zk.ui.Execution execution)
Returns a config parameter for the current cockpit. If it doesn't exist, this method tries to get the default cockpit parameter. Example: For wysiwyg editors toolbar configuration you can specify the key "default.fckToolbarConfig". If you are in cmscockpit, this method looks for the key "cmscockpit.default.fckToolbarConfig". If it doesn't find it, it returns the value for "cockpit.default.fckToolbarConfig".- Parameters:
key
- the key without cockpit prefixexecution
- the current execution- Returns:
- the value, can be null
-
addMacCommandClickListener
public static void addMacCommandClickListener(org.zkoss.zul.impl.XulElement component)
-
setComponentWidths
public static void setComponentWidths(java.lang.String[] widths, org.zkoss.zk.ui.HtmlBasedComponent... comps)
-
invalidateAllPortallayouts
public static void invalidateAllPortallayouts()
-
removeHtml
public static java.lang.String removeHtml(java.lang.String html)
-
removeEventListenersForComponent
public static void removeEventListenersForComponent(java.lang.String eventType, org.zkoss.zk.ui.Component component)
-
scrollIntoViewIfNeeded
public static void scrollIntoViewIfNeeded(org.zkoss.zk.ui.Component component, org.zkoss.zk.ui.Component scrollContainer)
Same asscrollIntoViewIfNeeded(Component, Component, int)
with '0' as last argument.
-
scrollIntoViewIfNeeded
public static void scrollIntoViewIfNeeded(org.zkoss.zk.ui.Component component, org.zkoss.zk.ui.Component scrollContainer, int childDepth)
Checks if the component is outside the scrollcontainers parent (i.e. not visible) and if so calls scrollIntoView.- Parameters:
component
- the component that should be made visible.scrollContainer
- the component that possesses the scrollbarchildDepth
- if the scrollContainer doesn't have scrollbars itself but one of its html child components that are not accessible in java, you can specify a number how often "firstChild" will be appended to fetch the real scrollcontainer.
-
updateMediaModel
public static void updateMediaModel(MediaModel currentMediaModel, org.zkoss.util.media.Media mediaContent, MediaService mediaService)
-
searchRestrictionsDisabledInCockpit
public static boolean searchRestrictionsDisabledInCockpit()
-
setManagedEventListener
public static boolean setManagedEventListener(org.zkoss.zk.ui.Component component, java.lang.String evtnm, org.zkoss.zk.ui.event.EventListener listener)
Adds and replaces anEventListener
at aComponent
. The methodComponent.addEventListener(String, EventListener)
doesn't allow to replace anEventListener
, if you call it twice, the second call will be ignored. You have to remove theEventListener
instance manually by invokingComponent.removeEventListener(String, EventListener)
but you have to know theEventListener
instance.
This method allows you to replace the previous addedEventListener
without knowing it, as long as it was also added by this method.- Parameters:
component
- the component the listener should be added to.evtnm
- the event name.listener
- the event listener.- Returns:
- true, if the listener could be added successfully or false, if another listener was already registered for the component and couldn't be removed.
-
-