fr.vergne.translation.editor.content.SimpleEntryComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of translation-editor Show documentation
Show all versions of translation-editor Show documentation
Graphical Editor for translation projects.
package fr.vergne.translation.editor.content;
import java.awt.Component;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import org.apache.commons.lang3.StringUtils;
import fr.vergne.translation.TranslationEntry;
import fr.vergne.translation.TranslationMetadata;
import fr.vergne.translation.TranslationMetadata.Field;
import fr.vergne.translation.editor.content.EntryComponentFactory.EntryComponent;
@SuppressWarnings("serial")
public class SimpleEntryComponent> extends
JPanel implements EntryComponent {
private final TranslationArea translationArea;
public SimpleEntryComponent(Entry entry, Collection limits) {
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
TranslationMetadata metadata = entry.getMetadata();
List lines = new LinkedList<>();
for (Field> field : metadata) {
Object value = metadata.get(field);
lines.add(field + ": " + value);
}
String tooltip = "" + StringUtils.join(lines, "
") + "";
JTextArea original = new JTextArea(entry.getOriginalContent());
original.setEditable(false);
original.setToolTipText(tooltip);
add(original);
translationArea = new TranslationArea(entry, limits);
translationArea.setToolTipText(tooltip);
add(translationArea);
}
public SimpleEntryComponent(Entry entry) {
this(entry, Collections. emptyList());
}
@Override
public Component getTranslationComponent() {
return translationArea;
}
}