rename prefix to path-prefix
This commit is contained in:
parent
e7479b17b9
commit
3f09556d1d
@ -26,8 +26,8 @@ public class SettingsDialog {
|
||||
|
||||
private TextFieldWithBrowseButton pathText;
|
||||
private JBTextField filePatternText;
|
||||
private JBTextField previewText;
|
||||
private JBTextField prefixText;
|
||||
private JBTextField previewLocaleText;
|
||||
private JBTextField pathPrefixText;
|
||||
private JBCheckBox codeAssistanceCheckbox;
|
||||
|
||||
public SettingsDialog(Project project) {
|
||||
@ -38,24 +38,25 @@ public class SettingsDialog {
|
||||
String localesPath = SettingsService.getInstance(project).getState().getLocalesPath();
|
||||
String filePattern = SettingsService.getInstance(project).getState().getFilePattern();
|
||||
String previewLocale = SettingsService.getInstance(project).getState().getPreviewLocale();
|
||||
String prefixLocale = SettingsService.getInstance(project).getState().getPrefix();
|
||||
String pathPrefix = SettingsService.getInstance(project).getState().getPathPrefix();
|
||||
boolean codeAssistance = SettingsService.getInstance(project).getState().isCodeAssistance();
|
||||
|
||||
if(prepare(localesPath, filePattern, previewLocale, prefixLocale, codeAssistance).show() == DialogWrapper.OK_EXIT_CODE) { // Save changes
|
||||
if(prepare(localesPath, filePattern, previewLocale, pathPrefix, codeAssistance).show() == DialogWrapper.OK_EXIT_CODE) { // Save changes
|
||||
SettingsService.getInstance(project).getState().setLocalesPath(pathText.getText());
|
||||
SettingsService.getInstance(project).getState().setFilePattern(filePatternText.getText());
|
||||
SettingsService.getInstance(project).getState().setPreviewLocale(previewText.getText());
|
||||
SettingsService.getInstance(project).getState().setPreviewLocale(previewLocaleText.getText());
|
||||
SettingsService.getInstance(project).getState().setCodeAssistance(codeAssistanceCheckbox.isSelected());
|
||||
SettingsService.getInstance(project).getState().setPrefix(prefixText.getText());
|
||||
SettingsService.getInstance(project).getState().setPathPrefix(pathPrefixText.getText());
|
||||
|
||||
// Reload instance
|
||||
DataStore.getInstance(project).reloadFromDisk();
|
||||
}
|
||||
}
|
||||
|
||||
private DialogBuilder prepare(String localesPath, String filePattern, String previewLocale, String prefixLocale, boolean codeAssistance) {
|
||||
private DialogBuilder prepare(String localesPath, String filePattern, String previewLocale, String pathPrefix, boolean codeAssistance) {
|
||||
JPanel rootPanel = new JPanel(new GridLayout(0, 1, 2, 2));
|
||||
|
||||
/* path */
|
||||
JBLabel pathLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.text"));
|
||||
pathText = new TextFieldWithBrowseButton(new JTextField(localesPath));
|
||||
|
||||
@ -66,28 +67,32 @@ public class SettingsDialog {
|
||||
rootPanel.add(pathLabel);
|
||||
rootPanel.add(pathText);
|
||||
|
||||
/* file pattern */
|
||||
JBLabel filePatternLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.file-pattern"));
|
||||
filePatternText = new JBTextField(filePattern);
|
||||
|
||||
rootPanel.add(filePatternLabel);
|
||||
rootPanel.add(filePatternText);
|
||||
|
||||
/* preview locale */
|
||||
JBLabel previewLocaleLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.preview"));
|
||||
previewLocaleText = new JBTextField(previewLocale);
|
||||
previewLocaleLabel.setLabelFor(previewLocaleText);
|
||||
|
||||
JBLabel previewLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.preview"));
|
||||
previewText = new JBTextField(previewLocale);
|
||||
previewLabel.setLabelFor(previewText);
|
||||
rootPanel.add(previewLocaleLabel);
|
||||
rootPanel.add(previewLocaleText);
|
||||
|
||||
rootPanel.add(previewLabel);
|
||||
rootPanel.add(previewText);
|
||||
/* path prefix */
|
||||
JBLabel pathPrefixLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.prefix"));
|
||||
pathPrefixText = new JBTextField(pathPrefix);
|
||||
|
||||
rootPanel.add(pathPrefixLabel);
|
||||
rootPanel.add(pathPrefixText);
|
||||
|
||||
/* code assistance */
|
||||
codeAssistanceCheckbox = new JBCheckBox(ResourceBundle.getBundle("messages").getString("settings.editor.assistance"));
|
||||
codeAssistanceCheckbox.setSelected(codeAssistance);
|
||||
|
||||
JBLabel prefixLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.prefix"));
|
||||
prefixText = new JBTextField(prefixLocale);
|
||||
rootPanel.add(prefixLabel);
|
||||
rootPanel.add(prefixText);
|
||||
|
||||
rootPanel.add(codeAssistanceCheckbox);
|
||||
|
||||
DialogBuilder builder = new DialogBuilder();
|
||||
|
@ -28,13 +28,13 @@ public class KeyCompletionProvider extends CompletionProvider<CompletionParamete
|
||||
}
|
||||
|
||||
String previewLocale = SettingsService.getInstance(project).getState().getPreviewLocale();
|
||||
String prefix = SettingsService.getInstance(project).getState().getPrefix();
|
||||
String pathPrefix = SettingsService.getInstance(project).getState().getPathPrefix();
|
||||
|
||||
String path = result.getPrefixMatcher().getPrefix();
|
||||
|
||||
DataStore instance = DataStore.getInstance(project);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
collect(map, instance.getTranslations().getNodes(), null, previewLocale, prefix);
|
||||
collect(map, instance.getTranslations().getNodes(), null, previewLocale, pathPrefix);
|
||||
Map<String, String> containedPath = new HashMap<>();
|
||||
StringBuilder prefixedKey = new StringBuilder();
|
||||
int maxPrefixLookUpLength = 5;
|
||||
@ -55,16 +55,16 @@ public class KeyCompletionProvider extends CompletionProvider<CompletionParamete
|
||||
});
|
||||
}
|
||||
|
||||
private void collect(Map<String, String> map, LocalizedNode node, String path, String locale, String prefix) {
|
||||
private void collect(Map<String, String> map, LocalizedNode node, String path, String locale, String pathPrefix) {
|
||||
if (node.isLeaf() && !node.getKey().equals(LocalizedNode.ROOT_KEY)) {
|
||||
String value = node.getValue().get(locale);
|
||||
map.put(path, value);
|
||||
if (prefix != null && !prefix.isEmpty()) {
|
||||
map.put(prefix + "." + path, value);
|
||||
if (pathPrefix != null && !pathPrefix.isEmpty()) {
|
||||
map.put(pathPrefix + "." + path, value);
|
||||
}
|
||||
} else {
|
||||
for (LocalizedNode child : node.getChildren()) {
|
||||
collect(map, child, path == null || path.isEmpty() ? child.getKey() : path + "." + child.getKey(), locale, prefix);
|
||||
collect(map, child, path == null || path.isEmpty() ? child.getKey() : path + "." + child.getKey(), locale, pathPrefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package de.marhali.easyi18n.editor.generic;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionContributor;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.patterns.*;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.xml.*;
|
||||
|
@ -16,7 +16,7 @@ public class SettingsState {
|
||||
private String localesPath;
|
||||
private String filePattern;
|
||||
private String previewLocale;
|
||||
private String prefix;
|
||||
private String pathPrefix;
|
||||
private Boolean codeAssistance;
|
||||
|
||||
public SettingsState() {}
|
||||
@ -53,11 +53,11 @@ public class SettingsState {
|
||||
this.codeAssistance = codeAssistance;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
public void setPathPrefix(String pathPrefix) {
|
||||
this.pathPrefix = pathPrefix;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
public String getPathPrefix() {
|
||||
return pathPrefix;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import de.marhali.easyi18n.model.SettingsState;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -14,6 +14,6 @@ translation.locales=Locales
|
||||
settings.path.title=Locales Directory
|
||||
settings.path.text=Locales directory
|
||||
settings.path.file-pattern=Translation file pattern
|
||||
settings.path.prefix=Path prefix
|
||||
settings.preview=Preview locale
|
||||
settings.editor.assistance=I18n key completion and annotation inside editor
|
||||
settings.path.prefix=Prefix
|
||||
settings.editor.assistance=I18n key completion and annotation inside editor
|
Loading…
x
Reference in New Issue
Block a user