idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
21,300
private List < Bucket > lookup ( Record record ) { List < Bucket > buckets = new ArrayList ( ) ; for ( Property p : config . getLookupProperties ( ) ) { String propname = p . getName ( ) ; Collection < String > values = record . getValues ( propname ) ; if ( values == null ) continue ; for ( String value : values ) { S...
Tokenizes lookup fields and returns all matching buckets in the index .
21,301
public void spawnThread ( DukeController controller , int check_interval ) { this . controller = controller ; timer = mgr . schedule ( this , 0 , check_interval * 1000 ) ; }
Starts a background thread which calls the controller every check_interval milliseconds . Returns immediately leaving the background thread running .
21,302
public String [ ] init ( String [ ] argv , int min , int max , Collection < CommandLineParser . Option > options ) throws IOException , SAXException { parser = new CommandLineParser ( ) ; parser . setMinimumArguments ( min ) ; parser . setMaximumArguments ( max ) ; parser . registerOption ( new CommandLineParser . Bool...
These exact lines are shared between three different tools so they have been moved here to reduce code duplication .
21,303
public static File createTempDirectory ( String prefix ) { File temp = null ; try { temp = File . createTempFile ( prefix != null ? prefix : "temp" , Long . toString ( System . nanoTime ( ) ) ) ; if ( ! ( temp . delete ( ) ) ) { throw new IOException ( "Could not delete temp file: " + temp . getAbsolutePath ( ) ) ; } i...
Creates a temporary folder using the given prefix to generate its name .
21,304
public static Configuration loadFromString ( String config ) throws IOException , SAXException { ConfigurationImpl cfg = new ConfigurationImpl ( ) ; XMLReader parser = XMLReaderFactory . createXMLReader ( ) ; parser . setContentHandler ( new ConfigHandler ( cfg , null ) ) ; Reader reader = new StringReader ( config ) ;...
Loads the configuration XML from the given string .
21,305
public void endRecord_ ( ) { Collection < Link > oldlinks = linkdb . getAllLinksFor ( getIdentity ( current ) ) ; if ( oldlinks != null ) { Map < String , Link > oldmap = new HashMap ( oldlinks . size ( ) ) ; for ( Link l : oldlinks ) oldmap . put ( makeKey ( l ) , l ) ; for ( Link newl : new ArrayList < Link > ( curli...
this method is called from the event methods
21,306
public void write ( Configuration config ) throws IOException { pp . startDocument ( ) ; pp . startElement ( "duke" , null ) ; pp . startElement ( "schema" , null ) ; writeElement ( "threshold" , "" + config . getThreshold ( ) ) ; if ( config . getMaybeThreshold ( ) != 0.0 ) writeElement ( "maybe-threshold" , "" + conf...
Writes the given configuration to the given file .
21,307
public static void parse ( Reader src , StatementHandler handler ) throws IOException { new NTriplesParser ( src , handler ) . parse ( ) ; }
Reads the NTriples file from the reader pushing statements into the handler .
21,308
public static int distance ( String s1 , String s2 ) { if ( s1 . length ( ) == 0 ) return s2 . length ( ) ; if ( s2 . length ( ) == 0 ) return s1 . length ( ) ; int s1len = s1 . length ( ) ; int [ ] matrix = new int [ ( s1len + 1 ) * ( s2 . length ( ) + 1 ) ] ; for ( int col = 0 ; col <= s2 . length ( ) ; col ++ ) matr...
This is the original naive implementation using the Wagner & Fischer algorithm from 1974 . It uses a flattened matrix for speed but still computes the entire matrix .
21,309
public static int compactDistance ( String s1 , String s2 ) { if ( s1 . length ( ) == 0 ) return s2 . length ( ) ; if ( s2 . length ( ) == 0 ) return s1 . length ( ) ; int maxdist = Math . min ( s1 . length ( ) , s2 . length ( ) ) / 2 ; int s1len = s1 . length ( ) ; int [ ] column = new int [ s1len + 1 ] ; int ix2 = 0 ...
Optimized version of the Wagner & Fischer algorithm that only keeps a single column in the matrix in memory at a time . It implements the simple cutoff but otherwise computes the entire matrix . It is roughly twice as fast as the original function .
21,310
public void commit ( ) { if ( directory == null ) return ; try { if ( reader != null ) reader . close ( ) ; iwriter . commit ( ) ; openSearchers ( ) ; } catch ( IOException e ) { throw new DukeException ( e ) ; } }
Flushes all changes to disk .
21,311
public Record findRecordById ( String id ) { if ( directory == null ) init ( ) ; Property idprop = config . getIdentityProperties ( ) . iterator ( ) . next ( ) ; for ( Record r : lookup ( idprop , id ) ) if ( r . getValue ( idprop . getName ( ) ) . equals ( id ) ) return r ; return null ; }
Look up record by identity .
21,312
public String clean ( String value ) { String orig = value ; boolean initialplus = findPlus ( value ) ; value = sub . clean ( value ) ; if ( value == null ) return null ; boolean zerozero = ! initialplus && value . startsWith ( "00" ) ; if ( zerozero ) value = value . substring ( 2 ) ; CountryCode ccode = findCountryCo...
look for zero after country code and remove if present
21,313
public boolean overrides ( Link other ) { if ( other . getStatus ( ) == LinkStatus . ASSERTED && status != LinkStatus . ASSERTED ) return false ; else if ( status == LinkStatus . ASSERTED && other . getStatus ( ) != LinkStatus . ASSERTED ) return true ; return timestamp > other . getTimestamp ( ) ; }
Returns true if the information in this link should take precedence over the information in the other link .
21,314
public void process ( ) { if ( error_skips > 0 ) { error_skips -- ; return ; } try { if ( logger != null ) logger . debug ( "Starting processing" ) ; status = "Processing" ; lastCheck = System . currentTimeMillis ( ) ; processor . deduplicate ( batch_size ) ; status = "Sleeping" ; if ( logger != null ) logger . debug (...
Runs the record linkage process .
21,315
void reportError ( Throwable throwable ) { if ( logger != null ) logger . error ( "Timer reported error" , throwable ) ; status = "Thread blocked on error: " + throwable ; error_skips = error_factor ; }
called by timer thread
21,316
public static String makePropertyName ( String name ) { char [ ] buf = new char [ name . length ( ) + 3 ] ; int pos = 0 ; buf [ pos ++ ] = 's' ; buf [ pos ++ ] = 'e' ; buf [ pos ++ ] = 't' ; for ( int ix = 0 ; ix < name . length ( ) ; ix ++ ) { char ch = name . charAt ( ix ) ; if ( ix == 0 ) ch = Character . toUpperCas...
public because it s used by other packages that use Duke
21,317
private List < String > mapObsoleteElements ( List < String > names ) { List < String > elementsToRemove = new ArrayList < > ( names . size ( ) ) ; for ( String name : names ) { if ( name . startsWith ( "android" ) ) continue ; elementsToRemove . add ( name ) ; } return elementsToRemove ; }
Maps all views that don t start with android namespace .
21,318
private void removeObsoleteElements ( List < String > names , Map < String , View > sharedElements , List < String > elementsToRemove ) { if ( elementsToRemove . size ( ) > 0 ) { names . removeAll ( elementsToRemove ) ; for ( String elementToRemove : elementsToRemove ) { sharedElements . remove ( elementToRemove ) ; } ...
Removes obsolete elements from names and shared elements .
21,319
public void onBindViewHolder ( GalleryAdapter . ViewHolder holder , int position , List < Object > payloads ) { if ( payloads . isEmpty ( ) ) { super . onBindViewHolder ( holder , position , payloads ) ; } else { for ( Object payload : payloads ) { boolean selected = isSelected ( position ) ; if ( SELECTION_PAYLOAD . e...
Binding view holder with payloads is used to handle partial changes in item .
21,320
public Slice newSlice ( long address , int size ) { if ( address <= 0 ) { throw new IllegalArgumentException ( "Invalid address: " + address ) ; } if ( size == 0 ) { return Slices . EMPTY_SLICE ; } return new Slice ( null , address , size , 0 , null ) ; }
Creates a slice for directly a raw memory address . This is inherently unsafe as it may be used to access arbitrary memory .
21,321
public Slice newSlice ( long address , int size , Object reference ) { if ( address <= 0 ) { throw new IllegalArgumentException ( "Invalid address: " + address ) ; } if ( reference == null ) { throw new NullPointerException ( "Object reference is null" ) ; } if ( size == 0 ) { return Slices . EMPTY_SLICE ; } return new...
Creates a slice for directly a raw memory address . This is inherently unsafe as it may be used to access arbitrary memory . The slice will hold the specified object reference to prevent the garbage collector from freeing it while it is in use by the slice .
21,322
public static int hash ( int input ) { int k1 = mixK1 ( input ) ; int h1 = mixH1 ( DEFAULT_SEED , k1 ) ; return fmix ( h1 , SizeOf . SIZE_OF_INT ) ; }
Special - purpose version for hashing a single int value . Value is treated as little - endian
21,323
public static boolean isAscii ( Slice utf8 ) { int length = utf8 . length ( ) ; int offset = 0 ; int length8 = length & 0x7FFF_FFF8 ; for ( ; offset < length8 ; offset += 8 ) { if ( ( utf8 . getLongUnchecked ( offset ) & TOP_MASK64 ) != 0 ) { return false ; } } if ( offset + 4 < length ) { if ( ( utf8 . getIntUnchecked...
Does the slice contain only 7 - bit ASCII characters .
21,324
public static int lengthOfCodePoint ( int codePoint ) { if ( codePoint < 0 ) { throw new InvalidCodePointException ( codePoint ) ; } if ( codePoint < 0x80 ) { return 1 ; } if ( codePoint < 0x800 ) { return 2 ; } if ( codePoint < 0x1_0000 ) { return 3 ; } if ( codePoint < 0x11_0000 ) { return 4 ; } throw new InvalidCode...
Gets the UTF - 8 sequence length of the code point .
21,325
public ComplexDouble divi ( ComplexDouble c , ComplexDouble result ) { double d = c . r * c . r + c . i * c . i ; double newR = ( r * c . r + i * c . i ) / d ; double newI = ( i * c . r - r * c . i ) / d ; result . r = newR ; result . i = newI ; return result ; }
Divide two complex numbers in - place
21,326
public static int [ ] randomPermutation ( int size ) { Random r = new Random ( ) ; int [ ] result = new int [ size ] ; for ( int j = 0 ; j < size ; j ++ ) { result [ j ] = j ; } for ( int j = size - 1 ; j > 0 ; j -- ) { int k = r . nextInt ( j ) ; int temp = result [ j ] ; result [ j ] = result [ k ] ; result [ k ] = t...
Create a random permutation of the numbers 0 ... size - 1 .
21,327
public static int [ ] randomSubset ( int k , int n ) { assert ( 0 < k && k <= n ) ; Random r = new Random ( ) ; int t = 0 , m = 0 ; int [ ] result = new int [ k ] ; while ( m < k ) { double u = r . nextDouble ( ) ; if ( ( n - t ) * u < k - m ) { result [ m ] = t ; m ++ ; } t ++ ; } return result ; }
Get a random sample of k out of n elements .
21,328
public static DoubleMatrix [ ] fullSVD ( DoubleMatrix A ) { int m = A . rows ; int n = A . columns ; DoubleMatrix U = new DoubleMatrix ( m , m ) ; DoubleMatrix S = new DoubleMatrix ( min ( m , n ) ) ; DoubleMatrix V = new DoubleMatrix ( n , n ) ; int info = NativeBlas . dgesvd ( 'A' , 'A' , m , n , A . dup ( ) . data ,...
Compute a singular - value decomposition of A .
21,329
private InputStream tryPath ( String path ) { Logger . getLogger ( ) . debug ( "Trying path \"" + path + "\"." ) ; return getClass ( ) . getResourceAsStream ( path ) ; }
Try to open a file at the given position .
21,330
private void loadLibraryFromStream ( String libname , InputStream is ) { try { File tempfile = createTempFile ( libname ) ; OutputStream os = new FileOutputStream ( tempfile ) ; logger . debug ( "tempfile.getPath() = " + tempfile . getPath ( ) ) ; long savedTime = System . currentTimeMillis ( ) ; byte buf [ ] = new byt...
Load a system library from a stream . Copies the library to a temp file and loads from there .
21,331
public static void checkVectorAddition ( ) { DoubleMatrix x = new DoubleMatrix ( 3 , 1 , 1.0 , 2.0 , 3.0 ) ; DoubleMatrix y = new DoubleMatrix ( 3 , 1 , 4.0 , 5.0 , 6.0 ) ; DoubleMatrix z = new DoubleMatrix ( 3 , 1 , 5.0 , 7.0 , 9.0 ) ; check ( "checking vector addition" , x . add ( y ) . equals ( z ) ) ; }
Check whether vector addition works . This is pure Java code and should work .
21,332
public static void checkXerbla ( ) { double [ ] x = new double [ 9 ] ; System . out . println ( "Check whether we're catching XERBLA errors. If you see something like \"** On entry to DGEMM parameter number 4 had an illegal value\", it didn't work!" ) ; try { NativeBlas . dgemm ( 'N' , 'N' , 3 , - 1 , 3 , 1.0 , x , 0...
Check whether error handling works . If it works you should see an ok otherwise you might see the actual error message and then the program exits .
21,333
public static void checkEigenvalues ( ) { DoubleMatrix A = new DoubleMatrix ( new double [ ] [ ] { { 3.0 , 2.0 , 0.0 } , { 2.0 , 3.0 , 2.0 } , { 0.0 , 2.0 , 3.0 } } ) ; DoubleMatrix E = new DoubleMatrix ( 3 , 1 ) ; NativeBlas . dsyev ( 'N' , 'U' , 3 , A . data , 0 , 3 , E . data , 0 ) ; check ( "checking existence of d...
Compute eigenvalues . This is a routine not in ATLAS but in the original LAPACK .
21,334
public static DoubleMatrix cholesky ( DoubleMatrix A ) { DoubleMatrix result = A . dup ( ) ; int info = NativeBlas . dpotrf ( 'U' , A . rows , result . data , 0 , A . rows ) ; if ( info < 0 ) { throw new LapackArgumentException ( "DPOTRF" , - info ) ; } else if ( info > 0 ) { throw new LapackPositivityException ( "DPOT...
Compute Cholesky decomposition of A
21,335
public static QRDecomposition < DoubleMatrix > qr ( DoubleMatrix A ) { int minmn = min ( A . rows , A . columns ) ; DoubleMatrix result = A . dup ( ) ; DoubleMatrix tau = new DoubleMatrix ( minmn ) ; SimpleBlas . geqrf ( result , tau ) ; DoubleMatrix R = new DoubleMatrix ( A . rows , A . columns ) ; for ( int i = 0 ; i...
QR decomposition .
21,336
public static DoubleMatrix absi ( DoubleMatrix x ) { for ( int i = 0 ; i < x . length ; i ++ ) x . put ( i , ( double ) Math . abs ( x . get ( i ) ) ) ; return x ; }
Sets all elements in this matrix to their absolute values . Note that this operation is in - place .
21,337
public static DoubleMatrix expm ( DoubleMatrix A ) { final double c0 = 1.0 ; final double c1 = 0.5 ; final double c2 = 0.12 ; final double c3 = 0.01833333333333333 ; final double c4 = 0.0019927536231884053 ; final double c5 = 1.630434782608695E-4 ; final double c6 = 1.0351966873706E-5 ; final double c7 = 5.175983436853...
Calculate matrix exponential of a square matrix .
21,338
public static VectorTile . Tile . GeomType toGeomType ( Geometry geometry ) { VectorTile . Tile . GeomType result = VectorTile . Tile . GeomType . UNKNOWN ; if ( geometry instanceof Point || geometry instanceof MultiPoint ) { result = VectorTile . Tile . GeomType . POINT ; } else if ( geometry instanceof LineString || ...
Get the MVT type mapping for the provided JTS Geometry .
21,339
private static boolean equalAsInts ( Vec2d a , Vec2d b ) { return ( ( int ) a . x ) == ( ( int ) b . x ) && ( ( int ) a . y ) == ( ( int ) b . y ) ; }
Return true if the values of the two vectors are equal when cast as ints .
21,340
private static void validate ( String name , Collection < Geometry > geometries , int extent ) { if ( name == null ) { throw new IllegalArgumentException ( "layer name is null" ) ; } if ( geometries == null ) { throw new IllegalArgumentException ( "geometry collection is null" ) ; } if ( extent <= 0 ) { throw new Illeg...
Validate the JtsLayer .
21,341
public int addKey ( String key ) { JdkUtils . requireNonNull ( key ) ; int nextIndex = keys . size ( ) ; final Integer mapIndex = JdkUtils . putIfAbsent ( keys , key , nextIndex ) ; return mapIndex == null ? nextIndex : mapIndex ; }
Add the key and return it s index code . If the key already is present the previous index code is returned and no insertion is done .
21,342
private void findScrollView ( ViewGroup viewGroup ) { scrollChild = viewGroup ; if ( viewGroup . getChildCount ( ) > 0 ) { int count = viewGroup . getChildCount ( ) ; View child ; for ( int i = 0 ; i < count ; i ++ ) { child = viewGroup . getChildAt ( i ) ; if ( child instanceof AbsListView || child instanceof ScrollVi...
Find out the scrollable child view from a ViewGroup .
21,343
private void removeAllBroadcasts ( Set < String > sessionIds ) { if ( sessionIds == null ) { for ( CmsSessionInfo info : OpenCms . getSessionManager ( ) . getSessionInfos ( ) ) { OpenCms . getSessionManager ( ) . getBroadcastQueue ( info . getSessionId ( ) . getStringValue ( ) ) . clear ( ) ; } return ; } for ( String ...
Removes all pending broadcasts
21,344
@ UiHandler ( "m_atDay" ) void onWeekDayChange ( ValueChangeEvent < String > event ) { if ( handleChange ( ) ) { m_controller . setWeekDay ( event . getValue ( ) ) ; } }
Handles week day changes .
21,345
private void addCheckBox ( final String internalValue , String labelMessageKey ) { CmsCheckBox box = new CmsCheckBox ( Messages . get ( ) . key ( labelMessageKey ) ) ; box . setInternalValue ( internalValue ) ; box . addValueChangeHandler ( new ValueChangeHandler < Boolean > ( ) { public void onValueChange ( ValueChang...
Creates a check box and adds it to the week panel and the checkboxes .
21,346
private void checkExactlyTheWeeksCheckBoxes ( Collection < WeekOfMonth > weeksToCheck ) { for ( CmsCheckBox cb : m_checkboxes ) { cb . setChecked ( weeksToCheck . contains ( WeekOfMonth . valueOf ( cb . getInternalValue ( ) ) ) ) ; } }
Check exactly the week check - boxes representing the given weeks .
21,347
private void fillWeekPanel ( ) { addCheckBox ( WeekOfMonth . FIRST . toString ( ) , Messages . GUI_SERIALDATE_WEEKDAYNUMBER_1_0 ) ; addCheckBox ( WeekOfMonth . SECOND . toString ( ) , Messages . GUI_SERIALDATE_WEEKDAYNUMBER_2_0 ) ; addCheckBox ( WeekOfMonth . THIRD . toString ( ) , Messages . GUI_SERIALDATE_WEEKDAYNUMB...
Fills the week panel with checkboxes .
21,348
public Label htmlLabel ( String html ) { Label label = new Label ( ) ; label . setContentMode ( ContentMode . HTML ) ; label . setValue ( html ) ; return label ; }
Creates a new HTML - formatted label with the given content .
21,349
public String readSnippet ( String name ) { String path = CmsStringUtil . joinPaths ( m_context . getSetupBean ( ) . getWebAppRfsPath ( ) , CmsSetupBean . FOLDER_SETUP , "html" , name ) ; try ( InputStream stream = new FileInputStream ( path ) ) { byte [ ] data = CmsFileUtil . readFully ( stream , false ) ; String resu...
Reads an HTML snippet with the given name .
21,350
public static List < String > getSelectOptionValues ( CmsObject cms , String rootPath , boolean allRemoved ) { try { cms = OpenCms . initCmsObject ( cms ) ; cms . getRequestContext ( ) . setSiteRoot ( "" ) ; CmsADEConfigData adeConfig = OpenCms . getADEManager ( ) . lookupConfiguration ( cms , rootPath ) ; if ( adeConf...
Returns all values that can be selected in the widget .
21,351
public void addRow ( Component component ) { Component actualComponent = component == null ? m_newComponentFactory . get ( ) : component ; I_CmsEditableGroupRow row = m_rowBuilder . buildRow ( this , actualComponent ) ; m_container . addComponent ( row ) ; updatePlaceholder ( ) ; updateButtonBars ( ) ; updateGroupValid...
Adds a row for the given component at the end of the group .
21,352
public void addRowAfter ( I_CmsEditableGroupRow row ) { int index = m_container . getComponentIndex ( row ) ; if ( index >= 0 ) { Component component = m_newComponentFactory . get ( ) ; I_CmsEditableGroupRow newRow = m_rowBuilder . buildRow ( this , component ) ; m_container . addComponent ( newRow , index + 1 ) ; } up...
Adds a new row after the given one .
21,353
public List < I_CmsEditableGroupRow > getRows ( ) { List < I_CmsEditableGroupRow > result = Lists . newArrayList ( ) ; for ( Component component : m_container ) { if ( component instanceof I_CmsEditableGroupRow ) { result . add ( ( I_CmsEditableGroupRow ) component ) ; } } return result ; }
Gets all rows .
21,354
public void moveDown ( I_CmsEditableGroupRow row ) { int index = m_container . getComponentIndex ( row ) ; if ( ( index >= 0 ) && ( index < ( m_container . getComponentCount ( ) - 1 ) ) ) { m_container . removeComponent ( row ) ; m_container . addComponent ( row , index + 1 ) ; } updateButtonBars ( ) ; }
Moves the given row down .
21,355
public void moveUp ( I_CmsEditableGroupRow row ) { int index = m_container . getComponentIndex ( row ) ; if ( index > 0 ) { m_container . removeComponent ( row ) ; m_container . addComponent ( row , index - 1 ) ; } updateButtonBars ( ) ; }
Moves the given row up .
21,356
public void remove ( I_CmsEditableGroupRow row ) { int index = m_container . getComponentIndex ( row ) ; if ( index >= 0 ) { m_container . removeComponent ( row ) ; } updatePlaceholder ( ) ; updateButtonBars ( ) ; updateGroupValidation ( ) ; }
Removes the given row .
21,357
public void adjustLinks ( String sourceFolder , String targetFolder ) throws CmsException { String rootSourceFolder = addSiteRoot ( sourceFolder ) ; String rootTargetFolder = addSiteRoot ( targetFolder ) ; String siteRoot = getRequestContext ( ) . getSiteRoot ( ) ; getRequestContext ( ) . setSiteRoot ( "" ) ; try { Cms...
Adjusts all links in the target folder that point to the source folder so that they are kept relative in the target folder where possible .
21,358
public void setRGB ( int red , int green , int blue ) throws Exception { CmsColor color = new CmsColor ( ) ; color . setRGB ( red , green , blue ) ; m_red = red ; m_green = green ; m_blue = blue ; m_hue = color . getHue ( ) ; m_saturation = color . getSaturation ( ) ; m_brightness = color . getValue ( ) ; m_tbRed . set...
Sets the Red Green and Blue color variables . This will automatically populate the Hue Saturation and Brightness and Hexadecimal fields too .
21,359
protected void doSave ( ) { List < CmsFavoriteEntry > entries = getEntries ( ) ; try { m_favDao . saveFavorites ( entries ) ; } catch ( Exception e ) { CmsErrorDialog . showErrorDialog ( e ) ; } }
Saves the list of currently displayed favorites .
21,360
List < CmsFavoriteEntry > getEntries ( ) { List < CmsFavoriteEntry > result = new ArrayList < > ( ) ; for ( I_CmsEditableGroupRow row : m_group . getRows ( ) ) { CmsFavoriteEntry entry = ( ( CmsFavInfo ) row ) . getEntry ( ) ; result . add ( entry ) ; } return result ; }
Gets the favorite entries corresponding to the currently displayed favorite widgets .
21,361
private CmsFavInfo createFavInfo ( CmsFavoriteEntry entry ) throws CmsException { String title = "" ; String subtitle = "" ; CmsFavInfo result = new CmsFavInfo ( entry ) ; CmsObject cms = A_CmsUI . getCmsObject ( ) ; String project = getProject ( cms , entry ) ; String site = getSite ( cms , entry ) ; try { CmsUUID idT...
Creates a favorite widget for a favorite entry .
21,362
private CmsFavoriteEntry getEntry ( Component row ) { if ( row instanceof CmsFavInfo ) { return ( ( CmsFavInfo ) row ) . getEntry ( ) ; } return null ; }
Gets the favorite entry for a given row .
21,363
private String getProject ( CmsObject cms , CmsFavoriteEntry entry ) throws CmsException { String result = m_projectLabels . get ( entry . getProjectId ( ) ) ; if ( result == null ) { result = cms . readProject ( entry . getProjectId ( ) ) . getName ( ) ; m_projectLabels . put ( entry . getProjectId ( ) , result ) ; } ...
Gets the project name for a favorite entry .
21,364
private String getSite ( CmsObject cms , CmsFavoriteEntry entry ) { CmsSite site = OpenCms . getSiteManager ( ) . getSiteForRootPath ( entry . getSiteRoot ( ) ) ; Item item = m_sitesContainer . getItem ( entry . getSiteRoot ( ) ) ; if ( item != null ) { return ( String ) ( item . getItemProperty ( "caption" ) . getValu...
Gets the site label for the entry .
21,365
private void onClickAdd ( ) { if ( m_currentLocation . isPresent ( ) ) { CmsFavoriteEntry entry = m_currentLocation . get ( ) ; List < CmsFavoriteEntry > entries = getEntries ( ) ; entries . add ( entry ) ; try { m_favDao . saveFavorites ( entries ) ; } catch ( Exception e ) { CmsErrorDialog . showErrorDialog ( e ) ; }...
The click handler for the add button .
21,366
public void setLocale ( String locale ) { try { m_locale = LocaleUtils . toLocale ( locale ) ; } catch ( IllegalArgumentException e ) { LOG . error ( Messages . get ( ) . getBundle ( ) . key ( Messages . ERR_TAG_INVALID_LOCALE_1 , "cms:navigation" ) , e ) ; m_locale = null ; } }
Sets the locale for which the property should be read .
21,367
public List < CmsFavoriteEntry > loadFavorites ( ) throws CmsException { List < CmsFavoriteEntry > result = new ArrayList < > ( ) ; try { CmsUser user = readUser ( ) ; String data = ( String ) user . getAdditionalInfo ( ADDINFO_KEY ) ; if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( data ) ) { return new ArrayList < > (...
Loads the favorite list .
21,368
public void saveFavorites ( List < CmsFavoriteEntry > favorites ) throws CmsException { try { JSONObject json = new JSONObject ( ) ; JSONArray array = new JSONArray ( ) ; for ( CmsFavoriteEntry entry : favorites ) { array . put ( entry . toJson ( ) ) ; } json . put ( BASE_KEY , array ) ; String data = json . toString (...
Saves the favorites .
21,369
private boolean validate ( CmsFavoriteEntry entry ) { try { String siteRoot = entry . getSiteRoot ( ) ; if ( ! m_okSiteRoots . contains ( siteRoot ) ) { m_rootCms . readResource ( siteRoot ) ; m_okSiteRoots . add ( siteRoot ) ; } CmsUUID project = entry . getProjectId ( ) ; if ( ! m_okProjects . contains ( project ) ) ...
Validates a favorite entry .
21,370
public void showCurrentDates ( Collection < CmsPair < Date , Boolean > > dates ) { m_overviewList . setDatesWithCheckState ( dates ) ; m_overviewPopup . center ( ) ; }
Shows the provided list of dates as current dates .
21,371
public void updateExceptions ( ) { m_exceptionsList . setDates ( m_model . getExceptions ( ) ) ; if ( m_model . getExceptions ( ) . size ( ) > 0 ) { m_exceptionsPanel . setVisible ( true ) ; } else { m_exceptionsPanel . setVisible ( false ) ; } }
Updates the exceptions panel .
21,372
@ UiHandler ( "m_currentTillEndCheckBox" ) void onCurrentTillEndChange ( ValueChangeEvent < Boolean > event ) { if ( handleChange ( ) ) { m_controller . setCurrentTillEnd ( event . getValue ( ) ) ; } }
Handle a current till end change event .
21,373
@ UiHandler ( "m_endTime" ) void onEndTimeChange ( CmsDateBoxEvent event ) { if ( handleChange ( ) && ! event . isUserTyping ( ) ) { m_controller . setEndTime ( event . getDate ( ) ) ; } }
Handle an end time change .
21,374
void onEndTypeChange ( ) { EndType endType = m_model . getEndType ( ) ; m_groupDuration . selectButton ( getDurationButtonForType ( endType ) ) ; switch ( endType ) { case DATE : case TIMES : m_durationPanel . setVisible ( true ) ; m_seriesEndDate . setValue ( m_model . getSeriesEndDate ( ) ) ; int occurrences = m_mode...
Called when the end type is changed .
21,375
void onPatternChange ( ) { PatternType patternType = m_model . getPatternType ( ) ; boolean isSeries = ! patternType . equals ( PatternType . NONE ) ; setSerialOptionsVisible ( isSeries ) ; m_seriesCheckBox . setChecked ( isSeries ) ; if ( isSeries ) { m_groupPattern . selectButton ( m_patternButtons . get ( patternTyp...
Called when the pattern has changed .
21,376
@ UiHandler ( "m_seriesCheckBox" ) void onSeriesChange ( ValueChangeEvent < Boolean > event ) { if ( handleChange ( ) ) { m_controller . setIsSeries ( event . getValue ( ) ) ; } }
Handle changes of the series check box .
21,377
@ UiHandler ( "m_startTime" ) void onStartTimeChange ( CmsDateBoxEvent event ) { if ( handleChange ( ) && ! event . isUserTyping ( ) ) { m_controller . setStartTime ( event . getDate ( ) ) ; } }
Handle a start time change .
21,378
@ UiHandler ( "m_wholeDayCheckBox" ) void onWholeDayChange ( ValueChangeEvent < Boolean > event ) { if ( handleChange ( ) ) { m_controller . setWholeDay ( event . getValue ( ) ) ; } }
Handle a whole day change event .
21,379
private void createAndAddButton ( PatternType pattern , String messageKey ) { CmsRadioButton btn = new CmsRadioButton ( pattern . toString ( ) , Messages . get ( ) . key ( messageKey ) ) ; btn . addStyleName ( I_CmsWidgetsLayoutBundle . INSTANCE . widgetCss ( ) . radioButtonlabel ( ) ) ; btn . setGroup ( m_groupPattern...
Creates a pattern choice radio button and adds it where necessary .
21,380
private void initDatesPanel ( ) { m_startLabel . setText ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_TIME_STARTTIME_0 ) ) ; m_startTime . setAllowInvalidValue ( true ) ; m_startTime . setValue ( m_model . getStart ( ) ) ; m_endLabel . setText ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_TIME_ENDTIM...
Initialize dates panel elements .
21,381
private void initDeactivationPanel ( ) { m_deactivationPanel . setVisible ( false ) ; m_deactivationText . setText ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_DEACTIVE_TEXT_0 ) ) ; }
Initialize elements of the panel displayed for the deactivated widget .
21,382
private void initDurationButtonGroup ( ) { m_groupDuration = new CmsRadioButtonGroup ( ) ; m_endsAfterRadioButton = new CmsRadioButton ( EndType . TIMES . toString ( ) , Messages . get ( ) . key ( Messages . GUI_SERIALDATE_DURATION_ENDTYPE_OCC_0 ) ) ; m_endsAfterRadioButton . setGroup ( m_groupDuration ) ; m_endsAtRadi...
Configure all UI elements in the ending - options panel .
21,383
private void initDurationPanel ( ) { m_durationPrefixLabel . setText ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_DURATION_PREFIX_0 ) ) ; m_durationAfterPostfixLabel . setText ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_DURATION_ENDTYPE_OCC_POSTFIX_0 ) ) ; m_seriesEndDate . setDateOnly ( true ) ; m...
Initialize elements from the duration panel .
21,384
private void initExceptionsPanel ( ) { m_exceptionsPanel . setLegend ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_PANEL_EXCEPTIONS_0 ) ) ; m_exceptionsPanel . addCloseHandler ( this ) ; m_exceptionsPanel . setVisible ( false ) ; }
Configure all UI elements in the exceptions panel .
21,385
private void initManagementPart ( ) { m_manageExceptionsButton . setText ( Messages . get ( ) . key ( Messages . GUI_SERIALDATE_BUTTON_MANAGE_EXCEPTIONS_0 ) ) ; m_manageExceptionsButton . getElement ( ) . getStyle ( ) . setFloat ( Style . Float . RIGHT ) ; }
Initialize the ui elements for the management part .
21,386
private void initPatternButtonGroup ( ) { m_groupPattern = new CmsRadioButtonGroup ( ) ; m_patternButtons = new HashMap < > ( ) ; createAndAddButton ( PatternType . DAILY , Messages . GUI_SERIALDATE_TYPE_DAILY_0 ) ; m_patternButtons . put ( PatternType . NONE , m_patternButtons . get ( PatternType . DAILY ) ) ; createA...
Initialize the pattern choice button group .
21,387
private void injectAdditionalStyles ( ) { try { Collection < String > stylesheets = OpenCms . getWorkplaceAppManager ( ) . getAdditionalStyleSheets ( ) ; for ( String stylesheet : stylesheets ) { A_CmsUI . get ( ) . getPage ( ) . addDependency ( new Dependency ( Type . STYLESHEET , stylesheet ) ) ; } } catch ( Exceptio...
Inject external stylesheets .
21,388
public String createSessionForResource ( String configPath , String fileName ) throws CmsUgcException { CmsUgcSession formSession = CmsUgcSessionFactory . getInstance ( ) . createSessionForFile ( getCmsObject ( ) , getRequest ( ) , configPath , fileName ) ; return "" + formSession . getId ( ) ; }
Creates a new form session to edit the file with the given name using the given form configuration .
21,389
public final void setValue ( String value ) { if ( ( null == value ) || value . isEmpty ( ) ) { setDefaultValue ( ) ; } else { try { tryToSetParsedValue ( value ) ; } catch ( @ SuppressWarnings ( "unused" ) Exception e ) { CmsDebugLog . consoleLog ( "Could not set invalid serial date value: " + value ) ; setDefaultValu...
Set the value as provided .
21,390
private JSONValue datesToJsonArray ( Collection < Date > dates ) { if ( null != dates ) { JSONArray result = new JSONArray ( ) ; for ( Date d : dates ) { result . set ( result . size ( ) , dateToJson ( d ) ) ; } return result ; } return null ; }
Converts a collection of dates to a JSON array with the long representation of the dates as strings .
21,391
private JSONValue dateToJson ( Date d ) { return null != d ? new JSONString ( Long . toString ( d . getTime ( ) ) ) : null ; }
Convert a date to the String representation we use in the JSON .
21,392
private Boolean readOptionalBoolean ( JSONValue val ) { JSONBoolean b = null == val ? null : val . isBoolean ( ) ; if ( b != null ) { return Boolean . valueOf ( b . booleanValue ( ) ) ; } return null ; }
Read an optional boolean value form a JSON value .
21,393
private Date readOptionalDate ( JSONValue val ) { JSONString str = null == val ? null : val . isString ( ) ; if ( str != null ) { try { return new Date ( Long . parseLong ( str . stringValue ( ) ) ) ; } catch ( @ SuppressWarnings ( "unused" ) NumberFormatException e ) { } } return null ; }
Read an optional Date value form a JSON value .
21,394
private int readOptionalInt ( JSONValue val ) { JSONString str = null == val ? null : val . isString ( ) ; if ( str != null ) { try { return Integer . valueOf ( str . stringValue ( ) ) . intValue ( ) ; } catch ( @ SuppressWarnings ( "unused" ) NumberFormatException e ) { } } return 0 ; }
Read an optional int value form a JSON value .
21,395
private Month readOptionalMonth ( JSONValue val ) { String str = readOptionalString ( val ) ; if ( null != str ) { try { return Month . valueOf ( str ) ; } catch ( @ SuppressWarnings ( "unused" ) IllegalArgumentException e ) { } } return null ; }
Read an optional month value form a JSON value .
21,396
private String readOptionalString ( JSONValue val ) { JSONString str = null == val ? null : val . isString ( ) ; if ( str != null ) { return str . stringValue ( ) ; } return null ; }
Read an optional string value form a JSON value .
21,397
private WeekDay readWeekDay ( JSONValue val ) throws IllegalArgumentException { String str = readOptionalString ( val ) ; if ( null != str ) { return WeekDay . valueOf ( str ) ; } throw new IllegalArgumentException ( ) ; }
Read a single weekday from the provided JSON value .
21,398
private JSONValue toJsonStringList ( Collection < ? extends Object > list ) { if ( null != list ) { JSONArray array = new JSONArray ( ) ; for ( Object o : list ) { array . set ( array . size ( ) , new JSONString ( o . toString ( ) ) ) ; } return array ; } else { return null ; } }
Convert a list of objects to a JSON array with the string representations of that objects .
21,399
private void tryToSetParsedValue ( String value ) throws Exception { JSONObject json = JSONParser . parseStrict ( value ) . isObject ( ) ; JSONValue val = json . get ( JsonKey . START ) ; setStart ( readOptionalDate ( val ) ) ; val = json . get ( JsonKey . END ) ; setEnd ( readOptionalDate ( val ) ) ; setWholeDay ( rea...
Try to set the value from the provided Json string .