remove description for now

This commit is contained in:
marhali 2022-04-11 22:07:45 +02:00
parent c348ea7d78
commit 6887a4e416
2 changed files with 25 additions and 93 deletions

View File

@ -37,7 +37,6 @@ abstract class TranslationDialog {
protected final @NotNull Translation origin; protected final @NotNull Translation origin;
protected final JTextField keyField; protected final JTextField keyField;
protected final JTextField descriptionField;
protected final Map<String, JTextField> localeValueFields; protected final Map<String, JTextField> localeValueFields;
/** /**
@ -55,7 +54,6 @@ abstract class TranslationDialog {
TranslationValue value = origin.getValue(); TranslationValue value = origin.getValue();
this.keyField = new JBTextField(converter.toString(origin.getKey())); this.keyField = new JBTextField(converter.toString(origin.getKey()));
this.descriptionField = new JBTextField(value != null ? value.getDescription() : null);
this.localeValueFields = new HashMap<>(); this.localeValueFields = new HashMap<>();
for(String locale : InstanceManager.get(project).store().getData().getLocales()) { for(String locale : InstanceManager.get(project).store().getData().getLocales()) {
@ -92,9 +90,8 @@ abstract class TranslationDialog {
*/ */
protected @NotNull Translation getState() { protected @NotNull Translation getState() {
KeyPath key = converter.fromString(keyField.getText()); KeyPath key = converter.fromString(keyField.getText());
TranslationValue value = new TranslationValue();
value.setDescription(descriptionField.getText()); TranslationValue value = new TranslationValue();
for(Map.Entry<String, JTextField> entry : localeValueFields.entrySet()) { for(Map.Entry<String, JTextField> entry : localeValueFields.entrySet()) {
value.put(entry.getKey(), entry.getValue().getText()); value.put(entry.getKey(), entry.getValue().getText());
@ -106,7 +103,6 @@ abstract class TranslationDialog {
private DialogBuilder createDialog() { private DialogBuilder createDialog() {
JPanel panel = FormBuilder.createFormBuilder() JPanel panel = FormBuilder.createFormBuilder()
.addLabeledComponent(bundle.getString("translation.key"), keyField, true) .addLabeledComponent(bundle.getString("translation.key"), keyField, true)
.addLabeledComponent(bundle.getString("translation.description"), descriptionField, 6, true)
.addComponent(createLocalesPanel(), 12) .addComponent(createLocalesPanel(), 12)
.getPanel(); .getPanel();

View File

@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Represents the set values behind a specific translation. * Represents the set values behind a specific translation.
@ -13,122 +14,57 @@ import java.util.Map;
*/ */
public class TranslationValue { public class TranslationValue {
private @Nullable String description; private @NotNull Map<String, String> localeValues;
private @NotNull Map<String, String> values;
private @Nullable Object misc;
public TranslationValue(@Nullable String description, @NotNull Map<String, String> values, @Nullable Object misc) {
this.description = description;
this.values = values;
this.misc = misc;
}
public TranslationValue(@NotNull Map<String, String> values) {
this(null, values, null);
}
public TranslationValue(@NotNull String locale, @NotNull String value) {
this(new HashMap<>(Map.of(locale, value)));
}
public TranslationValue() { public TranslationValue() {
this(null, new HashMap<>(), null); this.localeValues = new HashMap<>();
} }
/** public TranslationValue(@NotNull String locale, @NotNull String content) {
* Retrieve additional description for this translation this();
* @return Description localeValues.put(locale, content);
*/
public @Nullable String getDescription() {
return description;
} }
/** public Set<Map.Entry<String, String>> getEntries() {
* Override or set description for this translation return this.localeValues.entrySet();
* @param description Description
*/
public void setDescription(@Nullable String description) {
this.description = description;
} }
/** public Collection<String> getLocaleContents() {
* Set locale specific values. return this.localeValues.values();
* @param values New values
*/
public void setValues(@NotNull Map<String, String> values) {
this.values = values;
} }
public @NotNull Map<String, String> getValues() { public void setLocaleValues(@NotNull Map<String, String> localeValues) {
return values; this.localeValues = localeValues;
} }
/**
* Overrides or sets a value for a specific locale.
* @param locale Locale type
* @param value New value
*/
public void put(@NotNull String locale, @Nullable String value) {
if(value == null) { // Delete operation
values.remove(locale);
} else {
values.put(locale, value);
}
}
public void remove(String locale) {
values.remove(locale);
}
/**
* Retrieves the associated value for a specific locale
* @param locale Locale type
* @return Value or null if missing
*/
public @Nullable String get(@NotNull String locale) { public @Nullable String get(@NotNull String locale) {
return values.get(locale); return this.localeValues.get(locale);
} }
public boolean containsLocale(@Nullable String locale) { public void put(@NotNull String locale, @NotNull String content) {
return values.containsKey(locale); this.localeValues.put(locale, content);
} }
public @NotNull Collection<String> getLocaleValues() { public void remove(@NotNull String locale) {
return values.values(); this.localeValues.remove(locale);
}
public boolean containsLocale(@NotNull String locale) {
return this.localeValues.containsKey(locale);
} }
public int size() { public int size() {
return values.size(); return this.localeValues.size();
} }
public void clear() { public void clear() {
description = null; this.localeValues.clear();
values.clear();
misc = null;
}
/**
* I18n support data
* @return Data
*/
public @Nullable Object getMisc() {
return misc;
}
/**
* Set or update I18n support data
* @param misc New Data
*/
public void setMisc(@Nullable Object misc) {
this.misc = misc;
} }
@Override @Override
public String toString() { public String toString() {
return "TranslationValue{" + return "TranslationValue{" +
"description='" + description + '\'' + "localeValues=" + localeValues +
", values=" + values +
", misc=" + misc +
'}'; '}';
} }
} }