49 |
|
|
50 |
import schmitzm.swing.JPanel; |
import schmitzm.swing.JPanel; |
51 |
import schmitzm.swing.SpringUtilities; |
import schmitzm.swing.SpringUtilities; |
52 |
|
import schmitzm.swing.SwingUtil; |
53 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
54 |
|
|
55 |
/** |
/** |
73 |
/** |
/** |
74 |
* Remembers all {@link JTextField} that have been created. |
* Remembers all {@link JTextField} that have been created. |
75 |
*/ |
*/ |
76 |
private Set<JTextField> langTextFields = new HashSet<JTextField>(); |
private Set<TranslationJTextField> langTextFields = new HashSet<TranslationJTextField>(); |
|
|
|
77 |
private WeakHashMap<ActionListener, ActionListener> actionListeners = new WeakHashMap<ActionListener, ActionListener>(); |
private WeakHashMap<ActionListener, ActionListener> actionListeners = new WeakHashMap<ActionListener, ActionListener>(); |
78 |
|
|
79 |
/** |
/** |
92 |
public TranslationEditJPanel(String question, Translation trans, |
public TranslationEditJPanel(String question, Translation trans, |
93 |
List<String> languages_) { |
List<String> languages_) { |
94 |
super(new BorderLayout()); |
super(new BorderLayout()); |
95 |
|
|
96 |
|
SwingUtil.setMinimumWidth(this, 400); |
97 |
|
|
98 |
if (trans == null) |
if (trans == null) |
99 |
trans = new Translation(); |
trans = new Translation(); |
109 |
.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
110 |
add(questionLable, BorderLayout.NORTH); |
add(questionLable, BorderLayout.NORTH); |
111 |
} |
} |
112 |
|
|
113 |
|
/** |
114 |
|
* Add listeners |
115 |
|
*/ |
116 |
|
} |
117 |
|
|
118 |
|
/** |
119 |
|
* Creates a {@link JPanel} that asks the user for the translation of a |
120 |
|
* String in several languages and additionally puts a {@link JLabel} with a |
121 |
|
* question at the {@link JPanel}'s first row. |
122 |
|
* |
123 |
|
* <br/> |
124 |
|
* This constructor also sets a TitledBorder with the given title. |
125 |
|
*/ |
126 |
|
public TranslationEditJPanel(Translation title, List<String> languages2, |
127 |
|
String borderTitle) { |
128 |
|
this(title, languages2); |
129 |
|
|
130 |
|
setBorder(BorderFactory.createTitledBorder(borderTitle)); |
131 |
} |
} |
132 |
|
|
133 |
private JPanel getTranslationGrid() { |
private JPanel getTranslationGrid() { |
149 |
translationGrid.add(langDesc); |
translationGrid.add(langDesc); |
150 |
translationGrid.add(langTextField); |
translationGrid.add(langTextField); |
151 |
|
|
152 |
langTextFields.add(langTextField); |
langTextFields.add(langTextField); |
153 |
} |
} |
154 |
|
|
155 |
// Lay out the panel. |
// Lay out the panel. |
170 |
return trans; |
return trans; |
171 |
} |
} |
172 |
|
|
173 |
|
/** |
174 |
|
* TODO Is never called?! |
175 |
|
*/ |
176 |
|
public void dispose() { |
177 |
|
for (TranslationJTextField f: langTextFields) { |
178 |
|
f.dispose(); |
179 |
|
} |
180 |
|
} |
181 |
|
|
182 |
public void addTranslationChangeListener(final ActionListener al) { |
public void addTranslationChangeListener(final ActionListener al) { |
183 |
final ActionListener actionListener = new ActionListener() { |
final ActionListener actionListener = new ActionListener() { |
184 |
|
|