idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
18,800 | private void updateRegion ( ) { actMessage . setVisible ( false ) ; String state = ( String ) stateSelector . getSelected ( ) ; if ( STATE_ACT . equals ( state ) ) { actMessage . setVisible ( true ) ; regionSelector . setOptions ( new String [ ] { null , "Belconnen" , "City" , "Woden" } ) ; } else if ( STATE_NSW . equals ( state ) ) { regionSelector . setOptions ( new String [ ] { null , "Hunter" , "Riverina" , "Southern Tablelands" } ) ; } else if ( STATE_VIC . equals ( state ) ) { regionSelector . setOptions ( new String [ ] { null , "Gippsland" , "Melbourne" , "Mornington Peninsula" } ) ; } else { regionSelector . setOptions ( new Object [ ] { null } ) ; } } | Updates the options present in the region selector depending on the state selector s value . |
18,801 | public static InterceptorComponent replaceInterceptor ( final Class match , final InterceptorComponent replacement , final InterceptorComponent chain ) { if ( chain == null ) { return null ; } InterceptorComponent current = chain ; InterceptorComponent previous = null ; InterceptorComponent updatedChain = null ; while ( updatedChain == null ) { if ( match . isInstance ( current ) ) { replacement . setBackingComponent ( current . getBackingComponent ( ) ) ; if ( previous == null ) { updatedChain = replacement ; } else { previous . setBackingComponent ( replacement ) ; updatedChain = chain ; } } else { previous = current ; WebComponent next = current . getBackingComponent ( ) ; if ( next instanceof InterceptorComponent ) { current = ( InterceptorComponent ) next ; } else { updatedChain = chain ; } } } return updatedChain ; } | Utility method for replacing an individual interceptor within an existing chain . |
18,802 | protected static String render ( final WebComponent component ) { StringWriter stringWriter = new StringWriter ( ) ; PrintWriter printWriter = new PrintWriter ( stringWriter ) ; component . paint ( new WebXmlRenderContext ( printWriter ) ) ; printWriter . flush ( ) ; String content = stringWriter . toString ( ) ; return content ; } | Renders the given component to a web - XML String and returns it . This occurs outside the context of a Servlet . |
18,803 | public void attachUI ( final WComponent ui ) { if ( backing == null || backing instanceof WComponent ) { backing = ui ; } else if ( backing instanceof InterceptorComponent ) { ( ( InterceptorComponent ) backing ) . attachUI ( ui ) ; } else { throw new IllegalStateException ( "Unable to attachUI. Unknown type of WebComponent encountered. " + backing . getClass ( ) . getName ( ) ) ; } } | Add the WComponent to the end of the interceptor chain . |
18,804 | public void setAlignment ( final int col , final Alignment alignment ) { columnAlignments [ col ] = alignment == null ? Alignment . LEFT : alignment ; } | Sets the alignment of the given column . An IndexOutOfBoundsException will be thrown if col is out of bounds . |
18,805 | public static void copy ( final InputStream in , final OutputStream out ) throws IOException { copy ( in , out , DEFAULT_BUFFER_SIZE ) ; } | Copies information from the input stream to the output stream using the default copy buffer size . |
18,806 | public static void copy ( final InputStream in , final OutputStream out , final int bufferSize ) throws IOException { final byte [ ] buf = new byte [ bufferSize ] ; int bytesRead = in . read ( buf ) ; while ( bytesRead != - 1 ) { out . write ( buf , 0 , bytesRead ) ; bytesRead = in . read ( buf ) ; } out . flush ( ) ; } | Copies information from the input stream to the output stream using a specified buffer size . |
18,807 | public static void safeClose ( final Closeable stream ) { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { LOG . error ( "Failed to close resource stream" , e ) ; } } } | Closes an OutputStream logging any exceptions . |
18,808 | public void applySettings ( ) { messageList . clear ( ) ; messageList . add ( "" ) ; for ( int i = 1 ; messageBox . getMessages ( ) . size ( ) >= i ; i ++ ) { messageList . add ( String . valueOf ( i ) ) ; } selRemove . setOptions ( messageList ) ; selRemove . resetData ( ) ; btnRemove . setDisabled ( messageList . isEmpty ( ) ) ; btnRemoveAll . setDisabled ( messageList . isEmpty ( ) ) ; messageBox . setType ( ( com . github . bordertech . wcomponents . WMessageBox . Type ) messageBoxTypeSelect . getSelected ( ) ) ; messageBox . setVisible ( cbVisible . isSelected ( ) ) ; if ( tfTitle . getText ( ) != null && ! "" . equals ( tfTitle . getText ( ) ) ) { messageBox . setTitleText ( tfTitle . getText ( ) ) ; } else { messageBox . setTitleText ( null ) ; } } | applySettings is used to apply the setting to the various controls on the page . |
18,809 | public void escape ( ) throws IOException { LOG . debug ( "...ContentEscape escape()" ) ; if ( contentAccess == null ) { LOG . warn ( "No content to output" ) ; } else { String mimeType = contentAccess . getMimeType ( ) ; Response response = getResponse ( ) ; response . setContentType ( mimeType ) ; if ( isCacheable ( ) ) { getResponse ( ) . setHeader ( "Cache-Control" , CacheType . CONTENT_CACHE . getSettings ( ) ) ; } else { getResponse ( ) . setHeader ( "Cache-Control" , CacheType . CONTENT_NO_CACHE . getSettings ( ) ) ; } if ( contentAccess . getDescription ( ) != null ) { String fileName = WebUtilities . encodeForContentDispositionHeader ( contentAccess . getDescription ( ) ) ; if ( displayInline ) { response . setHeader ( "Content-Disposition" , "inline; filename=" + fileName ) ; } else { response . setHeader ( "Content-Disposition" , "attachment; filename=" + fileName ) ; } } if ( contentAccess instanceof ContentStreamAccess ) { InputStream stream = null ; try { stream = ( ( ContentStreamAccess ) contentAccess ) . getStream ( ) ; if ( stream == null ) { throw new SystemException ( "ContentAccess returned null stream, access=" + contentAccess ) ; } StreamUtil . copy ( stream , response . getOutputStream ( ) ) ; } finally { StreamUtil . safeClose ( stream ) ; } } else { byte [ ] bytes = contentAccess . getBytes ( ) ; if ( bytes == null ) { throw new SystemException ( "ContentAccess returned null data, access=" + contentAccess ) ; } response . getOutputStream ( ) . write ( bytes ) ; } } } | Writes the content to the response . |
18,810 | public Embed createEmbed ( String url ) { return getResourceFactory ( ) . getApiResource ( "/embed/" ) . entity ( new EmbedCreate ( url ) , MediaType . APPLICATION_JSON_TYPE ) . post ( Embed . class ) ; } | Grabs metadata and returns metadata for the given url such as title description and thumbnails . |
18,811 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WField field = ( WField ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; int inputWidth = field . getInputWidth ( ) ; xml . appendTagOpen ( "ui:field" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , field . isHidden ( ) , "true" ) ; xml . appendOptionalAttribute ( "inputWidth" , inputWidth > 0 , inputWidth ) ; xml . appendClose ( ) ; WLabel label = field . getLabel ( ) ; if ( label != null ) { label . paint ( renderContext ) ; } if ( field . getField ( ) != null ) { xml . appendTag ( "ui:input" ) ; field . getField ( ) . paint ( renderContext ) ; if ( field . getErrorIndicator ( ) != null ) { field . getErrorIndicator ( ) . paint ( renderContext ) ; } if ( field . getWarningIndicator ( ) != null ) { field . getWarningIndicator ( ) . paint ( renderContext ) ; } xml . appendEndTag ( "ui:input" ) ; } xml . appendEndTag ( "ui:field" ) ; } | Paints the given WField . |
18,812 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "hr" ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendEnd ( ) ; } | Paints the given WHorizontalRule . |
18,813 | private void addMenuItem ( final WComponent parent , final String text , final WText selectedMenuText ) { WMenuItem menuItem = new WMenuItem ( text , new ExampleMenuAction ( selectedMenuText ) ) ; menuItem . setActionObject ( text ) ; if ( parent instanceof WSubMenu ) { ( ( WSubMenu ) parent ) . add ( menuItem ) ; } else { ( ( WMenuItemGroup ) parent ) . add ( menuItem ) ; } } | Adds an example menu item with the given text and an example action to the a parent component . |
18,814 | private WMenuItem createImageMenuItem ( final String resource , final String desc , final String cacheKey , final WText selectedMenuText ) { WImage image = new WImage ( resource , desc ) ; image . setCacheKey ( cacheKey ) ; WDecoratedLabel label = new WDecoratedLabel ( image , new WText ( desc ) , null ) ; WMenuItem menuItem = new WMenuItem ( label , new ExampleMenuAction ( selectedMenuText ) ) ; menuItem . setActionObject ( desc ) ; return menuItem ; } | Creates an example menu item using an image . |
18,815 | public void setPaddingChar ( final char paddingChar ) { if ( Character . isDigit ( paddingChar ) ) { throw new IllegalArgumentException ( "Padding character should not be a digit." ) ; } getOrCreateComponentModel ( ) . paddingChar = paddingChar ; } | The padding character used in the partial date value . The default padding character is a space . If the padding character is a space then the date value will be right trimmed to remove the trailing spaces . |
18,816 | protected void validateComponent ( final List < Diagnostic > diags ) { if ( isValidDate ( ) ) { super . validateComponent ( diags ) ; } else { diags . add ( createErrorDiagnostic ( getComponentModel ( ) . errorMessage , this ) ) ; } } | Override WInput s validateComponent to perform further validation on the date . A partial date is invalid if there was text submitted but no date components were parsed . |
18,817 | public void setDate ( final Date date ) { if ( date == null ) { setPartialDate ( null , null , null ) ; } else { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; Integer year = cal . get ( Calendar . YEAR ) ; Integer month = cal . get ( Calendar . MONTH ) + 1 ; Integer day = cal . get ( Calendar . DAY_OF_MONTH ) ; setPartialDate ( day , month , year ) ; } } | Set the WPartialDateField with the given java date . |
18,818 | public Integer getDay ( ) { String dateValue = getValue ( ) ; if ( dateValue != null && dateValue . length ( ) == DAY_END ) { return parseDateComponent ( dateValue . substring ( DAY_START , DAY_END ) , getPaddingChar ( ) ) ; } else { return null ; } } | Returns the day of the month value . |
18,819 | public Integer getMonth ( ) { String dateValue = getValue ( ) ; if ( dateValue != null && dateValue . length ( ) >= MONTH_END ) { return parseDateComponent ( dateValue . substring ( MONTH_START , MONTH_END ) , getPaddingChar ( ) ) ; } else { return null ; } } | Returns the month value . |
18,820 | public Integer getYear ( ) { String dateValue = getValue ( ) ; if ( dateValue != null && dateValue . length ( ) >= YEAR_END ) { return parseDateComponent ( dateValue . substring ( YEAR_START , YEAR_END ) , getPaddingChar ( ) ) ; } else { return null ; } } | Returns the year value . |
18,821 | public Date getDate ( ) { if ( getYear ( ) != null && getMonth ( ) != null && getDay ( ) != null ) { return DateUtilities . createDate ( getDay ( ) , getMonth ( ) , getYear ( ) ) ; } return null ; } | Returns the java date value else null if the value cannot be parsed . |
18,822 | private boolean isValidCharacters ( final String component , final char padding ) { boolean paddingChars = false ; boolean digitChars = false ; for ( int i = 0 ; i < component . length ( ) ; i ++ ) { char chr = component . charAt ( i ) ; if ( chr == padding ) { if ( digitChars ) { return false ; } paddingChars = true ; } else if ( chr >= '0' && chr <= '9' ) { if ( paddingChars ) { return false ; } digitChars = true ; } else { return false ; } } return true ; } | Check the component is either all padding chars or all digit chars . |
18,823 | public static String getPathToRoot ( final WComponent component ) { StringBuffer buf = new StringBuffer ( ) ; for ( WComponent node = component ; node != null ; node = node . getParent ( ) ) { if ( buf . length ( ) != 0 ) { buf . insert ( 0 , '\n' ) ; } buf . insert ( 0 , node . getClass ( ) . getName ( ) ) ; } return buf . toString ( ) ; } | Retrieves a path of component classes from the given component to the root node . The path is formatted with one component on each line with the first line being the root node . |
18,824 | public static < T > T getAncestorOfClass ( final Class < T > clazz , final WComponent comp ) { if ( comp == null || clazz == null ) { return null ; } WComponent parent = comp . getParent ( ) ; while ( parent != null ) { if ( clazz . isInstance ( parent ) ) { return ( T ) parent ; } parent = parent . getParent ( ) ; } return null ; } | Attempts to find a component which is an ancestor of the given component and that is assignable to the given class . |
18,825 | public static WComponent getTop ( final WComponent comp ) { WComponent top = comp ; for ( WComponent parent = top . getParent ( ) ; parent != null ; parent = parent . getParent ( ) ) { top = parent ; } return top ; } | Retrieves the top - level WComponent in the tree . |
18,826 | public static String encodeUrl ( final String urlStr ) { if ( Util . empty ( urlStr ) ) { return urlStr ; } String percentEncode = percentEncodeUrl ( urlStr ) ; return encode ( percentEncode ) ; } | Encode URL for XML . |
18,827 | public static String percentEncodeUrl ( final String urlStr ) { if ( Util . empty ( urlStr ) ) { return urlStr ; } try { String decode = URIUtil . decode ( urlStr ) ; URI uri = new URI ( decode , false ) ; return uri . getEscapedURIReference ( ) ; } catch ( Exception e ) { return urlStr ; } } | Percent encode a URL to include in HTML . |
18,828 | public static String escapeForUrl ( final String input ) { if ( input == null || input . length ( ) == 0 ) { return input ; } final StringBuilder buffer = new StringBuilder ( input . length ( ) * 2 ) ; char [ ] characters = input . toCharArray ( ) ; for ( int i = 0 , len = input . length ( ) ; i < len ; ++ i ) { final char ch = characters [ i ] ; if ( ( ch >= 'A' && ch <= 'Z' ) || ( ch >= 'a' && ch <= 'z' ) || ( ch >= '0' && ch <= '9' ) || ch == '-' || ch == '_' || ch == '.' || ch == '~' ) { buffer . append ( ch ) ; } else if ( ch <= 127 ) { final String hexString = Integer . toHexString ( ch ) ; if ( hexString . length ( ) == 1 ) { buffer . append ( "%0" ) . append ( hexString ) ; } else { buffer . append ( '%' ) . append ( hexString ) ; } } else if ( ch <= 0x07FF ) { buffer . append ( '%' ) . append ( Integer . toHexString ( 0xc0 | ( ch >> 6 ) ) ) ; buffer . append ( '%' ) . append ( Integer . toHexString ( 0x80 | ( ch & 0x3F ) ) ) ; } else { buffer . append ( '%' ) . append ( Integer . toHexString ( 0xe0 | ( ch >> 12 ) ) ) ; buffer . append ( '%' ) . append ( Integer . toHexString ( 0x80 | ( ( ch >> 6 ) & 0x3F ) ) ) ; buffer . append ( '%' ) . append ( Integer . toHexString ( 0x80 | ( ch & 0x3F ) ) ) ; } } return buffer . toString ( ) ; } | Escapes the given string to make it presentable in a URL . This follows RFC 3986 with some extensions for UTF - 8 . |
18,829 | public static String encode ( final String input ) { if ( input == null || input . length ( ) == 0 ) { return input ; } return ENCODE . translate ( input ) ; } | Encode all the special characters found in the given string to their escape sequences according to the XML specification and returns the resultant string . Eg . cat& ; dog > ; ant becomes cat& ; amp ; dog & ; gt ; ant . |
18,830 | public static String decode ( final String encoded ) { if ( encoded == null || encoded . length ( ) == 0 || encoded . indexOf ( '&' ) == - 1 ) { return encoded ; } return DECODE . translate ( encoded ) ; } | This method is required on occasion because WebSphere Portal by default escapes < ; and > ; characters for security reasons . |
18,831 | public static String encodeBrackets ( final String input ) { if ( input == null || input . length ( ) == 0 ) { return input ; } return ENCODE_BRACKETS . translate ( input ) ; } | Encode open or closed brackets in the input String . |
18,832 | public static String decodeBrackets ( final String input ) { if ( input == null || input . length ( ) == 0 ) { return input ; } return DECODE_BRACKETS . translate ( input ) ; } | Decode open or closed brackets in the input String . |
18,833 | public static String doubleEncodeBrackets ( final String input ) { if ( input == null || input . length ( ) == 0 ) { return input ; } return DOUBLE_ENCODE_BRACKETS . translate ( input ) ; } | Double encode open or closed brackets in the input String . |
18,834 | public static String doubleDecodeBrackets ( final String input ) { if ( input == null || input . length ( ) == 0 ) { return input ; } return DOUBLE_DECODE_BRACKETS . translate ( input ) ; } | Decode double encoded open or closed brackets in the input String . |
18,835 | public static void appendGetParamForJavascript ( final String key , final String value , final StringBuffer vars , final boolean existingVars ) { vars . append ( existingVars ? '&' : '?' ) ; vars . append ( key ) . append ( '=' ) . append ( WebUtilities . escapeForUrl ( value ) ) ; } | This is a slightly different version of appendGetParam that doesn t encode the ampersand seperator . It is intended to be used in urls that are generated for javascript functions . |
18,836 | public static String generateRandom ( ) { long next = ATOMIC_COUNT . incrementAndGet ( ) ; StringBuffer random = new StringBuffer ( ) ; random . append ( new Date ( ) . getTime ( ) ) . append ( '-' ) . append ( next ) ; return random . toString ( ) ; } | Generates a random String . Can be useful for creating unique URLs by adding the String as a query parameter to the URL . |
18,837 | public static boolean isAncestor ( final WComponent component1 , final WComponent component2 ) { for ( WComponent parent = component2 . getParent ( ) ; parent != null ; parent = parent . getParent ( ) ) { if ( parent == component1 ) { return true ; } } return false ; } | Indicates whether a component is an ancestor of another . |
18,838 | public static UIContext getContextForComponent ( final WComponent component ) { UIContext result = UIContextHolder . getCurrent ( ) ; while ( result instanceof SubUIContext && ! ( ( SubUIContext ) result ) . isInContext ( component ) ) { result = ( ( SubUIContext ) result ) . getBacking ( ) ; } return result ; } | Returns the context for this component . The component may not be in the current context . |
18,839 | public static ComponentWithContext getComponentById ( final String id , final boolean visibleOnly ) { UIContext uic = UIContextHolder . getCurrent ( ) ; WComponent root = uic . getUI ( ) ; ComponentWithContext comp = TreeUtil . getComponentWithContextForId ( root , id , visibleOnly ) ; return comp ; } | Finds a component by its id . |
18,840 | public static UIContext findClosestContext ( final String id ) { UIContext uic = UIContextHolder . getCurrent ( ) ; WComponent root = uic . getUI ( ) ; UIContext closest = TreeUtil . getClosestContextForId ( root , id ) ; return closest ; } | Finds the closest context for the given component id . This handles the case where the component no longer exists due to having been removed from the UI or having a SubUIContext removed . |
18,841 | public static void updateBeanValue ( final WComponent component , final boolean visibleOnly ) { if ( ! component . isVisible ( ) && visibleOnly ) { return ; } if ( component instanceof WBeanComponent ) { ( ( WBeanComponent ) component ) . updateBeanValue ( ) ; } if ( component instanceof WDataTable || component instanceof WTable || component instanceof WRepeater ) { return ; } if ( component instanceof Container ) { for ( int i = ( ( Container ) component ) . getChildCount ( ) - 1 ; i >= 0 ; i -- ) { updateBeanValue ( ( ( Container ) component ) . getChildAt ( i ) , visibleOnly ) ; } } } | Updates the bean value with the current value of the component and all its bean - bound children . |
18,842 | public static String render ( final Request request , final WComponent component ) { boolean needsContext = UIContextHolder . getCurrent ( ) == null ; if ( needsContext ) { UIContextHolder . pushContext ( new UIContextImpl ( ) ) ; } try { StringWriter buffer = new StringWriter ( ) ; component . preparePaint ( request ) ; try ( PrintWriter writer = new PrintWriter ( buffer ) ) { component . paint ( new WebXmlRenderContext ( writer ) ) ; } return buffer . toString ( ) ; } finally { if ( needsContext ) { UIContextHolder . popContext ( ) ; } } } | Renders the given WComponent to a String outside of the context of a Servlet . This is good for getting hold of the XML for debugging unit testing etc . Also it is good for using the WComponent framework as a more generic templating framework . |
18,843 | public static String renderWithTransformToHTML ( final Request request , final WComponent component , final boolean includePageShell ) { boolean needsContext = UIContextHolder . getCurrent ( ) == null ; if ( needsContext ) { UIContextHolder . pushContext ( new UIContextImpl ( ) ) ; } try { InterceptorComponent templateRender = new TemplateRenderInterceptor ( ) ; InterceptorComponent transformXML = new TransformXMLInterceptor ( ) ; templateRender . setBackingComponent ( transformXML ) ; if ( includePageShell ) { transformXML . setBackingComponent ( new PageShellInterceptor ( ) ) ; } InterceptorComponent chain = templateRender ; chain . attachUI ( component ) ; chain . attachResponse ( new MockResponse ( ) ) ; StringWriter buffer = new StringWriter ( ) ; chain . preparePaint ( request ) ; try ( PrintWriter writer = new PrintWriter ( buffer ) ) { chain . paint ( new WebXmlRenderContext ( writer ) ) ; } return buffer . toString ( ) ; } finally { if ( needsContext ) { UIContextHolder . popContext ( ) ; } } } | Renders and transforms the given WComponent to a HTML String outside of the context of a Servlet . |
18,844 | public static String getContentType ( final String fileName ) { if ( Util . empty ( fileName ) ) { return ConfigurationProperties . getDefaultMimeType ( ) ; } String mimeType = null ; if ( fileName . lastIndexOf ( '.' ) > - 1 ) { String suffix = fileName . substring ( fileName . lastIndexOf ( '.' ) + 1 ) . toLowerCase ( ) ; mimeType = ConfigurationProperties . getFileMimeTypeForExtension ( suffix ) ; } if ( mimeType == null ) { mimeType = URLConnection . guessContentTypeFromName ( fileName ) ; if ( mimeType == null ) { mimeType = ConfigurationProperties . getDefaultMimeType ( ) ; } } return mimeType ; } | Attempts to guess the content - type for the given file name . |
18,845 | public static NamingContextable getParentNamingContext ( final WComponent component ) { if ( component == null ) { return null ; } WComponent child = component ; NamingContextable parent = null ; while ( true ) { NamingContextable naming = WebUtilities . getAncestorOfClass ( NamingContextable . class , child ) ; if ( naming == null ) { break ; } if ( WebUtilities . isActiveNamingContext ( naming ) ) { parent = naming ; break ; } child = naming ; } return parent ; } | Get this component s parent naming context . |
18,846 | private void updateBeanValueForColumnInRow ( final WTableRowRenderer rowRenderer , final UIContext rowContext , final List < Integer > rowIndex , final int col , final TableModel model ) { WComponent renderer = ( ( Container ) rowRenderer . getRenderer ( col ) ) . getChildAt ( 0 ) ; UIContextHolder . pushContext ( rowContext ) ; try { if ( renderer instanceof Container ) { WebUtilities . updateBeanValue ( renderer ) ; } else if ( renderer instanceof DataBound ) { Object oldValue = model . getValueAt ( rowIndex , col ) ; Object newValue = ( ( DataBound ) renderer ) . getData ( ) ; if ( ! Util . equals ( oldValue , newValue ) ) { model . setValueAt ( newValue , rowIndex , col ) ; } } } finally { UIContextHolder . popContext ( ) ; } } | Update the column in the row . |
18,847 | private void updateBeanValueForRowRenderer ( final WTableRowRenderer rowRenderer , final UIContext rowContext , final Class < ? extends WComponent > expandRenderer ) { Container expandWrapper = ( Container ) rowRenderer . getExpandedTreeNodeRenderer ( expandRenderer ) ; if ( expandWrapper == null ) { return ; } WComponent expandInstance = expandWrapper . getChildAt ( 0 ) ; UIContextHolder . pushContext ( rowContext ) ; try { WebUtilities . updateBeanValue ( expandInstance ) ; } finally { UIContextHolder . popContext ( ) ; } } | Update the expandable row renderer . |
18,848 | public void setSeparatorType ( final SeparatorType separatorType ) { getOrCreateComponentModel ( ) . separatorType = separatorType == null ? SeparatorType . NONE : separatorType ; } | Sets the separator used to visually separate rows or columns . |
18,849 | public void setStripingType ( final StripingType stripingType ) { getOrCreateComponentModel ( ) . stripingType = stripingType == null ? StripingType . NONE : stripingType ; } | Sets the striping type used to highlight alternate rows or columns . |
18,850 | public void setPaginationMode ( final PaginationMode paginationMode ) { getOrCreateComponentModel ( ) . paginationMode = paginationMode == null ? PaginationMode . NONE : paginationMode ; } | Sets the pagination mode . |
18,851 | public void setPaginationLocation ( final PaginationLocation location ) { getOrCreateComponentModel ( ) . paginationLocation = location == null ? PaginationLocation . AUTO : location ; } | Sets the location in the table to show the pagination controls . |
18,852 | public void setType ( final Type type ) { getOrCreateComponentModel ( ) . type = type == null ? Type . TABLE : type ; } | Sets the table type that controls how the table is displayed . |
18,853 | public void setSelectAllMode ( final SelectAllType selectAllMode ) { getOrCreateComponentModel ( ) . selectAllMode = selectAllMode == null ? SelectAllType . TEXT : selectAllMode ; } | Sets how the table row select all function should be displayed . |
18,854 | public List < WButton > getActions ( ) { final int numActions = actions . getChildCount ( ) ; List < WButton > buttons = new ArrayList < > ( numActions ) ; for ( int i = 0 ; i < numActions ; i ++ ) { WButton button = ( WButton ) actions . getChildAt ( i ) ; buttons . add ( button ) ; } return Collections . unmodifiableList ( buttons ) ; } | Retrieves the actions for the table . |
18,855 | public void addActionConstraint ( final WButton button , final ActionConstraint constraint ) { if ( button . getParent ( ) != actions ) { throw new IllegalArgumentException ( "Can only add a constraint to a button which is in this table's actions" ) ; } getOrCreateComponentModel ( ) . addActionConstraint ( button , constraint ) ; } | Adds a constraint to when the given action can be used . |
18,856 | public List < ActionConstraint > getActionConstraints ( final WButton button ) { List < ActionConstraint > constraints = getComponentModel ( ) . actionConstraints . get ( button ) ; return constraints == null ? null : Collections . unmodifiableList ( constraints ) ; } | Retrieves the constraints for the given action . |
18,857 | private void handleSortRequest ( final Request request ) { String sortColStr = request . getParameter ( getId ( ) + ".sort" ) ; String sortDescStr = request . getParameter ( getId ( ) + ".sortDesc" ) ; if ( sortColStr != null ) { if ( "" . equals ( sortColStr ) ) { setSort ( - 1 , false ) ; getOrCreateComponentModel ( ) . rowIndexMapping = null ; } else { try { int sortCol = Integer . parseInt ( sortColStr ) ; int [ ] cols = getColumnOrder ( ) ; if ( cols != null ) { sortCol = cols [ sortCol ] ; } boolean sortAsc = ! "true" . equalsIgnoreCase ( sortDescStr ) ; if ( sortCol != getSortColumnIndex ( ) || sortAsc != isSortAscending ( ) ) { sort ( sortCol , sortAsc ) ; setFocussed ( ) ; } } catch ( NumberFormatException e ) { LOG . warn ( "Invalid sort column: " + sortColStr ) ; } } } } | Handles a request containing sort instruction data . |
18,858 | public void sort ( final int sortCol , final boolean sortAsc ) { int [ ] rowIndexMappings = getTableModel ( ) . sort ( sortCol , sortAsc ) ; getOrCreateComponentModel ( ) . rowIndexMapping = rowIndexMappings ; setSort ( sortCol , sortAsc ) ; if ( rowIndexMappings == null ) { setSelectedRows ( null ) ; setExpandedRows ( null ) ; } } | Sort the table data by the specified column . |
18,859 | @ SuppressWarnings ( "checkstyle:parameternumber" ) private void calcChildrenRowIds ( final List < RowIdWrapper > rows , final RowIdWrapper row , final TableModel model , final RowIdWrapper parent , final Set < ? > expanded , final ExpandMode mode , final boolean forUpdate , final boolean editable ) { rows . add ( row ) ; if ( parent != null ) { parent . addChild ( row ) ; } List < Integer > rowIndex = row . getRowIndex ( ) ; if ( model . getRendererClass ( rowIndex ) != null ) { return ; } if ( ! model . isExpandable ( rowIndex ) ) { return ; } if ( ! model . hasChildren ( rowIndex ) ) { return ; } row . setHasChildren ( true ) ; boolean addChildren = ( mode == ExpandMode . CLIENT ) || ( expanded != null && expanded . contains ( row . getRowKey ( ) ) ) ; if ( ! addChildren ) { return ; } int children = model . getChildCount ( rowIndex ) ; if ( children == 0 ) { row . setHasChildren ( false ) ; return ; } if ( ! forUpdate && editable ) { addPrevExpandedRow ( row . getRowKey ( ) ) ; } for ( int i = 0 ; i < children ; i ++ ) { List < Integer > nextRow = new ArrayList < > ( row . getRowIndex ( ) ) ; nextRow . add ( i ) ; Object key = model . getRowKey ( nextRow ) ; RowIdWrapper wrapper = new RowIdWrapper ( nextRow , key , row ) ; calcChildrenRowIds ( rows , wrapper , model , row , expanded , mode , forUpdate , editable ) ; } } | Calculate the row ids of a row s children . |
18,860 | public void paint ( final RenderContext renderContext ) { super . paint ( renderContext ) ; UIContext uic = UIContextHolder . getCurrent ( ) ; if ( LOG . isDebugEnabled ( ) ) { UIContextDebugWrapper debugWrapper = new UIContextDebugWrapper ( uic ) ; LOG . debug ( "Session usage after paint:\n" + debugWrapper ) ; } LOG . debug ( "Performing session tidy up of WComponents (any WComponents disconnected from the active top component will not be tidied up." ) ; getUI ( ) . tidyUpUIContextForTree ( ) ; LOG . debug ( "After paint - Clearing scratch maps." ) ; uic . clearScratchMap ( ) ; uic . clearRequestScratchMap ( ) ; } | Override paint to clear out the scratch map and component models which are no longer necessary . |
18,861 | public void setButtonColumns ( final int numColumns ) { if ( numColumns < 1 ) { throw new IllegalArgumentException ( "Must have one or more columns" ) ; } CheckBoxSelectModel model = getOrCreateComponentModel ( ) ; model . numColumns = numColumns ; model . layout = numColumns == 1 ? LAYOUT_STACKED : LAYOUT_COLUMNS ; } | Sets the layout to be a certain number of columns . |
18,862 | protected void doHandleAjaxRefresh ( ) { final Action action = getRefreshAction ( ) ; if ( action == null ) { return ; } final ActionEvent event = new ActionEvent ( this , AJAX_REFRESH_ACTION_COMMAND , getAjaxFilter ( ) ) ; Runnable later = new Runnable ( ) { public void run ( ) { action . execute ( event ) ; } } ; invokeLater ( later ) ; } | Handle the AJAX refresh request . |
18,863 | public List < String > getSuggestions ( ) { Object table = getLookupTable ( ) ; if ( table == null ) { SuggestionsModel model = getComponentModel ( ) ; List < String > suggestions = model . getSuggestions ( ) ; return suggestions == null ? Collections . EMPTY_LIST : suggestions ; } else { List < ? > lookupSuggestions = APPLICATION_LOOKUP_TABLE . getTable ( table ) ; if ( lookupSuggestions == null || lookupSuggestions . isEmpty ( ) ) { return Collections . EMPTY_LIST ; } List < String > suggestions = new ArrayList < > ( lookupSuggestions . size ( ) ) ; for ( Object suggestion : lookupSuggestions ) { String sugg = APPLICATION_LOOKUP_TABLE . getDescription ( table , suggestion ) ; if ( sugg != null ) { suggestions . add ( sugg ) ; } } return Collections . unmodifiableList ( suggestions ) ; } } | Returns the complete list of suggestions available for selection for this user s session . |
18,864 | public void setSuggestions ( final List < String > suggestions ) { SuggestionsModel model = getOrCreateComponentModel ( ) ; model . setSuggestions ( suggestions ) ; } | Set the complete list of suggestions available for selection for this user s session . |
18,865 | public static String validateXMLAgainstSchema ( final String xml ) { if ( xml != null && ! xml . equals ( "" ) ) { String testXML = wrapXMLInRootElement ( xml ) ; try { SAXParserFactory spf = SAXParserFactory . newInstance ( ) ; spf . setNamespaceAware ( true ) ; spf . setValidating ( true ) ; SAXParser parser = spf . newSAXParser ( ) ; parser . setProperty ( "http://java.sun.com/xml/jaxp/properties/schemaLanguage" , XMLConstants . W3C_XML_SCHEMA_NS_URI ) ; Object schema = DebugValidateXML . class . getResource ( getSchemaPath ( ) ) . toString ( ) ; parser . setProperty ( "http://java.sun.com/xml/jaxp/properties/schemaSource" , schema ) ; DefaultHandler handler = new DefaultHandler ( ) { public void warning ( final SAXParseException e ) throws SAXException { LOG . warn ( "XML Schema warning: " + e . getMessage ( ) , e ) ; super . warning ( e ) ; } public void fatalError ( final SAXParseException e ) throws SAXException { throw e ; } public void error ( final SAXParseException e ) throws SAXException { throw e ; } } ; InputSource xmlSource = new InputSource ( new StringReader ( testXML ) ) ; parser . parse ( xmlSource , handler ) ; } catch ( SAXParseException e ) { return "At line " + e . getLineNumber ( ) + ", column: " + e . getColumnNumber ( ) + " ==> " + e . getMessage ( ) ; } catch ( Exception e ) { return e . getMessage ( ) ; } } return null ; } | Validate the component to make sure the generated XML is schema compliant . |
18,866 | public static String wrapXMLInRootElement ( final String xml ) { if ( xml . startsWith ( "<?xml" ) || xml . startsWith ( "<!DOCTYPE" ) ) { return xml ; } else { return XMLUtil . XML_DECLARATION + "<ui:root" + XMLUtil . STANDARD_NAMESPACES + ">" + xml + "</ui:root>" ; } } | Wrap the XML in a root element before validating . |
18,867 | public static void registerResource ( final InternalResource resource ) { String resourceName = resource . getResourceName ( ) ; if ( ! RESOURCES . containsKey ( resourceName ) ) { RESOURCES . put ( resourceName , resource ) ; RESOURCE_CACHE_KEYS . put ( resourceName , computeHash ( resource ) ) ; } } | Adds a resource to the resource map . |
18,868 | public static String computeHash ( final InternalResource resource ) { final int bufferSize = 1024 ; try ( InputStream stream = resource . getStream ( ) ) { if ( stream == null ) { return null ; } Checksum checksumEngine = new CRC32 ( ) ; byte [ ] buf = new byte [ bufferSize ] ; for ( int read = stream . read ( buf ) ; read != - 1 ; read = stream . read ( buf ) ) { checksumEngine . update ( buf , 0 , read ) ; } return Long . toHexString ( checksumEngine . getValue ( ) ) ; } catch ( Exception e ) { throw new SystemException ( "Error calculating resource hash" , e ) ; } } | Computes a simple hash of the resource contents . |
18,869 | protected void doReplace ( final String search , final Writer backing ) { WComponent component = componentsByKey . get ( search ) ; UIContextHolder . pushContext ( uic ) ; try { component . paint ( new WebXmlRenderContext ( ( PrintWriter ) backing ) ) ; } finally { UIContextHolder . popContext ( ) ; } } | Replaces the search string by rendering the corresponding component . |
18,870 | protected Object getTopRowBean ( final List < Integer > row ) { List < ? > lvl = getBeanList ( ) ; if ( lvl == null || lvl . isEmpty ( ) ) { return null ; } int rowIdx = row . get ( 0 ) ; Object rowData = lvl . get ( rowIdx ) ; return rowData ; } | Return the top level bean for this row index . |
18,871 | protected Object getBeanPropertyValue ( final String property , final Object bean ) { if ( bean == null ) { return null ; } if ( "." . equals ( property ) ) { return bean ; } try { Object data = PropertyUtils . getProperty ( bean , property ) ; return data ; } catch ( Exception e ) { LOG . error ( "Failed to get bean property " + property + " on " + bean , e ) ; return null ; } } | Get the bean property value . |
18,872 | protected void setBeanPropertyValue ( final String property , final Object bean , final Serializable value ) { if ( bean == null ) { return ; } if ( "." . equals ( property ) ) { LOG . error ( "Set of entire bean is not supported by this model" ) ; return ; } try { PropertyUtils . setProperty ( bean , property , value ) ; } catch ( Exception e ) { LOG . error ( "Failed to set bean property " + property + " on " + bean , e ) ; } } | Set the bean property value . |
18,873 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WDataTable table = ( WDataTable ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "ui:table" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , table . isHidden ( ) , "true" ) ; xml . appendOptionalAttribute ( "caption" , table . getCaption ( ) ) ; switch ( table . getType ( ) ) { case TABLE : xml . appendAttribute ( "type" , "table" ) ; break ; case HIERARCHIC : xml . appendAttribute ( "type" , "hierarchic" ) ; break ; default : throw new SystemException ( "Unknown table type: " + table . getType ( ) ) ; } switch ( table . getStripingType ( ) ) { case ROWS : xml . appendAttribute ( "striping" , "rows" ) ; break ; case COLUMNS : xml . appendAttribute ( "striping" , "cols" ) ; break ; case NONE : break ; default : throw new SystemException ( "Unknown striping type: " + table . getStripingType ( ) ) ; } switch ( table . getSeparatorType ( ) ) { case HORIZONTAL : xml . appendAttribute ( "separators" , "horizontal" ) ; break ; case VERTICAL : xml . appendAttribute ( "separators" , "vertical" ) ; break ; case BOTH : xml . appendAttribute ( "separators" , "both" ) ; break ; case NONE : break ; default : throw new SystemException ( "Unknown separator type: " + table . getSeparatorType ( ) ) ; } xml . appendClose ( ) ; if ( table . getPaginationMode ( ) != PaginationMode . NONE ) { paintPaginationElement ( table , xml ) ; } if ( table . getSelectMode ( ) != SelectMode . NONE ) { paintRowSelectionElement ( table , xml ) ; } if ( table . getExpandMode ( ) != ExpandMode . NONE ) { paintRowExpansionElement ( table , xml ) ; } if ( table . isSortable ( ) ) { paintSortElement ( table , xml ) ; } paintColumnHeadings ( table , renderContext ) ; paintRows ( table , renderContext ) ; paintTableActions ( table , renderContext ) ; xml . appendEndTag ( "ui:table" ) ; } | Paints the given WDataTable . |
18,874 | private void paintPaginationElement ( final WDataTable table , final XmlStringBuilder xml ) { TableDataModel model = table . getDataModel ( ) ; xml . appendTagOpen ( "ui:pagination" ) ; if ( model instanceof TreeTableDataModel ) { TreeNode firstNode = ( ( TreeTableDataModel ) model ) . getNodeAtLine ( 0 ) ; xml . appendAttribute ( "rows" , firstNode == null ? 0 : firstNode . getParent ( ) . getChildCount ( ) ) ; } else { xml . appendAttribute ( "rows" , model . getRowCount ( ) ) ; } xml . appendAttribute ( "rowsPerPage" , table . getRowsPerPage ( ) ) ; xml . appendAttribute ( "currentPage" , table . getCurrentPage ( ) ) ; switch ( table . getPaginationMode ( ) ) { case CLIENT : xml . appendAttribute ( "mode" , "client" ) ; break ; case DYNAMIC : case SERVER : xml . appendAttribute ( "mode" , "dynamic" ) ; break ; case NONE : break ; default : throw new SystemException ( "Unknown pagination mode: " + table . getPaginationMode ( ) ) ; } xml . appendEnd ( ) ; } | Paint the pagination aspects of the WDataTable . |
18,875 | public void setAction ( final Action action ) { MenuItemModel model = getOrCreateComponentModel ( ) ; model . action = action ; model . url = null ; } | Sets the action to execute when the menu item is invoked . |
18,876 | public void setUrl ( final String url ) { MenuItemModel model = getOrCreateComponentModel ( ) ; model . url = url ; model . action = null ; } | Sets the URL to navigate to when the menu item is invoked . |
18,877 | public void setMessage ( final String message , final Serializable ... args ) { getOrCreateComponentModel ( ) . message = I18nUtilities . asMessage ( message , args ) ; } | Sets the confirmation message that is to be displayed to the user for this menu item . |
18,878 | public void handleRequest ( final Request request ) { if ( isDisabled ( ) ) { return ; } if ( isMenuPresent ( request ) ) { String requestValue = request . getParameter ( getId ( ) ) ; if ( requestValue != null ) { if ( ! "POST" . equals ( request . getMethod ( ) ) ) { LOG . warn ( "Menu item on a request that is not a POST. Will be ignored." ) ; return ; } final Action action = getAction ( ) ; if ( action != null ) { final ActionEvent event = new ActionEvent ( this , this . getActionCommand ( ) , this . getActionObject ( ) ) ; Runnable later = new Runnable ( ) { public void run ( ) { action . execute ( event ) ; } } ; invokeLater ( later ) ; } } } } | Override handleRequest in order to perform processing for this component . This implementation checks for selection of the menu item and executes the associated action if it has been set . |
18,879 | protected boolean isMenuPresent ( final Request request ) { WMenu menu = WebUtilities . getAncestorOfClass ( WMenu . class , this ) ; if ( menu != null ) { return menu . isPresent ( request ) ; } return false ; } | Determine if this WMenuItem s parent WMenu is on the Request . |
18,880 | public void setEditable ( final boolean editable ) { setType ( editable ? DropdownType . COMBO : DropdownType . NATIVE ) ; } | Sets whether the users are able to enter in an arbitrary value rather than having to pick one from the drop - down list . |
18,881 | private void buildUI ( ) { add ( new WSkipLinks ( ) ) ; add ( headerPanel ) ; headerPanel . add ( new UtilityBar ( ) ) ; headerPanel . add ( new WHeading ( HeadingLevel . H1 , "WComponents" ) ) ; add ( mainPanel ) ; mainPanel . add ( menuPanel ) ; mainPanel . add ( exampleSection ) ; WPanel footer = new WPanel ( WPanel . Type . FOOTER ) ; footer . add ( lastLoaded ) ; add ( footer ) ; add ( new WAjaxControl ( menuPanel . getTree ( ) , new AjaxTarget [ ] { menuPanel . getMenu ( ) , exampleSection } ) ) ; } | Add all the bits in the right order . |
18,882 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WPopup popup = ( WPopup ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; int width = popup . getWidth ( ) ; int height = popup . getHeight ( ) ; String targetWindow = popup . getTargetWindow ( ) ; xml . appendTagOpen ( "ui:popup" ) ; xml . appendUrlAttribute ( "url" , popup . getUrl ( ) ) ; xml . appendOptionalAttribute ( "width" , width > 0 , width ) ; xml . appendOptionalAttribute ( "height" , height > 0 , height ) ; xml . appendOptionalAttribute ( "resizable" , popup . isResizable ( ) , "true" ) ; xml . appendOptionalAttribute ( "showScrollbars" , popup . isScrollable ( ) , "true" ) ; xml . appendOptionalAttribute ( "targetWindow" , ! Util . empty ( targetWindow ) , targetWindow ) ; xml . appendClose ( ) ; xml . appendEndTag ( "ui:popup" ) ; } | Paints the given WPopup . |
18,883 | public static ObjectGraphNode dump ( final Object obj ) { ObjectGraphDump dump = new ObjectGraphDump ( false , true ) ; ObjectGraphNode root = new ObjectGraphNode ( ++ dump . nodeCount , null , obj . getClass ( ) . getName ( ) , obj ) ; dump . visit ( root ) ; return root ; } | Dumps the contents of the session attributes . |
18,884 | private void visit ( final ObjectGraphNode currentNode ) { Object currentValue = currentNode . getValue ( ) ; if ( currentValue == null || ( currentValue instanceof java . lang . ref . SoftReference ) || currentNode . isPrimitive ( ) || currentNode . isSimpleType ( ) ) { return ; } if ( isObjectVisited ( currentNode ) ) { ObjectGraphNode ref = visitedNodes . get ( currentValue ) ; currentNode . setRefNode ( ref ) ; return ; } markObjectVisited ( currentNode ) ; if ( currentValue instanceof List ) { visitList ( currentNode ) ; } else if ( currentValue instanceof Map ) { visitMap ( currentNode ) ; } else if ( currentValue instanceof ComponentModel ) { visitComponentModel ( currentNode ) ; } else if ( currentValue instanceof Field ) { visitComplexType ( currentNode ) ; summariseNode ( currentNode ) ; } else if ( currentValue . getClass ( ) . isArray ( ) ) { visitArray ( currentNode ) ; } else { visitComplexType ( currentNode ) ; } } | Implementation of the tree walk . |
18,885 | private void visitComplexType ( final ObjectGraphNode node ) { Field [ ] fields = getAllInstanceFields ( node . getValue ( ) ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { Object fieldValue = readField ( fields [ i ] , node . getValue ( ) ) ; String fieldType = fields [ i ] . getType ( ) . getName ( ) ; ObjectGraphNode childNode = new ObjectGraphNode ( ++ nodeCount , fields [ i ] . getName ( ) , fieldType , fieldValue ) ; node . add ( childNode ) ; visit ( childNode ) ; } } | Visits all the fields in the given complex object . |
18,886 | private void visitComplexTypeWithDiff ( final ObjectGraphNode node , final Object otherInstance ) { if ( otherInstance == null ) { visitComplexType ( node ) ; } else { Field [ ] fields = getAllInstanceFields ( node . getValue ( ) ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { Object fieldValue = readField ( fields [ i ] , node . getValue ( ) ) ; Object otherValue = readField ( fields [ i ] , otherInstance ) ; String fieldType = fields [ i ] . getType ( ) . getName ( ) ; String nodeFieldName = fields [ i ] . getName ( ) + ( Util . equals ( fieldValue , otherValue ) ? "" : "*" ) ; ObjectGraphNode childNode = new ObjectGraphNode ( ++ nodeCount , nodeFieldName , fieldType , fieldValue ) ; node . add ( childNode ) ; visit ( childNode ) ; } } } | Visits all the fields in the given complex object noting differences . |
18,887 | private void visitComponentModel ( final ObjectGraphNode node ) { ComponentModel model = ( ComponentModel ) node . getValue ( ) ; ComponentModel sharedModel = null ; List < Field > fieldList = ReflectionUtil . getAllFields ( node . getValue ( ) , true , false ) ; Field [ ] fields = fieldList . toArray ( new Field [ fieldList . size ( ) ] ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( ComponentModel . class . equals ( fields [ i ] . getDeclaringClass ( ) ) && "sharedModel" . equals ( fields [ i ] . getName ( ) ) ) { sharedModel = ( ComponentModel ) readField ( fields [ i ] , model ) ; } } visitComplexTypeWithDiff ( node , sharedModel ) ; } | Visits all the fields in the given ComponentModel . |
18,888 | private Object readField ( final Field field , final Object obj ) { try { return field . get ( obj ) ; } catch ( IllegalAccessException e ) { LOG . error ( "Failed to read " + field . getName ( ) + " of " + obj . getClass ( ) . getName ( ) , e ) ; } return null ; } | Reads the contents of a field . |
18,889 | private void visitArray ( final ObjectGraphNode node ) { if ( node . getValue ( ) instanceof Object [ ] ) { Object [ ] array = ( Object [ ] ) node . getValue ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { String entryType = array [ i ] == null ? Object . class . getName ( ) : array [ i ] . getClass ( ) . getName ( ) ; ObjectGraphNode childNode = new ObjectGraphNode ( ++ nodeCount , "[" + i + "]" , entryType , array [ i ] ) ; node . add ( childNode ) ; visit ( childNode ) ; } } else { ObjectGraphNode childNode = new ObjectGraphNode ( ++ nodeCount , "[primitive array]" , node . getValue ( ) . getClass ( ) . getName ( ) , node . getValue ( ) ) ; node . add ( childNode ) ; } } | Visits all the elements of the given array . |
18,890 | private void visitList ( final ObjectGraphNode node ) { int index = 0 ; for ( Iterator i = ( ( List ) node . getValue ( ) ) . iterator ( ) ; i . hasNext ( ) ; ) { Object entry = i . next ( ) ; String entryType = entry == null ? Object . class . getName ( ) : entry . getClass ( ) . getName ( ) ; ObjectGraphNode childNode = new ObjectGraphNode ( ++ nodeCount , "[" + index ++ + "]" , entryType , entry ) ; node . add ( childNode ) ; visit ( childNode ) ; } adjustOverhead ( node ) ; } | Visits all the elements of the given list . |
18,891 | private void summariseNode ( final ObjectGraphNode node ) { int size = node . getSize ( ) ; node . removeAll ( ) ; node . setSize ( size ) ; } | For some types we don t care about their internals so just summarise the size . |
18,892 | private void visitMap ( final ObjectGraphNode node ) { Map map = ( Map ) node . getValue ( ) ; for ( Iterator i = map . entrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) i . next ( ) ; Object key = entry . getKey ( ) ; if ( key != null ) { ObjectGraphNode keyNode = new ObjectGraphNode ( ++ nodeCount , "key" , key . getClass ( ) . getName ( ) , key ) ; node . add ( keyNode ) ; visit ( keyNode ) ; } else { ObjectGraphNode keyNode = new ObjectGraphNode ( ++ nodeCount , "key" , Object . class . getName ( ) , null ) ; node . add ( keyNode ) ; } Object value = entry . getValue ( ) ; if ( value != null ) { ObjectGraphNode valueNode = new ObjectGraphNode ( ++ nodeCount , "value" , value . getClass ( ) . getName ( ) , value ) ; node . add ( valueNode ) ; visit ( valueNode ) ; } else { ObjectGraphNode valueNode = new ObjectGraphNode ( ++ nodeCount , "value" , Object . class . getName ( ) , null ) ; node . add ( valueNode ) ; } } adjustOverhead ( node ) ; } | Visits all the keys and entries of the given map . |
18,893 | private Field [ ] getAllInstanceFields ( final Object obj ) { Field [ ] fields = instanceFieldsByClass . get ( obj . getClass ( ) ) ; if ( fields == null ) { List < Field > fieldList = ReflectionUtil . getAllFields ( obj , excludeStatic , excludeTransient ) ; fields = fieldList . toArray ( new Field [ fieldList . size ( ) ] ) ; instanceFieldsByClass . put ( obj . getClass ( ) , fields ) ; } return fields ; } | Retrieves all the instance fields for the given object . |
18,894 | private static void renderHelper ( final WebXmlRenderContext renderContext , final Diagnosable component , final List < Diagnostic > diags , final int severity ) { if ( diags . isEmpty ( ) ) { return ; } XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( TAG_NAME ) ; xml . appendAttribute ( "id" , "_wc_" . concat ( UUID . randomUUID ( ) . toString ( ) ) ) ; xml . appendAttribute ( "type" , getLevel ( severity ) ) ; xml . appendAttribute ( "for" , component . getId ( ) ) ; xml . appendClose ( ) ; for ( Diagnostic diagnostic : diags ) { xml . appendTag ( MESSAGE_TAG_NAME ) ; xml . appendEscaped ( diagnostic . getDescription ( ) ) ; xml . appendEndTag ( MESSAGE_TAG_NAME ) ; } xml . appendEndTag ( TAG_NAME ) ; } | Render the diagnostics . |
18,895 | public static void renderDiagnostics ( final Diagnosable component , final WebXmlRenderContext renderContext ) { List < Diagnostic > diags = component . getDiagnostics ( Diagnostic . ERROR ) ; if ( diags != null ) { renderHelper ( renderContext , component , diags , Diagnostic . ERROR ) ; } diags = component . getDiagnostics ( Diagnostic . WARNING ) ; if ( diags != null ) { renderHelper ( renderContext , component , diags , Diagnostic . WARNING ) ; } diags = component . getDiagnostics ( Diagnostic . INFO ) ; if ( diags != null ) { renderHelper ( renderContext , component , diags , Diagnostic . INFO ) ; } diags = component . getDiagnostics ( Diagnostic . SUCCESS ) ; if ( diags != null ) { renderHelper ( renderContext , component , diags , Diagnostic . SUCCESS ) ; } } | Render diagnostics for the component . |
18,896 | private void handleWarpToTheFuture ( final UIContext uic ) { StepCountUtil . incrementSessionStep ( uic ) ; WComponent application = getUI ( ) ; if ( application instanceof WApplication ) { LOG . warn ( "The handleStepError method will be called on WApplication." ) ; ( ( WApplication ) application ) . handleStepError ( ) ; } } | Warp the user to the future by replacing the entire page . |
18,897 | private void handleRenderRedirect ( final PrintWriter writer ) { UIContext uic = UIContextHolder . getCurrent ( ) ; LOG . warn ( "User will be redirected to " + redirectUrl ) ; getResponse ( ) . setContentType ( WebUtilities . CONTENT_TYPE_XML ) ; writer . write ( XMLUtil . getXMLDeclarationWithThemeXslt ( uic ) ) ; writer . print ( "<ui:ajaxresponse " ) ; writer . print ( XMLUtil . UI_NAMESPACE ) ; writer . print ( ">" ) ; writer . print ( "<ui:ajaxtarget id=\"" + triggerId + "\" action=\"replace\">" ) ; writer . print ( "<ui:redirect url=\"" + redirectUrl + "\" />" ) ; writer . print ( "</ui:ajaxtarget>" ) ; writer . print ( "</ui:ajaxresponse>" ) ; } | Redirect the user via the AJAX response . |
18,898 | private String buildApplicationUrl ( final UIContext uic ) { Environment env = uic . getEnvironment ( ) ; return env . getPostPath ( ) ; } | Build the url to refresh the application . |
18,899 | public static Serializable asMessage ( final String text , final Serializable ... args ) { if ( text == null ) { return null ; } else if ( args == null || args . length == 0 ) { return text ; } else { return new Message ( text , args ) ; } } | Converts a message String and optional message arguments to a an appropriate format for internationalisation . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.