1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.xnap.gui.component;
20
21 import javax.swing.text.JTextComponent;
22
23 import org.apache.log4j.Logger;
24 import org.xnap.i18n.I18n;
25 import org.xnap.util.*;
26
27 public class CompletionModeFactory
28 {
29
30
31 public static final String DEFAULT_COMPLETION = I18n.marktr("Default");
32
33 public static final String AUTOMATIC_COMPLETION = I18n.marktr("Automatic");
34
35 public static final String SHORT_AUTOMATIC_COMPLETION
36 = I18n.marktr("Short Automatic");
37
38 public static final String AUTOMATIC_DROPDOWN_COMPLETION
39 = I18n.marktr("Automatic Dropdown");
40
41 public static final String NO_COMPLETION = I18n.marktr("None");
42
43 public static final String MANUAL_COMPLETION
44 = I18n.marktr("Manual");
45
46 public static final String EMACS_COMPLETION
47 = I18n.marktr("Emacs");
48
49 public static final String DROPDOWN_COMPLETION
50 = I18n.marktr("Dropdown List");
51
52 public static final String[] DEFAULT_COMPLETION_MODES = new String[] {
53 NO_COMPLETION, DROPDOWN_COMPLETION, AUTOMATIC_COMPLETION,
54 SHORT_AUTOMATIC_COMPLETION, AUTOMATIC_DROPDOWN_COMPLETION,
55 MANUAL_COMPLETION, EMACS_COMPLETION,
56 };
57
58
59
60 private static Logger logger = Logger.getLogger(CompletionModeFactory.class);
61
62
63
64 public CompletionModeFactory()
65 {
66
67 }
68
69
70
71 public static CompletionMode createCompletionMode(String key,
72 JTextComponent c,
73 boolean wholeText)
74 {
75 if (key.equals(DEFAULT_COMPLETION)) {
76 String def = Preferences.getInstance().getDefaultCompletionMode();
77
78 if (def.equals(DEFAULT_COMPLETION)) {
79 return new DropDownListCompletionMode(c, wholeText);
80 }
81 else {
82 return createCompletionMode(def, c, wholeText);
83 }
84 }
85 else if (key.equals(NO_COMPLETION)) {
86 return new NoCompletionMode(c, wholeText);
87 }
88 else if (key.equals(DROPDOWN_COMPLETION)) {
89 return new DropDownListCompletionMode(c, wholeText);
90 }
91 else if (key.equals(AUTOMATIC_COMPLETION)) {
92 return new AutomaticCompletionMode(c, wholeText);
93 }
94 else if (key.equals(SHORT_AUTOMATIC_COMPLETION)) {
95 return new ShortAutomaticCompletionMode(c, wholeText);
96 }
97 else if (key.equals(AUTOMATIC_DROPDOWN_COMPLETION)) {
98 return new AutomaticDropDownCompletionMode(c, wholeText);
99 }
100 else if (key.equals(MANUAL_COMPLETION)) {
101 return new ManualCompletionMode(c, wholeText);
102 }
103 else if (key.equals(EMACS_COMPLETION)) {
104 return new EmacsCompletionMode(c, wholeText);
105 }
106 else {
107
108 return new DropDownListCompletionMode(c, wholeText);
109 }
110 }
111
112 }