update to new data structure
This commit is contained in:
parent
da7f5f5663
commit
8b375cb201
@ -9,14 +9,18 @@ import com.intellij.ui.components.JBScrollPane;
|
|||||||
import com.intellij.ui.treeStructure.Tree;
|
import com.intellij.ui.treeStructure.Tree;
|
||||||
|
|
||||||
import de.marhali.easyi18n.InstanceManager;
|
import de.marhali.easyi18n.InstanceManager;
|
||||||
|
import de.marhali.easyi18n.dialog.EditDialog;
|
||||||
import de.marhali.easyi18n.listener.ReturnKeyListener;
|
import de.marhali.easyi18n.listener.ReturnKeyListener;
|
||||||
import de.marhali.easyi18n.model.*;
|
import de.marhali.easyi18n.model.TranslationData;
|
||||||
|
import de.marhali.easyi18n.model.action.TranslationDelete;
|
||||||
import de.marhali.easyi18n.model.bus.BusListener;
|
import de.marhali.easyi18n.model.bus.BusListener;
|
||||||
import de.marhali.easyi18n.action.treeview.CollapseTreeViewAction;
|
import de.marhali.easyi18n.action.treeview.CollapseTreeViewAction;
|
||||||
import de.marhali.easyi18n.action.treeview.ExpandTreeViewAction;
|
import de.marhali.easyi18n.action.treeview.ExpandTreeViewAction;
|
||||||
import de.marhali.easyi18n.dialog.EditDialog;
|
|
||||||
import de.marhali.easyi18n.listener.DeleteKeyListener;
|
import de.marhali.easyi18n.listener.DeleteKeyListener;
|
||||||
import de.marhali.easyi18n.listener.PopupClickListener;
|
import de.marhali.easyi18n.listener.PopupClickListener;
|
||||||
|
import de.marhali.easyi18n.model.KeyPath;
|
||||||
|
import de.marhali.easyi18n.model.Translation;
|
||||||
|
import de.marhali.easyi18n.model.TranslationValue;
|
||||||
import de.marhali.easyi18n.renderer.TreeRenderer;
|
import de.marhali.easyi18n.renderer.TreeRenderer;
|
||||||
import de.marhali.easyi18n.settings.ProjectSettingsService;
|
import de.marhali.easyi18n.settings.ProjectSettingsService;
|
||||||
import de.marhali.easyi18n.tabs.mapper.TreeModelMapper;
|
import de.marhali.easyi18n.tabs.mapper.TreeModelMapper;
|
||||||
@ -127,13 +131,13 @@ public class TreeView implements BusListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeyPath fullPath = TreeUtil.getFullPath(path);
|
KeyPath fullPath = TreeUtil.getFullPath(path);
|
||||||
Translation translation = InstanceManager.get(project).store().getData().getTranslation(fullPath);
|
TranslationValue value = InstanceManager.get(project).store().getData().getTranslation(fullPath);
|
||||||
|
|
||||||
if (translation == null) {
|
if (value == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new EditDialog(project, new KeyedTranslation(fullPath, translation)).showAndHandle();
|
new EditDialog(project, new Translation(fullPath, value)).showAndHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteSelectedNodes() {
|
private void deleteSelectedNodes() {
|
||||||
@ -147,7 +151,7 @@ public class TreeView implements BusListener {
|
|||||||
KeyPath fullPath = TreeUtil.getFullPath(path);
|
KeyPath fullPath = TreeUtil.getFullPath(path);
|
||||||
|
|
||||||
InstanceManager.get(project).processUpdate(
|
InstanceManager.get(project).processUpdate(
|
||||||
new TranslationDelete(new KeyedTranslation(fullPath, null))
|
new TranslationDelete(new Translation(fullPath, null))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,14 @@ package de.marhali.easyi18n.tabs.mapper;
|
|||||||
import com.intellij.ide.projectView.PresentationData;
|
import com.intellij.ide.projectView.PresentationData;
|
||||||
import com.intellij.ui.JBColor;
|
import com.intellij.ui.JBColor;
|
||||||
|
|
||||||
import de.marhali.easyi18n.model.*;
|
import de.marhali.easyi18n.model.TranslationData;
|
||||||
|
import de.marhali.easyi18n.model.TranslationNode;
|
||||||
import de.marhali.easyi18n.model.bus.FilterMissingTranslationsListener;
|
import de.marhali.easyi18n.model.bus.FilterMissingTranslationsListener;
|
||||||
import de.marhali.easyi18n.model.bus.SearchQueryListener;
|
import de.marhali.easyi18n.model.bus.SearchQueryListener;
|
||||||
|
import de.marhali.easyi18n.model.KeyPath;
|
||||||
|
import de.marhali.easyi18n.model.TranslationValue;
|
||||||
import de.marhali.easyi18n.settings.ProjectSettings;
|
import de.marhali.easyi18n.settings.ProjectSettings;
|
||||||
|
import de.marhali.easyi18n.util.KeyPathConverter;
|
||||||
import de.marhali.easyi18n.util.UiUtil;
|
import de.marhali.easyi18n.util.UiUtil;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -31,7 +35,7 @@ public class TreeModelMapper extends DefaultTreeModel implements SearchQueryList
|
|||||||
super(null);
|
super(null);
|
||||||
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.converter = new KeyPathConverter(state.isNestedKeys());
|
this.converter = new KeyPathConverter(state);
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
|
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
|
||||||
@ -53,15 +57,15 @@ public class TreeModelMapper extends DefaultTreeModel implements SearchQueryList
|
|||||||
query = query.toLowerCase();
|
query = query.toLowerCase();
|
||||||
|
|
||||||
for(KeyPath currentKey : this.data.getFullKeys()) {
|
for(KeyPath currentKey : this.data.getFullKeys()) {
|
||||||
Translation translation = this.data.getTranslation(currentKey);
|
TranslationValue translation = this.data.getTranslation(currentKey);
|
||||||
String loweredKey = this.converter.concat(currentKey).toLowerCase();
|
String loweredKey = this.converter.toString(currentKey).toLowerCase();
|
||||||
|
|
||||||
if(query.contains(loweredKey) || loweredKey.contains(query)) {
|
if(query.contains(loweredKey) || loweredKey.contains(query)) {
|
||||||
shadow.setTranslation(currentKey, translation);
|
shadow.setTranslation(currentKey, translation);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String currentContent : translation.values()) {
|
for(String currentContent : translation.getLocaleContents()) {
|
||||||
if(currentContent.toLowerCase().contains(query)) {
|
if(currentContent.toLowerCase().contains(query)) {
|
||||||
shadow.setTranslation(currentKey, translation);
|
shadow.setTranslation(currentKey, translation);
|
||||||
break;
|
break;
|
||||||
@ -85,9 +89,9 @@ public class TreeModelMapper extends DefaultTreeModel implements SearchQueryList
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(KeyPath currentKey : this.data.getFullKeys()) {
|
for(KeyPath currentKey : this.data.getFullKeys()) {
|
||||||
Translation translation = this.data.getTranslation(currentKey);
|
TranslationValue translation = this.data.getTranslation(currentKey);
|
||||||
|
|
||||||
if(translation.values().size() != this.data.getLocales().size()) {
|
if(translation.getLocaleContents().size() != this.data.getLocales().size()) {
|
||||||
shadow.setTranslation(currentKey, translation);
|
shadow.setTranslation(currentKey, translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +129,7 @@ public class TreeModelMapper extends DefaultTreeModel implements SearchQueryList
|
|||||||
} else {
|
} else {
|
||||||
String previewLocale = this.state.getPreviewLocale();
|
String previewLocale = this.state.getPreviewLocale();
|
||||||
String sub = "(" + previewLocale + ": " + childTranslationNode.getValue().get(previewLocale) + ")";
|
String sub = "(" + previewLocale + ": " + childTranslationNode.getValue().get(previewLocale) + ")";
|
||||||
String tooltip = UiUtil.generateHtmlTooltip(childTranslationNode.getValue());
|
String tooltip = UiUtil.generateHtmlTooltip(childTranslationNode.getValue().getEntries());
|
||||||
|
|
||||||
PresentationData data = new PresentationData(key, sub, null, null);
|
PresentationData data = new PresentationData(key, sub, null, null);
|
||||||
data.setTooltip(tooltip);
|
data.setTooltip(tooltip);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user