1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets; 22 23 24 import java.util.ArrayList ; 25 import java.util.Arrays ; 26 import java.util.List ; 27 28 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 29 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants; 30 31 32 38 public class HistoryUtils 39 { 40 41 47 public static void save( String key, String value ) 48 { 49 String [] history = load( key ); 51 List <String > list = new ArrayList <String >( Arrays.asList( history ) ); 52 53 if ( list.contains( value ) ) 55 { 56 list.remove( value ); 57 } 58 list.add( 0, value ); 59 60 while ( list.size() > BrowserCommonConstants.HISTORYSIZE ) 62 { 63 list.remove( list.size() - 1 ); 64 } 65 66 history = list.toArray( new String [list.size()] ); 68 BrowserCommonActivator.getDefault().getDialogSettings().put( key, history ); 69 70 } 71 72 73 79 public static String [] load( String key ) 80 { 81 String [] history = BrowserCommonActivator.getDefault().getDialogSettings().getArray( key ); 82 if ( history == null ) 83 { 84 history = new String [0]; 85 } 86 return history; 87 } 88 89 } 90 | Popular Tags |