idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
18,900
public static String format ( final Locale locale , final String text , final Object ... args ) { if ( text == null ) { return null ; } String localisedText = getLocalisedText ( locale , text ) ; String message = localisedText == null ? text : localisedText ; if ( args != null ) { try { return MessageFormat . format ( ...
Formats the given text optionally using locale - specific text .
18,901
public static Locale getEffectiveLocale ( ) { Locale effectiveLocale = null ; UIContext uic = UIContextHolder . getCurrent ( ) ; if ( uic != null ) { effectiveLocale = uic . getLocale ( ) ; } if ( effectiveLocale == null ) { String defaultLocale = ConfigurationProperties . getDefaultLocale ( ) ; effectiveLocale = new L...
Get the locale currently in use .
18,902
public static String getLocalisedText ( final Locale locale , final String text ) { String message = null ; String resourceBundleBaseName = getResourceBundleBaseName ( ) ; if ( ! Util . empty ( resourceBundleBaseName ) ) { Locale effectiveLocale = locale ; if ( effectiveLocale == null ) { effectiveLocale = getEffective...
Attempts to retrieve the localized message for the given text .
18,903
public static boolean validateFileType ( final FileItemWrap newFile , final List < String > fileTypes ) { if ( newFile == null ) { return false ; } if ( fileTypes == null || fileTypes . isEmpty ( ) ) { return true ; } final List < String > fileExts = fileTypes . stream ( ) . filter ( fileType -> fileType . startsWith (...
Checks if the file item is one among the supplied file types . This first checks against file extensions then against file mime types
18,904
public static String getFileMimeType ( final File file ) { if ( file != null ) { try { final Tika tika = new Tika ( ) ; return tika . detect ( file . getInputStream ( ) ) ; } catch ( IOException ex ) { LOG . error ( "Invalid file, name " + file . getName ( ) , ex ) ; } } return null ; }
Identify the mime type of a file .
18,905
public static boolean validateFileSize ( final FileItemWrap newFile , final long maxFileSize ) { if ( newFile == null ) { return false ; } if ( maxFileSize < 1 ) { return true ; } return ( newFile . getSize ( ) <= maxFileSize ) ; }
Checks if the file item size is within the supplied max file size .
18,906
public static String getInvalidFileTypeMessage ( final List < String > fileTypes ) { if ( fileTypes == null ) { return null ; } return String . format ( I18nUtilities . format ( null , InternalMessages . DEFAULT_VALIDATION_ERROR_FILE_WRONG_TYPE ) , StringUtils . join ( fileTypes . toArray ( new Object [ fileTypes . siz...
Returns invalid fileTypes error message .
18,907
public static String getInvalidFileSizeMessage ( final long maxFileSize ) { return String . format ( I18nUtilities . format ( null , InternalMessages . DEFAULT_VALIDATION_ERROR_FILE_WRONG_SIZE ) , FileUtil . readableFileSize ( maxFileSize ) ) ; }
Returns invalid fileSize error message .
18,908
public List < Diagnostic > getDiagnostics ( ) { FieldIndicatorModel model = getComponentModel ( ) ; return Collections . unmodifiableList ( model . diagnostics ) ; }
Return the diagnostics for this indicator .
18,909
public void setWidth ( final int width ) { if ( width > 100 ) { throw new IllegalArgumentException ( "Width (" + width + ") cannot be greater than 100 percent" ) ; } getOrCreateComponentModel ( ) . width = Math . max ( 0 , width ) ; }
Sets the column width .
18,910
public void paint ( final RenderContext renderContext ) { getResponse ( ) . setHeader ( "Cache-Control" , type . getSettings ( ) ) ; if ( ! type . isCache ( ) ) { getResponse ( ) . setHeader ( "Pragma" , "no-cache" ) ; getResponse ( ) . setHeader ( "Expires" , "-1" ) ; } super . paint ( renderContext ) ; }
Set the appropriate response headers for caching or not caching the response .
18,911
public void addMessage ( final boolean encode , final String msg , final Serializable ... args ) { MessageModel model = getOrCreateComponentModel ( ) ; model . messages . add ( new Duplet < > ( I18nUtilities . asMessage ( msg , args ) , encode ) ) ; MemoryUtil . checkSize ( model . messages . size ( ) , this . getClass...
Adds a message to the message box .
18,912
public void removeMessages ( final int index ) { MessageModel model = getOrCreateComponentModel ( ) ; if ( model . messages != null ) { model . messages . remove ( index ) ; } }
Removes a message from the message box .
18,913
public void clearMessages ( ) { MessageModel model = getOrCreateComponentModel ( ) ; if ( model . messages != null ) { model . messages . clear ( ) ; } }
Removes all messages from the message box .
18,914
public List < String > getMessages ( ) { MessageModel model = getComponentModel ( ) ; List < String > messages = new ArrayList < > ( model . messages . size ( ) ) ; for ( Duplet < Serializable , Boolean > message : model . messages ) { String text = I18nUtilities . format ( null , message . getFirst ( ) ) ; boolean enc...
Retrieves the list of messages .
18,915
public void setVideo ( final Video [ ] video ) { List < Video > list = video == null ? null : Arrays . asList ( video ) ; getOrCreateComponentModel ( ) . video = list ; }
Sets the video clip in multiple formats . The client will try to load the first video clip and if it fails or isn t supported it will move on to the next video clip . Only the first clip which can be played on the client will be used .
18,916
public Video [ ] getVideo ( ) { List < Video > list = getComponentModel ( ) . video ; return list == null ? null : list . toArray ( new Video [ ] { } ) ; }
Retrieves the video clips associated with this WVideo .
18,917
public void setMediaGroup ( final String mediaGroup ) { String currMediaGroup = getMediaGroup ( ) ; if ( ! Objects . equals ( mediaGroup , currMediaGroup ) ) { getOrCreateComponentModel ( ) . mediaGroup = mediaGroup ; } }
Sets the media group .
18,918
public void setAltText ( final String altText ) { String currAltText = getAltText ( ) ; if ( ! Objects . equals ( altText , currAltText ) ) { getOrCreateComponentModel ( ) . altText = altText ; } }
Sets the alternative text to display when the video clip can not be played .
18,919
public void setTracks ( final Track [ ] tracks ) { List < Track > list = tracks == null ? null : Arrays . asList ( tracks ) ; getOrCreateComponentModel ( ) . tracks = list ; }
Sets the tracks for the video . The tracks are used to provide additional information relating to the video for example subtitles .
18,920
public Track [ ] getTracks ( ) { List < Track > list = getComponentModel ( ) . tracks ; return list == null ? null : list . toArray ( new Track [ ] { } ) ; }
Retrieves additional tracks associated with the video . The tracks provide additional information relating to the video for example subtitles .
18,921
public boolean isVisible ( ) { if ( ! super . isVisible ( ) ) { return false ; } Video [ ] video = getVideo ( ) ; return video != null && video . length > 0 ; }
Override isVisible to also return false if there are no video clips to play .
18,922
public void handleRequest ( final Request request ) { super . handleRequest ( request ) ; String targ = request . getParameter ( Environment . TARGET_ID ) ; boolean contentReqested = ( targ != null && targ . equals ( getTargetId ( ) ) ) ; if ( contentReqested && request . getParameter ( POSTER_REQUEST_PARAM_KEY ) != nu...
When an video element is rendered to the client the browser will make a second request to get the video content . The handleRequest method has been overridden to detect whether the request is the content fetch request by looking for the parameter that we encode in the content url .
18,923
private void handlePosterRequest ( ) { Image poster = getComponentModel ( ) . poster ; if ( poster != null ) { ContentEscape escape = new ContentEscape ( poster ) ; escape . setCacheable ( ! Util . empty ( getCacheKey ( ) ) ) ; throw escape ; } else { LOG . warn ( "Client requested non-existant poster" ) ; } }
Handles a request for the poster .
18,924
private void handleVideoRequest ( final Request request ) { String videoRequested = request . getParameter ( VIDEO_INDEX_REQUEST_PARAM_KEY ) ; int videoFileIndex = 0 ; try { videoFileIndex = Integer . parseInt ( videoRequested ) ; } catch ( NumberFormatException e ) { LOG . error ( "Failed to parse video index: " + vid...
Handles a request for a video .
18,925
private void handleTrackRequest ( final Request request ) { String trackRequested = request . getParameter ( TRACK_INDEX_REQUEST_PARAM_KEY ) ; int trackIndex = 0 ; try { trackIndex = Integer . parseInt ( trackRequested ) ; } catch ( NumberFormatException e ) { LOG . error ( "Failed to parse track index: " + trackIndex ...
Handles a request for an auxillary track .
18,926
public void setAudio ( final Audio [ ] audio ) { List < Audio > list = audio == null ? null : Arrays . asList ( audio ) ; getOrCreateComponentModel ( ) . audio = list ; }
Sets the audio clip in multiple formats for all users . The client will try to load the first audio clip and if it fails or isn t supported it will move on to the next audio clip . Only the first clip which can be played on the client will be used .
18,927
public Audio [ ] getAudio ( ) { List < Audio > list = getComponentModel ( ) . audio ; return list == null ? null : list . toArray ( new Audio [ ] { } ) ; }
Retrieves the audio clips associated with this WAudio .
18,928
public boolean isVisible ( ) { if ( ! super . isVisible ( ) ) { return false ; } Audio [ ] audio = getAudio ( ) ; return audio != null && audio . length > 0 ; }
Override isVisible to also return false if there are no audio clips to play .
18,929
public void handleRequest ( final Request request ) { super . handleRequest ( request ) ; if ( isDisabled ( ) ) { return ; } String targ = request . getParameter ( Environment . TARGET_ID ) ; String audioFileRequested = request . getParameter ( AUDIO_INDEX_REQUEST_PARAM_KEY ) ; boolean contentReqested = targ != null &&...
When an audio element is rendered to the client the browser will make a second request to get the audio content . The handleRequest method has been overridden to detect whether the request is the content fetch request by looking for the parameter that we encode in the content url .
18,930
private WFieldLayout recursiveFieldLayout ( final int curr , final int startAt ) { WFieldLayout innerLayout = new WFieldLayout ( ) ; innerLayout . setLabelWidth ( 20 ) ; if ( curr == 0 && startAt == 0 ) { innerLayout . setMargin ( new Margin ( Size . LARGE , null , null , null ) ) ; } innerLayout . setOrdered ( true ) ...
Create a recursive field layout .
18,931
protected void handleFileUploadRequest ( final WMultiFileWidget widget , final XmlStringBuilder xml , final String uploadId ) { FileWidgetUpload file = widget . getFile ( uploadId ) ; if ( file == null ) { throw new SystemException ( "Invalid file id [" + uploadId + "] to render uploaded response." ) ; } int idx = widg...
Paint the response for the file uploaded in this request .
18,932
private String typesToString ( final List < String > types ) { if ( types == null || types . isEmpty ( ) ) { return null ; } StringBuffer typesString = new StringBuffer ( ) ; for ( Iterator < String > iter = types . iterator ( ) ; iter . hasNext ( ) ; ) { typesString . append ( iter . next ( ) ) ; if ( iter . hasNext (...
Flattens the list of accepted mime types into a format suitable for rendering .
18,933
protected void afterPaint ( final RenderContext renderContext ) { super . afterPaint ( renderContext ) ; if ( this . isPressed ( ) && renderContext instanceof WebXmlRenderContext ) { PrintWriter writer = ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) ; StringBuffer temp = dumpAll ( ) ; writer . println ( "<b...
Override afterPaint to paint the profile information if the button has been pressed .
18,934
public StringBuffer dumpAll ( ) { WComponent root = WebUtilities . getTop ( this ) ; Map < String , GroupData > compTallyByClass = new TreeMap < > ( ) ; GroupData compDataOverall = new GroupData ( ) ; StringBuffer out = new StringBuffer ( ) ; String className = root . getClass ( ) . getName ( ) ; out . append ( "<stron...
Dumps all the profiling information in textual format to a StringBuffer .
18,935
public final R inRangeWith ( TQProperty < R > highProperty , T value ) { expr ( ) . inRangeWith ( _name , highProperty . _name , value ) ; return _root ; }
Value in Range between 2 properties .
18,936
protected void afterPaint ( final RenderContext renderContext ) { super . afterPaint ( renderContext ) ; UicStats stats = new UicStats ( UIContextHolder . getCurrent ( ) ) ; stats . analyseWC ( this ) ; if ( renderContext instanceof WebXmlRenderContext ) { PrintWriter writer = ( ( WebXmlRenderContext ) renderContext ) ...
Override afterPaint to write the statistics after the component is painted .
18,937
public void setTreeModel ( final TreeItemModel treeModel ) { getOrCreateComponentModel ( ) . treeModel = treeModel ; clearItemIdMaps ( ) ; setSelectedRows ( null ) ; setExpandedRows ( null ) ; setCustomTree ( ( TreeItemIdNode ) null ) ; }
Sets the tree model which provides row data .
18,938
protected void clearItemIdMaps ( ) { if ( getScratchMap ( ) != null ) { getScratchMap ( ) . remove ( CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY ) ; getScratchMap ( ) . remove ( ALL_IDS_TO_INDEX_SCRATCH_MAP_KEY ) ; getScratchMap ( ) . remove ( EXPANDED_IDS_TO_INDEX_MAPPING_SCRATCH_MAP_KEY ) ; } }
Clear the item id maps from the scratch map .
18,939
public Map < String , TreeItemIdNode > getCustomIdNodeMap ( ) { if ( getScratchMap ( ) == null ) { return createCustomIdNodeMapping ( ) ; } Map < String , TreeItemIdNode > map = ( Map < String , TreeItemIdNode > ) getScratchMap ( ) . get ( CUSTOM_IDS_TO_NODE_SCRATCH_MAP_KEY ) ; if ( map == null ) { map = createCustomId...
Map an item id to its node in the custom tree . As this can be expensive save the map onto the scratch pad .
18,940
public Map < String , List < Integer > > getExpandedItemIdIndexMap ( ) { boolean expandedOnly = getExpandMode ( ) != ExpandMode . CLIENT ; if ( getScratchMap ( ) == null ) { if ( getCustomTree ( ) == null ) { return createItemIdIndexMap ( expandedOnly ) ; } else { return createExpandedCustomIdIndexMapping ( expandedOnl...
Map expanded item ids to their row index . As this can be expensive save the map onto the scratch pad .
18,941
protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; if ( isCurrentAjaxTrigger ( ) ) { AjaxOperation operation = AjaxHelper . getCurrentOperation ( ) ; if ( operation . isInternalAjaxRequest ( ) ) { operation . setAction ( AjaxOperation . AjaxAction . IN ) ; } } T...
Override preparePaint to register an AJAX operation .
18,942
protected void checkExpandedCustomNodes ( ) { TreeItemIdNode custom = getCustomTree ( ) ; if ( custom == null ) { return ; } Set < String > expanded = getExpandedRows ( ) ; for ( TreeItemIdNode node : custom . getChildren ( ) ) { processCheckExpandedCustomNodes ( node , expanded ) ; } }
Check if custom nodes that are expanded need their child nodes added from the model .
18,943
private void handleItemImageRequest ( final Request request ) { String itemId = request . getParameter ( ITEM_REQUEST_KEY ) ; if ( itemId == null ) { throw new SystemException ( "No tree item id provided for image request." ) ; } if ( ! isValidTreeItem ( itemId ) ) { throw new SystemException ( "Tree item id for an ima...
Handle a targeted request to retrieve the tree item image .
18,944
private void handleOpenItemRequest ( final Request request ) { String param = request . getParameter ( ITEM_REQUEST_KEY ) ; if ( param == null ) { throw new SystemException ( "No tree item id provided for open request." ) ; } int offset = getItemIdPrefix ( ) . length ( ) ; if ( param . length ( ) <= offset ) { throw ne...
Handles a request containing an open request .
18,945
private void handleShuffleState ( final Request request ) { String json = request . getParameter ( SHUFFLE_REQUEST_KEY ) ; if ( Util . empty ( json ) ) { return ; } TreeItemIdNode newTree ; try { newTree = TreeItemUtil . convertJsonToTree ( json ) ; } catch ( Exception e ) { LOG . warn ( "Could not parse JSON for shuff...
Handle the tree items that have been shuffled by the client .
18,946
private void handleExpandedState ( final Request request ) { String [ ] paramValue = request . getParameterValues ( getId ( ) + OPEN_REQUEST_KEY ) ; if ( paramValue == null ) { paramValue = new String [ 0 ] ; } String [ ] expandedRowIds = removeEmptyStrings ( paramValue ) ; Set < String > newExpansionIds = new HashSet ...
Handle the current expanded state .
18,947
private Map < String , List < Integer > > createItemIdIndexMap ( final boolean expandedOnly ) { Map < String , List < Integer > > map = new HashMap < > ( ) ; TreeItemModel treeModel = getTreeModel ( ) ; int rows = treeModel . getRowCount ( ) ; Set < String > expanded = null ; WTree . ExpandMode mode = getExpandMode ( )...
Map item ids to the row index .
18,948
private void processItemIdIndexMapping ( final Map < String , List < Integer > > map , final List < Integer > rowIndex , final TreeItemModel treeModel , final Set < String > expandedRows ) { String id = treeModel . getItemId ( rowIndex ) ; if ( id == null ) { return ; } map . put ( id , rowIndex ) ; if ( ! treeModel . ...
Iterate through the table model to add the item ids and their row index .
18,949
private Map < String , TreeItemIdNode > createCustomIdNodeMapping ( ) { TreeItemIdNode custom = getCustomTree ( ) ; if ( custom == null ) { return Collections . EMPTY_MAP ; } Map < String , TreeItemIdNode > map = new HashMap < > ( ) ; processCustomIdNodeMapping ( map , custom ) ; return Collections . unmodifiableMap ( ...
Create the map between the custom item id and its node .
18,950
private void processCustomIdNodeMapping ( final Map < String , TreeItemIdNode > map , final TreeItemIdNode node ) { String itemId = node . getItemId ( ) ; if ( ! Util . empty ( itemId ) ) { map . put ( itemId , node ) ; } for ( TreeItemIdNode childItem : node . getChildren ( ) ) { processCustomIdNodeMapping ( map , chi...
Iterate over the custom tree structure to add entries to the map .
18,951
private Map < String , List < Integer > > createExpandedCustomIdIndexMapping ( final boolean expandedOnly ) { TreeItemIdNode custom = getCustomTree ( ) ; if ( custom == null ) { return Collections . EMPTY_MAP ; } Set < String > expanded = null ; if ( expandedOnly ) { expanded = getExpandedRows ( ) ; } Map < String , Li...
Crate a map of the expanded custom item ids and their row index .
18,952
private void loadCustomNodeChildren ( final TreeItemIdNode node ) { if ( ! node . hasChildren ( ) || ! node . getChildren ( ) . isEmpty ( ) ) { return ; } String itemId = node . getItemId ( ) ; List < Integer > rowIndex = getRowIndexForCustomItemId ( itemId ) ; TreeItemModel model = getTreeModel ( ) ; if ( ! model . is...
Load the children of a custom node that was flagged as having children .
18,953
private String getRole ( final WMenuItem item ) { if ( ! item . isSelectAllowed ( ) ) { return null ; } MenuSelectContainer selectContainer = WebUtilities . getAncestorOfClass ( MenuSelectContainer . class , item ) ; if ( selectContainer == null ) { return CHECKBOX_ROLE ; } return MenuSelectContainer . SelectionMode . ...
The selection mode of the menu item .
18,954
public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WMenuItem item = ( WMenuItem ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "ui:menuitem" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute...
Paints the given WMenuItem .
18,955
public void show ( ) { StringBuffer out = new StringBuffer ( ) ; for ( Iterator iter = repeater . getBeanList ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { MyData data = ( MyData ) iter . next ( ) ; out . append ( data . getName ( ) ) . append ( " : " ) . append ( data . getCount ( ) ) . append ( '\n' ) ; } selectorTex...
Show the current list of beans used by the repeater .
18,956
public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WMessageBox messageBox = ( WMessageBox ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; if ( messageBox . hasMessages ( ) ) { xml . appendTagOpen ( "ui:messagebox" ) ; xml . appendAttribute ( "id" , compo...
Paints the given WMessageBox .
18,957
protected void preparePaintComponent ( final Request request ) { if ( ! isInitialised ( ) ) { MyDataBean myBean = new MyDataBean ( ) ; myBean . setName ( "My Bean" ) ; myBean . addBean ( new SomeDataBean ( "blah" , "more blah" ) ) ; myBean . addBean ( new SomeDataBean ( ) ) ; repeaterFields . setData ( myBean ) ; setIn...
Override preparepaint to initialise the data on first acecss by a user .
18,958
public void serviceRequest ( final Request request ) { if ( "POST" . equals ( request . getMethod ( ) ) ) { SubordinateControlHelper . applyRegisteredControls ( request , true ) ; } super . serviceRequest ( request ) ; }
Before servicing the request apply the registered subordinate controls to make sure any state changes that have occurred on the client are applied .
18,959
public void preparePaint ( final Request request ) { SubordinateControlHelper . clearAllRegisteredControls ( ) ; super . preparePaint ( request ) ; SubordinateControlHelper . applyRegisteredControls ( request , false ) ; }
After the prepare paint phase apply the registered subordinate controls to make sure all the components are in the correct state before being rendered to the client .
18,960
public synchronized WComponent getUI ( final Object httpServletRequest ) { String configuredUIClassName = getComponentToLaunchClassName ( ) ; if ( sharedUI == null || ! Util . equals ( configuredUIClassName , uiClassName ) ) { uiClassName = configuredUIClassName ; WComponent ui = createUI ( ) ; if ( ui instanceof WAppl...
This method has been overridden to load a WComponent from parameters .
18,961
protected WComponent createUI ( ) { WComponent sharedApp ; uiClassName = getComponentToLaunchClassName ( ) ; if ( uiClassName == null ) { sharedApp = new WText ( "You need to set the class name of the WComponent you want to run.<br />" + "Do this by setting the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" in you...
Creates the UI which the launcher displays . If there is misconfiguration or error a UI containing an error message is returned .
18,962
private void createExampleUi ( ) { add ( new WHeading ( HeadingLevel . H2 , "Contacts" ) ) ; add ( repeater ) ; WButton addBtn = new WButton ( "Add" ) ; addBtn . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { addNewContact ( ) ; } } ) ; newNameField . setDefaultSubmitButton ( addBtn ) ; ...
Add all the required UI artefacts for this example .
18,963
private void printEditedDetails ( ) { StringBuilder buf = new StringBuilder ( ) ; for ( Object contact : repeater . getBeanList ( ) ) { buf . append ( contact ) . append ( '\n' ) ; } console . setText ( buf . toString ( ) ) ; }
Write the list of contacts into the textarea console . Any modified phone numbers should be printed out .
18,964
public List < ? > getNotSelected ( ) { List options = getOptions ( ) ; if ( options == null || options . isEmpty ( ) ) { return Collections . EMPTY_LIST ; } List notSelected = new ArrayList ( options ) ; notSelected . removeAll ( getSelected ( ) ) ; return Collections . unmodifiableList ( notSelected ) ; }
Returns the options which are not selected .
18,965
protected List < ? > getNewSelections ( final Request request ) { String [ ] paramValues = request . getParameterValues ( getId ( ) ) ; if ( paramValues == null || paramValues . length == 0 ) { return NO_SELECTION ; } List < String > values = Arrays . asList ( paramValues ) ; List < Object > newSelections = new ArrayLi...
Determines which selections have been added in the given request .
18,966
protected void validateComponent ( final List < Diagnostic > diags ) { super . validateComponent ( diags ) ; List < ? > selected = getValue ( ) ; if ( ! selected . isEmpty ( ) ) { int value = selected . size ( ) ; int min = getMinSelect ( ) ; int max = getMaxSelect ( ) ; if ( min > 0 && value < min ) { diags . add ( cr...
Override WInput s validateComponent to perform further validation on the options selected .
18,967
public void handleRequest ( final Request request ) { String clientState = request . getParameter ( getId ( ) ) ; if ( clientState != null ) { setCollapsed ( clientState . equalsIgnoreCase ( "closed" ) ) ; } }
Override handleRequest to perform processing necessary for this component . This is used to handle the server - side collapsible mode and to synchronise with the client - side state for the other modes .
18,968
protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; if ( content != null ) { switch ( getMode ( ) ) { case EAGER : { content . setVisible ( true ) ; AjaxHelper . registerContainer ( getId ( ) , getId ( ) + "-content" , content . getId ( ) ) ; break ; } case LAZY ...
Override preparePaintComponent in order to toggle the visibility of the content or to register the appropriate ajax operation .
18,969
public final void setMax ( final int max ) { if ( max < 0 ) { throw new IllegalArgumentException ( ILLEGAL_MAX ) ; } if ( max != getMax ( ) ) { getOrCreateComponentModel ( ) . max = max ; } }
Sets the maximum value of the progress bar .
18,970
public int getValue ( ) { int max = getMax ( ) ; Integer data = ( Integer ) getData ( ) ; return data == null ? 0 : Math . max ( 0 , Math . min ( max , data ) ) ; }
Retrieves the value of the progress bar .
18,971
public final void setProgressBarType ( final ProgressBarType type ) { ProgressBarType currentType = getProgressBarType ( ) ; ProgressBarType typeToSet = type == null ? DEFAULT_TYPE : type ; if ( typeToSet != currentType ) { getOrCreateComponentModel ( ) . barType = typeToSet ; } }
Sets the progress bar type .
18,972
private void buildControl ( ) { buildControlPanel . reset ( ) ; buildTargetPanel . reset ( ) ; setupTrigger ( ) ; SubordinateTarget target = setupTarget ( ) ; com . github . bordertech . wcomponents . subordinate . Action trueAction ; com . github . bordertech . wcomponents . subordinate . Action falseAction ; switch (...
Build the subordinate control .
18,973
private void setupTrigger ( ) { String label = drpTriggerType . getSelected ( ) + " Trigger" ; WFieldLayout layout = new WFieldLayout ( ) ; layout . setLabelWidth ( LABEL_WIDTH ) ; buildControlPanel . add ( layout ) ; switch ( ( TriggerType ) drpTriggerType . getSelected ( ) ) { case RadioButtonGroup : trigger = new Ra...
Setup the trigger for the subordinate control .
18,974
private void setPresets ( ) { TriggerType selectedTrigger = ( TriggerType ) drpTriggerType . getSelected ( ) ; comboField . setVisible ( selectedTrigger != TriggerType . DateField && selectedTrigger != TriggerType . NumberField ) ; dateField . setVisible ( selectedTrigger == TriggerType . DateField ) ; numberField . se...
Setup the default values for the configuration options .
18,975
public R jsonEqualTo ( String path , Object value ) { expr ( ) . jsonEqualTo ( _name , path , value ) ; return _root ; }
Value at the given JSON path is equal to the given value .
18,976
public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WProgressBar progressBar = ( WProgressBar ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "html:progress" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendAt...
Paints the given WProgressBar .
18,977
private void applySettings ( ) { buttonContainer . reset ( ) ; WButton exampleButton = new WButton ( tfButtonLabel . getText ( ) ) ; exampleButton . setRenderAsLink ( cbRenderAsLink . isSelected ( ) ) ; exampleButton . setText ( tfButtonLabel . getText ( ) ) ; if ( cbSetImage . isSelected ( ) ) { exampleButton . setIma...
this is were the majority of the work is done for building the button . Note that it is in a container that is reset effectively creating a new button . this is only done to enable to dynamically change the button to a link and back .
18,978
public void setLeftColumn ( final String heading , final WComponent content ) { setLeftColumn ( new WHeading ( WHeading . MINOR , heading ) , content ) ; }
Sets the left column content .
18,979
public void setRightColumn ( final String heading , final WComponent content ) { setRightColumn ( new WHeading ( WHeading . MINOR , heading ) , content ) ; }
Sets the right column content .
18,980
private void setContent ( final WColumn column , final WHeading heading , final WComponent content ) { column . removeAll ( ) ; if ( heading != null ) { column . add ( heading ) ; } if ( content != null ) { column . add ( content ) ; } if ( hasLeftContent ( ) && hasRightContent ( ) ) { leftColumn . setWidth ( 50 ) ; ri...
Sets the content of the given column and updates the column widths and visibilities .
18,981
public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WTab tab = ( WTab ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "ui:tab" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , com...
Paints the given WTab .
18,982
public String getText ( ) { String text = super . getText ( ) ; FilterTextModel model = getComponentModel ( ) ; if ( text != null && model . search != null && model . replace != null ) { text = text . replaceAll ( model . search , model . replace ) ; } return text ; }
Override in order to filter the encoded text .
18,983
public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WTree tree = ( WTree ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; String openId = tree . getOpenRequestItemId ( ) ; if ( openId != null ) { handleOpenItemRequest ( tree , xml , openId ) ; return ; } T...
Paints the given WTree .
18,984
protected void handleOpenItemRequest ( final WTree tree , final XmlStringBuilder xml , final String itemId ) { TreeItemModel model = tree . getTreeModel ( ) ; Set < String > selectedRows = new HashSet ( tree . getSelectedRows ( ) ) ; WTree . ExpandMode mode = tree . getExpandMode ( ) ; Set < String > expandedRows = new...
Paint the item that was on the open request .
18,985
protected void handlePaintItems ( final WTree tree , final XmlStringBuilder xml ) { TreeItemModel model = tree . getTreeModel ( ) ; int rows = model . getRowCount ( ) ; if ( rows > 0 ) { Set < String > selectedRows = new HashSet ( tree . getSelectedRows ( ) ) ; Set < String > expandedRows = new HashSet ( tree . getExpa...
Paint the tree items .
18,986
protected void paintItem ( final WTree tree , final WTree . ExpandMode mode , final TreeItemModel model , final List < Integer > rowIndex , final XmlStringBuilder xml , final Set < String > selectedRows , final Set < String > expandedRows ) { String itemId = model . getItemId ( rowIndex ) ; boolean selected = selectedR...
Iterate of over the rows to render the tree items .
18,987
protected void handlePaintCustom ( final WTree tree , final XmlStringBuilder xml ) { TreeItemModel model = tree . getTreeModel ( ) ; TreeItemIdNode root = tree . getCustomTree ( ) ; Set < String > selectedRows = new HashSet ( tree . getSelectedRows ( ) ) ; Set < String > expandedRows = new HashSet ( tree . getExpandedR...
Paint the custom tree layout .
18,988
protected void paintCustomItem ( final WTree tree , final WTree . ExpandMode mode , final TreeItemModel model , final TreeItemIdNode node , final XmlStringBuilder xml , final Set < String > selectedRows , final Set < String > expandedRows ) { String itemId = node . getItemId ( ) ; List < Integer > rowIndex = tree . get...
Iterate of over the nodes to render the custom layout of the tree items .
18,989
private Action buttonAction ( final String preface ) { return new Action ( ) { public void execute ( final ActionEvent event ) { StringBuffer buf = new StringBuffer ( preface ) ; buf . append ( "\n" ) ; for ( Object selected : wTable . getSelectedRows ( ) ) { PersonBean person = ( PersonBean ) selected ; buf . append (...
Common action for the table buttons .
18,990
public static Map < String , WComponent > mapTaggedComponents ( final Map < String , Object > context , final Map < String , WComponent > taggedComponents ) { Map < String , WComponent > componentsByKey = new HashMap < > ( ) ; for ( Map . Entry < String , WComponent > tagged : taggedComponents . entrySet ( ) ) { String...
Replace each component tag with the key so it can be used in the replace writer .
18,991
public void setHead ( final WComponent head ) { DecoratedLabelModel model = getOrCreateComponentModel ( ) ; if ( model . head != null ) { remove ( model . head ) ; } model . head = head ; if ( head != null ) { add ( head ) ; } }
Sets the label head content .
18,992
public void setBody ( final WComponent body ) { DecoratedLabelModel model = getOrCreateComponentModel ( ) ; if ( body == null ) { throw new IllegalArgumentException ( "Body content must not be null" ) ; } if ( model . body != null ) { remove ( model . body ) ; } model . body = body ; add ( body ) ; }
Sets the label body content .
18,993
public void setTail ( final WComponent tail ) { DecoratedLabelModel model = getOrCreateComponentModel ( ) ; if ( model . tail != null ) { remove ( model . tail ) ; } model . tail = tail ; if ( tail != null ) { add ( tail ) ; } }
Sets the label tail content .
18,994
public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WTimeoutWarning warning = ( WTimeoutWarning ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; final int timoutPeriod = warning . getTimeoutPeriod ( ) ; if ( timoutPeriod > 0 ) { xml . appendTagOpen ( "ui:s...
Paints the given WTimeoutWarning if the component s timeout period is greater than 0 .
18,995
public void render ( final WComponent component , final RenderContext renderContext ) { if ( renderContext instanceof WebXmlRenderContext ) { doRender ( component , ( WebXmlRenderContext ) renderContext ) ; } else { throw new SystemException ( "Unable to render web xml output to " + renderContext ) ; } }
Renders the component .
18,996
protected final void paintChildren ( final Container container , final WebXmlRenderContext renderContext ) { final int size = container . getChildCount ( ) ; for ( int i = 0 ; i < size ; i ++ ) { WComponent child = container . getChildAt ( i ) ; child . paint ( renderContext ) ; } }
Paints the children of the given component .
18,997
public void logVelocityMessage ( final int level , final String message ) { switch ( level ) { case LogSystem . WARN_ID : LOG . warn ( message ) ; break ; case LogSystem . INFO_ID : LOG . info ( message ) ; break ; case LogSystem . DEBUG_ID : LOG . debug ( message ) ; break ; case LogSystem . ERROR_ID : LOG . error ( m...
Log velocity engine messages .
18,998
public static String getCombinedForSection ( final String sectionName , final String ... args ) { return getCombinedAutocomplete ( getNamedSection ( sectionName ) , args ) ; }
Combine autocomplete values into a single String suitable to apply to a named auto - fill section .
18,999
public void addToGroup ( final T component ) { ComponentGroupModel model = getOrCreateComponentModel ( ) ; model . components . add ( component ) ; MemoryUtil . checkSize ( model . components . size ( ) , this . getClass ( ) . getSimpleName ( ) ) ; }
Add a component to this group .