All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.vergne.translation.editor.content.SimpleEntryComponent Maven / Gradle / Ivy

There is a newer version: 2.0
Show newest version
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; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy