Class StyleSheetHandler
- All Implemented Interfaces:
HasHandlers
-
Field Summary
Fields inherited from class com.smartgwt.client.core.BaseClass
config, configOnly, factoryCreated, factoryProperties, id, scClassName -
Constructor Summary
ConstructorsConstructorDescriptionStyleSheetHandler(String cssText, boolean autoLoad) StyleSheetHandler(String name, String cssText, boolean autoLoad) -
Method Summary
Modifier and TypeMethodDescriptioncreate()filterCssText(String className) Returns all styles for the passed className or array of classNames.filterCssText(String... className) Returns all styles for the passed className or array of classNames.booleanWhen true, this handler will automaticallyinjectit's stylesheet into the DOM.String[]Returns the list of CSS class-names defined in this handler'sstylesheet.A string representation of all the CSS styles in this handler'sstyleSheet.getJsObj()getName()The name for this handler.static StyleSheetHandlergetOrCreateRef(JavaScriptObject jsObj) A reference to this handler's stylesheet-element in the DOM.booleaninjectCssText(String cssText) Injects text defining a block of selectors into this handler'sstylesheet.voidCreate this handler'sstylesheetelement in the DOM.booleanbooleanloaded()Has this handler'sstyleSheetbeen loaded into the DOM?booleanmodifyClass(String className, String cssText) Inject a string of css settings into a single CSS class, via a new rule in this handler'sstylesheet.booleanremoveClass(String className) Remove the passed CSS class from thestylesheet, by deleting it's rules and pruning it from multi-class selectors.booleanrenameClass(String oldName, String newName) Rename the passed oldClass to newClass in all rules that reference it.setAutoLoad(boolean autoLoad) When true, this handler will automaticallyinjectit's stylesheet into the DOM.setCssText(String cssText) A string representation of all the CSS styles in this handler'sstyleSheet.voidThe name for this handler.voidunload()Remove this handler'sstylesheetfrom the DOM and destroy it.Methods inherited from class com.smartgwt.client.core.BaseClass
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoID, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName
-
Constructor Details
-
StyleSheetHandler
public StyleSheetHandler() -
StyleSheetHandler
-
StyleSheetHandler
-
StyleSheetHandler
-
-
Method Details
-
getOrCreateRef
-
setJavaScriptObject
- Overrides:
setJavaScriptObjectin classBaseClass
-
create
-
isCreated
public boolean isCreated() -
getJsObj
-
getOrCreateJsObj
- Overrides:
getOrCreateJsObjin classBaseClass
-
setAutoLoad
When true, this handler will automaticallyinjectit's stylesheet into the DOM.- Parameters:
autoLoad- New autoLoad value. Default value is false- Returns:
StyleSheetHandlerinstance, for chaining setter calls- Throws:
IllegalStateException- this property cannot be changed after the underlying component has been created
-
getAutoLoad
public boolean getAutoLoad()When true, this handler will automaticallyinjectit's stylesheet into the DOM.- Returns:
- Current autoLoad value. Default value is false
-
setCssText
A string representation of all the CSS styles in this handler'sstyleSheet.
If this method is called after the component has been drawn/initialized: Replace the entire CSS in this handler'sstylesheet.If the stylesheet is already in the DOM, it is first
unloaded, thecssTextis updated and then the stylesheet isinjectedback into the DOM. Otherwise, the handler's cssText is updated and no further action is taken.- Parameters:
cssText- complete cssText to apply to the stylesheet. Default value is null- Returns:
StyleSheetHandlerinstance, for chaining setter calls
-
getCssText
A string representation of all the CSS styles in this handler'sstyleSheet.- Returns:
- Current cssText value. Default value is null
-
setName
The name for this handler. This value is applied as both the 'id' and 'title' attributes on the handler'sstylesheet.- Parameters:
name- New name value. Default value is null- Returns:
StyleSheetHandlerinstance, for chaining setter calls- Throws:
IllegalStateException- this property cannot be changed after the underlying component has been created
-
getName
The name for this handler. This value is applied as both the 'id' and 'title' attributes on the handler'sstylesheet.- Returns:
- Current name value. Default value is null
-
getStyleSheet
A reference to this handler's stylesheet-element in the DOM. This attribute cannot be set - seeinjectSheet()andunload()for details.Note : This method should be called only after the underlying component has been created.
- Returns:
- Current styleSheet value. Default value is null
- Throws:
IllegalStateException- if the underlying component has not yet been created.
-
filterCssText
Returns all styles for the passed className or array of classNames. The output is a single compound string in the format ".class1 { css settings; } .class2 { css settings; } ... ".This string may then be imported directly into another stylesheet, either
replacing contentoradding to it.- Parameters:
className- one or more CSS-class names to get the declaration for- Returns:
- the CSS declaration for the passed className
-
filterCssText
Returns all styles for the passed className or array of classNames. The output is a single compound string in the format ".class1 { css settings; } .class2 { css settings; } ... ".This string may then be imported directly into another stylesheet, either
replacing contentoradding to it.- Parameters:
className- one or more CSS-class names to get the declaration for- Returns:
- the CSS declaration for the passed className
-
getClassList
Returns the list of CSS class-names defined in this handler'sstylesheet.- Returns:
- the list of CSS class-names defined in the stylesheet
-
injectCssText
Injects text defining a block of selectors into this handler'sstylesheet.The passed 'cssText' string should contain one or more selectors, each in the format '.className [, className ...] { css settings; }'. Use
modifyClass(className, cssText-without-braces)to apply styles to a specific CSS class.- Parameters:
cssText- string of css selectors and their settings to apply to this handler'sstylesheet.- Returns:
- returns true if CSS was injected, false otherwise
-
injectSheet
public void injectSheet()Create this handler'sstylesheetelement in the DOM. -
loaded
public boolean loaded()Has this handler'sstyleSheetbeen loaded into the DOM?- Returns:
- true if this handler's stylesheet is currently loaded into the DOM
-
modifyClass
Inject a string of css settings into a single CSS class, via a new rule in this handler'sstylesheet.The passed 'cssText' should contain semi-colon -separated CSS settings only, not the selector/className or enclosing braces - { }.
- Parameters:
className- name of the CSS class to apply the cssText tocssText- string of css settings to apply to the passed className in this handler'sstylesheet.- Returns:
- returns true if CSS was applied, false otherwise
-
removeClass
Remove the passed CSS class from thestylesheet, by deleting it's rules and pruning it from multi-class selectors.- Parameters:
className- name of the CSS class to remove from the stylesheet- Returns:
- returns true if CSS was removed, false otherwise
-
renameClass
Rename the passed oldClass to newClass in all rules that reference it.- Parameters:
oldName- name of the CSS class to rename in the stylesheetnewName- new name for the CSS class- Returns:
- returns true if a class was renamed, false otherwise
-
unload
public void unload()Remove this handler'sstylesheetfrom the DOM and destroy it.
-