From 6887a4e416c03a015a768753a000c5afd167face Mon Sep 17 00:00:00 2001 From: marhali Date: Mon, 11 Apr 2022 22:07:45 +0200 Subject: [PATCH] remove description for now --- .../easyi18n/dialog/TranslationDialog.java | 6 +- .../easyi18n/model/TranslationValue.java | 112 ++++-------------- 2 files changed, 25 insertions(+), 93 deletions(-) diff --git a/src/main/java/de/marhali/easyi18n/dialog/TranslationDialog.java b/src/main/java/de/marhali/easyi18n/dialog/TranslationDialog.java index d60c74f..5d69681 100644 --- a/src/main/java/de/marhali/easyi18n/dialog/TranslationDialog.java +++ b/src/main/java/de/marhali/easyi18n/dialog/TranslationDialog.java @@ -37,7 +37,6 @@ abstract class TranslationDialog { protected final @NotNull Translation origin; protected final JTextField keyField; - protected final JTextField descriptionField; protected final Map localeValueFields; /** @@ -55,7 +54,6 @@ abstract class TranslationDialog { TranslationValue value = origin.getValue(); this.keyField = new JBTextField(converter.toString(origin.getKey())); - this.descriptionField = new JBTextField(value != null ? value.getDescription() : null); this.localeValueFields = new HashMap<>(); for(String locale : InstanceManager.get(project).store().getData().getLocales()) { @@ -92,9 +90,8 @@ abstract class TranslationDialog { */ protected @NotNull Translation getState() { KeyPath key = converter.fromString(keyField.getText()); - TranslationValue value = new TranslationValue(); - value.setDescription(descriptionField.getText()); + TranslationValue value = new TranslationValue(); for(Map.Entry entry : localeValueFields.entrySet()) { value.put(entry.getKey(), entry.getValue().getText()); @@ -106,7 +103,6 @@ abstract class TranslationDialog { private DialogBuilder createDialog() { JPanel panel = FormBuilder.createFormBuilder() .addLabeledComponent(bundle.getString("translation.key"), keyField, true) - .addLabeledComponent(bundle.getString("translation.description"), descriptionField, 6, true) .addComponent(createLocalesPanel(), 12) .getPanel(); diff --git a/src/main/java/de/marhali/easyi18n/model/TranslationValue.java b/src/main/java/de/marhali/easyi18n/model/TranslationValue.java index 6abd17b..6ca10bd 100644 --- a/src/main/java/de/marhali/easyi18n/model/TranslationValue.java +++ b/src/main/java/de/marhali/easyi18n/model/TranslationValue.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Set; /** * Represents the set values behind a specific translation. @@ -13,122 +14,57 @@ import java.util.Map; */ public class TranslationValue { - private @Nullable String description; - private @NotNull Map values; - private @Nullable Object misc; - - public TranslationValue(@Nullable String description, @NotNull Map values, @Nullable Object misc) { - this.description = description; - this.values = values; - this.misc = misc; - } - - public TranslationValue(@NotNull Map values) { - this(null, values, null); - } - - public TranslationValue(@NotNull String locale, @NotNull String value) { - this(new HashMap<>(Map.of(locale, value))); - } + private @NotNull Map localeValues; public TranslationValue() { - this(null, new HashMap<>(), null); + this.localeValues = new HashMap<>(); } - /** - * Retrieve additional description for this translation - * @return Description - */ - public @Nullable String getDescription() { - return description; + public TranslationValue(@NotNull String locale, @NotNull String content) { + this(); + localeValues.put(locale, content); } - /** - * Override or set description for this translation - * @param description Description - */ - public void setDescription(@Nullable String description) { - this.description = description; + public Set> getEntries() { + return this.localeValues.entrySet(); } - /** - * Set locale specific values. - * @param values New values - */ - public void setValues(@NotNull Map values) { - this.values = values; + public Collection getLocaleContents() { + return this.localeValues.values(); } - public @NotNull Map getValues() { - return values; + public void setLocaleValues(@NotNull Map localeValues) { + 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) { - return values.get(locale); + return this.localeValues.get(locale); } - public boolean containsLocale(@Nullable String locale) { - return values.containsKey(locale); + public void put(@NotNull String locale, @NotNull String content) { + this.localeValues.put(locale, content); } - public @NotNull Collection getLocaleValues() { - return values.values(); + public void remove(@NotNull String locale) { + this.localeValues.remove(locale); + } + + public boolean containsLocale(@NotNull String locale) { + return this.localeValues.containsKey(locale); } public int size() { - return values.size(); + return this.localeValues.size(); } public void clear() { - description = null; - 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; + this.localeValues.clear(); } @Override public String toString() { return "TranslationValue{" + - "description='" + description + '\'' + - ", values=" + values + - ", misc=" + misc + + "localeValues=" + localeValues + '}'; } }