1 21 22 package org.armedbear.j; 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 27 public final class ChooseSessionDialog extends InputDialog 28 { 29 public ChooseSessionDialog(String title) 30 { 31 super(Editor.currentEditor(), "Name:", title, 32 Editor.getSessionName()); 33 setHistory(new History("chooseSession")); 34 editor.centerDialog(this); 35 } 36 37 protected List getCompletions(String prefix) 38 { 39 ArrayList list = null; 40 if (prefix != null) { 41 final int prefixLength = prefix.length(); 42 File dir = Session.getSessionDirectory(); 43 if (dir != null) { 44 String [] names = dir.list(); 45 for (int i = 0; i < names.length; i++) { 46 String name = names[i]; 47 if (name.regionMatches(true, 0, prefix, 0, prefixLength)) { 48 if (list == null) 49 list = new ArrayList (); 50 list.add(name); 51 } 52 } 53 } 54 } 55 return list; 56 } 57 } 58 | Popular Tags |