idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
18,400
public List < Duplet < String , ArrayList < WComponent > > > getTerms ( ) { Map < String , Duplet < String , ArrayList < WComponent > > > componentsByTerm = new HashMap <> ( ) ; List < Duplet < String , ArrayList < WComponent > > > result = new ArrayList <> ( ) ; List < WComponent > childList = content . getComponentModel ( ) . getChildren ( ) ; if ( childList != null ) { for ( int i = 0 ; i < childList . size ( ) ; i ++ ) { WComponent child = childList . get ( i ) ; String term = child . getTag ( ) ; Duplet < String , ArrayList < WComponent > > termComponents = componentsByTerm . get ( term ) ; if ( termComponents == null ) { termComponents = new Duplet <> ( term , new ArrayList < WComponent > ( ) ) ; componentsByTerm . put ( term , termComponents ) ; result . add ( termComponents ) ; } termComponents . getSecond ( ) . add ( child ) ; } } return result ; }
Groups a definition list s child components by their term for rendering .
247
14
18,401
private List < WComponent > getComponentsForTerm ( final String term ) { List < WComponent > childList = content . getComponentModel ( ) . getChildren ( ) ; List < WComponent > result = new ArrayList <> ( ) ; if ( childList != null ) { for ( int i = 0 ; i < childList . size ( ) ; i ++ ) { WComponent child = childList . get ( i ) ; if ( term . equals ( child . getTag ( ) ) ) { result . add ( child ) ; } } } return result ; }
Retrieves the components for the given term .
122
10
18,402
public void setArgs ( final Serializable ... args ) { this . args = args == null || args . length == 0 ? null : args ; }
Sets the message format arguments .
31
7
18,403
public int addSpaceContact ( int spaceId , ContactCreate create , boolean silent ) { return getResourceFactory ( ) . getApiResource ( "/contact/space/" + spaceId + "/" ) . queryParam ( "silent" , silent ? "1" : "0" ) . entity ( create , MediaType . APPLICATION_JSON_TYPE ) . post ( ContactCreateResponse . class ) . getId ( ) ; }
Adds a new contact to the given space .
92
9
18,404
public void updateSpaceContact ( int profileId , ContactUpdate update , boolean silent , boolean hook ) { getResourceFactory ( ) . getApiResource ( "/contact/" + profileId ) . queryParam ( "silent" , silent ? "1" : "0" ) . queryParam ( "hook" , hook ? "1" : "0" ) . entity ( update , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; }
Updates the entire space contact . Only fields which have values specified will be updated . To delete the contents of a field pass an empty array for the value .
97
32
18,405
public < T , F , R > List < T > getContacts ( ProfileField < F , R > key , F value , Integer limit , Integer offset , ProfileType < T > type , ContactOrder order , ContactType contactType ) { WebResource resource = getResourceFactory ( ) . getApiResource ( "/contact/" ) ; return getContactsCommon ( resource , key , value , limit , offset , type , order , contactType ) ; }
Used to get a list of contacts for the user .
96
11
18,406
@ Override public void handleRequest ( final Request request ) { super . handleRequest ( request ) ; String targ = request . getParameter ( Environment . TARGET_ID ) ; boolean contentReqested = ( targ != null && targ . equals ( getTargetId ( ) ) ) ; if ( contentReqested ) { ContentEscape escape = new ContentEscape ( getImage ( ) ) ; escape . setCacheable ( ! Util . empty ( getCacheKey ( ) ) ) ; throw escape ; } }
When an img element is included in the html output of a page the browser will make a second request to get the image contents . The handleRequest method has been overridden to detect whether the request is the image content fetch request by looking for the parameter that we encode in the image url .
109
58
18,407
public void setImage ( final Image image ) { ImageModel model = getOrCreateComponentModel ( ) ; model . image = image ; model . imageUrl = null ; }
Sets the image .
36
5
18,408
public void setImageUrl ( final String imageUrl ) { ImageModel model = getOrCreateComponentModel ( ) ; model . imageUrl = imageUrl ; model . image = null ; }
Sets the image to an external URL .
39
9
18,409
@ Override public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WRadioButtonSelect rbSelect = ( WRadioButtonSelect ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; int cols = rbSelect . getButtonColumns ( ) ; boolean readOnly = rbSelect . isReadOnly ( ) ; xml . appendTagOpen ( "ui:radiobuttonselect" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , rbSelect . isHidden ( ) , "true" ) ; if ( readOnly ) { xml . appendAttribute ( "readOnly" , "true" ) ; } else { xml . appendOptionalAttribute ( "disabled" , rbSelect . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "required" , rbSelect . isMandatory ( ) , "true" ) ; xml . appendOptionalAttribute ( "submitOnChange" , rbSelect . isSubmitOnChange ( ) , "true" ) ; xml . appendOptionalAttribute ( "toolTip" , component . getToolTip ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , component . getAccessibleText ( ) ) ; } xml . appendOptionalAttribute ( "frameless" , rbSelect . isFrameless ( ) , "true" ) ; switch ( rbSelect . getButtonLayout ( ) ) { case COLUMNS : xml . appendAttribute ( "layout" , "column" ) ; xml . appendOptionalAttribute ( "layoutColumnCount" , cols > 0 , String . valueOf ( cols ) ) ; break ; case FLAT : xml . appendAttribute ( "layout" , "flat" ) ; break ; case STACKED : xml . appendAttribute ( "layout" , "stacked" ) ; break ; default : throw new SystemException ( "Unknown radio button layout: " + rbSelect . getButtonLayout ( ) ) ; } xml . appendClose ( ) ; // Options List < ? > options = rbSelect . getOptions ( ) ; boolean renderSelectionsOnly = readOnly ; if ( options != null ) { int optionIndex = 0 ; Object selectedOption = rbSelect . getSelected ( ) ; for ( Object option : options ) { if ( option instanceof OptionGroup ) { throw new SystemException ( "Option groups not supported in WRadioButtonSelect." ) ; } else { renderOption ( rbSelect , option , optionIndex ++ , xml , selectedOption , renderSelectionsOnly ) ; } } } if ( ! readOnly ) { DiagnosticRenderUtil . renderDiagnostics ( rbSelect , renderContext ) ; } xml . appendEndTag ( "ui:radiobuttonselect" ) ; if ( rbSelect . isAjax ( ) ) { paintAjax ( rbSelect , xml ) ; } }
Paints the given WRadioButtonSelect .
683
10
18,410
private void paintAjax ( final WRadioButtonSelect rbSelect , final XmlStringBuilder xml ) { // Start tag xml . appendTagOpen ( "ui:ajaxtrigger" ) ; xml . appendAttribute ( "triggerId" , rbSelect . getId ( ) ) ; xml . appendClose ( ) ; // Target xml . appendTagOpen ( "ui:ajaxtargetid" ) ; xml . appendAttribute ( "targetId" , rbSelect . getAjaxTarget ( ) . getId ( ) ) ; xml . appendEnd ( ) ; // End tag xml . appendEndTag ( "ui:ajaxtrigger" ) ; }
Paints the AJAX information for the given WRadioButtonSelect .
144
15
18,411
@ Override public void setBean ( final Object bean ) { BeanAndProviderBoundComponentModel model = getOrCreateComponentModel ( ) ; model . setBean ( bean ) ; if ( getBeanProperty ( ) == null ) { setBeanProperty ( "." ) ; } // Remove values in scratch map removeBeanFromScratchMap ( ) ; }
Sets the bean associated with this WBeanComponent . This method of bean association is discouraged as the bean will be stored in the user s session . A better alternative is to provide a BeanProvider and a Bean Id .
78
45
18,412
@ Override public void setBeanId ( final Object beanId ) { BeanAndProviderBoundComponentModel model = getOrCreateComponentModel ( ) ; model . setBeanId ( beanId ) ; // Remove values in scratch map removeBeanFromScratchMap ( ) ; }
Sets the bean id associated with this WBeanComponent .
60
13
18,413
@ Override public void setBeanProperty ( final String propertyName ) { String currBeanProperty = getBeanProperty ( ) ; if ( ! Objects . equals ( propertyName , currBeanProperty ) ) { getOrCreateComponentModel ( ) . setBeanProperty ( propertyName ) ; } }
Sets the bean property that this component is interested in . The bean property is expressed in Jakarta PropertyUtils bean notation with an extension of . to indicate that the bean itself should be used .
67
39
18,414
protected void doUpdateBeanValue ( final Object value ) { String beanProperty = getBeanProperty ( ) ; if ( beanProperty != null && beanProperty . length ( ) > 0 && ! "." . equals ( beanProperty ) ) { Object bean = getBean ( ) ; if ( bean != null ) { try { Object beanValue = getBeanValue ( ) ; if ( ! Util . equals ( beanValue , value ) ) { PropertyUtils . setProperty ( bean , beanProperty , value ) ; } } catch ( Exception e ) { LOG . error ( "Failed to set bean property " + beanProperty + " on " + bean ) ; } } } }
Updates the bean value with the new value .
145
10
18,415
protected void removeBeanFromScratchMap ( ) { Map < Object , Object > scratchMap = getBeanScratchMap ( ) ; if ( scratchMap == null ) { return ; } scratchMap . remove ( SCRATCHMAP_BEAN_ID_KEY ) ; scratchMap . remove ( SCRATCHMAP_BEAN_OBJECT_KEY ) ; }
Remove the bean from the scratch maps .
79
8
18,416
public boolean isChanged ( ) { Object currentValue = getData ( ) ; Object sharedValue = ( ( BeanAndProviderBoundComponentModel ) getDefaultModel ( ) ) . getData ( ) ; if ( getBeanProperty ( ) != null ) { sharedValue = getBeanValue ( ) ; } return ! Util . equals ( currentValue , sharedValue ) ; }
Indicates whether this component s data has changed from the default value .
79
14
18,417
@ Override public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WTabSet tabSet = ( WTabSet ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "ui:tabset" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendAttribute ( "type" , getTypeAsString ( tabSet . getType ( ) ) ) ; xml . appendOptionalAttribute ( "disabled" , tabSet . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , tabSet . isHidden ( ) , "true" ) ; xml . appendOptionalAttribute ( "contentHeight" , tabSet . getContentHeight ( ) ) ; xml . appendOptionalAttribute ( "showHeadOnly" , tabSet . isShowHeadOnly ( ) , "true" ) ; xml . appendOptionalAttribute ( "single" , TabSetType . ACCORDION . equals ( tabSet . getType ( ) ) && tabSet . isSingle ( ) , "true" ) ; if ( WTabSet . TabSetType . ACCORDION . equals ( tabSet . getType ( ) ) ) { xml . appendOptionalAttribute ( "groupName" , tabSet . getGroupName ( ) ) ; } xml . appendClose ( ) ; // Render margin MarginRendererUtil . renderMargin ( tabSet , renderContext ) ; paintChildren ( tabSet , renderContext ) ; xml . appendEndTag ( "ui:tabset" ) ; }
Paints the given WTabSet .
387
8
18,418
private void createUI ( ) { add ( new WHeading ( HeadingLevel . H2 , "Contacts" ) ) ; add ( repeater ) ; createButtonBar ( ) ; createAddContactSubForm ( ) ; createPrintContactsSubForm ( ) ; }
Creates the example UI .
58
6
18,419
private void createButtonBar ( ) { // Update and reset controls for the repeater. WPanel buttonPanel = new WPanel ( WPanel . Type . FEATURE ) ; buttonPanel . setMargin ( new Margin ( Size . MEDIUM , null , Size . LARGE , null ) ) ; buttonPanel . setLayout ( new BorderLayout ( ) ) ; WButton updateButton = new WButton ( "Update" ) ; updateButton . setImage ( "/image/document-save-5.png" ) ; updateButton . setImagePosition ( WButton . ImagePosition . EAST ) ; buttonPanel . add ( updateButton , BorderLayout . EAST ) ; WButton resetButton = new WButton ( "Reset" ) ; resetButton . setImage ( "/image/edit-undo-8.png" ) ; resetButton . setImagePosition ( WButton . ImagePosition . WEST ) ; resetButton . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { repeater . setData ( fetchDataList ( ) ) ; } } ) ; buttonPanel . add ( resetButton , BorderLayout . WEST ) ; add ( buttonPanel ) ; add ( new WAjaxControl ( updateButton , repeater ) ) ; add ( new WAjaxControl ( resetButton , repeater ) ) ; }
Create the UI artefacts for the update and reset buttons .
287
12
18,420
private void createAddContactSubForm ( ) { add ( new WHeading ( HeadingLevel . H3 , "Add a new contact" ) ) ; WButton addBtn = new WButton ( "Add" ) ; addBtn . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { addNewContact ( ) ; } } ) ; addBtn . setImage ( "/image/address-book-new.png" ) ; newNameField . setDefaultSubmitButton ( addBtn ) ; WContainer container = new WContainer ( ) ; container . add ( newNameField ) ; container . add ( addBtn ) ; WFieldLayout layout = new WFieldLayout ( ) ; add ( layout ) ; layout . addField ( "New contact name" , container ) ; add ( new WAjaxControl ( addBtn , new AjaxTarget [ ] { repeater , newNameField } ) ) ; }
Create the UI artefacts for the Add contact sub form .
205
12
18,421
private void createPrintContactsSubForm ( ) { add ( new WHeading ( HeadingLevel . H3 , "Print to CSV" ) ) ; WButton printBtn = new WButton ( "Print" ) ; printBtn . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { printDetails ( ) ; } } ) ; printBtn . setImage ( "/image/document-print.png" ) ; printBtn . setImagePosition ( WButton . ImagePosition . EAST ) ; WFieldLayout layout = new WFieldLayout ( ) ; add ( layout ) ; layout . setMargin ( new Margin ( Size . LARGE , null , null , null ) ) ; layout . addField ( "Print output" , printOutput ) ; layout . addField ( ( WLabel ) null , printBtn ) ; add ( new WAjaxControl ( printBtn , printOutput ) ) ; }
Create the UI artefacts for the Print contacts sub form .
206
12
18,422
private void printDetails ( ) { StringBuilder builder = new StringBuilder ( "\"Name\",\"Phone\",\"Roles\",\"Identifier\"\n" ) ; for ( Object contact : repeater . getBeanList ( ) ) { builder . append ( contact ) . append ( ' ' ) ; } printOutput . setText ( builder . toString ( ) ) ; }
Write the list of contacts into the WTextArea printOutput .
80
13
18,423
private static List < ContactDetails > fetchDataList ( ) { List < ContactDetails > list = new ArrayList <> ( ) ; list . add ( new ContactDetails ( "David" , "1234" , new String [ ] { "a" , "b" } ) ) ; list . add ( new ContactDetails ( "Jun" , "1111" , new String [ ] { "c" } ) ) ; list . add ( new ContactDetails ( "Martin" , null , new String [ ] { "b" } ) ) ; return list ; }
Retrieves dummy data used by this example .
119
10
18,424
private WFieldSet addFieldSet ( final String title , final WFieldSet . FrameType type ) { final WFieldSet fieldset = new WFieldSet ( title ) ; fieldset . setFrameType ( type ) ; fieldset . setMargin ( new Margin ( null , null , Size . LARGE , null ) ) ; final WFieldLayout layout = new WFieldLayout ( ) ; fieldset . add ( layout ) ; layout . setLabelWidth ( 25 ) ; layout . addField ( "Street address" , new WTextField ( ) ) ; final WField add2Field = layout . addField ( "Street address line 2" , new WTextField ( ) ) ; add2Field . getLabel ( ) . setHidden ( true ) ; layout . addField ( "Suburb" , new WTextField ( ) ) ; layout . addField ( "State/Territory" , new WDropdown ( new String [ ] { "" , "ACT" , "NSW" , "NT" , "QLD" , "SA" , "TAS" , "VIC" , "WA" } ) ) ; //NOTE: this is an Australia-specific post code field. An Australian post code is not a number as they may contain a leading zero. final WTextField postcode = new WTextField ( ) ; postcode . setMaxLength ( 4 ) ; postcode . setColumns ( 4 ) ; postcode . setMinLength ( 3 ) ; layout . addField ( "Postcode" , postcode ) ; add ( fieldset ) ; return fieldset ; }
Creates a WFieldSet with content and a given FrameType .
341
14
18,425
private void makeSimpleExample ( ) { add ( new WHeading ( HeadingLevel . H3 , "Simple WRadioButtonSelect" ) ) ; WPanel examplePanel = new WPanel ( ) ; examplePanel . setLayout ( new FlowLayout ( FlowLayout . VERTICAL , Size . MEDIUM ) ) ; add ( examplePanel ) ; /** * The radio button select. */ final WRadioButtonSelect rbSelect = new WRadioButtonSelect ( "australian_state" ) ; final WTextField text = new WTextField ( ) ; text . setReadOnly ( true ) ; text . setText ( NO_SELECTION ) ; WButton update = new WButton ( "Update" ) ; update . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { text . setText ( "The selected item is: " + rbSelect . getSelected ( ) ) ; } } ) ; //setting the default submit button improves usability. It can be set on a WPanel or the WRadioButtonSelect directly examplePanel . setDefaultSubmitButton ( update ) ; examplePanel . add ( new WLabel ( "Select a state or territory" , rbSelect ) ) ; examplePanel . add ( rbSelect ) ; examplePanel . add ( text ) ; examplePanel . add ( update ) ; add ( new WAjaxControl ( update , text ) ) ; }
Make a simple editable example . The label for this example is used to get the example for use in the unit tests .
306
25
18,426
private void makeFramelessExample ( ) { add ( new WHeading ( HeadingLevel . H3 , "WRadioButtonSelect without its frame" ) ) ; add ( new ExplanatoryText ( "When a WRadioButtonSelect is frameless it loses some of its coherence, especially when its WLabel is hidden or " + "replaced by a toolTip. Using a frameless WRadioButtonSelect is useful within an existing WFieldLayout as it can provide a more " + "consistent user interface but only if it has a relatively small number of options." ) ) ; final WRadioButtonSelect select = new SelectWithSelection ( "australian_state" ) ; select . setFrameless ( true ) ; add ( new WLabel ( "Frameless with default selection" , select ) ) ; add ( select ) ; }
Make a simple editable example without a frame .
181
10
18,427
private void addInsideAFieldLayoutExample ( ) { add ( new WHeading ( HeadingLevel . H3 , "WRadioButtonSelect inside a WFieldLayout" ) ) ; add ( new ExplanatoryText ( "When a WRadioButtonSelect is inside a WField its label is exposed in a way which appears and behaves like a regular HTML label." + " This allows WRadioButtonSelects to be used in a layout with simple form controls (such as WTextField) and produce a consistent" + " and predicatable interface.\n" + "The third example in this set uses a null label and a toolTip to hide the labelling element. This can lead to user confusion and" + " is not recommended." ) ) ; // Note: the wrapper WPanel here is to work around a bug in validation. See https://github.com/BorderTech/wcomponents/issues/1370 final WPanel wrapper = new WPanel ( ) ; add ( wrapper ) ; final WMessages messages = new WMessages ( ) ; wrapper . add ( messages ) ; WFieldLayout layout = new WFieldLayout ( ) ; layout . setLabelWidth ( 25 ) ; wrapper . add ( layout ) ; WButton resetThisBit = new WButton ( "Reset this bit" ) ; resetThisBit . setCancel ( true ) ; resetThisBit . setAjaxTarget ( wrapper ) ; resetThisBit . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { wrapper . reset ( ) ; } } ) ; layout . addField ( resetThisBit ) ; String [ ] options = new String [ ] { "Dog" , "Cat" , "Bird" , "Turtle" } ; WRadioButtonSelect select = new WRadioButtonSelect ( options ) ; layout . addField ( "Select an animal" , select ) ; String [ ] options2 = new String [ ] { "Parrot" , "Galah" , "Cockatoo" , "Lyre" } ; select = new WRadioButtonSelect ( options2 ) ; select . setMandatory ( true ) ; layout . addField ( "You must select a bird" , select ) ; select . setFrameless ( true ) ; //a tooltip can be used as a label stand-in even in a WField String [ ] options3 = new String [ ] { "Carrot" , "Beet" , "Brocolli" , "Bacon - the perfect vegetable" } ; select = new WRadioButtonSelect ( options3 ) ; //if you absolutely do not want a WLabel in a WField then it has to be added using null cast to a WLabel. layout . addField ( ( WLabel ) null , select ) ; select . setToolTip ( "Veggies" ) ; WButton btnValidate = new WButton ( "validate" ) ; btnValidate . setAction ( new ValidatingAction ( messages . getValidationErrors ( ) , layout ) { @ Override public void executeOnValid ( final ActionEvent event ) { // do nothing } } ) ; layout . addField ( btnValidate ) ; wrapper . add ( new WAjaxControl ( btnValidate , wrapper ) ) ; }
When a WRadioButtonSelect is added to a WFieldLayout the legend is moved . The first CheckBoxSelect has a frame the second doesn t
702
31
18,428
private void addFlatSelectExample ( ) { add ( new WHeading ( HeadingLevel . H3 , "WRadioButtonSelect with flat layout" ) ) ; add ( new ExplanatoryText ( "Setting the layout to FLAT will make the radio buttons be rendered in a horizontal line. They will wrap when they" + " reach the edge of the parent container." ) ) ; final WRadioButtonSelect select = new WRadioButtonSelect ( "australian_state" ) ; select . setButtonLayout ( WRadioButtonSelect . LAYOUT_FLAT ) ; add ( new WLabel ( "Flat selection" , select ) ) ; add ( select ) ; }
adds a WRadioButtonSelect with LAYOUT_FLAT .
148
16
18,429
private void addReadOnlyExamples ( ) { add ( new WHeading ( HeadingLevel . H3 , "Read-only WRadioButtonSelect examples" ) ) ; add ( new ExplanatoryText ( "These examples all use the same list of options: the states and territories list from the editable examples above. " + "When the readOnly state is specified only that option which is selected is output.\n" + "Since no more than one option is able to be selected the layout and frame settings are ignored in the read only state." ) ) ; WFieldLayout layout = new WFieldLayout ( ) ; add ( layout ) ; WRadioButtonSelect select = new WRadioButtonSelect ( "australian_state" ) ; select . setReadOnly ( true ) ; layout . addField ( "Read only with no selection" , select ) ; select = new SelectWithSelection ( "australian_state" ) ; select . setReadOnly ( true ) ; layout . addField ( "Read only with selection" , select ) ; }
Examples of readonly states . When in a read only state only the selected option is output . Since a WRadioButtonSeelct can only have 0 or 1 selected option the LAYOUT and FRAME are ignored .
227
46
18,430
private void addContentRow ( final String contentDesc , final ContentAccess contentAccess , final MutableContainer target ) { // Demonstrate WButton + WContent, round trip WButton button = new WButton ( contentDesc ) ; final WContent buttonContent = new WContent ( ) ; button . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { buttonContent . setContentAccess ( contentAccess ) ; buttonContent . display ( ) ; } } ) ; WContainer buttonCell = new WContainer ( ) ; buttonCell . add ( buttonContent ) ; buttonCell . add ( button ) ; target . add ( buttonCell ) ; // Demonstrate WButton + WContent, using AJAX WButton ajaxButton = new WButton ( contentDesc ) ; final WContent ajaxContent = new WContent ( ) ; ajaxButton . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { ajaxContent . setContentAccess ( contentAccess ) ; ajaxContent . display ( ) ; } } ) ; WContainer ajaxCell = new WContainer ( ) ; // The WContent must be wrapped in an AJAX targetable container WPanel ajaxContentPanel = new WPanel ( ) ; ajaxContentPanel . add ( ajaxContent ) ; ajaxCell . add ( ajaxButton ) ; ajaxCell . add ( ajaxContentPanel ) ; ajaxButton . setAjaxTarget ( ajaxContentPanel ) ; target . add ( ajaxCell ) ; // Demonstrate WContentLink - new window WContentLink contentLinkNewWindow = new WContentLink ( contentDesc ) { @ Override protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; setContentAccess ( contentAccess ) ; } } ; target . add ( contentLinkNewWindow ) ; // Demonstrate WContentLink - prompt to save WContentLink contentLinkPromptToSave = new WContentLink ( contentDesc ) { @ Override protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; setContentAccess ( contentAccess ) ; } } ; contentLinkPromptToSave . setDisplayMode ( DisplayMode . PROMPT_TO_SAVE ) ; target . add ( contentLinkPromptToSave ) ; // Demonstrate WContentLink - inline WContentLink contentLinkInline = new WContentLink ( contentDesc ) { @ Override protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; setContentAccess ( contentAccess ) ; } } ; contentLinkInline . setDisplayMode ( DisplayMode . DISPLAY_INLINE ) ; target . add ( contentLinkInline ) ; // Demonstrate targeting of content via a URL WMenu menu = new WMenu ( WMenu . MenuType . FLYOUT ) ; final WContent menuContent = new WContent ( ) ; menuContent . setDisplayMode ( DisplayMode . PROMPT_TO_SAVE ) ; WMenuItem menuItem = new WMenuItem ( contentDesc ) { @ Override protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; menuContent . setContentAccess ( contentAccess ) ; setUrl ( menuContent . getUrl ( ) ) ; } } ; menu . add ( menuItem ) ; WContainer menuCell = new WContainer ( ) ; menuCell . add ( menuContent ) ; menuCell . add ( menu ) ; target . add ( menuCell ) ; }
Adds components to the given container which demonstrate various ways of acessing the given content .
777
18
18,431
private void applySettings ( ) { linkContainer . reset ( ) ; WLink exampleLink = new WLink ( ) ; exampleLink . setText ( tfLinkLabel . getText ( ) ) ; final String url = tfUrlField . getValue ( ) ; if ( "" . equals ( url ) || ! isValidUrl ( url ) ) { tfUrlField . setText ( URL ) ; exampleLink . setUrl ( URL ) ; } else { exampleLink . setUrl ( url ) ; } exampleLink . setRenderAsButton ( cbRenderAsButton . isSelected ( ) ) ; exampleLink . setText ( tfLinkLabel . getText ( ) ) ; if ( cbSetImage . isSelected ( ) ) { WImage linkImage = new WImage ( "/image/attachment.png" , "Add attachment" ) ; exampleLink . setImage ( linkImage . getImage ( ) ) ; exampleLink . setImagePosition ( ( ImagePosition ) ddImagePosition . getSelected ( ) ) ; } exampleLink . setDisabled ( cbDisabled . isSelected ( ) ) ; if ( tfAccesskey . getText ( ) != null && tfAccesskey . getText ( ) . length ( ) > 0 ) { exampleLink . setAccessKey ( tfAccesskey . getText ( ) . toCharArray ( ) [ 0 ] ) ; } if ( cbOpenNew . isSelected ( ) ) { exampleLink . setOpenNewWindow ( true ) ; exampleLink . setTargetWindowName ( "_blank" ) ; } else { exampleLink . setOpenNewWindow ( false ) ; } linkContainer . add ( exampleLink ) ; }
this is were the majority of the work is done for building the link . Note that it is in a container that is reset effectively creating a new link . this is only done to enable to dynamically change the link to a button and back .
355
48
18,432
public void showDetails ( final ActionEvent event ) { // Track down the data associated with this event. MyData data = ( MyData ) event . getActionObject ( ) ; displayDialog . setData ( data ) ; dialog . display ( ) ; }
Handle show details .
53
4
18,433
private WMessages getWMessageInstance ( ) { MessageContainer container = getMessageContainer ( component ) ; WMessages result = null ; if ( container == null ) { LOG . warn ( "No MessageContainer as ancestor of " + component + ". Messages will not be added" ) ; } else { result = container . getMessages ( ) ; if ( result == null ) { LOG . warn ( "No messages in container of " + component + ". Messages will not be added" ) ; } } return result ; }
Utility method that searches for the WMessages instance for the given component . If not found a warning will be logged and null returned .
109
28
18,434
@ Override public void error ( final String code ) { WMessages instance = getWMessageInstance ( ) ; if ( instance != null ) { instance . error ( code ) ; } }
Adds an error message .
40
5
18,435
public void setBeanList ( final List beanList ) { RepeaterModel model = getOrCreateComponentModel ( ) ; model . setData ( beanList ) ; // Clean up any stale data. HashSet rowIds = new HashSet ( beanList . size ( ) ) ; for ( Object bean : beanList ) { rowIds . add ( getRowId ( bean ) ) ; } cleanupStaleContexts ( rowIds ) ; // Clean up cached component IDs UIContext uic = UIContextHolder . getCurrent ( ) ; if ( uic != null && getRepeatRoot ( ) != null ) { clearScratchMaps ( this ) ; } }
Remember the list of beans that hold the data object for each row .
146
14
18,436
protected void clearScratchMaps ( final WComponent node ) { UIContext uic = UIContextHolder . getCurrent ( ) ; uic . clearRequestScratchMap ( node ) ; uic . clearScratchMap ( node ) ; if ( node instanceof WRepeater ) { WRepeater repeater = ( WRepeater ) node ; List < UIContext > rowContextList = repeater . getRowContexts ( ) ; WComponent repeatedComponent = repeater . getRepeatedComponent ( ) ; for ( UIContext rowContext : rowContextList ) { UIContextHolder . pushContext ( rowContext ) ; try { clearScratchMaps ( repeatedComponent ) ; } finally { UIContextHolder . popContext ( ) ; } } // Make sure the repeater's scratch map has not been repopulated by processing its children uic . clearRequestScratchMap ( node ) ; uic . clearScratchMap ( node ) ; } else if ( node instanceof Container ) { Container container = ( Container ) node ; for ( int i = 0 ; i < container . getChildCount ( ) ; i ++ ) { clearScratchMaps ( container . getChildAt ( i ) ) ; } } }
Recursively clears cached component scratch maps . This is called when the bean list changes as the beans may have changed .
269
24
18,437
public List getBeanList ( ) { List beanList = ( List ) getData ( ) ; if ( beanList == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( beanList ) ; }
Retrieves the list of dataBeans that holds the data object for each row . The list returned will be the same instance as the one supplied via the setBeanList method . Will never return null but it can return an empty list .
51
50
18,438
@ Override public void validate ( final List < Diagnostic > diags ) { // Validate each row. List beanList = this . getBeanList ( ) ; WComponent row = getRepeatedComponent ( ) ; for ( int i = 0 ; i < beanList . size ( ) ; i ++ ) { Object rowData = beanList . get ( i ) ; UIContext rowContext = getRowContext ( rowData , i ) ; UIContextHolder . pushContext ( rowContext ) ; try { row . validate ( diags ) ; } finally { UIContextHolder . popContext ( ) ; } } }
Validates each row .
138
5
18,439
@ Override public void handleRequest ( final Request request ) { assertConfigured ( ) ; // // Service the request for each row. // List beanList = getBeanList ( ) ; HashSet rowIds = new HashSet ( beanList . size ( ) ) ; WComponent row = getRepeatedComponent ( ) ; for ( int i = 0 ; i < beanList . size ( ) ; i ++ ) { Object rowData = beanList . get ( i ) ; rowIds . add ( getRowId ( rowData ) ) ; // Each row has its own context. This is why we can reuse the same // WComponent instance for each row. UIContext rowContext = getRowContext ( rowData , i ) ; try { UIContextHolder . pushContext ( rowContext ) ; row . serviceRequest ( request ) ; } finally { UIContextHolder . popContext ( ) ; } } cleanupStaleContexts ( rowIds ) ; }
Override handleRequest to process the request for each row .
210
11
18,440
protected void cleanupStaleContexts ( final Set < ? > rowIds ) { RepeaterModel model = getOrCreateComponentModel ( ) ; if ( model . rowContextMap != null ) { for ( Iterator < Map . Entry < Object , SubUIContext > > i = model . rowContextMap . entrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { Map . Entry < Object , SubUIContext > entry = i . next ( ) ; Object rowId = entry . getKey ( ) ; if ( ! rowIds . contains ( rowId ) ) { i . remove ( ) ; } } if ( model . rowContextMap . isEmpty ( ) ) { model . rowContextMap = null ; } } }
Removes any stale contexts from the row context map .
164
11
18,441
@ Override protected void preparePaintComponent ( final Request request ) { assertConfigured ( ) ; List beanList = getBeanList ( ) ; List < Integer > used = new ArrayList <> ( ) ; for ( int i = 0 ; i < beanList . size ( ) ; i ++ ) { Object rowData = beanList . get ( i ) ; // Each row has its own context. This is why we can reuse the same // WComponent instance for each row. UIContext rowContext = getRowContext ( rowData , i ) ; // Check the context has not been used for another row Integer subId = ( ( SubUIContext ) rowContext ) . getContextId ( ) ; if ( used . contains ( subId ) ) { Object rowId = ( ( SubUIContext ) rowContext ) . getRowId ( ) ; String msg = "The row context for row id [" + rowId + "] has already been used for another row. " + "Either the row ID is not unique or the row bean has not implemented equals/hashcode " + "or no rowIdBeanProperty set on the repeater that uniquely identifies the row." ; throw new SystemException ( msg ) ; } used . add ( subId ) ; UIContextHolder . pushContext ( rowContext ) ; try { prepareRow ( request , i ) ; } finally { UIContextHolder . popContext ( ) ; } } }
Override preparePaintComponent to prepare each row for painting .
312
12
18,442
protected void prepareRow ( final Request request , final int rowIndex ) { WComponent row = getRepeatedComponent ( ) ; row . preparePaint ( request ) ; }
Prepares a single row for painting .
36
8
18,443
public UIContext getRowContext ( final Object rowBean , final int rowIndex ) { RepeaterModel model = getOrCreateComponentModel ( ) ; Object rowId = getRowId ( rowBean ) ; if ( model . rowContextMap == null ) { model . rowContextMap = new HashMap <> ( ) ; } SubUIContext rowContext = model . rowContextMap . get ( rowId ) ; if ( rowContext == null ) { int seq = model . rowContextIdSequence ++ ; // Just for the first row, check rowId has implemented equals/hashcode. Assumes each row will use the same // row id class. if ( seq == 0 ) { try { if ( rowId . getClass ( ) != rowId . getClass ( ) . getMethod ( "equals" , Object . class ) . getDeclaringClass ( ) || rowId . getClass ( ) != rowId . getClass ( ) . getMethod ( "hashCode" ) . getDeclaringClass ( ) ) { LOG . warn ( "Row id class [" + rowId . getClass ( ) . getName ( ) + "] has not implemented equals or hashcode. This can cause errors when matching a row context. " + "Implement equals/hashcode on the row bean or refer to setRowIdBeanProperty method on WRepeater." ) ; } } catch ( Exception e ) { LOG . info ( "Error checking equals and hashcode implementation on the row id. " + e . getMessage ( ) , e ) ; } } // Get the row render id name (used in naming context for each row) String renderId = getRowIdName ( rowBean , rowId ) ; if ( renderId == null ) { // Just use the context id as the row naming context rowContext = new SubUIContext ( this , seq ) ; } else { // Check ID is properly formed // Must only contain letters, digits and or underscores Matcher matcher = ROW_ID_CONTEXT_NAME_PATTERN . matcher ( renderId ) ; if ( ! matcher . matches ( ) ) { throw new IllegalArgumentException ( "Row idName [" + renderId + "] must start with a letter and followed by letters, digits and or underscores." ) ; } rowContext = new SubUIContext ( this , seq , renderId ) ; } rowContext . setRowId ( rowId ) ; model . rowContextMap . put ( rowId , rowContext ) ; } rowContext . setRowIndex ( rowIndex ) ; // just incase it has changed return rowContext ; }
Retrieves the UIContext for a row .
563
12
18,444
public Object getRowBeanForSubcontext ( final SubUIContext subContext ) { if ( subContext . repeatRoot != getRepeatRoot ( ) ) { // TODO: Is this still necessary? throw new IllegalArgumentException ( "SubUIContext is not for this WRepeater instance." ) ; } // We need to get the list using the parent context // so that e.g. caching in the scratch map works properly. UIContextHolder . pushContext ( subContext . getParentContext ( ) ) ; try { return getRowData ( subContext . getRowId ( ) ) ; } finally { UIContextHolder . popContext ( ) ; } }
Returns the row data for the given row context .
149
10
18,445
private Object getRowData ( final Object rowId ) { // We cache row id --> row bean mapping per request for performance (to avoid nested loops) Map dataByRowId = ( Map ) getScratchMap ( ) . get ( SCRATCHMAP_DATA_BY_ROW_ID_KEY ) ; if ( dataByRowId == null ) { dataByRowId = createRowIdCache ( ) ; } Object data = dataByRowId . get ( rowId ) ; if ( data == null && ! dataByRowId . containsKey ( rowId ) ) { // Ok, new data has probably been added. We need to cache the new data. dataByRowId = createRowIdCache ( ) ; data = dataByRowId . get ( rowId ) ; } return data ; }
Returns the row data corresponding to the given id .
171
10
18,446
protected Object getRowId ( final Object rowBean ) { String rowIdProperty = getComponentModel ( ) . rowIdProperty ; if ( rowIdProperty == null || rowBean == null ) { return rowBean ; } try { return PropertyUtils . getProperty ( rowBean , rowIdProperty ) ; } catch ( Exception e ) { LOG . error ( "Failed to read row property \"" + rowIdProperty + "\" on " + rowBean , e ) ; return rowBean ; } }
Retrieves the row id for the given row .
112
11
18,447
public List < UIContext > getRowContexts ( ) { List < ? > beanList = this . getBeanList ( ) ; List < UIContext > contexts = new ArrayList <> ( beanList . size ( ) ) ; for ( int i = 0 ; i < beanList . size ( ) ; i ++ ) { Object rowData = beanList . get ( i ) ; contexts . add ( this . getRowContext ( rowData , i ) ) ; } return Collections . unmodifiableList ( contexts ) ; }
Retrieves the row contexts for all rows .
116
10
18,448
public void assignTask ( int taskId , int responsible ) { getResourceFactory ( ) . getApiResource ( "/task/" + taskId + "/assign" ) . entity ( new AssignValue ( responsible ) , MediaType . APPLICATION_JSON_TYPE ) . post ( ) ; }
Assigns the task to another user . This makes the user responsible for the task and its completion .
63
21
18,449
public void completeTask ( int taskId ) { getResourceFactory ( ) . getApiResource ( "/task/" + taskId + "/complete" ) . entity ( new Empty ( ) , MediaType . APPLICATION_JSON_TYPE ) . post ( ) ; }
Mark the given task as completed .
56
7
18,450
public void updateDueDate ( int taskId , LocalDate dueDate ) { getResourceFactory ( ) . getApiResource ( "/task/" + taskId + "/due_date" ) . entity ( new TaskDueDate ( dueDate ) , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; }
Updates the due date of the task to the given value
68
12
18,451
public void updatePrivate ( int taskId , boolean priv ) { getResourceFactory ( ) . getApiResource ( "/task/" + taskId + "/private" ) . entity ( new TaskPrivate ( priv ) , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; }
Update the private flag on the given task .
61
9
18,452
public void updateText ( int taskId , String text ) { getResourceFactory ( ) . getApiResource ( "/task/" + taskId + "/text" ) . entity ( new TaskText ( text ) , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; }
Updates the text of the task .
61
8
18,453
public int createTask ( TaskCreate task , boolean silent , boolean hook ) { TaskCreateResponse response = getResourceFactory ( ) . getApiResource ( "/task/" ) . queryParam ( "silent" , silent ? "1" : "0" ) . queryParam ( "hook" , hook ? "1" : "0" ) . entity ( task , MediaType . APPLICATION_JSON_TYPE ) . post ( TaskCreateResponse . class ) ; return response . getId ( ) ; }
Creates a new task with no reference to other objects .
107
12
18,454
public List < Task > getTasksWithReference ( Reference reference ) { return getResourceFactory ( ) . getApiResource ( "/task/" + reference . getType ( ) . name ( ) . toLowerCase ( ) + "/" + reference . getId ( ) + "/" ) . get ( new GenericType < List < Task > > ( ) { } ) ; }
Gets a list of tasks with a reference to the given object . This will return both active and completed tasks . The reference will not be set on the individual tasks .
80
34
18,455
private Date convertDate ( final Object data ) { if ( data == null ) { return null ; } else if ( data instanceof Date ) { return ( Date ) data ; } else if ( data instanceof Long ) { return new Date ( ( Long ) data ) ; } else if ( data instanceof Calendar ) { return ( ( Calendar ) data ) . getTime ( ) ; } else if ( data instanceof String ) { try { SimpleDateFormat sdf = new SimpleDateFormat ( INTERNAL_DATE_FORMAT ) ; sdf . setLenient ( lenient ) ; return sdf . parse ( ( String ) data ) ; } catch ( ParseException e ) { throw new SystemException ( "Could not convert String data [" + data + "] to a date." ) ; } } throw new SystemException ( "Cannot convert data type " + data . getClass ( ) + " to a date." ) ; }
Attempts to convert the given object to a date . Throws a SystemException on error .
198
18
18,456
@ Override protected void validateComponent ( final List < Diagnostic > diags ) { if ( isParseable ( ) ) { super . validateComponent ( diags ) ; validateDate ( diags ) ; } else { diags . add ( createErrorDiagnostic ( getComponentModel ( ) . errorMessage , this ) ) ; } }
Override WInput s validateComponent to perform further validation on the date .
73
14
18,457
@ Override public void setModel ( final WebComponent component , final WebModel model ) { map . put ( component , model ) ; }
Stores the extrinsic state information for the given component .
29
13
18,458
@ Override public void invokeLater ( final UIContext uic , final Runnable runnable ) { if ( invokeLaterRunnables == null ) { invokeLaterRunnables = new ArrayList <> ( ) ; } invokeLaterRunnables . add ( new UIContextImplRunnable ( uic , runnable ) ) ; }
Adds a runnable to the list of runnables to be invoked later .
79
17
18,459
@ Override public void setFocussed ( final WComponent component , final UIContext uic ) { this . focussed = component ; this . focussedUIC = uic ; }
Sets the component in this UIC which is to be the focus of the client browser cursor . The id of the component is used to find the focussed element in the rendered html . Since id could be different in different contexts the context of the component is also needed .
42
55
18,460
@ Override public Object getFwkAttribute ( final String name ) { if ( attribMap == null ) { return null ; } return attribMap . get ( name ) ; }
Reserved for internal framework use . Retrieves a framework attribute .
39
14
18,461
@ Override public void setFwkAttribute ( final String name , final Object value ) { if ( attribMap == null ) { attribMap = new HashMap <> ( ) ; } attribMap . put ( name , value ) ; }
Reserved for internal framework use . Sets a framework attribute .
53
12
18,462
@ Override public Map < Object , Object > getScratchMap ( final WComponent component ) { if ( scratchMaps == null ) { scratchMaps = new HashMap <> ( ) ; } Map < Object , Object > componentScratchMap = scratchMaps . get ( component ) ; if ( componentScratchMap == null ) { componentScratchMap = new HashMap <> ( 2 ) ; scratchMaps . put ( component , componentScratchMap ) ; } return componentScratchMap ; }
Reserved for internal framework use . Retrieves a scratch area where data can be temporarily stored . WComponents must not rely on data being available in the scratch area after each phase .
105
38
18,463
private void setupLabel ( ) { // To retain compatibility with the WText API, create a WText for this component, // which gets added to the label body. WText textBody = new WText ( ) { @ Override public boolean isEncodeText ( ) { return WHeading . this . isEncodeText ( ) ; } @ Override public String getText ( ) { return WHeading . this . getText ( ) ; } } ; if ( label . getBody ( ) == null ) { label . setBody ( textBody ) ; } else { WComponent oldBody = label . getBody ( ) ; WContainer newBody = new WContainer ( ) ; label . setBody ( newBody ) ; newBody . add ( textBody ) ; newBody . add ( oldBody ) ; } }
Setup the label .
173
4
18,464
private void addNullLabelExample ( ) { add ( new WHeading ( HeadingLevel . H2 , "How to use accessible null WLabels" ) ) ; add ( new ExplanatoryText ( "These examples shows how sometime a null WLabel is the right thing to do." + "\n This example uses a WFieldSet as the labelled component and it has its own \"label\"." ) ) ; // We want to add a WFieldSet to a WFieldLayout but without an extra label. WFieldLayout fieldsFlat = new WFieldLayout ( ) ; fieldsFlat . setMargin ( new Margin ( null , null , Size . XL , null ) ) ; add ( fieldsFlat ) ; WFieldSet fs = new WFieldSet ( "Do you like Bananas?" ) ; fieldsFlat . addField ( ( WLabel ) null , fs ) ; // now add the WRadioButtons to the WFieldSet using an inner WFieldLayout WFieldLayout innerLayout = new WFieldLayout ( WFieldLayout . LAYOUT_STACKED ) ; // The content will be a group of WRadioButtons RadioButtonGroup group1 = new RadioButtonGroup ( ) ; WRadioButton rb1 = group1 . addRadioButton ( 1 ) ; WRadioButton rb2 = group1 . addRadioButton ( 2 ) ; //make the labels for the radio buttons WLabel rb1Label = new WLabel ( "" , rb1 ) ; WImage labelImage = new WImage ( "/image/success.png" , "I still like bananas" ) ; labelImage . setHtmlClass ( "wc-valign-bottom" ) ; rb1Label . add ( labelImage ) ; WLabel rb2Label = new WLabel ( "" , rb2 ) ; labelImage = new WImage ( "/image/error.png" , "I still dislike bananas" ) ; labelImage . setHtmlClass ( "wc-valign-bottom" ) ; rb2Label . add ( labelImage ) ; innerLayout . addField ( rb1Label , rb1 ) ; innerLayout . addField ( rb2Label , rb2 ) ; // add the content to the WFieldLayout - the order really doesn't matter. fs . add ( group1 ) ; fs . add ( innerLayout ) ; }
Example of when and how to use a null WLabel .
510
12
18,465
@ Override public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WHeading heading = ( WHeading ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "ui:heading" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendAttribute ( "level" , heading . getHeadingLevel ( ) . getLevel ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , heading . getAccessibleText ( ) ) ; xml . appendClose ( ) ; // Render margin MarginRendererUtil . renderMargin ( heading , renderContext ) ; if ( heading . getDecoratedLabel ( ) == null ) { // Constructed with a String xml . append ( heading . getText ( ) , heading . isEncodeText ( ) ) ; } else { heading . getDecoratedLabel ( ) . paint ( renderContext ) ; } xml . appendEndTag ( "ui:heading" ) ; }
Paints the given WHeading .
271
8
18,466
@ Override protected boolean execute ( ) { // Disabled triggers are always false if ( ( trigger instanceof Disableable ) && ( ( Disableable ) trigger ) . isDisabled ( ) && ! ( trigger instanceof Input && ( ( Input ) trigger ) . isReadOnly ( ) ) ) { return false ; } final Object triggerValue = getTriggerValue ( null ) ; final Object compareValue = getCompareValue ( ) ; return executeCompare ( triggerValue , compareValue ) ; }
Compare the trigger and compare value .
100
7
18,467
public boolean isTabVisible ( final int idx ) { WTab tab = getTab ( idx ) ; Container tabParent = tab . getParent ( ) ; if ( tabParent instanceof WTabGroup ) { return tab . isVisible ( ) && tabParent . isVisible ( ) ; } else { return tab . isVisible ( ) ; } }
Indicates whether the tab at the given index is visible .
78
12
18,468
public int getTabIndex ( final WComponent content ) { List < WTab > tabs = getTabs ( ) ; final int count = tabs . size ( ) ; for ( int i = 0 ; i < count ; i ++ ) { WTab tab = tabs . get ( i ) ; if ( content == tab . getContent ( ) ) { return i ; } } return - 1 ; }
Retrieves the tab index for the given tab content .
83
12
18,469
private int clientIndexToTabIndex ( final int clientIndex ) { int childCount = getTotalTabs ( ) ; int serverIndex = clientIndex ; for ( int i = 0 ; i <= serverIndex && i < childCount ; i ++ ) { if ( ! isTabVisible ( i ) ) { serverIndex ++ ; } } return serverIndex ; }
The client - side tab indices will differ from the WTabSet s indices when one or more tabs are invisible .
76
23
18,470
public String getGroupName ( ) { if ( TabSetType . ACCORDION . equals ( getType ( ) ) ) { CollapsibleGroup group = getComponentModel ( ) . group ; return ( group == null ? null : group . getGroupName ( ) ) ; } return null ; }
The collapsible group name that this tabset belongs to .
63
12
18,471
private WMenu buildColumnMenu ( final WText selectedMenuText ) { WMenu menu = new WMenu ( WMenu . MenuType . COLUMN ) ; menu . setSelectMode ( SelectMode . SINGLE ) ; menu . setRows ( 8 ) ; StringTreeNode root = getOrgHierarchyTree ( ) ; mapColumnHierarchy ( menu , root , selectedMenuText ) ; // Demonstrate different menu modes getSubMenuByText ( "Australia" , menu ) . setAccessKey ( ' ' ) ; getSubMenuByText ( "NSW" , menu ) . setMode ( MenuMode . CLIENT ) ; getSubMenuByText ( "Branch 1" , menu ) . setMode ( MenuMode . DYNAMIC ) ; getSubMenuByText ( "VIC" , menu ) . setMode ( MenuMode . LAZY ) ; WMenuItem itemWithIcon = new WMenuItem ( "Help" ) ; itemWithIcon . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { // do something } } ) ; itemWithIcon . setHtmlClass ( HtmlClassProperties . ICON_HELP_BEFORE ) ; menu . add ( itemWithIcon ) ; return menu ; }
Builds up a column menu for inclusion in the example .
276
12
18,472
private StringTreeNode getOrgHierarchyTree ( ) { // Hierarchical data in a flat format. // If an Object array contains 1 String element, it is a leaf node. // Else an Object array contains 1 String element + object arrays and is a branch node. Object [ ] data = new Object [ ] { "Australia" , new Object [ ] { "ACT" } , new Object [ ] { "NSW" , new Object [ ] { "Paramatta" } , new Object [ ] { "Sydney" , new Object [ ] { "Branch 1" , new Object [ ] { "Processing Team 1" } , new Object [ ] { "Processing Team 2" , new Object [ ] { "Robert Rogriguez" } , new Object [ ] { "Phillip Sedgwick" } , new Object [ ] { "Donald Sullivan" } , new Object [ ] { "All" } } , new Object [ ] { "Processing Team 3" , new Object [ ] { "Jim McCarthy" } , new Object [ ] { "Peter Dunne" } , new Object [ ] { "Nicole Brown" } , new Object [ ] { "All" } } , new Object [ ] { "Processing Team 4" } , new Object [ ] { "Processing Team 5" } , new Object [ ] { "All" } } , new Object [ ] { "Branch 2" } , new Object [ ] { "Branch 3" } } , new Object [ ] { "Broken Hill" } , new Object [ ] { "Tamworth" } , new Object [ ] { "Griffith" } , new Object [ ] { "Wollongong" } , new Object [ ] { "Port Macquarie" } , new Object [ ] { "Moree" } , new Object [ ] { "Orange" } , new Object [ ] { "Richmond" } , new Object [ ] { "Bathurst" } , new Object [ ] { "Newcastle" } , new Object [ ] { "Nowra" } , new Object [ ] { "Woy Woy" } , new Object [ ] { "Maitland" } , new Object [ ] { "Hay" } , new Object [ ] { "Bourke" } , new Object [ ] { "Lightning Ridge" } , new Object [ ] { "Coffs Harbour" } , new Object [ ] { "All" } } , new Object [ ] { "VIC" , new Object [ ] { "Melbourne" } , new Object [ ] { "Wangaratta" } , new Object [ ] { "Broken Hill" } , new Object [ ] { "Albury" } , new Object [ ] { "Ballarat" } , new Object [ ] { "Bendigo" } , new Object [ ] { "Horsham" } , new Object [ ] { "Portland" } , new Object [ ] { "Geelong" } , new Object [ ] { "Shepparton" } , new Object [ ] { "Hamilton" } , new Object [ ] { "Morewell" } } , new Object [ ] { "SA" } , new Object [ ] { "NT" } , new Object [ ] { "QLD" } , new Object [ ] { "WA" } , new Object [ ] { "TAS" } } ; return buildOrgHierarchyTree ( data ) ; }
Builds an organisation hierarchy tree for the column menu example .
738
12
18,473
private StringTreeNode buildOrgHierarchyTree ( final Object [ ] data ) { StringTreeNode childNode = new StringTreeNode ( ( String ) data [ 0 ] ) ; if ( data . length > 1 ) { for ( int i = 1 ; i < data . length ; i ++ ) { childNode . add ( buildOrgHierarchyTree ( ( Object [ ] ) data [ i ] ) ) ; } } return childNode ; }
Builds one level of the org hierarchy tree .
95
10
18,474
private WSubMenu getSubMenuByText ( final String text , final WComponent node ) { if ( node instanceof WSubMenu ) { WSubMenu subMenu = ( WSubMenu ) node ; if ( text . equals ( subMenu . getText ( ) ) ) { return subMenu ; } for ( MenuItem item : subMenu . getMenuItems ( ) ) { WSubMenu result = getSubMenuByText ( text , item ) ; if ( result != null ) { return result ; } } } else if ( node instanceof WMenu ) { WMenu menu = ( WMenu ) node ; for ( MenuItem item : menu . getMenuItems ( ) ) { WSubMenu result = getSubMenuByText ( text , item ) ; if ( result != null ) { return result ; } } } return null ; }
Retrieves a sub menu by its text .
177
10
18,475
@ Deprecated public static Size intToSize ( final int convert ) { // NOTE: no zero size margin in the old versions. if ( convert <= 0 ) { return null ; } if ( convert <= MAX_SMALL ) { return Size . SMALL ; } if ( convert <= MAX_MED ) { return Size . MEDIUM ; } if ( convert <= MAX_LARGE ) { return Size . LARGE ; } return Size . XL ; }
Convert an int space to a Size . For backwards compatibility during conversion of int spaces to Size spaces .
95
21
18,476
@ Deprecated public static int sizeToInt ( final Size size ) { if ( size == null ) { return - 1 ; } switch ( size ) { case ZERO : return 0 ; case SMALL : return MAX_SMALL ; case MEDIUM : return MAX_MED ; case LARGE : return MAX_LARGE ; default : return COMMON_XL ; } }
Convert a size back to a representative int . For testing only during conversion of int spaces to Size spaces .
79
22
18,477
public void removeTag ( Reference reference , String tag ) { getResourceFactory ( ) . getApiResource ( "/tag/" + reference . toURLFragment ( ) ) . queryParam ( "text" , tag ) . delete ( ) ; }
Removes a single tag from an object .
52
9
18,478
public List < TagReference > getTagsOnAppWithText ( int appId , String text ) { return getResourceFactory ( ) . getApiResource ( "/tag/app/" + appId + "/search/" ) . queryParam ( "text" , text ) . get ( new GenericType < List < TagReference > > ( ) { } ) ; }
Returns the objects that are tagged with the given text on the app . The objects are returned sorted descending by the time the tag was added .
76
28
18,479
public List < TagReference > getTagsOnOrgWithText ( int orgId , String text ) { return getResourceFactory ( ) . getApiResource ( "/tag/org/" + orgId + "/search/" ) . queryParam ( "text" , text ) . get ( new GenericType < List < TagReference > > ( ) { } ) ; }
Returns the objects that are tagged with the given text on the org . The objects are returned sorted descending by the time the tag was added .
76
28
18,480
public List < TagReference > getTagsOnSpaceWithText ( int spaceId , String text ) { return getResourceFactory ( ) . getApiResource ( "/tag/space/" + spaceId + "/search/" ) . queryParam ( "text" , text ) . get ( new GenericType < List < TagReference > > ( ) { } ) ; }
Returns the objects that are tagged with the given text on the space . The objects are returned sorted descending by the time the tag was added .
76
28
18,481
public void addTab ( final WComponent card , final String name ) { WContainer titledCard = new WContainer ( ) ; WText title = new WText ( "<b>[" + name + "]:</b><br/>" ) ; title . setEncodeText ( false ) ; titledCard . add ( title ) ; titledCard . add ( card ) ; deck . add ( titledCard ) ; final TabButton button = new TabButton ( name , titledCard ) ; button . setAction ( new Action ( ) { @ Override public void execute ( final ActionEvent event ) { deck . makeVisible ( button . getAssociatedCard ( ) ) ; } } ) ; btnPanel . add ( button ) ; }
Adds a tab .
152
4
18,482
public static void main ( final String [ ] args ) throws Exception { // Set the logger to use the text area logger System . setProperty ( "org.apache.commons.logging.Log" , "com.github.bordertech.wcomponents.lde.StandaloneLauncher$TextAreaLogger" ) ; // Set the port number to a random port Configuration internalWComponentConfig = Config . getInstance ( ) ; CompositeConfiguration config = new CompositeConfiguration ( new MapConfiguration ( new HashMap < String , Object > ( ) ) ) ; config . addConfiguration ( internalWComponentConfig ) ; // Internal WComponent config next config . setProperty ( ConfigurationProperties . LDE_SERVER_PORT , 0 ) ; Config . setConfiguration ( config ) ; getInstance ( ) . launcher . run ( ) ; getInstance ( ) . log ( "LDE now running on " + getInstance ( ) . launcher . getUrl ( ) + ' ' ) ; }
The entry point when the launcher is run as a java application .
205
13
18,483
private void readFields ( ) { plain . setText ( tf1 . getText ( ) ) ; mandatory . setText ( tf2 . getText ( ) ) ; readOnly . setText ( tf3 . getText ( ) ) ; disabled . setText ( tf4 . getText ( ) ) ; width . setText ( tf5 . getText ( ) ) ; }
Read fields is a simple method to read all the fields and populate the encoded text fields .
80
18
18,484
public void setSource ( final String sourceText ) { String formattedSource ; if ( sourceText == null ) { formattedSource = "" ; } else { formattedSource = WebUtilities . encode ( sourceText ) ; // XML escape content } source . setText ( formattedSource ) ; }
Sets the source code to be displayed in the panel .
59
12
18,485
public static void main ( final String [ ] args ) throws Exception { // Use jetty to run the servlet. Server server = new Server ( ) ; SocketConnector connector = new SocketConnector ( ) ; connector . setMaxIdleTime ( 0 ) ; connector . setPort ( 8080 ) ; server . addConnector ( connector ) ; WebAppContext context = new WebAppContext ( ) ; context . setContextPath ( "/" ) ; context . addServlet ( HelloWServlet . class . getName ( ) , "/*" ) ; context . addServlet ( ThemeServlet . class . getName ( ) , "/theme/*" ) ; context . setResourceBase ( "." ) ; server . setHandler ( context ) ; server . start ( ) ; }
This main method exists to make it easy to run this servlet without having to create a web . xml file build a war and deploy it .
163
29
18,486
@ Override public boolean isDisabled ( ) { if ( isFlagSet ( ComponentModel . DISABLED_FLAG ) ) { return true ; } MenuContainer container = WebUtilities . getAncestorOfClass ( MenuContainer . class , this ) ; if ( container instanceof Disableable && ( ( Disableable ) container ) . isDisabled ( ) ) { return true ; } return false ; }
Indicates whether this sub menu is disabled in the given context .
86
13
18,487
@ Override public void handleRequest ( final Request request ) { if ( isDisabled ( ) ) { // Protect against client-side tampering of disabled/read-only fields. return ; } if ( isMenuPresent ( request ) ) { // If current ajax trigger, process menu for current selections if ( AjaxHelper . isCurrentAjaxTrigger ( this ) ) { WMenu menu = WebUtilities . getAncestorOfClass ( WMenu . class , this ) ; menu . handleRequest ( request ) ; // Execute associated action, if set final Action action = getAction ( ) ; if ( action != null ) { final ActionEvent event = new ActionEvent ( this , this . getActionCommand ( ) , this . getActionObject ( ) ) ; Runnable later = new Runnable ( ) { @ Override public void run ( ) { action . execute ( event ) ; } } ; invokeLater ( later ) ; } } boolean openState = "true" . equals ( request . getParameter ( getId ( ) + ".open" ) ) ; setOpen ( openState ) ; } }
Override handleRequest in order to perform processing for this component . This implementation checks for submenu selection and executes the associated action if it has been set .
236
30
18,488
@ Override protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; String targetId = getContent ( ) . getId ( ) ; String contentId = getId ( ) + "-content" ; switch ( getComponentModel ( ) . mode ) { case LAZY : { getContent ( ) . setVisible ( isOpen ( ) ) ; AjaxHelper . registerContainer ( getId ( ) , contentId , targetId ) ; break ; } case DYNAMIC : { AjaxHelper . registerContainer ( getId ( ) , contentId , targetId ) ; getContent ( ) . setVisible ( isOpen ( ) ) ; break ; } case EAGER : { AjaxHelper . registerContainer ( getId ( ) , contentId , targetId ) ; // Will always be visible break ; } case SERVER : { // same as DYNAMIC AjaxHelper . registerContainer ( getId ( ) , contentId , targetId ) ; getContent ( ) . setVisible ( isOpen ( ) ) ; break ; } case CLIENT : { // Will always be visible break ; } default : // do nothing. break ; } }
Override preparePaintComponent in order to correct the visibility of the sub - menu s children before they are rendered .
250
23
18,489
@ Override public String getValueAsString ( ) { String result = null ; String [ ] inputs = getValue ( ) ; if ( inputs != null && inputs . length > 0 ) { StringBuffer stringValues = new StringBuffer ( ) ; for ( int i = 0 ; i < inputs . length ; i ++ ) { if ( i > 0 ) { stringValues . append ( ", " ) ; } stringValues . append ( inputs [ i ] ) ; } result = stringValues . toString ( ) ; } return result ; }
The string is a comma seperated list of the string inputs .
112
14
18,490
@ Override public void serviceRequest ( final Request request ) { // Get window id off the request windowId = request . getParameter ( WWindow . WWINDOW_REQUEST_PARAM_KEY ) ; if ( windowId == null ) { super . serviceRequest ( request ) ; } else { // Get the window component ComponentWithContext target = WebUtilities . getComponentById ( windowId , true ) ; if ( target == null ) { throw new SystemException ( "No window component for id " + windowId ) ; } // Setup the Environment on the context UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; Environment originalEnvironment = uic . getEnvironment ( ) ; uic . setEnvironment ( new EnvironmentDelegate ( originalEnvironment , windowId , target ) ) ; if ( attachWindow ) { attachUI ( target . getComponent ( ) ) ; } UIContextHolder . pushContext ( target . getContext ( ) ) ; try { super . serviceRequest ( request ) ; } finally { uic . setEnvironment ( originalEnvironment ) ; UIContextHolder . popContext ( ) ; } } }
Temporarily replaces the environment while the request is being handled .
250
13
18,491
@ Override public void preparePaint ( final Request request ) { if ( windowId == null ) { super . preparePaint ( request ) ; } else { // Get the window component ComponentWithContext target = WebUtilities . getComponentById ( windowId , true ) ; if ( target == null ) { throw new SystemException ( "No window component for id " + windowId ) ; } UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; Environment originalEnvironment = uic . getEnvironment ( ) ; uic . setEnvironment ( new EnvironmentDelegate ( originalEnvironment , windowId , target ) ) ; UIContextHolder . pushContext ( target . getContext ( ) ) ; try { super . preparePaint ( request ) ; } finally { uic . setEnvironment ( originalEnvironment ) ; UIContextHolder . popContext ( ) ; } } }
Temporarily replaces the environment while the UI prepares to render .
197
13
18,492
@ Override public void paint ( final RenderContext renderContext ) { if ( windowId == null ) { super . paint ( renderContext ) ; } else { // Get the window component ComponentWithContext target = WebUtilities . getComponentById ( windowId , true ) ; if ( target == null ) { throw new SystemException ( "No window component for id " + windowId ) ; } UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; Environment originalEnvironment = uic . getEnvironment ( ) ; uic . setEnvironment ( new EnvironmentDelegate ( originalEnvironment , windowId , target ) ) ; UIContextHolder . pushContext ( target . getContext ( ) ) ; try { super . paint ( renderContext ) ; } finally { uic . setEnvironment ( originalEnvironment ) ; UIContextHolder . popContext ( ) ; } } }
Temporarily replaces the environment while the UI is being rendered .
195
13
18,493
private void paintPaginationDetails ( final WTable table , final XmlStringBuilder xml ) { TableModel model = table . getTableModel ( ) ; xml . appendTagOpen ( "ui:pagination" ) ; xml . appendAttribute ( "rows" , model . getRowCount ( ) ) ; xml . appendOptionalAttribute ( "rowsPerPage" , table . getRowsPerPage ( ) > 0 , table . getRowsPerPage ( ) ) ; xml . appendAttribute ( "currentPage" , table . getCurrentPage ( ) ) ; switch ( table . getPaginationMode ( ) ) { case CLIENT : xml . appendAttribute ( "mode" , "client" ) ; break ; case DYNAMIC : xml . appendAttribute ( "mode" , "dynamic" ) ; break ; case NONE : break ; default : throw new SystemException ( "Unknown pagination mode: " + table . getPaginationMode ( ) ) ; } if ( table . getPaginationLocation ( ) != WTable . PaginationLocation . AUTO ) { switch ( table . getPaginationLocation ( ) ) { case TOP : xml . appendAttribute ( "controls" , "top" ) ; break ; case BOTTOM : xml . appendAttribute ( "controls" , "bottom" ) ; break ; case BOTH : xml . appendAttribute ( "controls" , "both" ) ; break ; default : throw new SystemException ( "Unknown pagination control location: " + table . getPaginationLocation ( ) ) ; } } xml . appendClose ( ) ; // Rows per page options if ( table . getRowsPerPageOptions ( ) != null ) { xml . appendTag ( "ui:rowsselect" ) ; for ( Integer option : table . getRowsPerPageOptions ( ) ) { xml . appendTagOpen ( "ui:option" ) ; xml . appendAttribute ( "value" , option ) ; xml . appendEnd ( ) ; } xml . appendEndTag ( "ui:rowsselect" ) ; } xml . appendEndTag ( "ui:pagination" ) ; }
Paint the pagination aspects of the table .
459
10
18,494
private void paintSortDetails ( final WTable table , final XmlStringBuilder xml ) { int col = table . getSortColumnIndex ( ) ; boolean ascending = table . isSortAscending ( ) ; xml . appendTagOpen ( "ui:sort" ) ; if ( col >= 0 ) { // Allow for column order int [ ] cols = table . getColumnOrder ( ) ; if ( cols != null ) { for ( int i = 0 ; i < cols . length ; i ++ ) { if ( cols [ i ] == col ) { col = i ; break ; } } } xml . appendAttribute ( "col" , col ) ; xml . appendOptionalAttribute ( "descending" , ! ascending , "true" ) ; } switch ( table . getSortMode ( ) ) { case DYNAMIC : xml . appendAttribute ( "mode" , "dynamic" ) ; break ; default : throw new SystemException ( "Unknown sort mode: " + table . getSortMode ( ) ) ; } xml . appendEnd ( ) ; }
Paints the sort details .
227
6
18,495
private void paintTableActions ( final WTable table , final WebXmlRenderContext renderContext ) { XmlStringBuilder xml = renderContext . getWriter ( ) ; List < WButton > tableActions = table . getActions ( ) ; if ( ! tableActions . isEmpty ( ) ) { boolean hasActions = false ; for ( WButton button : tableActions ) { if ( ! button . isVisible ( ) ) { continue ; } if ( ! hasActions ) { hasActions = true ; xml . appendTag ( "ui:actions" ) ; } xml . appendTag ( "ui:action" ) ; List < WTable . ActionConstraint > constraints = table . getActionConstraints ( button ) ; if ( constraints != null ) { for ( WTable . ActionConstraint constraint : constraints ) { int minRows = constraint . getMinSelectedRowCount ( ) ; int maxRows = constraint . getMaxSelectedRowCount ( ) ; String message = constraint . getMessage ( ) ; String type = constraint . isError ( ) ? "error" : "warning" ; xml . appendTagOpen ( "ui:condition" ) ; xml . appendOptionalAttribute ( "minSelectedRows" , minRows > 0 , minRows ) ; xml . appendOptionalAttribute ( "maxSelectedRows" , maxRows > 0 , maxRows ) ; xml . appendAttribute ( "selectedOnOther" , this . selectedOnOther ) ; xml . appendAttribute ( "type" , type ) ; xml . appendAttribute ( "message" , I18nUtilities . format ( null , message ) ) ; xml . appendEnd ( ) ; } } button . paint ( renderContext ) ; xml . appendEndTag ( "ui:action" ) ; } if ( hasActions ) { xml . appendEndTag ( "ui:actions" ) ; } } }
Paints the table actions of the table .
412
9
18,496
private void paintColumnHeading ( final WTableColumn col , final boolean sortable , final WebXmlRenderContext renderContext ) { XmlStringBuilder xml = renderContext . getWriter ( ) ; int width = col . getWidth ( ) ; Alignment align = col . getAlign ( ) ; xml . appendTagOpen ( "ui:th" ) ; xml . appendOptionalAttribute ( "width" , width > 0 , width ) ; xml . appendOptionalAttribute ( "sortable" , sortable , "true" ) ; if ( Alignment . RIGHT . equals ( align ) ) { xml . appendAttribute ( "align" , "right" ) ; } else if ( Alignment . CENTER . equals ( align ) ) { xml . appendAttribute ( "align" , "center" ) ; } xml . appendClose ( ) ; col . paint ( renderContext ) ; xml . appendEndTag ( "ui:th" ) ; }
Paints a single column heading .
200
7
18,497
public void updateUI ( ) { if ( ! Util . empty ( panelContent . getText ( ) ) ) { panelContentRO . setData ( panelContent . getData ( ) ) ; } else { panelContentRO . setText ( SAMPLE_CONTENT ) ; } panel . setType ( ( WPanel . Type ) panelType . getSelected ( ) ) ; String headingText = tfHeading . getText ( ) ; if ( ! Util . empty ( tfHeading . getText ( ) ) ) { heading . setText ( tfHeading . getText ( ) ) ; panel . setTitleText ( headingText ) ; } else { heading . setText ( SAMPLE_HEADER ) ; panel . setTitleText ( SAMPLE_TITLE_TEXT ) ; } }
Set up the WPanel so that the appropriate items are visible based on configuration settings .
169
17
18,498
private void buildUI ( ) { buildTargetPanel ( ) ; buildConfigOptions ( ) ; add ( new WHorizontalRule ( ) ) ; add ( panel ) ; add ( new WHorizontalRule ( ) ) ; // We need this reflection of the selected menu item just so we can reuse the menu from the // MenuBarExample. It serves no purpose in this example so I am going to hide it. WPanel hiddenPanel = new WPanel ( ) { @ Override public boolean isHidden ( ) { return true ; } } ; hiddenPanel . add ( selectedMenuText ) ; add ( hiddenPanel ) ; add ( new WAjaxControl ( applyConfigButton , panel ) ) ; buildSubordinates ( ) ; }
Add the components in the required order .
152
8
18,499
private void buildConfigOptions ( ) { WFieldLayout layout = new WFieldLayout ( WFieldLayout . LAYOUT_STACKED ) ; layout . setMargin ( new Margin ( null , null , Size . LARGE , null ) ) ; layout . addField ( "Select a WPanel Type" , panelType ) ; contentField = layout . addField ( "Panel content" , panelContent ) ; headingField = layout . addField ( "heading" , tfHeading ) ; showMenuField = layout . addField ( "Show menu" , showMenu ) ; showUtilBarField = layout . addField ( "Show utility bar" , showUtilBar ) ; layout . addField ( ( WLabel ) null , applyConfigButton ) ; add ( layout ) ; }
Set up the UI for the configuration options .
168
9