deprecate legacy data system
This commit is contained in:
parent
de88d0d96c
commit
befdea277b
@ -4,7 +4,7 @@ import com.intellij.icons.AllIcons;
|
|||||||
import com.intellij.openapi.actionSystem.AnAction;
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -23,6 +23,6 @@ public class ReloadAction extends AnAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||||
DataStore.getInstance(e.getProject()).reloadFromDisk();
|
LegacyDataStore.getInstance(e.getProject()).reloadFromDisk();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ import com.intellij.ui.components.JBLabel;
|
|||||||
import com.intellij.ui.components.JBScrollPane;
|
import com.intellij.ui.components.JBScrollPane;
|
||||||
import com.intellij.ui.components.JBTextField;
|
import com.intellij.ui.components.JBTextField;
|
||||||
|
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.model.KeyedTranslation;
|
import de.marhali.easyi18n.model.KeyedTranslation;
|
||||||
import de.marhali.easyi18n.model.TranslationCreate;
|
import de.marhali.easyi18n.model.TranslationCreate;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class AddDialog {
|
|||||||
});
|
});
|
||||||
|
|
||||||
TranslationCreate creation = new TranslationCreate(new KeyedTranslation(keyTextField.getText(), messages));
|
TranslationCreate creation = new TranslationCreate(new KeyedTranslation(keyTextField.getText(), messages));
|
||||||
DataStore.getInstance(project).processUpdate(creation);
|
LegacyDataStore.getInstance(project).processUpdate(creation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DialogBuilder prepare() {
|
private DialogBuilder prepare() {
|
||||||
@ -75,7 +75,7 @@ public class AddDialog {
|
|||||||
|
|
||||||
JPanel valuePanel = new JPanel(new GridLayout(0, 1, 2, 2));
|
JPanel valuePanel = new JPanel(new GridLayout(0, 1, 2, 2));
|
||||||
valueTextFields = new HashMap<>();
|
valueTextFields = new HashMap<>();
|
||||||
for(String locale : DataStore.getInstance(project).getTranslations().getLocales()) {
|
for(String locale : LegacyDataStore.getInstance(project).getTranslations().getLocales()) {
|
||||||
JBLabel localeLabel = new JBLabel(locale);
|
JBLabel localeLabel = new JBLabel(locale);
|
||||||
JBTextField localeText = new JBTextField();
|
JBTextField localeText = new JBTextField();
|
||||||
localeLabel.setLabelFor(localeText);
|
localeLabel.setLabelFor(localeText);
|
||||||
|
@ -6,7 +6,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
|||||||
import com.intellij.ui.components.JBLabel;
|
import com.intellij.ui.components.JBLabel;
|
||||||
import com.intellij.ui.components.JBScrollPane;
|
import com.intellij.ui.components.JBScrollPane;
|
||||||
import com.intellij.ui.components.JBTextField;
|
import com.intellij.ui.components.JBTextField;
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.model.KeyedTranslation;
|
import de.marhali.easyi18n.model.KeyedTranslation;
|
||||||
import de.marhali.easyi18n.model.TranslationDelete;
|
import de.marhali.easyi18n.model.TranslationDelete;
|
||||||
import de.marhali.easyi18n.model.TranslationUpdate;
|
import de.marhali.easyi18n.model.TranslationUpdate;
|
||||||
@ -40,10 +40,10 @@ public class EditDialog {
|
|||||||
int code = prepare().show();
|
int code = prepare().show();
|
||||||
|
|
||||||
if(code == DialogWrapper.OK_EXIT_CODE) { // Edit
|
if(code == DialogWrapper.OK_EXIT_CODE) { // Edit
|
||||||
DataStore.getInstance(project).processUpdate(new TranslationUpdate(origin, getChanges()));
|
LegacyDataStore.getInstance(project).processUpdate(new TranslationUpdate(origin, getChanges()));
|
||||||
|
|
||||||
} else if(code == DeleteActionDescriptor.EXIT_CODE) { // Delete
|
} else if(code == DeleteActionDescriptor.EXIT_CODE) { // Delete
|
||||||
DataStore.getInstance(project).processUpdate(new TranslationDelete(origin));
|
LegacyDataStore.getInstance(project).processUpdate(new TranslationDelete(origin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class EditDialog {
|
|||||||
|
|
||||||
JPanel valuePanel = new JPanel(new GridLayout(0, 1, 2, 2));
|
JPanel valuePanel = new JPanel(new GridLayout(0, 1, 2, 2));
|
||||||
valueTextFields = new HashMap<>();
|
valueTextFields = new HashMap<>();
|
||||||
for(String locale : DataStore.getInstance(project).getTranslations().getLocales()) {
|
for(String locale : LegacyDataStore.getInstance(project).getTranslations().getLocales()) {
|
||||||
JBLabel localeLabel = new JBLabel(locale);
|
JBLabel localeLabel = new JBLabel(locale);
|
||||||
JBTextField localeText = new JBTextField(this.origin.getTranslations().get(locale));
|
JBTextField localeText = new JBTextField(this.origin.getTranslations().get(locale));
|
||||||
localeLabel.setLabelFor(localeText);
|
localeLabel.setLabelFor(localeText);
|
||||||
|
@ -5,7 +5,7 @@ import com.intellij.lang.annotation.HighlightSeverity;
|
|||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
|
||||||
import de.marhali.easyi18n.model.LocalizedNode;
|
import de.marhali.easyi18n.model.LocalizedNode;
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.service.SettingsService;
|
import de.marhali.easyi18n.service.SettingsService;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -39,7 +39,7 @@ public class KeyAnnotator {
|
|||||||
searchKey = searchKey.substring(1);
|
searchKey = searchKey.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalizedNode node = DataStore.getInstance(project).getTranslations().getNode(searchKey);
|
LocalizedNode node = LegacyDataStore.getInstance(project).getTranslations().getNode(searchKey);
|
||||||
|
|
||||||
if(node == null) { // Unknown translation. Just ignore it
|
if(node == null) { // Unknown translation. Just ignore it
|
||||||
return;
|
return;
|
||||||
|
@ -29,7 +29,7 @@ public class KeyCompletionProvider extends CompletionProvider<CompletionParamete
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataStore store = DataStore.getInstance(project);
|
LegacyDataStore store = LegacyDataStore.getInstance(project);
|
||||||
String previewLocale = SettingsService.getInstance(project).getState().getPreviewLocale();
|
String previewLocale = SettingsService.getInstance(project).getState().getPreviewLocale();
|
||||||
String pathPrefix = SettingsService.getInstance(project).getState().getPathPrefix();
|
String pathPrefix = SettingsService.getInstance(project).getState().getPathPrefix();
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import de.marhali.easyi18n.dialog.AddDialog;
|
|||||||
import de.marhali.easyi18n.dialog.EditDialog;
|
import de.marhali.easyi18n.dialog.EditDialog;
|
||||||
import de.marhali.easyi18n.model.KeyedTranslation;
|
import de.marhali.easyi18n.model.KeyedTranslation;
|
||||||
import de.marhali.easyi18n.model.LocalizedNode;
|
import de.marhali.easyi18n.model.LocalizedNode;
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -52,7 +52,7 @@ public class KeyReference extends PsiReferenceBase<PsiElement> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void navigate(boolean requestFocus) {
|
public void navigate(boolean requestFocus) {
|
||||||
LocalizedNode node = DataStore.getInstance(getProject()).getTranslations().getNode(getKey());
|
LocalizedNode node = LegacyDataStore.getInstance(getProject()).getTranslations().getNode(getKey());
|
||||||
|
|
||||||
if(node != null) {
|
if(node != null) {
|
||||||
new EditDialog(getProject(), new KeyedTranslation(getKey(), node.getValue())).showAndHandle();
|
new EditDialog(getProject(), new KeyedTranslation(getKey(), node.getValue())).showAndHandle();
|
||||||
|
@ -5,7 +5,7 @@ import com.intellij.psi.*;
|
|||||||
import com.intellij.util.ProcessingContext;
|
import com.intellij.util.ProcessingContext;
|
||||||
|
|
||||||
import de.marhali.easyi18n.editor.KeyReference;
|
import de.marhali.easyi18n.editor.KeyReference;
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.service.SettingsService;
|
import de.marhali.easyi18n.service.SettingsService;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -38,7 +38,7 @@ public class GenericKeyReferenceContributor extends PsiReferenceContributor {
|
|||||||
return PsiReference.EMPTY_ARRAY;
|
return PsiReference.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DataStore.getInstance(element.getProject()).getTranslations().getNode(value) == null) {
|
if(LegacyDataStore.getInstance(element.getProject()).getTranslations().getNode(value) == null) {
|
||||||
if(!KeyReference.isReferencable(value)) { // Creation policy
|
if(!KeyReference.isReferencable(value)) { // Creation policy
|
||||||
return PsiReference.EMPTY_ARRAY;
|
return PsiReference.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.intellij.psi.*;
|
|||||||
import com.intellij.util.ProcessingContext;
|
import com.intellij.util.ProcessingContext;
|
||||||
|
|
||||||
import de.marhali.easyi18n.editor.KeyReference;
|
import de.marhali.easyi18n.editor.KeyReference;
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.service.SettingsService;
|
import de.marhali.easyi18n.service.SettingsService;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -45,7 +45,7 @@ public class KotlinKeyReferenceContributor extends PsiReferenceContributor {
|
|||||||
return PsiReference.EMPTY_ARRAY;
|
return PsiReference.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DataStore.getInstance(element.getProject()).getTranslations().getNode(value) == null) {
|
if(LegacyDataStore.getInstance(element.getProject()).getTranslations().getNode(value) == null) {
|
||||||
return PsiReference.EMPTY_ARRAY;
|
return PsiReference.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Interface to communicate data changes between data store and ui components.
|
* Interface to communicate data changes between data store and ui components.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface DataSynchronizer {
|
public interface DataSynchronizer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||||||
* Translated messages for a dedicated key.
|
* Translated messages for a dedicated key.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
|
@Deprecated // Might be deprecated
|
||||||
public class KeyedTranslation {
|
public class KeyedTranslation {
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
@ -11,6 +11,7 @@ import java.util.*;
|
|||||||
* Represents structured tree view for translated messages.
|
* Represents structured tree view for translated messages.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class LocalizedNode {
|
public class LocalizedNode {
|
||||||
|
|
||||||
public static final String ROOT_KEY = "root";
|
public static final String ROOT_KEY = "root";
|
||||||
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
* Represents translation state instance. IO operations will be based on this file.
|
* Represents translation state instance. IO operations will be based on this file.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class Translations {
|
public class Translations {
|
||||||
|
|
||||||
public static Translations empty() {
|
public static Translations empty() {
|
||||||
|
@ -27,9 +27,10 @@ import java.util.function.Consumer;
|
|||||||
* Factory service to manage localized messages for multiple projects at once.
|
* Factory service to manage localized messages for multiple projects at once.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
public class DataStore {
|
@Deprecated
|
||||||
|
public class LegacyDataStore {
|
||||||
|
|
||||||
private static final Map<Project, DataStore> INSTANCES = new WeakHashMap<>();
|
private static final Map<Project, LegacyDataStore> INSTANCES = new WeakHashMap<>();
|
||||||
|
|
||||||
private final Project project;
|
private final Project project;
|
||||||
private final List<DataSynchronizer> synchronizer;
|
private final List<DataSynchronizer> synchronizer;
|
||||||
@ -37,18 +38,18 @@ public class DataStore {
|
|||||||
private Translations translations;
|
private Translations translations;
|
||||||
private String searchQuery;
|
private String searchQuery;
|
||||||
|
|
||||||
public static DataStore getInstance(@NotNull Project project) {
|
public static LegacyDataStore getInstance(@NotNull Project project) {
|
||||||
DataStore store = INSTANCES.get(project);
|
LegacyDataStore store = INSTANCES.get(project);
|
||||||
|
|
||||||
if(store == null) {
|
if(store == null) {
|
||||||
store = new DataStore(project);
|
store = new LegacyDataStore(project);
|
||||||
INSTANCES.put(project, store);
|
INSTANCES.put(project, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataStore(@NotNull Project project) {
|
private LegacyDataStore(@NotNull Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.synchronizer = new ArrayList<>();
|
this.synchronizer = new ArrayList<>();
|
||||||
this.translations = Translations.empty();
|
this.translations = Translations.empty();
|
@ -4,7 +4,7 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.ui.components.JBScrollPane;
|
import com.intellij.ui.components.JBScrollPane;
|
||||||
import com.intellij.ui.table.JBTable;
|
import com.intellij.ui.table.JBTable;
|
||||||
|
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.model.LocalizedNode;
|
import de.marhali.easyi18n.model.LocalizedNode;
|
||||||
import de.marhali.easyi18n.model.DataSynchronizer;
|
import de.marhali.easyi18n.model.DataSynchronizer;
|
||||||
import de.marhali.easyi18n.model.Translations;
|
import de.marhali.easyi18n.model.Translations;
|
||||||
@ -54,7 +54,7 @@ public class TableView implements DataSynchronizer {
|
|||||||
|
|
||||||
if(row >= 0) {
|
if(row >= 0) {
|
||||||
String fullPath = String.valueOf(table.getValueAt(row, 0));
|
String fullPath = String.valueOf(table.getValueAt(row, 0));
|
||||||
LocalizedNode node = DataStore.getInstance(project).getTranslations().getNode(fullPath);
|
LocalizedNode node = LegacyDataStore.getInstance(project).getTranslations().getNode(fullPath);
|
||||||
|
|
||||||
if(node != null) {
|
if(node != null) {
|
||||||
new EditDialog(project, new KeyedTranslation(fullPath, node.getValue())).showAndHandle();
|
new EditDialog(project, new KeyedTranslation(fullPath, node.getValue())).showAndHandle();
|
||||||
@ -67,7 +67,7 @@ public class TableView implements DataSynchronizer {
|
|||||||
for (int selectedRow : table.getSelectedRows()) {
|
for (int selectedRow : table.getSelectedRows()) {
|
||||||
String fullPath = String.valueOf(table.getValueAt(selectedRow, 0));
|
String fullPath = String.valueOf(table.getValueAt(selectedRow, 0));
|
||||||
|
|
||||||
DataStore.getInstance(project).processUpdate(
|
LegacyDataStore.getInstance(project).processUpdate(
|
||||||
new TranslationDelete(new KeyedTranslation(fullPath, null)));
|
new TranslationDelete(new KeyedTranslation(fullPath, null)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -78,7 +78,7 @@ public class TableView implements DataSynchronizer {
|
|||||||
@Nullable String searchQuery, @Nullable String scrollTo) {
|
@Nullable String searchQuery, @Nullable String scrollTo) {
|
||||||
|
|
||||||
table.setModel(new TableModelTranslator(translations, searchQuery, update ->
|
table.setModel(new TableModelTranslator(translations, searchQuery, update ->
|
||||||
DataStore.getInstance(project).processUpdate(update)));
|
LegacyDataStore.getInstance(project).processUpdate(update)));
|
||||||
|
|
||||||
if(scrollTo != null) {
|
if(scrollTo != null) {
|
||||||
int row = -1;
|
int row = -1;
|
||||||
|
@ -8,7 +8,7 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.ui.components.JBScrollPane;
|
import com.intellij.ui.components.JBScrollPane;
|
||||||
import com.intellij.ui.treeStructure.Tree;
|
import com.intellij.ui.treeStructure.Tree;
|
||||||
|
|
||||||
import de.marhali.easyi18n.service.DataStore;
|
import de.marhali.easyi18n.service.LegacyDataStore;
|
||||||
import de.marhali.easyi18n.model.LocalizedNode;
|
import de.marhali.easyi18n.model.LocalizedNode;
|
||||||
import de.marhali.easyi18n.model.DataSynchronizer;
|
import de.marhali.easyi18n.model.DataSynchronizer;
|
||||||
import de.marhali.easyi18n.model.Translations;
|
import de.marhali.easyi18n.model.Translations;
|
||||||
@ -100,7 +100,7 @@ public class TreeView implements DataSynchronizer {
|
|||||||
|
|
||||||
if(node.getUserObject() instanceof PresentationData) {
|
if(node.getUserObject() instanceof PresentationData) {
|
||||||
String fullPath = TreeUtil.getFullPath(path);
|
String fullPath = TreeUtil.getFullPath(path);
|
||||||
LocalizedNode localizedNode = DataStore.getInstance(project).getTranslations().getNode(fullPath);
|
LocalizedNode localizedNode = LegacyDataStore.getInstance(project).getTranslations().getNode(fullPath);
|
||||||
|
|
||||||
if(localizedNode != null) {
|
if(localizedNode != null) {
|
||||||
new EditDialog(project,new KeyedTranslation(fullPath, localizedNode.getValue())).showAndHandle();
|
new EditDialog(project,new KeyedTranslation(fullPath, localizedNode.getValue())).showAndHandle();
|
||||||
@ -120,7 +120,7 @@ public class TreeView implements DataSynchronizer {
|
|||||||
for (TreePath path : tree.getSelectionPaths()) {
|
for (TreePath path : tree.getSelectionPaths()) {
|
||||||
String fullPath = TreeUtil.getFullPath(path);
|
String fullPath = TreeUtil.getFullPath(path);
|
||||||
|
|
||||||
DataStore.getInstance(project).processUpdate(
|
LegacyDataStore.getInstance(project).processUpdate(
|
||||||
new TranslationDelete(new KeyedTranslation(fullPath, null)));
|
new TranslationDelete(new KeyedTranslation(fullPath, null)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||||||
* Utility tool to support the translations instance
|
* Utility tool to support the translations instance
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
|
@Deprecated // SectionUtil
|
||||||
public class TranslationsUtil {
|
public class TranslationsUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<depends optional="true" config-file="de.marhali.easyi18n-kotlin.xml">org.jetbrains.kotlin</depends>
|
<depends optional="true" config-file="de.marhali.easyi18n-kotlin.xml">org.jetbrains.kotlin</depends>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<toolWindow id="Easy I18n" anchor="bottom" factoryClass="de.marhali.easyi18n.TranslatorToolWindowFactory" />
|
<toolWindow id="Easy I18n" anchor="bottom" factoryClass="de.marhali.easyi18n.service.TranslatorToolWindowFactory" />
|
||||||
<projectService serviceImplementation="de.marhali.easyi18n.service.SettingsService" />
|
<projectService serviceImplementation="de.marhali.easyi18n.service.SettingsService" />
|
||||||
|
|
||||||
<completion.contributor language="any"
|
<completion.contributor language="any"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user