Subversion Repositories wimsdev

Rev

Blame | Last modification | View Log | RSS feed

  1. package rene.gui;
  2.  
  3. import java.awt.event.ItemEvent;
  4. import java.awt.event.ItemListener;
  5.  
  6. import rene.util.FileName;
  7. import rene.util.MyVector;
  8. import rene.util.list.ListClass;
  9. import rene.util.list.ListElement;
  10.  
  11. public class HistoryTextFieldChoice extends MyChoice
  12.         implements ItemListener
  13. {       HistoryTextField T;
  14.         DoActionListener AL;
  15.         MyVector V=new MyVector();
  16.         public int MaxLength=32;
  17.  
  18.         public HistoryTextFieldChoice (HistoryTextField t)
  19.         {       T=t;
  20.                 addItemListener(this);
  21.         }
  22.        
  23.         public void setDoActionListener (DoActionListener al)
  24.         {       AL=al;
  25.         }
  26.        
  27.         public void itemStateChanged (ItemEvent e)
  28.         {       int n=getSelectedIndex();
  29.                 String s=(String)V.elementAt(n);
  30.                 if (s.equals("   ")) return;
  31.                 if (AL!=null) AL.doAction(s);
  32.                 else T.doAction(s);
  33.         }
  34.        
  35.         public void update ()
  36.         {       removeAll();
  37.                 V.removeAllElements();
  38.                 ListClass l=T.getHistory();
  39.                 ListElement e=l.last();
  40.                 if (e==null || ((String)e.content()).equals(""))
  41.                 {       V.addElement("   ");
  42.                         add("   ");
  43.                 }
  44.                 while (e!=null)
  45.                 {       String s=(String)e.content();
  46.                         if (!s.equals(""))
  47.                         {       V.addElement(s);
  48.                                 add(FileName.chop(s,MaxLength));
  49.                         }
  50.                         e=e.previous();
  51.                 }
  52.         }
  53.        
  54.         public String getRecent ()
  55.         {       if (V.size()>1) return (String)V.elementAt(1);
  56.                 else return "";
  57.         }
  58. }
  59.