Class UIThemeChooser
- All Implemented Interfaces:
EventListener, IFocusComp, IMessageBox, IComponent, ICustomDataProvider, IGProp<GProp<?>[]>, IPropCnr, IUIComp, IUIFocusComp, IVSComponentListener, IVSComponentState, IVSFieldListener, Cloneable
- Direct Known Subclasses:
EUIThemeChooser
The client does the work. The component carries no state of its own: the client widget (iz/ui/UIThemeChooser.js) applies the choice through the one existing mechanism, izUIScheme.set() of iz/uischeme.js - the same code path as the theme= entry URL member and the Java API IClientSessionGyro.setUIScheme(UISchemes.Family,UISchemes.Mode), with the same persistence (localStorage in a Browser or an installed PWA, the launcher's settings in iiziRun) and the same report to the server (IClientSessionGyro.getUIScheme(), IClientSessionGyro.getUISchemeChoice(), the listeners). Nothing is sent to the server by the component itself. The three texts the tooltip shows, one per mode, are the component's properties PN_LIGHT_TEXT, PN_DARK_TEXT and PN_AUTO_TEXT, each a plain KString that an application binds to its text tables; when a text is not set, the client's own string table (strings_en.js: THEME_LIGHT, THEME_DARK, THEME_AUTO) gives the English default.
Hidden where the application allows one mode only. An application whose App page pins the appearance (ModuleApp.getUIModes(): light only or dark only) has nothing to choose: the component is then hidden (UIComp.setVisible(boolean), no space taken) when the panel is virtualized for a client session, from the modes the session carries (IClientSessionGyro.getUIModes()). In the Designer, where no client session exists, the component is always shown. The rule is isShownFor(int).
Families (IIZI, Graphite, Contrast) are not offered by the component in v5: an application has no allowance of families today, so the ruled "where the application allows more than one" cannot be read; the family drop-down is v5.1 through this same component.
- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from interface IMessageBox
IMessageBox.IconNested classes/interfaces inherited from interface IVSComponentState
IVSComponentState.StateField Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe property name of the text shown for the auto mode (follow the system):autoText, a plain KString, absent for the client's default.static final StringThe property name of the text shown for the dark mode:darkText, a plain KString, absent for the client's default.static final StringThe property name of the text shown for the light mode:lightText, a plain KString, absent for the client's default.Fields inherited from class UIComp
EMPTY, REMOTE_FOCUS_EVENT, styles, vsFieldFields inherited from class PropCnr
EMPTY_CLASSES, EMPTY_CNRS, EXTENDS_FRAMEWORK_ERROR_IDFields inherited from class GProp
GPDEBUG, PROP_ATTR_STRING_EDITOR_PROP, PROP_ATTR_STRING_ERRORED_NAME, PROP_ATTR_STRING_EXTENDS, PROP_ATTR_STRING_EXTENDS_FINAL, PROP_ATTR_STRING_EXTENDS_PRIVATE, PROP_ATTR_STRING_NULLABLE, PROP_ATTR_STRING_PRIVATE, PROP_ATTR_STRING_PRIVATE_CHANGE_EVENT, PROP_ATTR_STRING_READ_ONLY, PROP_ATTR_STRING_SECRET, PROP_USER_1, PROP_USER_2Fields inherited from interface IGProp
EQC_ERROR_IGNORE_ALL, EQC_ERROR_IGNORE_REFERENCES, EQC_IGNORE_ARRAY, EQC_IGNORE_VOLATILE_OR_EDITOR, EQC_INCLUDE_PRIVATE, EQC_SAVE_FILE, EQC_SAVE_RELEVANT_ONLY, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATEFields inherited from interface IMessageBox
ICON_ERROR, ICON_INFORMATION, ICON_MAP, ICON_NONE, ICON_QUESTION, ICON_WARNINGFields inherited from interface IUIComp
ERROR, INFORMATION, NONE, WARNINGConstructor Summary
ConstructorsConstructorDescriptionCreates the component without a name.UIThemeChooser(Atom propertyAtom) Creates the component with the specified name.UIThemeChooser(Atom propertyAtom, GProp<?>[] newValue) Creates the component with the specified name, initialized to contain theGPropitems.Method Summary
Modifier and TypeMethodDescriptionclone()Clones the component.Returns the size of the component in pixels: the 16 x 16 icon box of its button, the size of a menu item's icon node in the shipped desktop themes.Gets the text shown for the auto mode (follow the system).Gets the text shown for the dark mode.final intGets the device type: -1=mobile, 0=both, 1=desktop.Gets the text shown for the light mode.booleanhideWhenOneMode(int uiModes) Hides the component when the application allows one mode only, seeisShownFor(int).static booleanisShownFor(int uiModes) Checks if the chooser is shown for the modes an application allows: it is shown when the user has a choice, light and dark (UISchemes.MODES_BOTH), and hidden when the application pins one mode (UISchemes.MODES_LIGHTorUISchemes.MODES_DARK).protected voidonVirtualizationCompleted(IAppSessionGyro appGyro, IClientSessionGyro clientGyro, VirtualSpace virtualSpace, boolean isPostResolve) Called when virtualization completed: the component is hidden when the client session's application allows one mode only (IClientSessionGyro.getUIModes()), before the tree is sent to the client, so that no space is taken for it.booleansetAutoText(String text) Sets the text shown for the auto mode (follow the system).booleansetDarkText(String text) Sets the text shown for the dark mode.booleansetLightText(String text) Sets the text shown for the light mode.Methods inherited from class UIComp
add, addMappings, assignFontInfoResolver, canAcceptUIContainerFocus, canAlignX, canAlignY, canFillX, canFillY, canRequestFocus, canRequestFocus, clearErrorMessage, couldRequestFocusIfVirtualized, createStyles, createTitleProp, disconnectVSField, doUpdateVSFieldFromUIComponent, enterVSProcessing, exitVSProcessing, fireSelection, fireSelection, forbiddenGetCustomDataMap, getBadge, getBestVSFieldValueType, getComponentID, getComponentMappings, getCSSClassNames, getErrorMessage, getErrorMessage, getErrorMessageEx, getErrorMessageString, getErrorMessageString, getErrorMessageStringEx, getFirstContainerVSStateFocus, getFixHeight, getFixWidth, getFontInfo, getForcedAlignX, getForcedAlignY, getKStringText, getLayout, getLayoutMgr, getLayoutMgr, getMappedVSComponent, getMessage, getMessageText, getPixelHeight, getPixelWidth, getPredefinedProps, getSize, getStyles, getStyles, getText, getTitle, getTitleKS, getTitlePKS, getTooltip, getTooltipText, getTrigger, getUIPanel, getUIParent, getValue, getValue, getVirtualSpace, getVSField, getVSStateFocus, hasExplicitHeight, hasExplicitWidth, hasFocus, hasImplicitAlignFillX, hasImplicitAlignFillY, hasImplicitHeight, hasImplicitWidth, hasSelectionChanged, initPropCnr, invokeOnUICreateTree, isEnabled, isMobile, isReadOnly, isRTL, isVisible, isVSFieldDisconnected, mustHaveExplicitHeight, mustHaveExplicitWidth, mustHaveHeight, mustHaveWidth, onBroken, onComponentSelectedInParent, onEventSelf, onFocusGained, onNotifySelectionChanged, onParentStateChanged, onPrepare, onPrepare, onPropDispose, onRemoteEvent, onResolved, onSelectionChanged, onStateChanged, onValueChanged, processVSComponentSelection, reconnectVSField, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusEx, requestFocusEx, requestFocusEx, requestFocusEx, resetComponentID, setBadge, setBadge, setComponentToVSField, setCSSClassNames, setCSSClassNames2, setEnabled, setEnabled, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setHTMLText, setLayoutMgr, setMessage, setMessage, setReadOnly, setReadOnly, setText, setText, setTitle, setTitle, setTitle, setTooltip, setTooltip, setUIContainerFocus, setVisible, setVisible, setVSFieldMessageToComponent, setVSFieldToComponent, verify, verifyComponentScopeMethods inherited from class PropCnr
__transferChildProps, addPredefinedProps, addProp, addProp, addProp2, addProp2, appendPropValue, completeVirtualize, containsProp, containsProp, convertLoadedProp, createCopyOfAtom, createUniqueAtom, createUniqueAtom, createUniqueAtom, createVSReference, doPropEqualsArrayValues, enablePropCommunication, enablePropHashMap, equalsTree, equalsTree, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getBool, getBool, getBool, getBool, getChildPropError, getChildPropError, getChildPropErrorSeverity, getChildPropErrorSeverity, getErrorsProp, getExtendsContainer, getExtendsError, getExtendsName, getExtendsOverride, getExtendsPossibleClasses, getFirstProp, getFirstProp, getFocusEngine, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNumber, getNumber, getNumber, getNumber, getPossibleChildren, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getPropBaseReference, getPropCnr, getPropCount, getPropCount, getPropIndex, getPropIndex, getPropIndexes, getProps, getProps, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue0, getRetargetedVerifyContainer, getString, getString, getString, getString, getValueClasses, getVSReference, hasSendData, initializeElement, initializeExtendsFramework, initializeProp, initializePropTree, initializeValue, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsPropertyValid, isExtendsRoot, isPropAddRemoveAllowed, isPropCommunicating, isPropExtended, isPropValueTreeLockNeeded, list, list, logPropNotFound, maybeAddProp, onInsertProp, onPropRemoved, onPropTreeInitialized, onReferenceEvent, onVirtualContainerCreated, paramString, prepare, removeAllProps, removeAllProps2, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, reorderProps, replaceProps, requestFocus, requestFocusEx, resolveReferences, resolveRuntimeReferences, setBool, setBool, setBool, setBool, setCreateRequiredProp, setExtendsName, setExtendsOverride, setInt, setInt, setInt, setLong, setLong, setLong, setLong, setNumber, setNumber, setNumber, setNumber, setProp, setProp, setProp, setProp2, setProp2, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setString, setString, setString, setString, shouldCreateProps, shouldSerializeToXML, toElementString, toNativeValue0, usePropHashMap, usesPropIndex, validateChildPropInValue, validateClassInstances, validatePropType, validatePropValue, verifyInternalUseOnly, verifyTree, virtualizeMethods inherited from class GProp
addPropError, addPropListener, appendProp, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalValues, finalize, fine, fine, finer, finer, finest, finest, fromElementString, getAliasName, getAppSessionGyro, getAppWorker, getAtomPath, getAttribute, getChildReferencePropName, getClientSessionGyro, getClientWorker, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropName, getFullPropNameDebug, getFullPropNameDebug, getListeners, getModuleFolder, getModuleFolder, getParent, getParent, getProjectName, getPropAtom, getPropError, getPropError, getPropErroredName, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromPath, getPropFromReference, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropReferenceTarget, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getPropValueObject, getReferencePropName, getReferencePropNameNoAssert, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParentNoAssert, getTreeLock, hasChanged, hasCircularReferencesError, hashCode, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropErrorPersisted, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropForEditor, isPropForEditorAtCreation, isPropNullable, isPropPrivate, isPropPrivateAtCreation, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropRootLoading, isPropRootTreeModificationsAllowed, isPropSaveRelevant, isPropSecret, isPropSecretCapable, isPropUSER, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, isSibling, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onInitialize, onPropInvalidateCache, onPropParentChanged, onPropValueSet, paramString, paramValue, post, post, removePropError, removePropListener, removePropUSER, renameProp, renameProp2, resetChangedTree, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPrivateCreateRequiredProp, setPropError, setPropErroredName, setPropExtended, setPropExtendsFinal, setPropExtendsPrivate, setPropForEditor, setPropNullable, setPropPrivate, setPropReadOnly, setPropSecret, setPropUSER, setPropValue, setPropValue, setPropValue, setPropValueIncognito, setPropVolatile, severe, severe, severe, shouldSerializeToXML, throwIfReadOnly, toNativeValue, toShortString, toShortString, toString, toString, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warningMethods inherited from interface IComponent
messageBoxMethods inherited from interface ICustomDataProvider
getCustomData, putCustomData, putCustomDataIfAbsentMethods inherited from interface IFocusComp
requestFocus, requestFocus, requestFocusEx, requestFocusExMethods inherited from interface IGProp
addPropError, addPropListener, dispose, equals, fine, fine, finer, finer, finest, finest, fromElementString, getAppSessionGyro, getAtomPath, getClientSessionGyro, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropNameDebug, getModuleFolder, getModuleFolder, getParent, getParent, getPropAtom, getPropBaseReference, getPropError, getPropError, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getReferencePropName, getRelativePropName, getRootParent, getTreeLock, getValueClasses, getVSReference, hasChanged, hasCircularReferencesError, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCommunicating, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropNullable, isPropPrivate, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropVirtualized, isSibling, list, list, list, list, list, mapAliasToReference, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, onEventSelf, onPropTreeInitialized, onRemoteEvent, removePropError, removePropListener, renameProp, resolveRuntimeReferences, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPropError, setPropExtendsFinal, setPropExtendsPrivate, setPropNullable, setPropPrivate, setPropReadOnly, setPropValue, setPropValue, severe, severe, severe, toElementString, toNativeValue, triggerRemoteEvent, triggerRemoteEvent, validateProp, validatePropType, validatePropValue, verify, warning, warning, warningMethods inherited from interface IMessageBox
messageBox, messageBox, messageBoxMethods inherited from interface IPropCnr
addProp, addProp, addProp2, addProp2, canRequestFocus, canRequestFocus, canRequestFocus, containsProp, containsProp, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized, createCopyOfAtom, createUniqueAtom, createUniqueAtom, enablePropCommunication, enablePropHashMap, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getBool, getBool, getBool, getBool, getChildPropError, getChildPropError, getChildPropErrorSeverity, getChildPropErrorSeverity, getErrorsProp, getExtendsError, getExtendsName, getExtendsPossibleClasses, getFirstProp, getFirstProp, getFocusEngine, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNumber, getNumber, getNumber, getNumber, getPossibleChildren, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getPropCnr, getPropCount, getPropIndex, getPropIndex, getPropIndexes, getProps, getProps, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getString, getString, getString, getString, hasFocus, initializeExtendsFramework, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsRoot, isPropAddRemoveAllowed, isPropExtended, removeAllProps, removeAllProps2, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, reorderProps, requestFocus, requestFocusEx, setBool, setBool, setBool, setBool, setExtendsName, setExtendsOverride, setInt, setInt, setInt, setLong, setLong, setLong, setLong, setNumber, setNumber, setNumber, setNumber, setProp, setProp, setProp, setProp2, setProp2, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setString, setString, setString, setString, usePropHashMap, usesPropIndex, validateClassInstancesMethods inherited from interface IUIComp
getContainerFirstUIComponent, getContainerFirstUIComponentNull, getFirstUIComponent, getFirstUIComponentNull, getPanelUIComponent, getPanelUIComponentNull, getUIRefMethods inherited from interface IUIFocusComp
onFocusGained, onFocusLost
Field Details
PN_LIGHT_TEXT
The property name of the text shown for the light mode:lightText, a plain KString, absent for the client's default.- See Also:
PN_DARK_TEXT
The property name of the text shown for the dark mode:darkText, a plain KString, absent for the client's default.- See Also:
PN_AUTO_TEXT
The property name of the text shown for the auto mode (follow the system):autoText, a plain KString, absent for the client's default.- See Also:
Constructor Details
UIThemeChooser
public UIThemeChooser()Creates the component without a name. The name must be set in all cases using thesetPropertyAtomcall.UIThemeChooser
Creates the component with the specified name. All system-reserved names for components begins with "$".- Parameters:
propertyAtom- the name of the component, unique within it's parent.
UIThemeChooser
Creates the component with the specified name, initialized to contain theGPropitems. All system-reserved names for components begins with "$".- Parameters:
propertyAtom- The name of the component, unique within it's parent.newValue- The array of all properties the component should have.- Throws:
PropException- when at least one of the properties to initialize the component with is invalid.
Method Details
clone
Clones the component.Cloning is used for "virtualization" of a property tree in the server.
getDeviceType
public final int getDeviceType()Gets the device type: -1=mobile, 0=both, 1=desktop.- Specified by:
getDeviceTypein interfaceIUIComp
isShownFor
public static boolean isShownFor(int uiModes) Checks if the chooser is shown for the modes an application allows: it is shown when the user has a choice, light and dark (UISchemes.MODES_BOTH), and hidden when the application pins one mode (UISchemes.MODES_LIGHTorUISchemes.MODES_DARK). A stored value outside the three (an ERROR of the App page's verification) pins nothing and leaves the chooser shown.- Parameters:
uiModes- The modes the application allows,ModuleApp.getUIModes().- Returns:
- true when the chooser is shown, false when it is hidden.
hideWhenOneMode
public boolean hideWhenOneMode(int uiModes) Hides the component when the application allows one mode only, seeisShownFor(int).- Parameters:
uiModes- The modes the application allows,ModuleApp.getUIModes().- Returns:
- true when the component was hidden by this call, false when it is shown or was hidden already.
onVirtualizationCompleted
protected void onVirtualizationCompleted(IAppSessionGyro appGyro, IClientSessionGyro clientGyro, VirtualSpace virtualSpace, boolean isPostResolve) Called when virtualization completed: the component is hidden when the client session's application allows one mode only (IClientSessionGyro.getUIModes()), before the tree is sent to the client, so that no space is taken for it.This method is called to the entire tree of the newly virtualized property container.
- Overrides:
onVirtualizationCompletedin classPropCnr- Parameters:
appGyro- The application gyro instance performing the virtualization.clientGyro- The client gyro session, can benullif not initialized from the client gyro.virtualSpace- The virtualized VirtualSpace.isPostResolve- Flag indicating this call is done after references are attempted to be resolved.
getLightText
Gets the text shown for the light mode.- Returns:
- The text replacing the client's default 'Light', null for the default.
setLightText
Sets the text shown for the light mode.- Parameters:
text- The text replacing the client's default 'Light', null for the default.- Returns:
trueif changed,falsefor no change.
getDarkText
Gets the text shown for the dark mode.- Returns:
- The text replacing the client's default 'Dark', null for the default.
setDarkText
Sets the text shown for the dark mode.- Parameters:
text- The text replacing the client's default 'Dark', null for the default.- Returns:
trueif changed,falsefor no change.
getAutoText
Gets the text shown for the auto mode (follow the system).- Returns:
- The text replacing the client's default 'Auto', null for the default.
setAutoText
Sets the text shown for the auto mode (follow the system).- Parameters:
text- The text replacing the client's default 'Auto', null for the default.- Returns:
trueif changed,falsefor no change.
getApproximateSize
Returns the size of the component in pixels: the 16 x 16 icon box of its button, the size of a menu item's icon node in the shipped desktop themes.- Specified by:
getApproximateSizein classUIComp- Returns:
- The size 16x16.