idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
123,700
public void postDelete ( String blogName , Long postId ) { Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( "id" , postId . toString ( ) ) ; requestBuilder . post ( JumblrClient . blogPath ( blogName , "/post/delete" ) , map ) ; }
Delete a given post
123,701
public void postEdit ( String blogName , Long id , Map < String , ? > detail ) throws IOException { Map < String , Object > sdetail = JumblrClient . safeOptionMap ( detail ) ; sdetail . put ( "id" , id ) ; requestBuilder . postMultipart ( JumblrClient . blogPath ( blogName , "/post/edit" ) , sdetail ) ; }
Save edits for a given post
123,702
public Long postCreate ( String blogName , Map < String , ? > detail ) throws IOException { return requestBuilder . postMultipart ( JumblrClient . blogPath ( blogName , "/post" ) , detail ) . getId ( ) ; }
Create a post
123,703
public < T extends Post > T newPost ( String blogName , Class < T > klass ) throws IllegalAccessException , InstantiationException { T post = klass . newInstance ( ) ; post . setClient ( this ) ; post . setBlogName ( blogName ) ; return post ; }
Set up a new post of a given type
123,704
public List < User > followers ( Map < String , ? > options ) { return client . blogFollowers ( this . name , options ) ; }
Get followers for this blog
123,705
public List < Post > posts ( Map < String , ? > options ) { return client . blogPosts ( name , options ) ; }
Get the posts for this blog
123,706
public List < Post > likedPosts ( Map < String , ? > options ) { return client . blogLikes ( this . name , options ) ; }
Get likes posts for this blog
123,707
public List < Post > queuedPosts ( Map < String , ? > options ) { return client . blogQueuedPosts ( name , options ) ; }
Get the queued posts for this blog
123,708
public List < Post > draftPosts ( Map < String , ? > options ) { return client . blogDraftPosts ( name , options ) ; }
Get the draft posts for this blog
123,709
public List < Post > submissions ( Map < String , ? > options ) { return client . blogSubmissions ( name , options ) ; }
Get the submissions for this blog
123,710
public < T extends Post > T newPost ( Class < T > klass ) throws IllegalAccessException , InstantiationException { return client . newPost ( name , klass ) ; }
Create a new post of a given type for this blog
123,711
public PhotoType getType ( ) { if ( this . source != null ) { return PhotoType . SOURCE ; } if ( this . file != null ) { return PhotoType . FILE ; } return null ; }
Get the type of this photo
123,712
public Token postXAuth ( final String email , final String password ) { OAuthRequest request = constructXAuthPost ( email , password ) ; setToken ( "" , "" ) ; sign ( request ) ; return clearXAuth ( request . send ( ) ) ; }
Posts an XAuth request . A new method is needed because the response from the server is not a standard Tumblr JSON response .
123,713
private OAuthRequest constructXAuthPost ( String email , String password ) { OAuthRequest request = new OAuthRequest ( Verb . POST , xauthEndpoint ) ; request . addBodyParameter ( "x_auth_username" , email ) ; request . addBodyParameter ( "x_auth_password" , password ) ; request . addBodyParameter ( "x_auth_mode" , "cl...
Construct an XAuth request
123,714
public LazyType getType ( int index ) throws LazyException { LazyNode token = getValueToken ( index ) ; switch ( token . type ) { case LazyNode . OBJECT : return LazyType . OBJECT ; case LazyNode . ARRAY : return LazyType . ARRAY ; case LazyNode . VALUE_TRUE : return LazyType . BOOLEAN ; case LazyNode . VALUE_FALSE : r...
Returns the value type of the given field .
123,715
public boolean getBoolean ( int index ) { LazyNode token = getValueToken ( index ) ; if ( token . type == LazyNode . VALUE_TRUE ) return true ; if ( token . type == LazyNode . VALUE_FALSE ) return false ; throw new LazyException ( "Requested value is not a boolean" , token ) ; }
Returns the boolean value stored at the given index .
123,716
public boolean optBoolean ( int index ) { LazyNode token = getOptionalValueToken ( index ) ; if ( token == null ) return false ; if ( token . type == LazyNode . VALUE_NULL ) return false ; if ( token . type == LazyNode . VALUE_TRUE ) return true ; if ( token . type == LazyNode . VALUE_FALSE ) return false ; throw new L...
Returns the boolean value stored at the given index or null if there was no such value .
123,717
public String getString ( int index ) throws LazyException { LazyNode token = getValueToken ( index ) ; return token . getStringValue ( ) ; }
Returns the string value stored at the given index .
123,718
public String optString ( int index ) { LazyNode token = getOptionalValueToken ( index ) ; if ( token == null ) return null ; if ( token . type == LazyNode . VALUE_NULL ) return null ; return token . getStringValue ( ) ; }
Returns the string value stored at the given index or null if there was no such value .
123,719
public int optInt ( int index ) { LazyNode token = getOptionalValueToken ( index ) ; if ( token == null ) return 0 ; if ( token . type == LazyNode . VALUE_NULL ) return 0 ; return token . getIntValue ( ) ; }
Returns the int value stored at the given index or 0 if there was no such value .
123,720
public long optLong ( int index ) { LazyNode token = getOptionalValueToken ( index ) ; if ( token == null ) return 0l ; if ( token . type == LazyNode . VALUE_NULL ) return 0l ; return token . getLongValue ( ) ; }
Returns the long value stored at the given index or 0 if there was no such value .
123,721
public double optDouble ( int index ) { LazyNode token = getOptionalValueToken ( index ) ; if ( token == null ) return 0.0 ; if ( token . type == LazyNode . VALUE_NULL ) return 0.0 ; return token . getDoubleValue ( ) ; }
Returns the double value stored at the given index or 0 . 0 if there was no such value .
123,722
public boolean isNull ( int index ) throws LazyException { LazyNode token = getValueToken ( index ) ; if ( token . type == LazyNode . VALUE_NULL ) return true ; return false ; }
Returns true if the value stored at the given index is null .
123,723
private LazyNode getOptionalValueToken ( int index ) throws LazyException { if ( index < 0 ) throw new LazyException ( "Array undex can not be negative" ) ; int num = 0 ; LazyNode child = root . child ; if ( selectInt > - 1 && index >= selectInt ) { num = selectInt ; child = selectToken ; } while ( child != null ) { if...
Values for an array are attached as children on the token representing the array itself . This method finds the correct child for a given index and returns it .
123,724
private void push ( final LazyNode token ) { stackTop . addChild ( token ) ; if ( ( stackPointer & STACK_INCREASE ) == STACK_INCREASE ) { LazyNode [ ] newStack = new LazyNode [ STACK_SIZE + STACK_INCREASE + 1 ] ; System . arraycopy ( stack , 0 , newStack , 0 , STACK_SIZE ) ; STACK_SIZE = STACK_SIZE + STACK_INCREASE + 1...
Push a token onto the stack and attach it to the previous top as a child
123,725
private LazyNode pop ( ) { LazyNode value = stackTop ; stackPointer -- ; if ( stackPointer > 0 ) { stackTop = stack [ stackPointer - 1 ] ; } return value ; }
Pop a token off the stack and reset the stackTop pointer
123,726
private final void consumeWhiteSpace ( ) { char c = cbuf [ n ] ; while ( c == CH_SPACE || c == CH_LINEFEED || c == CH_TAB || c == CH_CARRIAGE_RETURN ) { n ++ ; c = cbuf [ n ] ; } }
Utility method to consume sections of whitespace
123,727
private final boolean consumeString ( ) throws LazyException { boolean escaped = false ; n ++ ; char c = cbuf [ n ] ; while ( c != CH_QUOTE ) { if ( c == CH_BACKSLASH ) { n ++ ; c = cbuf [ n ] ; if ( ! ( c == CH_QUOTE || c == CH_BACKSLASH || c == CH_SLASH || c == CH_b || c == CH_f || c == CH_n || c == CH_r || c == CH_t...
element if an escape character is found
123,728
private final boolean consumeNumber ( char c ) throws LazyException { boolean floatChar = false ; if ( c == CH_DASH ) { n ++ ; c = cbuf [ n ] ; if ( c < CH_0 || c > CH_9 ) { throw new LazyException ( "Digit expected" , n ) ; } } n ++ ; if ( c == CH_0 ) { c = cbuf [ n ] ; if ( c >= CH_0 && c <= CH_9 ) { throw new LazyEx...
of the number does not validate correctly
123,729
private void init ( ) { slidingWindow = new LinkedHashMap < String , Integer > ( windowSize + 1 , .75F , false ) { protected boolean removeEldestEntry ( Map . Entry < String , Integer > eldest ) { return size ( ) > windowSize ; } } ; }
Initializes the internal sliding window data structure .
123,730
public String get ( short index ) { if ( index < 0 ) return null ; if ( index >= next ) return null ; return data [ index ] ; }
Returns the value held at a specific location in the dictionary .
123,731
public short put ( String value ) { if ( dataMap . containsKey ( value ) ) { dictionaryHit ++ ; return dataMap . get ( value ) ; } if ( next == MAX_SIZE ) { dictionaryMiss ++ ; return - 1 ; } if ( minRepetitions == 0 ) { data [ next ] = value ; dataMap . put ( value , next ) ; dirty = true ; dictionaryHit ++ ; return n...
Add a new value to the dictionary if we have seen it a certain number of times within the current sliding window . If not return - 1 and mark that we saw it . If the value is already in the dictionary just return the lookup position .
123,732
protected void addChild ( LazyNode token ) { if ( lastChild == null ) { child = token ; lastChild = token ; return ; } lastChild . next = token ; lastChild = token ; }
Add a new child to the current linked list of child tokens
123,733
protected int getChildCount ( ) { int num = 0 ; LazyNode token = child ; while ( token != null ) { num ++ ; token = token . next ; } return num ; }
Count the children attached to this token . Be aware that this requires actual linked list traversal!
123,734
protected int getIntValue ( ) throws LazyException { int i = startIndex ; boolean sign = false ; int value = 0 ; if ( type == VALUE_FLOAT ) { return ( int ) getDoubleValue ( ) ; } else if ( type == VALUE_STRING || type == VALUE_ESTRING ) { if ( dirty ) { if ( dirtyBuf . charAt ( i ) == '-' ) { sign = true ; i ++ ; } fo...
Parses the characters of this token and attempts to construct an integer value from them .
123,735
protected double getDoubleValue ( ) throws LazyException { double d = 0.0 ; String str = getStringValue ( ) ; try { d = Double . parseDouble ( str ) ; } catch ( NumberFormatException nfe ) { } return d ; }
Parses the characters of this token and attempts to construct a double value from them .
123,736
protected String getStringValue ( ) { if ( type == VALUE_NULL ) { return null ; } else if ( ! ( type == VALUE_ESTRING || type == EFIELD ) ) { if ( dirty ) { return dirtyBuf . substring ( startIndex , endIndex ) ; } return new String ( cbuf , startIndex , endIndex - startIndex ) ; } else { StringBuilder buf = new String...
Extracts a string containing the characters given by this token . If the token was marked as having escaped characters they will be unescaped before the value is returned .
123,737
private void addCommaSeparatedChildren ( Template template ) { LazyNode next = child ; boolean first = true ; while ( next != null ) { if ( first ) { first = false ; } else { template . addConstant ( "," ) ; } next . addSegments ( template ) ; next = next . next ; } }
Functionality for extracting templates
123,738
protected static LazyNode readFromBuffer ( byte [ ] raw ) { ByteBuffer buf = ByteBuffer . wrap ( raw ) ; return readFromBuffer ( buf ) ; }
Functionality for reading and writing LazyNode structures
123,739
public static LazyElement parse ( String str ) throws LazyException { int index = 0 ; while ( index < str . length ( ) ) { char ch = str . charAt ( index ) ; if ( ch == '[' ) { return new LazyArray ( str ) ; } if ( ch == '{' ) { return new LazyObject ( str ) ; } index ++ ; } throw new LazyException ( "The given string ...
Parses a string and returns either a LazyObject or LazyArray
123,740
public int length ( ) { if ( root . child == null ) { return 0 ; } if ( length > - 1 ) { return length ; } length = root . getChildCount ( ) ; return length ; }
Returns the number of fields on this object
123,741
public String getString ( String key ) throws LazyException { LazyNode token = getFieldToken ( key ) ; return token . getStringValue ( ) ; }
Returns the string value stored in this object for the given key .
123,742
public String optString ( String key , String defaultValue ) { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return defaultValue ; if ( token . type == LazyNode . VALUE_NULL ) return defaultValue ; return token . getStringValue ( ) ; }
Returns the string value stored in this object for the given key . Returns the default value if there is no such key .
123,743
public int getInt ( String key ) throws LazyException { LazyNode token = getFieldToken ( key ) ; return token . getIntValue ( ) ; }
Returns the integer value stored in this object for the given key .
123,744
public int optInt ( String key ) { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return 0 ; if ( token . type == LazyNode . VALUE_NULL ) return 0 ; return token . getIntValue ( ) ; }
Returns the integer value stored in this object for the given key . Returns 0 if there is no such key .
123,745
public long getLong ( String key ) throws LazyException { LazyNode token = getFieldToken ( key ) ; return token . getLongValue ( ) ; }
Returns the long value stored in this object for the given key .
123,746
public long optLong ( String key ) { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return 0l ; if ( token . type == LazyNode . VALUE_NULL ) return 0l ; return token . getLongValue ( ) ; }
Returns the long value stored in this object for the given key . Returns 0 if there is no such key .
123,747
public double getDouble ( String key ) throws LazyException { LazyNode token = getFieldToken ( key ) ; return token . getDoubleValue ( ) ; }
Returns the double value stored in this object for the given key .
123,748
public double optDouble ( String key ) { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return 0.0 ; if ( token . type == LazyNode . VALUE_NULL ) return 0.0 ; return token . getDoubleValue ( ) ; }
Returns the double value stored in this object for the given key . Returns 0 . 0 if there is no such key .
123,749
public boolean isNull ( String key ) { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return true ; if ( token . type == LazyNode . VALUE_NULL ) return true ; return false ; }
Returns true if the value stored in this object for the given key is null .
123,750
public boolean getBoolean ( String key ) { LazyNode token = getFieldToken ( key ) ; if ( token . type == LazyNode . VALUE_STRING || token . type == LazyNode . VALUE_ESTRING ) { String str = token . getStringValue ( ) . toLowerCase ( ) . trim ( ) ; if ( str . equals ( "true" ) ) return true ; if ( str . equals ( "false"...
Returns the boolean value stored in this object for the given key .
123,751
public boolean optBoolean ( String key ) { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return false ; if ( token . type == LazyNode . VALUE_STRING || token . type == LazyNode . VALUE_ESTRING ) { String str = token . getStringValue ( ) . toLowerCase ( ) . trim ( ) ; if ( str . equals ( "true" )...
Returns the boolean value stored in this object for the given key . Returns false if there is no such key .
123,752
public LazyObject getJSONObject ( String key ) throws LazyException { LazyNode token = getFieldToken ( key ) ; if ( token . type != LazyNode . OBJECT ) throw new LazyException ( "Requested value is not an object" , token ) ; LazyObject obj = new LazyObject ( token ) ; obj . parent = this ; return obj ; }
Returns the JSON object stored in this object for the given key .
123,753
public LazyObject optJSONObject ( String key ) throws LazyException { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return null ; if ( token . type == LazyNode . VALUE_NULL ) return null ; if ( token . type != LazyNode . OBJECT ) return null ; LazyObject obj = new LazyObject ( token ) ; obj . pa...
Returns the JSON object stored in this object for the given key on null if the key doesn t exist .
123,754
public LazyArray getJSONArray ( String key ) throws LazyException { LazyNode token = getFieldToken ( key ) ; if ( token . type != LazyNode . ARRAY ) throw new LazyException ( "Requested value is not an array" , token ) ; LazyArray arr = new LazyArray ( token ) ; arr . parent = this ; return arr ; }
Returns the JSON array stored in this object for the given key .
123,755
public LazyArray optJSONArray ( String key ) throws LazyException { LazyNode token = getOptionalFieldToken ( key ) ; if ( token == null ) return null ; if ( token . type == LazyNode . VALUE_NULL ) return null ; if ( token . type != LazyNode . ARRAY ) return null ; LazyArray arr = new LazyArray ( token ) ; arr . parent ...
Returns the JSON array stored in this object for the given key or null if the key doesn t exist .
123,756
public Set < String > keySet ( ) { HashSet < String > set = new HashSet < String > ( ) ; Iterator < String > keys = keys ( ) ; while ( keys . hasNext ( ) ) { set . add ( keys . next ( ) ) ; } return set ; }
Returns a set containing all keys on this object . If possible use the keys iterator instead for improved performance .
123,757
private boolean keyMatch ( String key , LazyNode token ) { if ( token . type == LazyNode . EFIELD ) { String field = token . getStringValue ( ) ; return field . equals ( key ) ; } else { int length = key . length ( ) ; if ( token . endIndex - token . startIndex != length ) { return false ; } if ( token . dirty ) { for ...
Utility method to evaluate wether a given string matches the value of a field .
123,758
public boolean has ( String key ) { LazyNode child = root . child ; while ( child != null ) { if ( keyMatch ( key , child ) ) { return true ; } child = child . next ; } return false ; }
Returns true if the given key matches a field on this object .
123,759
public String read ( ByteBuffer buf , DictionaryCache dict ) { StringBuilder out = new StringBuilder ( ) ; if ( pre != null ) out . append ( pre ) ; if ( type == VOID ) return out . toString ( ) ; if ( type == NULL ) { out . append ( "null" ) ; return out . toString ( ) ; } if ( type == BYTE ) { out . append ( buf . ge...
Read this segment from a byte buffer using the given dictionary for lookups . The dictionary may be null if no dictionary values were used when writing data for this segment .
123,760
public static Builder fromJndi ( final Context context , final String lookupKey , Flavor flavor ) { Options options = new OptionsDefault ( flavor ) ; return new BuilderImpl ( null , ( ) -> { DataSource ds ; try { ds = ( DataSource ) context . lookup ( lookupKey ) ; } catch ( Exception e ) { throw new DatabaseException ...
Builder method to create and initialize an instance of this class using a JNDI resource . To use this method you must explicitly indicate what Flavor of database we are dealing with .
123,761
public static < T > Handler < T > mdc ( final Handler < T > handler ) { if ( handler == null ) { throw new IllegalArgumentException ( "handler may not be null" ) ; } final Map < String , String > mdc = MDC . getCopyOfContextMap ( ) ; return t -> { Map < String , String > restore = MDC . getCopyOfContextMap ( ) ; try { ...
Wrap a Handler in a way that will preserve the SLF4J MDC context . The context from the current thread at the time of this method call will be cached and restored within the wrapper at the time the handler is invoked . This version delegates the handler call directly on the thread that calls it .
123,762
public Sql listSeparator ( String sql ) { if ( listFirstItem . peek ( ) ) { listFirstItem . pop ( ) ; listFirstItem . push ( false ) ; return this ; } else { return append ( sql ) ; } }
Appends the passed bit of sql only if a previous item has already been appended and notes that the list is not empty .
123,763
public Category getSelectedCategory ( ) { TreeItem < Category > selectedTreeItem = navigationView . treeView . getSelectionModel ( ) . getSelectedItem ( ) ; if ( selectedTreeItem != null ) { return navigationView . treeView . getSelectionModel ( ) . getSelectedItem ( ) . getValue ( ) ; } return null ; }
Retrieves the currently selected category in the TreeSearchView .
123,764
private void createRadioButtons ( ) { node . getChildren ( ) . clear ( ) ; radioButtons . clear ( ) ; for ( int i = 0 ; i < field . getItems ( ) . size ( ) ; i ++ ) { RadioButton rb = new RadioButton ( ) ; rb . setText ( field . getItems ( ) . get ( i ) . toString ( ) ) ; rb . setToggleGroup ( toggleGroup ) ; radioButt...
This method creates radio buttons and adds them to radioButtons and is used when the itemsProperty on the field changes .
123,765
public void layoutParts ( ) { StringBuilder styleClass = new StringBuilder ( "group" ) ; int nextRow = PreferencesFxUtils . getRowCount ( grid ) + 1 ; if ( preferencesGroup . getTitle ( ) != null ) { grid . add ( titleLabel , 0 , nextRow ++ , 2 , 1 ) ; styleClass . append ( "-title" ) ; titleLabel . getStyleClass ( ) ....
Defines the layout of the rendered group .
123,766
private void setupClose ( ) { this . getButtonTypes ( ) . add ( ButtonType . CLOSE ) ; Node closeButton = dialog . getDialogPane ( ) . lookupButton ( ButtonType . CLOSE ) ; closeButton . managedProperty ( ) . bind ( closeButton . visibleProperty ( ) ) ; closeButton . setVisible ( false ) ; }
Instantiates a close button and makes it invisible . Dialog requires at least one button to close the dialog window .
123,767
public void doWithoutListeners ( Setting setting , Runnable action ) { LOGGER . trace ( String . format ( "doWithoutListeners: setting: %s" , setting ) ) ; setListenerActive ( false ) ; LOGGER . trace ( "removed listener" ) ; action . run ( ) ; LOGGER . trace ( "performed action" ) ; setListenerActive ( true ) ; LOGGER...
Enables to perform an action without firing the attached ChangeListener of a Setting . This is used by undo and redo since those shouldn t cause a new change to be added .
123,768
public boolean undo ( ) { LOGGER . trace ( "undo, before, size: " + changes . size ( ) + " pos: " + position . get ( ) + " validPos: " + validPosition . get ( ) ) ; Change lastChange = prev ( ) ; if ( lastChange != null ) { doWithoutListeners ( lastChange . getSetting ( ) , lastChange :: undo ) ; LOGGER . trace ( "undo...
Undos a change in the history .
123,769
public boolean redo ( ) { LOGGER . trace ( "redo, before, size: " + changes . size ( ) + " pos: " + position . get ( ) + " validPos: " + validPosition . get ( ) ) ; Change nextChange = next ( ) ; if ( nextChange != null ) { doWithoutListeners ( nextChange . getSetting ( ) , nextChange :: redo ) ; LOGGER . trace ( "redo...
Redos a change in the history .
123,770
public void clear ( boolean undoAll ) { LOGGER . trace ( "Clear called, with undoAll: " + undoAll ) ; if ( undoAll ) { undoAll ( ) ; } LOGGER . trace ( "Clearing changes" ) ; changes . clear ( ) ; position . set ( - 1 ) ; validPosition . set ( - 1 ) ; }
Clears the change history .
123,771
public void translate ( ) { if ( translationService == null ) { title . setValue ( titleKey . getValue ( ) ) ; return ; } if ( ! Strings . isNullOrEmpty ( titleKey . getValue ( ) ) ) { title . setValue ( translationService . translate ( titleKey . get ( ) ) ) ; } }
Updates the title based on the titleKey for i18n . If there is no translationService the title will be the same as the titleKey . If there is a translationService the titleKey will be used to lookup the translated variant using the translationService and the title is set .
123,772
private void createCheckboxes ( ) { node . getChildren ( ) . clear ( ) ; checkboxes . clear ( ) ; for ( int i = 0 ; i < field . getItems ( ) . size ( ) ; i ++ ) { CheckBox cb = new CheckBox ( ) ; cb . setText ( field . getItems ( ) . get ( i ) . toString ( ) ) ; cb . setSelected ( field . getSelection ( ) . contains ( ...
This method creates node and adds them to checkboxes and is used when the itemsProperty on the field changes .
123,773
private void setupCheckboxBindings ( ) { for ( CheckBox checkbox : checkboxes ) { checkbox . disableProperty ( ) . bind ( field . editableProperty ( ) . not ( ) ) ; } }
Sets up bindings for all checkboxes .
123,774
private void setupCheckboxEventHandlers ( ) { for ( int i = 0 ; i < checkboxes . size ( ) ; i ++ ) { final int j = i ; checkboxes . get ( i ) . setOnAction ( event -> { if ( checkboxes . get ( j ) . isSelected ( ) ) { field . select ( j ) ; } else { field . deselect ( j ) ; } } ) ; } }
Sets up event handlers for all checkboxes .
123,775
private void setupTextField ( ) { searchFld = new CustomTextField ( ) ; GlyphFont fontAwesome = GlyphFontRegistry . font ( "FontAwesome" ) ; Glyph glyph = fontAwesome . create ( FontAwesome . Glyph . SEARCH ) . color ( Color . GRAY ) ; glyph . setPadding ( new Insets ( 0 , 3 , 0 , 5 ) ) ; searchFld . setLeft ( glyph ) ...
Initializes the TextField and sets the search icon .
123,776
public void init ( PreferencesFxModel model , StringProperty searchText , ObjectProperty < TreeItemPredicate < Category > > predicateProperty ) { this . model = model ; initializeSearch ( ) ; initializeSearchText ( searchText ) ; bindFilterPredicate ( predicateProperty ) ; }
Initializes the SearchHandler by initially creating all necessary lists for filtering and setting up the bindings .
123,777
private void initializeSearchTextListener ( ) { searchText . addListener ( ( observable , oldText , newText ) -> { if ( newText . equals ( "" ) ) { resetSearch ( ) ; } else { updateSearch ( newText ) ; } } ) ; }
Reacts upon changes in the search text . If the search text is empty everything will be unmarked else the search will be updated .
123,778
public void bindFilterPredicate ( ObjectProperty < TreeItemPredicate < Category > > predicateProperty ) { predicateProperty . bind ( Bindings . createObjectBinding ( ( ) -> { if ( searchText . get ( ) == null || searchText . get ( ) . isEmpty ( ) ) { return null ; } return TreeItemPredicate . create ( filterPredicate )...
Binds the predicateProperty to ensure filtering according to the searchText .
123,779
public PreferencesFx saveSettings ( boolean save ) { preferencesFxModel . setSaveSettings ( save ) ; if ( ! save ) { preferencesFxModel . getStorageHandler ( ) . clearPreferences ( ) ; } return this ; }
Defines whether the adjusted settings of the application should be saved or not .
123,780
public PreferencesFx removeEventHandler ( EventType < PreferencesFxEvent > eventType , EventHandler < ? super PreferencesFxEvent > eventHandler ) { preferencesFxModel . removeEventHandler ( eventType , eventHandler ) ; return this ; }
Unregisters a previously registered event handler from the model . One handler might have been registered for different event types so the caller needs to specify the particular event type from which to unregister the handler .
123,781
private void initializeCategoryTranslation ( ) { flatCategoriesLst . forEach ( category -> { translationServiceProperty ( ) . addListener ( ( observable , oldValue , newValue ) -> { category . translate ( newValue ) ; newValue . addListener ( ( ) -> category . translate ( newValue ) ) ; } ) ; } ) ; }
Sets up a binding of the TranslationService on the model so that the Category s title gets translated properly according to the TranslationService used .
123,782
public Category loadSelectedCategory ( ) { String breadcrumb = storageHandler . loadSelectedCategory ( ) ; Category defaultCategory = getCategories ( ) . get ( DEFAULT_CATEGORY ) ; if ( breadcrumb == null ) { return defaultCategory ; } return flatCategoriesLst . stream ( ) . filter ( category -> category . getBreadcrum...
Loads the last selected Category before exiting the Preferences window .
123,783
public void removeEventHandler ( EventType < PreferencesFxEvent > eventType , EventHandler < ? super PreferencesFxEvent > eventHandler ) { if ( eventType == null ) { throw new NullPointerException ( "Argument eventType must not be null" ) ; } if ( eventHandler == null ) { throw new NullPointerException ( "Argument even...
Unregisters a previously registered event handler . One handler might have been registered for different event types so the caller needs to specify the particular event type from which to unregister the handler .
123,784
public ObservableList loadObservableList ( String breadcrumb , ObservableList defaultObservableList ) { String json = getSerializedPreferencesValue ( breadcrumb , gson . toJson ( defaultObservableList ) ) ; return FXCollections . observableArrayList ( gson . fromJson ( json , ArrayList . class ) ) ; }
Searches in the preferences after a serialized ArrayList using the given key deserializes and returns it as ObservableArrayList . When an ObservableList is deserialzed Gson returns an ArrayList and needs to be wrapped into an ObservableArrayList . This is only needed for loading .
123,785
public static < P > Setting of ( String description , ListProperty < P > items , ObjectProperty < P > selection ) { return new Setting < > ( description , Field . ofSingleSelectionType ( items , selection ) . label ( description ) . render ( new SimpleComboBoxControl < > ( ) ) , selection ) ; }
Creates a combobox with single selection .
123,786
public static < P > Setting of ( String description , ListProperty < P > items , ListProperty < P > selections ) { return new Setting < > ( description , Field . ofMultiSelectionType ( items , selections ) . label ( description ) . render ( new SimpleListViewControl < > ( ) ) , selections ) ; }
Creates a combobox with multiselection . At least one element has to be selected at all times .
123,787
public static < F extends Field < F > , P extends Property > Setting of ( String description , F field , P property ) { return new Setting < > ( description , field . label ( description ) , property ) ; }
Creates a setting of a custom defined field .
123,788
public final Setting validate ( Validator ... newValue ) { if ( field instanceof DataField ) { ( ( DataField ) field ) . validate ( newValue ) ; } else { throw new UnsupportedOperationException ( "Field type must be instance of DataField" ) ; } return this ; }
Sets the list of validators for the current field . This overrides all validators that have previously been added .
123,789
public void mark ( ) { if ( ! marked ) { SimpleControl renderer = ( SimpleControl ) getField ( ) . getRenderer ( ) ; Node markNode = renderer . getFieldLabel ( ) ; markNode . getStyleClass ( ) . add ( MARKED_STYLE_CLASS ) ; markNode . setOnMouseExited ( unmarker ) ; marked = ! marked ; } }
Marks a setting . Is used for the search which marks and unmarks items depending on the match as a form of visual feedback .
123,790
public void unmark ( ) { if ( marked ) { SimpleControl renderer = ( SimpleControl ) getField ( ) . getRenderer ( ) ; Node markNode = renderer . getFieldLabel ( ) ; markNode . getStyleClass ( ) . remove ( MARKED_STYLE_CLASS ) ; markNode . removeEventHandler ( MouseEvent . MOUSE_EXITED , unmarker ) ; marked = ! marked ; ...
Unmarks a setting . Is used for the search which marks and unmarks items depending on the match as a form of visual feedback .
123,791
private void loadLastWindowState ( ) { if ( persistWindowState ) { setPrefSize ( storageHandler . loadWindowWidth ( ) , storageHandler . loadWindowHeight ( ) ) ; getScene ( ) . getWindow ( ) . setX ( storageHandler . loadWindowPosX ( ) ) ; getScene ( ) . getWindow ( ) . setY ( storageHandler . loadWindowPosY ( ) ) ; mo...
Loads last saved size and position of the window .
123,792
private void addI18nListener ( ) { model . translationServiceProperty ( ) . addListener ( ( observable , oldValue , newValue ) -> { if ( oldValue != newValue ) { form . i18n ( newValue ) ; newValue . addListener ( categoryModel :: updateGroupDescriptions ) ; if ( ! Objects . equals ( breadCrumbPresenter , null ) ) { ne...
Updates the internal FormsFX form with the most current TranslationService . Makes sure the group descriptions are updated with changing locale .
123,793
public void translate ( String language ) { switch ( language ) { case "EN" : rootPane . rbs . changeLocale ( rootPane . rbEN ) ; break ; case "DE" : rootPane . rbs . changeLocale ( rootPane . rbDE ) ; break ; default : throw new IllegalArgumentException ( "Not a valid locale" ) ; } }
Sets the locale of the form .
123,794
public void mark ( ) { if ( ! marked ) { preferencesGroup . getRenderer ( ) . addStyleClass ( MARKED_STYLE_CLASS ) ; preferencesGroup . getRenderer ( ) . getTitleLabel ( ) . setOnMouseExited ( unmarker ) ; marked = ! marked ; } }
Marks this group in the GUI . Is used for the search which marks and unmarks items depending on the match as a form of visual feedback .
123,795
public void unmark ( ) { if ( marked ) { preferencesGroup . getRenderer ( ) . removeStyleClass ( MARKED_STYLE_CLASS ) ; preferencesGroup . getRenderer ( ) . getTitleLabel ( ) . removeEventHandler ( MouseEvent . MOUSE_EXITED , unmarker ) ; marked = ! marked ; } }
Unmarks this group in the GUI . Is used for the search which marks and unmarks items depending on the match as a form of visual feedback .
123,796
public boolean setView ( final Category category ) { LOGGER . trace ( "CategoryController, setView: " + category ) ; CategoryView categoryView = views . get ( category ) ; if ( categoryView != null ) { setContent ( categoryView ) ; categoryView . minWidthProperty ( ) . bind ( widthProperty ( ) . subtract ( SCROLLBAR_SU...
Sets the current view to the one of the respective category . This method can be called in the presenter to switch to a different CategoryView . Controls the way views are being transitioned from one to another .
123,797
public void addListener ( ReadOnlyObjectProperty < Category > categoryProperty ) { categoryProperty . addListener ( ( observable , oldCategory , newCategory ) -> { setView ( newCategory ) ; } ) ; }
Sets the view according to the current category in categoryProperty . Must ensure that the category is already loaded else it will fail .
123,798
public static List < Category > flattenCategories ( List < Category > categoryLst ) { if ( categoryLst == null ) { return null ; } List < Category > flatCategoryLst = new ArrayList < > ( ) ; flattenCategories ( flatCategoryLst , categoryLst ) ; return flatCategoryLst ; }
Puts all categories and their respective children recursively flattened into a list .
123,799
private static void flattenCategories ( List < Category > flatList , List < Category > categories ) { categories . forEach ( category -> { flatList . add ( category ) ; List < Category > children = category . getChildren ( ) ; if ( children != null ) { flattenCategories ( flatList , children ) ; } } ) ; }
Goes through the list of parent categories and adds each category it visists to the flatList .