idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
6,000
public String formatDate ( Date d ) { if ( d == null ) return null ; JsDate jsd = JsDate . create ( d . getTime ( ) ) ; return internFormat ( input . getElement ( ) , getActiveDateFormat ( ) , jsd ) ; }
Doesn t change anything just formats passed date as string according to widget s current settings .
6,001
protected JQMButton createButton ( String text , String url , DataIcon icon ) { JQMButton button = new JQMButton ( text , url ) ; if ( icon != null ) button . withBuiltInIcon ( icon ) ; return button ; }
Internal method for creating a button
6,002
@ UiChild ( tagname = "backButton" , limit = 1 ) public void setBackButton ( JQMButton button ) { button . setBack ( true ) ; setLeftButton ( button ) ; }
Sets the given button in the left position and sets that buttons role to back . Any existing left button will be replaced .
6,003
public JQMButton setBackButton ( String text ) { JQMButton button = new JQMButton ( text ) ; button . withBuiltInIcon ( DataIcon . LEFT ) ; setBackButton ( button ) ; return button ; }
Creates an auto back button with the given text and replaces the current left button if any .
6,004
@ UiChild ( tagname = "leftButton" , limit = 1 ) public void setLeftButton ( JQMButton button ) { if ( left != null ) remove ( left ) ; button . setPosOnBand ( PosOnBand . LEFT ) ; left = button ; insert ( left , 0 ) ; }
Sets the left button to be the given button . Any existing button is removed .
6,005
@ UiChild ( tagname = "rightButton" , limit = 1 ) public void setRightButton ( JQMButton button ) { if ( right != null ) remove ( right ) ; button . setPosOnBand ( PosOnBand . RIGHT ) ; right = button ; add ( right ) ; }
Sets the right button to be the given button . Any existing button is removed .
6,006
public void setHref ( String href ) { JQMCommon . setAttribute ( a , "href" , href ) ; if ( external == null && ! Empty . is ( href ) && ( href . startsWith ( "http:" ) || href . startsWith ( "https:" ) ) ) { setExternal ( true ) ; } }
The destination URL of the link
6,007
public void add ( JQMSubmit submit ) { super . add ( submit ) ; submit . addClickHandler ( new ClickHandler ( ) { public void onClick ( ClickEvent event ) { submit ( ) ; } } ) ; }
Add the given submit button to the form and automatically have it set to submit the form on a click event .
6,008
public void addValidator ( Widget notifiedWidget , Validator validator , boolean immediate , Widget positionErrorAfter , JQMFormWidget ... firingWidgets ) { boolean labelAdded = false ; if ( firingWidgets != null ) { for ( JQMFormWidget w : firingWidgets ) { Label la = w . addErrorLabel ( ) ; if ( la == null ) continue ; labelAdded = true ; addErrorLabel ( validator , la , w . asWidget ( ) ) ; } } if ( ! labelAdded ) { Label label = new InlineLabel ( ) ; label . setStyleName ( JQM4GWT_ERROR_LABEL_STYLENAME ) ; if ( globalValidationErrorStyles != null && ! globalValidationErrorStyles . isEmpty ( ) ) { JQMCommon . addStyleNames ( label , globalValidationErrorStyles ) ; } label . setVisible ( false ) ; if ( positionErrorAfter == null ) { addErrorLabel ( validator , label , null ) ; add ( label ) ; } else { boolean inserted = false ; Widget w = positionErrorAfter ; while ( w != null ) { int i = getWidgetIndex ( w ) ; if ( i >= 0 ) { i ++ ; while ( i < getWidgetCount ( ) ) { Widget wi = getWidget ( i ) ; if ( wi instanceof Label && JQMCommon . hasStyle ( wi , JQM4GWT_ERROR_LABEL_STYLENAME ) ) { i ++ ; } else { break ; } } insert ( label , i ) ; inserted = true ; break ; } w = w . getParent ( ) ; } if ( ! inserted ) { addErrorLabel ( validator , label , null ) ; add ( label ) ; } else { addErrorLabel ( validator , label , positionErrorAfter ) ; } } } registerValidatorWithFiringWidgets ( validator , firingWidgets , immediate ) ; boolean required = validator instanceof NotNullOrEmptyValidator ; String validatorClass = STYLE_FORM_VALIDATOR + getShortClassName ( validator . getClass ( ) ) ; if ( notifiedWidget != null ) { notifiedWidgets . put ( validator , notifiedWidget ) ; notifiedWidget . getElement ( ) . addClassName ( validatorClass ) ; if ( required ) notifiedWidget . getElement ( ) . addClassName ( STYLE_FORM_REQUIRED ) ; } else if ( firingWidgets != null ) { for ( JQMFormWidget w : firingWidgets ) { w . asWidget ( ) . getElement ( ) . addClassName ( validatorClass ) ; if ( required ) w . asWidget ( ) . getElement ( ) . addClassName ( STYLE_FORM_REQUIRED ) ; } } }
Adds a validator and binds it to the collection of widgets . The widget list can be empty .
6,009
public void clearValidationStyles ( ) { for ( JQMFormWidget widget : widgetValidators . keySet ( ) ) { UIObject ui = widget . asWidget ( ) ; Collection < Validator > validators = widgetValidators . get ( widget ) ; for ( Validator v : validators ) { if ( notifiedWidgets . containsKey ( v ) ) { ui = notifiedWidgets . get ( v ) ; } removeStyles ( v , ui ) ; } } }
Remove all validation styles
6,010
public void setError ( String string ) { Label errorLabel = new Label ( string ) ; errorLabel . setStyleName ( JQM4GWT_ERROR_LABEL_STYLENAME ) ; errorLabel . addStyleName ( JQM4GWT_GENERAL_ERROR_LABEL_STYLENAME ) ; generalErrors . add ( errorLabel ) ; generalErrors . getElement ( ) . scrollIntoView ( ) ; }
Set a general error on the form .
6,011
public boolean validate ( boolean scrollToFirstError ) { boolean validated = true ; for ( JQMFormWidget widget : widgetValidators . keySet ( ) ) { if ( ! validate ( widget ) ) validated = false ; } if ( ! validated && scrollToFirstError ) scrollToFirstError ( ) ; return validated ; }
Perform validation for all validators setting error messages where appropriate .
6,012
protected boolean validate ( JQMFormWidget widget ) { boolean validated = true ; Collection < Validator > validators = widgetValidators . get ( widget ) ; for ( Validator v : validators ) if ( ! validate ( v , widget . asWidget ( ) ) ) validated = false ; return validated ; }
Performs validation for a single widget first resetting all validation messages on that widget .
6,013
protected boolean validate ( Validator validator , UIObject ui ) { if ( notifiedWidgets . containsKey ( validator ) ) ui = notifiedWidgets . get ( validator ) ; String msg = validator . validate ( ) ; if ( msg == null || msg . length ( ) == 0 ) { validationStyles ( validator , null , ui , true ) ; return true ; } else { validationStyles ( validator , msg , ui , false ) ; return false ; } }
Perform validation for a single validator
6,014
public static Stream < Element > stream ( Element element ) { return StreamSupport . stream ( new ElementParentsIterable ( element ) . spliterator ( ) , false ) ; }
Creates stream with parent chain
6,015
public void rerender ( ) { clear ( ) ; if ( dataItems != null ) { for ( M m : dataItems ) { addDataItem ( m ) ; } } doRefresh ( ) ; }
Needed in case of renderer changed so list has to be visually reconstructed by new renderer .
6,016
public void setThemeIfCurrentEmpty ( String themeName ) { if ( themeName == null || themeName . isEmpty ( ) ) return ; String theme = getTheme ( ) ; if ( theme == null || theme . isEmpty ( ) ) { setTheme ( themeName ) ; } }
Sets new theme only in case if currently no theme is defined for this widget .
6,017
public void setDfltTableStylesStr ( String classes ) { dfltTableStyles . clear ( ) ; if ( classes == null || classes . isEmpty ( ) ) return ; List < String > lst = StrUtils . split ( classes , " " ) ; for ( int k = 0 ; k < lst . size ( ) ; k ++ ) { String s = lst . get ( k ) . trim ( ) ; DataTableStyleClass cls ; try { cls = DataTableStyleClass . valueOf ( s ) ; dfltTableStyles . add ( cls ) ; } catch ( Exception ex ) { continue ; } } }
Expected DataTableStyleClass enum values as space separated string .
6,018
public void adjustColumnSizing ( ) { JsDataTable . adjustColumnSizing ( getElement ( ) ) ; Element sb = findUpperElement ( SCROLL_BODY ) ; if ( sb != null ) sb . setScrollLeft ( 0 ) ; }
Aligns header to match the columns useful after resize or orientation changes .
6,019
public HasText addDivider ( String text ) { JQMListDivider d = new JQMListDivider ( text ) ; appendDivider ( d ) ; return d ; }
Add a new divider with the given text and an automatically assigned id .
6,020
public JQMList addItems ( Collection < String > items ) { for ( String item : items ) addItem ( item ) ; return this ; }
Add a collection of read only items .
6,021
public boolean removeDivider ( String text ) { for ( int k = 0 ; k < list . getWidgetCount ( ) ; k ++ ) { Widget w = list . getWidget ( k ) ; if ( isDivider ( w ) && w . getElement ( ) . getInnerText ( ) . equals ( text ) ) { list . remove ( k ) ; items . remove ( k ) ; return true ; } } return false ; }
Remove the divider with the given text . This method will search all the dividers and remove the first divider found with the given text .
6,022
public boolean removeDividerByTag ( Object tag ) { if ( tag == null ) return false ; for ( int k = 0 ; k < list . getWidgetCount ( ) ; k ++ ) { Widget w = list . getWidget ( k ) ; if ( isDivider ( w ) && tag . equals ( ( ( JQMListDivider ) w ) . getTag ( ) ) ) { list . remove ( k ) ; items . remove ( k ) ; return true ; } } return false ; }
Remove the divider with the given tag . This method will search all the dividers and remove the first divider found with the given tag .
6,023
public JQMListDivider findDivider ( String text ) { for ( int k = 0 ; k < list . getWidgetCount ( ) ; k ++ ) { Widget w = list . getWidget ( k ) ; if ( isDivider ( w ) && w . getElement ( ) . getInnerText ( ) . equals ( text ) ) { return ( JQMListDivider ) w ; } } return null ; }
Find the divider with the given text . This method will search all the dividers and return the first divider found with the given text .
6,024
public JQMListDivider findDividerByTag ( Object tag ) { if ( tag == null ) return null ; for ( int k = 0 ; k < list . getWidgetCount ( ) ; k ++ ) { Widget w = list . getWidget ( k ) ; if ( isDivider ( w ) && tag . equals ( ( ( JQMListDivider ) w ) . getTag ( ) ) ) { return ( JQMListDivider ) w ; } } return null ; }
Find the divider with the given tag . This method will search all the dividers and return the first divider found with the given tag .
6,025
public int findInsertIdxByDivider ( JQMListDivider d ) { if ( d == null ) return - 1 ; int i = findDividerIdx ( d ) ; if ( i == - 1 ) return - 1 ; List < JQMListItem > lst = getItems ( ) ; int rslt = i + 1 ; while ( rslt < lst . size ( ) ) { if ( lst . get ( rslt ) == null ) { return rslt ; } rslt ++ ; } return rslt ; }
For given divider finds the index at which new item should be inserted to become a part of this divider s group .
6,026
public int findItemOnlyIdx ( JQMListItem item ) { if ( item == null ) return - 1 ; List < JQMListItem > items = getItems ( ) ; if ( items == null ) return - 1 ; int i = items . indexOf ( item ) ; if ( i == - 1 ) return - 1 ; int j = 0 ; for ( JQMListItem k : items ) { if ( k == null ) continue ; if ( k == item ) return j ; j ++ ; } return - 1 ; }
Ignores dividers only counts JQMListItem bands .
6,027
public JQMListItem findItemByTag ( Object tag ) { if ( tag == null ) return null ; List < JQMListItem > lst = getItems ( ) ; for ( JQMListItem i : lst ) { if ( i == null ) continue ; if ( tag . equals ( i . getTag ( ) ) ) return i ; } return null ; }
Find the list item with the given tag . This method will search all the items and return the first item found with the given tag .
6,028
public void removeItem ( JQMListItem item ) { if ( item != null ) { items . remove ( item ) ; list . remove ( item ) ; } }
Removes the given item from the list
6,029
public void setHeaderTheme ( String value ) { headerTheme = value ; ComplexPanel r = findHeadRow ( ) ; if ( r != null ) setEltHeaderTheme ( r . getElement ( ) , value ) ; r = findHeadGroupsRow ( ) ; if ( r != null ) setEltHeaderTheme ( r . getElement ( ) , value ) ; }
Swatch header color ui - bar - + value will be used
6,030
protected int getNumOfCols ( ) { if ( ! columns . isEmpty ( ) ) return getHeadRegularColCnt ( ) + columns . size ( ) ; if ( loaded && ! colTitleWidgets . isEmpty ( ) ) return getHeadRegularColCnt ( ) + colTitleWidgets . size ( ) ; return getHeadRegularColCnt ( ) ; }
important for body because exact number of columns should be known when populating
6,031
public Double getValue ( ) { Double rslt = getUiValue ( ) ; if ( rslt == null ) return internVal ; if ( internVal == null ) { Double min = getMin ( ) ; if ( rslt == min || rslt != null && rslt . equals ( min ) ) return null ; } internVal = rslt ; return rslt ; }
returns the current value of the slider
6,032
public Double getMax ( ) { String v = input . getElement ( ) . getAttribute ( "max" ) ; if ( v == null || v . isEmpty ( ) ) return null ; return Double . valueOf ( v ) ; }
Returns the max value of the slider
6,033
public void setMax ( Double max ) { String maxStr = doubleToNiceStr ( max ) ; JQMCommon . setAttribute ( input , "max" , maxStr ) ; refreshMax ( input . getElement ( ) . getId ( ) , maxStr ) ; validateValue ( ) ; }
Sets the new max range for the slider .
6,034
public void setMin ( Double min ) { String minStr = doubleToNiceStr ( min ) ; JQMCommon . setAttribute ( input , "min" , minStr ) ; refreshMin ( input . getElement ( ) . getId ( ) , minStr ) ; validateValue ( ) ; }
Sets the new min range for the slider
6,035
public void setValue ( Double value , boolean fireEvents ) { Double old = getValue ( ) ; if ( old == value || old != null && old . equals ( value ) ) return ; internVal = value ; setInputValueAttr ( value ) ; ignoreChange = true ; try { refresh ( input . getElement ( ) . getId ( ) , doubleToNiceStr ( value ) ) ; } finally { ignoreChange = false ; } if ( fireEvents ) ValueChangeEvent . fire ( this , value ) ; }
Sets the value of the slider to the given value
6,036
public JQMListItem addHeaderText ( int n , String html ) { Element e = Document . get ( ) . createHElement ( n ) ; e . setInnerHTML ( html ) ; attachChild ( e ) ; return this ; }
Adds a header element containing the given text .
6,037
public JQMListItem addText ( String html ) { Element e = Document . get ( ) . createPElement ( ) ; e . setInnerHTML ( html ) ; attachChild ( e ) ; return this ; }
Adds a paragraph element containing the given text .
6,038
public JQMListItem addDiv ( String html ) { Element e = Document . get ( ) . createDivElement ( ) ; e . setInnerHTML ( html ) ; attachChild ( e ) ; return this ; }
Adds a div element containing the given text .
6,039
public JQMListItem removeImage ( ) { if ( imageElem != null ) { imageElem . removeFromParent ( ) ; imageElem = null ; } getElement ( ) . removeClassName ( STYLE_UI_LI_HAS_THUMB ) ; return this ; }
Removes the value of the image element if any . It is safe to call this method regardless of if an image has been set or not .
6,040
public JQMListItem removeHref ( ) { if ( anchor == null ) return this ; if ( anchorPanel != null ) { List < Widget > lst = new ArrayList < Widget > ( ) ; for ( int i = anchorPanel . getWidgetCount ( ) - 1 ; i >= 0 ; i -- ) { Widget w = anchorPanel . getWidget ( i ) ; anchorPanel . remove ( i ) ; lst . add ( 0 , w ) ; } remove ( anchorPanel ) ; cleanUpLI ( ) ; for ( Widget w : lst ) this . add ( w ) ; } else { moveAnchorChildrenToThis ( ) ; getElement ( ) . removeChild ( anchor ) ; } anchor = null ; anchorPanel = null ; setSplitHref ( null ) ; return this ; }
Remove the url from this list item changing the item into a read only item .
6,041
public void setAside ( String text ) { if ( text == null ) throw new RuntimeException ( "Cannot set aside to null. Call removeAside() if you wanted to remove the aside text" ) ; if ( asideElem == null ) createAndAttachAsideElem ( ) ; asideElem . setInnerText ( text ) ; }
Sets the content of the aside . The aside is supplemental content that is positioned to the right of the main content .
6,042
public void setText ( String text ) { if ( text == null ) { if ( headerElem != null ) { removeChild ( headerElem ) ; headerElem = null ; } return ; } if ( headerElem == null ) { headerElem = Document . get ( ) . createHElement ( 3 ) ; attachChild ( headerElem ) ; } headerElem . setInnerText ( text ) ; }
Sets the content of the main text to the given value .
6,043
public void setHref ( String url ) { if ( url == null ) throw new RuntimeException ( "Cannot set URL to null. Call removeUrl() if you wanted to remove the URL" ) ; if ( anchor == null ) { if ( controlGroupRoot != null ) { remove ( controlGroupRoot ) ; anchor = Document . get ( ) . createAnchorElement ( ) ; anchor . setAttribute ( "href" , url ) ; moveThisChildrenToAnchor ( ) ; cleanUpLI ( ) ; prepareAnchorForControlGroup ( ) ; getElement ( ) . appendChild ( anchor ) ; checkAnchorPanel ( ) ; } else { anchor = Document . get ( ) . createAnchorElement ( ) ; moveThisChildrenToAnchor ( ) ; getElement ( ) . appendChild ( anchor ) ; } addItemActivationHandlers ( ) ; } anchor . setAttribute ( "href" , url ) ; }
Sets the url to link to for this item . If this item was a read only item it automatically becomes linkable .
6,044
public void setControlGroup ( boolean value , boolean linkable ) { if ( value ) { createControlGroup ( linkable ) ; } else if ( controlGroup != null ) { if ( anchorPanel != null ) remove ( anchorPanel ) ; else if ( anchor != null ) getElement ( ) . removeChild ( anchor ) ; anchor = null ; anchorPanel = null ; setSplitHref ( null ) ; controlGroupRoot = null ; controlGroup = null ; checkBoxInput = null ; } }
true - prepare and allow to add widgets to this list box item .
6,045
public void setTransition ( Transition transition ) { if ( anchor == null ) { if ( transition != null ) { setUrl ( "#" ) ; } else { return ; } } if ( anchor != null ) JQMCommon . setTransition ( anchor , transition ) ; }
Sets the transition to be used by this list item when loading the URL .
6,046
public void setSplitTransition ( Transition transition ) { if ( split == null ) { if ( transition != null ) { setSplitHref ( "#" ) ; } else { return ; } } if ( split != null ) JQMCommon . setTransition ( split , transition ) ; }
Sets the transition to be used by this list item split part when loading the URL .
6,047
public void setContainerId ( String containerId ) { if ( getId ( ) == null ) { super . setContainerId ( containerId ) ; JQMContext . attachAndEnhance ( this ) ; } else if ( ! containerId . equals ( getId ( ) ) ) { throw new IllegalStateException ( "Attempt to change JQMPage with containerId '" + getId ( ) + "' to '" + containerId + "' failed - once set, it cannot be changed." ) ; } }
Sets the containerId so it can be referenced by name . This can only be set once . All subsequent attempts on this instance will result in an IllegalStateException .
6,048
protected void addLogical ( Widget child ) { child . removeFromParent ( ) ; getChildren ( ) . add ( child ) ; adopt ( child ) ; }
Logical add operation . If you do this you are responsible for adding it to the DOM yourself .
6,049
protected boolean removeLogical ( Widget w ) { if ( w . getParent ( ) != this ) { return false ; } try { orphan ( w ) ; } finally { getChildren ( ) . remove ( w ) ; } return true ; }
Logical remove operation . If you do this you are responsible for removing it from the DOM yourself .
6,050
public void add ( Widget widget ) { if ( widget instanceof HasJqmHeader ) { setHeader ( ( HasJqmHeader ) widget ) ; return ; } else if ( widget instanceof HasJqmFooter ) { setFooter ( ( HasJqmFooter ) widget ) ; return ; } else if ( widget instanceof JQMContent ) { throw new RuntimeException ( "Do not add content widgets here, call createContent() instead" ) ; } getPrimaryContent ( ) . add ( widget ) ; }
Adds a widget to the primary content container of this page .
6,051
public JQMContent createContent ( ) { JQMContent content = new JQMContent ( ) ; Element elt = getElement ( ) ; add ( content , elt ) ; return content ; }
Creates a content container on this page and returns it . Content can then be added to this secondary container . There is no limit to the number of secondary content containers that can be created .
6,052
private static void prepareTransparentGoing ( boolean add , String transparentPageId ) { Element p = Document . get ( ) . getBody ( ) ; if ( p != null ) { String s = JQM4GWT_DLG_TRANSPARENT_GOING_PREFIX + transparentPageId ; if ( add ) { p . addClassName ( JQM4GWT_DLG_TRANSPARENT_GOING ) ; p . addClassName ( s ) ; } else { p . removeClassName ( s ) ; String ss = JQMCommon . getStyleStartsWith ( p , JQM4GWT_DLG_TRANSPARENT_GOING_PREFIX ) ; if ( Empty . is ( ss ) ) p . removeClassName ( JQM4GWT_DLG_TRANSPARENT_GOING ) ; } } }
GOING means from beforeShow till afterHide .
6,053
public void setFooter ( HasJqmFooter footer ) { removeFooter ( ) ; this . footer = footer ; if ( this . footer == null ) return ; addLogical ( footer . getFooterStage ( ) ) ; getElement ( ) . appendChild ( footer . getJqmFooter ( ) . getElement ( ) ) ; }
Sets the footer element overriding an existing footer if any .
6,054
public void setHeader ( HasJqmHeader header ) { removeHeader ( ) ; this . header = header ; if ( this . header == null ) return ; addLogical ( header . getHeaderStage ( ) ) ; if ( panel == null ) { getElement ( ) . insertBefore ( header . getJqmHeader ( ) . getElement ( ) , getElement ( ) . getFirstChild ( ) ) ; } else { getElement ( ) . insertAfter ( header . getJqmHeader ( ) . getElement ( ) , panel . getElement ( ) ) ; } }
Sets the header element overriding an existing header if any .
6,055
public void setContentAddStyleNames ( String value ) { if ( value == null || value . isEmpty ( ) ) return ; JQMCommon . addStyleNames ( content , value ) ; }
Additional class names can be added directly to content div for better custom styling . The same idea as UiBinder s embedded addStyleNames functionality .
6,056
public void setContentHeightPercent ( double contentHeightPercent ) { double oldVal = this . contentHeightPercent ; this . contentHeightPercent = contentHeightPercent ; if ( oldVal != this . contentHeightPercent && content != null && content . isAttached ( ) ) { recalcContentHeightPercent ( ) ; centerContent ( ) ; initWindowResize ( ) ; } }
Defines content band s height as percent of available content area s height .
6,057
public void restoreRolePage ( ) { JQMCommon . setDataRole ( this , "page" ) ; JQMCommon . setDataDialog ( this , false ) ; removeStyleName ( STYLE_UI_DIALOG ) ; Element elt = getElement ( ) ; Element dlgContain = JQMCommon . findChild ( elt , UI_DIALOG_CONTAIN ) ; if ( dlgContain != null ) { JQMCommon . moveChildren ( dlgContain , elt ) ; elt . removeChild ( dlgContain ) ; } JQMHeader h = getHeader ( ) ; if ( h != null ) { Element btn = JQMCommon . findChild ( h . getElement ( ) , "ui-btn-icon-notext" ) ; if ( btn != null && "#" . equals ( JQMCommon . getAttribute ( btn , "href" ) ) && ( DataIcon . DELETE == JQMCommon . getIcon ( btn ) || DataIcon . DELETE == JQMCommon . getStyleIcon ( btn ) ) ) { h . getElement ( ) . removeChild ( btn ) ; } } }
There is no correct way to restore page after it was called as dialog so this method is ugly hack but it s useful and working .
6,058
public JQMRadio addRadio ( String value , String text ) { JQMRadio radio = new JQMRadio ( value , text ) ; addRadio ( radio ) ; return radio ; }
Adds a new radio button to this radioset using the given value and text . Returns a JQMRadio instance which can be used to change the value and label of the radio button .
6,059
@ UiChild ( tagname = "radio" ) public void addRadio ( JQMRadio radio ) { radio . setName ( fieldset . getId ( ) ) ; radios . add ( radio ) ; radio . setTheme ( theme ) ; fieldset . add ( radio . getInput ( ) ) ; fieldset . add ( radio . getLabel ( ) ) ; }
UiBinder call method to add a radio button
6,060
private String getValueForId ( String id ) { for ( int k = 0 ; k < fieldset . getWidgetCount ( ) ; k ++ ) { Widget widget = fieldset . getWidget ( k ) ; if ( id . equals ( widget . getElement ( ) . getAttribute ( "id" ) ) ) return widget . getElement ( ) . getAttribute ( "value" ) ; } return null ; }
Returns the value of the button that has the given id
6,061
public void setValue ( String value , boolean fireEvents ) { String oldValue = fireEvents ? getValue ( ) : null ; boolean changed = false ; for ( JQMRadio r : radios ) { TextBox radio = r . getInput ( ) ; if ( ! isChecked ( radio ) ) continue ; boolean checked = value != null && value . equals ( radio . getValue ( ) ) ? true : false ; if ( ! checked ) { setChecked ( radio , false ) ; changed = true ; } } for ( JQMRadio r : radios ) { TextBox radio = r . getInput ( ) ; boolean checked = value != null && value . equals ( radio . getValue ( ) ) ? true : false ; if ( isChecked ( radio ) != checked ) { setChecked ( radio , checked ) ; changed = true ; } } if ( fireEvents && changed ) { String newValue = getValue ( ) ; boolean eq = newValue == oldValue || newValue != null && newValue . equals ( oldValue ) ; if ( ! eq ) { SelectionEvent . fire ( this , newValue ) ; ValueChangeEvent . fire ( this , newValue ) ; } } }
Sets the currently selected radio to the given value .
6,062
public void setPosOnBand ( PosOnBand value ) { if ( value == null ) { getElement ( ) . removeClassName ( STYLE_UI_BTN_RIGHT ) ; getElement ( ) . removeClassName ( STYLE_UI_BTN_LEFT ) ; } else { switch ( value ) { case LEFT : getElement ( ) . addClassName ( STYLE_UI_BTN_LEFT ) ; break ; case RIGHT : getElement ( ) . addClassName ( STYLE_UI_BTN_RIGHT ) ; break ; } } }
Works in case of this button placed on Header Popup ...
6,063
private PluralRule instantiateCustomPluralRuleClass ( Class < ? extends PluralRule > clazz ) { PluralRule retVal ; try { String pluralClassName = clazz . getName ( ) + "_" + this . getLocale ( ) . getLanguage ( ) ; try { Class < ? > pClass = Class . forName ( pluralClassName ) ; retVal = ( PluralRule ) pClass . newInstance ( ) ; } catch ( ClassNotFoundException e ) { retVal = clazz . newInstance ( ) ; } } catch ( InstantiationException e ) { throw new RuntimeException ( "Could not instantiate custom PluralRule class. " + "Make sure the class is not an abstract class or interface and has a default constructor." , e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( "Could not instantiate custom Plural Rule class." , e ) ; } return retVal ; }
Instantiates the plural rule class given inside the PluralCount annotation . The pluralRule class that is instantiated is based on the language originally given to the library . If that language is not found defaults to the given class .
6,064
private static Consumer < JavaFile > write ( ProcessingEnvironment processingEnv ) { return file -> { try { file . writeTo ( processingEnv . getFiler ( ) ) ; } catch ( IOException e ) { JavaFileObject obj = file . toJavaFileObject ( ) ; throw new ProcessingException ( "Can't write" , obj . getName ( ) , obj . getKind ( ) , e ) ; } } ; }
Consumer which writes classes as java files
6,065
private static Stream < Element > asFields ( Element element ) { switch ( element . getKind ( ) ) { case FIELD : return Stream . of ( element ) ; case CLASS : return element . getEnclosedElements ( ) . stream ( ) . flatMap ( MatcherFactoryGenerator :: asFields ) ; } return Stream . empty ( ) ; }
Recursively adds to stream all fields of class of fields of nested class
6,066
@ UiChild ( limit = 1 , tagname = "buttonActivePersist" ) public void addActivePersist ( final JQMButton button ) { if ( button == null ) return ; addActive ( button ) ; button . getElement ( ) . addClassName ( "ui-state-persist" ) ; }
Restore the button s active state each time the page is shown while it exists in the DOM .
6,067
public void setIconPos ( IconPos pos ) { if ( pos == null ) { JQMCommon . setIconPos ( this , pos ) ; } else { IconPos oldPos = getIconPos ( ) ; JQMCommon . setIconPos ( this , pos ) ; for ( int i = 0 ; i < buttons . size ( ) ; i ++ ) { JQMButton btn = buttons . get ( i ) ; IconPos p = btn . getIconPos ( ) ; if ( p == null || oldPos == null || p . equals ( oldPos ) ) btn . setIconPos ( pos ) ; } } }
Sets the position of the icon . If you desire an icon only button then set the position to IconPos . NOTEXT
6,068
private void rebase ( ) { for ( int k = 0 ; k < flow . getWidgetCount ( ) ; k ++ ) { Widget widget = flow . getWidget ( k ) ; String cellStyleName = getCellStyleName ( k ) ; removeAllCellStyles ( widget . getElement ( ) ) ; prepareCellPercentStyle ( k , widget ) ; widget . getElement ( ) . addClassName ( cellStyleName ) ; } }
Update the stylesheets of all cells
6,069
public static boolean isRealHidden ( Widget widget ) { if ( widget == null || ! widget . isAttached ( ) ) return true ; Element elt = widget . getElement ( ) ; return ! UIObject . isVisible ( elt ) || Mobile . isHidden ( elt ) ; }
Expensive based on jQuery realistic visibility check .
6,070
public static String hyphenToCamelCase ( String hyphenStr ) { if ( hyphenStr == null || hyphenStr . isEmpty ( ) ) return hyphenStr ; int p = hyphenStr . indexOf ( '-' ) ; if ( p == - 1 ) return hyphenStr ; StringBuilder sb = new StringBuilder ( hyphenStr ) ; do { int i = p + 1 ; if ( i < sb . length ( ) ) { sb . setCharAt ( i , Character . toUpperCase ( sb . charAt ( i ) ) ) ; } sb . deleteCharAt ( p ) ; p = sb . indexOf ( "-" , p ) ; if ( p == - 1 ) break ; } while ( true ) ; return sb . toString ( ) ; }
Converts aaa - bbb - ccc to aaaBbbCcc
6,071
public static void moveChildren ( Element from , Element to ) { if ( from == null || to == null || from == to ) return ; for ( int k = from . getChildCount ( ) - 1 ; k >= 0 ; k -- ) { Node node = from . getChild ( k ) ; from . removeChild ( node ) ; to . insertFirst ( node ) ; } }
Moves all children of from element onto to element .
6,072
public static void render ( String id ) { if ( id == null || id . isEmpty ( ) ) { throw new IllegalArgumentException ( "render() for empty id is not possible" ) ; } renderImpl ( id ) ; }
Ask JQuery Mobile to render the child elements of the element with the given id .
6,073
public static String getDigitsOnly ( String s ) { if ( isEmpty ( s ) ) return s ; String rslt = s . trim ( ) ; if ( isEmpty ( rslt ) ) return rslt ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < rslt . length ( ) ; i ++ ) { char ch = rslt . charAt ( i ) ; if ( Character . isDigit ( ch ) ) sb . append ( ch ) ; } return sb . toString ( ) ; }
Returns only digits from specified string
6,074
public static boolean isDigitsOnly ( String s ) { if ( isEmpty ( s ) ) return false ; String rslt = s . trim ( ) ; if ( isEmpty ( rslt ) ) return false ; for ( int i = 0 ; i < rslt . length ( ) ; i ++ ) { char ch = rslt . charAt ( i ) ; if ( ! Character . isDigit ( ch ) ) return false ; } return true ; }
Returns true if specified string contains only digits
6,075
public boolean isSelected ( String id ) { for ( JQMCheckbox box : checks ) { if ( id . equals ( box . getId ( ) ) ) return box . isChecked ( ) ; } return false ; }
Returns true if the checkbox with the given id is selected .
6,076
private void initChangeHandler ( ) { JQMChangeHandler handler = new JQMChangeHandler ( ) { public void onEvent ( JQMEvent < ? > event ) { DomEvent . fireNativeEvent ( Document . get ( ) . createChangeEvent ( ) , input ) ; } } ; JQMHandlerRegistration . registerJQueryHandler ( new WidgetHandlerCounter ( ) { public int getHandlerCountForWidget ( GwtEvent . Type < ? > type ) { return getHandlerCount ( type ) ; } } , this , handler , JQMComponentEvents . CHANGE , JQMEventFactory . getType ( JQMComponentEvents . CHANGE , JQMChangeHandler . class ) ) ; }
Standard GWT ChangeEvent is not working for search input that s why we have to activate it manually by listening jQuery change event .
6,077
private static < T > InputStream getPropertiesFile ( Class < T > clazz , ULocale locale ) { String localeStr = "" ; if ( locale != null ) { localeStr = '_' + locale . getName ( ) ; } String filePath = clazz . getName ( ) . replace ( DOT , SLASH ) + localeStr + PROPERTIES_EXT ; return clazz . getClassLoader ( ) . getResourceAsStream ( filePath ) ; }
Get the properties file associated with the given interface and locale as an InputStream . Use the return value in an InputStream reader to load the properties file data into a Properties object .
6,078
public String getValue ( ) { switch ( getSelectedIndex ( ) ) { case 0 : if ( internVal == null ) return null ; internVal = getValue1 ( ) ; return internVal ; case 1 : internVal = getValue2 ( ) ; return internVal ; default : return null ; } }
Returns the currently selected value or null if there is no currently selected button
6,079
public void setValue ( String value , boolean fireEvents ) { int newIdx = value == null ? 0 : value . equals ( getValue1 ( ) ) ? 0 : value . equals ( getValue2 ( ) ) ? 1 : 0 ; int oldIdx = getSelectedIndex ( ) ; String oldVal = fireEvents ? getValue ( ) : null ; internVal = value ; if ( oldIdx != newIdx ) { inSetValue = true ; try { setSelectedIndex ( newIdx ) ; } finally { inSetValue = false ; } } if ( fireEvents ) { boolean eq = internVal == oldVal || internVal != null && internVal . equals ( oldVal ) ; if ( ! eq ) ValueChangeEvent . fire ( this , internVal ) ; } }
Sets the currently selected value .
6,080
public void setTrackTheme ( String value ) { trackTheme = value != null ? value . trim ( ) : value ; refreshTrackTheme ( ) ; }
Sets the theme for the track button
6,081
public void setDefaultContentType ( DefaultContentType value ) { defaultContentType = value ; if ( defaultContentType != null ) { setData ( "" ) ; searchable = false ; orderable = false ; } }
Set default static content for a column - predefined widgets defaultContent will be used for innerHtml if defined .
6,082
public String calcDefaultContent ( ) { if ( defaultContentType == null ) return defaultContent ; String s ; switch ( defaultContentType ) { case BUTTON : s = "<button data-role='none'>" ; if ( ! Empty . is ( defaultContent ) ) s += defaultContent ; return s + "</button>" ; case CHECKBOX : case CHECKBOX_ROWSELECT : s = "<input type='checkbox' data-role='none'" ; if ( DefaultContentType . CHECKBOX_ROWSELECT . equals ( defaultContentType ) ) { s += " class='" + JsDataTable . CHECKBOX_ROWSEL + "'" ; } if ( ! Empty . is ( defaultContent ) ) { s += ">" + defaultContent + "</input>" ; } else { s += "></input>" ; } return s ; case ROW_DETAILS : return "" ; default : return defaultContent ; } }
Combines both defaultContentType and defaultContent and generates proper content .
6,083
public boolean satisfies ( Match match , int ... ind ) { assertIndLength ( ind ) ; Set values = new HashSet ( ) ; for ( BioPAXElement gen : con1 . generate ( match , ind ) ) { values . addAll ( pa1 . getValueFromBean ( gen ) ) ; } if ( value == EMPTY ) return values . isEmpty ( ) ; if ( oper == Operation . NOT_EMPTY_AND_NOT_INTERSECT && values . isEmpty ( ) ) return false ; else if ( value == USE_SECOND_ARG ) { BioPAXElement q = match . get ( ind [ 1 ] ) ; return oper == Operation . INTERSECT ? values . contains ( q ) : ! values . contains ( q ) ; } else if ( value instanceof Collection ) { Collection query = ( Collection ) value ; values . retainAll ( query ) ; if ( oper == Operation . INTERSECT ) return ! values . isEmpty ( ) ; else return values . isEmpty ( ) ; } else if ( pa2 != null ) { Set others = new HashSet ( ) ; for ( BioPAXElement gen : con2 . generate ( match , ind ) ) { others . addAll ( pa2 . getValueFromBean ( gen ) ) ; } switch ( oper ) { case INTERSECT : others . retainAll ( values ) ; return ! others . isEmpty ( ) ; case NOT_INTERSECT : others . retainAll ( values ) ; return others . isEmpty ( ) ; case NOT_EMPTY_AND_NOT_INTERSECT : if ( others . isEmpty ( ) ) return false ; others . retainAll ( values ) ; return others . isEmpty ( ) ; default : throw new RuntimeException ( "Unhandled operation: " + oper ) ; } } else if ( oper == Operation . INTERSECT ) return values . contains ( value ) ; else return ! values . contains ( value ) ; }
Checks if the generated elements from the first mapped element has either the desired value or has some value in common with the elements generated from second mapped element .
6,084
protected void initUpperEquivalent ( ) { this . upperEquivalent = new HashSet < Node > ( ) ; for ( PhysicalEntity eq : pe . getMemberPhysicalEntityOf ( ) ) { Node node = ( Node ) graph . getGraphObject ( eq ) ; if ( node != null ) this . upperEquivalent . add ( node ) ; } upperEquivalentInited = true ; }
Finds homology parent .
6,085
protected void initLowerEquivalent ( ) { this . lowerEquivalent = new HashSet < Node > ( ) ; for ( PhysicalEntity eq : pe . getMemberPhysicalEntity ( ) ) { Node node = ( Node ) graph . getGraphObject ( eq ) ; if ( node != null ) this . lowerEquivalent . add ( node ) ; } lowerEquivalentInited = true ; }
Finds member nodes if this is a homology node
6,086
public < T extends BioPAXElement > T copy ( Model model , T source , String newID ) { T copy = copy ( source , newID ) ; model . add ( copy ) ; return copy ; }
Creates a copy of the BioPAX object with all its properties are the same and also adds it to a model .
6,087
public boolean satisfies ( Match match , int ... ind ) { return generate ( match , ind ) . contains ( match . get ( ind [ ind . length - 1 ] ) ) ; }
Use this method only if constraint canGenerate and satisfaction criteria is that simple .
6,088
protected ConversionDirectionType getCatalysisDirection ( Control cont ) { if ( cont instanceof Catalysis ) { CatalysisDirectionType catDir = ( ( Catalysis ) cont ) . getCatalysisDirection ( ) ; if ( catDir == CatalysisDirectionType . LEFT_TO_RIGHT ) { return ConversionDirectionType . LEFT_TO_RIGHT ; } else if ( catDir == CatalysisDirectionType . RIGHT_TO_LEFT ) { return ConversionDirectionType . RIGHT_TO_LEFT ; } } return null ; }
Gets the direction of the Control if exists .
6,089
protected List < Control > getControlChain ( Control control , Interaction inter ) { LinkedList < Control > list = new LinkedList < Control > ( ) ; list . add ( control ) ; boolean found = search ( list , inter ) ; if ( ! found ) throw new RuntimeException ( "No link from Control to Conversion." ) ; return list ; }
Gets the chain of Control staring from the given Control leading to the given Interaction . Use this method only if you are sure that there is a link from the control to conversion . Otherwise a RuntimeException is thrown . This assumes that there is only one control chain towards the interaction . It not then one of the chains will be returned .
6,090
private boolean search ( LinkedList < Control > list , Interaction inter ) { if ( list . getLast ( ) . getControlled ( ) . contains ( inter ) ) return true ; for ( Process process : list . getLast ( ) . getControlled ( ) ) { if ( process instanceof Control ) { if ( list . contains ( process ) ) continue ; list . add ( ( Control ) process ) ; if ( search ( list , inter ) ) return true ; else list . removeLast ( ) ; } } return false ; }
Checks if the control chain is actually controlling the Interaction .
6,091
protected Set < PhysicalEntity > getConvParticipants ( Conversion conv , RelType type ) { ConversionDirectionType dir = getDirection ( conv ) ; if ( dir == ConversionDirectionType . REVERSIBLE ) { HashSet < PhysicalEntity > set = new HashSet < PhysicalEntity > ( conv . getLeft ( ) ) ; set . addAll ( conv . getRight ( ) ) ; return set ; } else if ( dir == ConversionDirectionType . RIGHT_TO_LEFT ) { return type == RelType . INPUT ? conv . getRight ( ) : conv . getLeft ( ) ; } else return type == RelType . OUTPUT ? conv . getRight ( ) : conv . getLeft ( ) ; }
Gets input ot output participants of the Conversion .
6,092
protected ConversionDirectionType findDirectionInPathways ( Conversion conv ) { Set < StepDirection > dirs = new HashSet < StepDirection > ( ) ; for ( PathwayStep step : conv . getStepProcessOf ( ) ) { if ( step instanceof BiochemicalPathwayStep ) { StepDirection dir = ( ( BiochemicalPathwayStep ) step ) . getStepDirection ( ) ; if ( dir != null ) dirs . add ( dir ) ; } } if ( dirs . size ( ) > 1 ) return ConversionDirectionType . REVERSIBLE ; else if ( ! dirs . isEmpty ( ) ) { return dirs . iterator ( ) . next ( ) == StepDirection . LEFT_TO_RIGHT ? ConversionDirectionType . LEFT_TO_RIGHT : ConversionDirectionType . RIGHT_TO_LEFT ; } else return null ; }
Searches pathways that contains this conversion for the possible directions . If both directions exist then the result is reversible .
6,093
protected ConversionDirectionType findDirectionInCatalysis ( Conversion conv ) { Set < ConversionDirectionType > dirs = new HashSet < ConversionDirectionType > ( ) ; for ( Control control : conv . getControlledOf ( ) ) { ConversionDirectionType dir = getCatalysisDirection ( control ) ; if ( dir != null ) dirs . add ( dir ) ; } if ( dirs . size ( ) > 1 ) return ConversionDirectionType . REVERSIBLE ; else if ( ! dirs . isEmpty ( ) ) return dirs . iterator ( ) . next ( ) ; else return null ; }
Searches the controlling catalysis for possible direction of the conversion .
6,094
public String getValue ( Match m , int col ) { assert col == 0 ; return getRelatedIDs ( ( SmallMoleculeReference ) m . get ( "SMR" , getPattern ( ) ) ) ; }
Gets the ids of the small molecule reference and its physical entities .
6,095
private String getRelatedIDs ( SmallMoleculeReference smr ) { String ids = smr . getUri ( ) ; for ( Object o : new PathAccessor ( "SmallMoleculeReference/entityReferenceOf" ) . getValueFromBean ( smr ) ) { SimplePhysicalEntity spe = ( SimplePhysicalEntity ) o ; ids += "\n" + spe . getUri ( ) ; } return ids ; }
Gets IDs of the small molecule reference and its physical entities .
6,096
public static Set < ModificationFeature > [ ] getChangedModifications ( PhysicalEntity before , PhysicalEntity after ) { Set < Modification > set1 = collectFeatures ( before ) ; Set < Modification > set2 = collectFeatures ( after ) ; Set < Modification > temp = new HashSet < Modification > ( set1 ) ; set1 . removeAll ( set2 ) ; set2 . removeAll ( temp ) ; Set < Modification > furtherRemove = new HashSet < Modification > ( ) ; for ( Modification m1 : set1 ) { for ( Modification m2 : set2 ) { if ( furtherRemove . contains ( m2 ) ) continue ; if ( m1 . getKey ( ) . equals ( m2 . getKey ( ) ) ) { furtherRemove . add ( m1 ) ; furtherRemove . add ( m2 ) ; break ; } } } set1 . removeAll ( furtherRemove ) ; set2 . removeAll ( furtherRemove ) ; return new Set [ ] { collectFeatures ( set2 ) , collectFeatures ( set1 ) } ; }
Gets the differential features .
6,097
public void writeResult ( Map < BioPAXElement , List < Match > > matches , OutputStream out ) throws IOException { writeResultAsSIF ( matches , out , true , getSourceLabel ( ) , getTargetLabel ( ) ) ; }
Writes the result as A B where A and B are gene symbols and whitespace is tab .
6,098
public static Constraint nameEquals ( String ... name ) { return new Field ( "Named/name" , Field . Operation . INTERSECT , new HashSet < String > ( Arrays . asList ( name ) ) ) ; }
Filters Named to contain a name from the input set .
6,099
public static Constraint differentialActivity ( boolean activating ) { if ( activating ) return new AND ( new MappedConst ( new ActivityConstraint ( true ) , 1 ) , new MappedConst ( new ActivityConstraint ( false ) , 0 ) ) ; else return new AND ( new MappedConst ( new ActivityConstraint ( true ) , 0 ) , new MappedConst ( new ActivityConstraint ( false ) , 1 ) ) ; }
Gets a constraint to ensure that ensures only one of the two PhysicalEntities has an activity . Size of this constraint is 2 .