1 20 package org.apache.directory.ldapstudio.proxy.view; 21 22 23 import java.util.ArrayList ; 24 import java.util.Arrays ; 25 import java.util.List ; 26 27 import org.apache.directory.ldapstudio.proxy.Activator; 28 import org.apache.directory.ldapstudio.proxy.ProxyConstants; 29 30 31 37 public class HistoryUtils 38 { 39 public static void save( String key, String value ) 40 { 41 String [] history = load( key ); 43 List <String > list = new ArrayList <String >( Arrays.asList( history ) ); 44 45 if ( list.contains( value ) ) 47 { 48 list.remove( value ); 49 } 50 list.add( 0, value ); 51 52 while ( list.size() > ProxyConstants.DIALOG_HISTORY_SIZE ) 54 { 55 list.remove( list.size() - 1 ); 56 } 57 58 history = ( String [] ) list.toArray( new String [list.size()] ); 60 Activator.getDefault().getDialogSettings().put( key, history ); 61 62 } 63 64 65 public static String [] load( String key ) 66 { 67 String [] history = Activator.getDefault().getDialogSettings().getArray( key ); 68 if ( history == null ) 69 { 70 history = new String [0]; 71 } 72 return history; 73 } 74 } 75 | Popular Tags |