parent
0b9d6c0369
commit
7762b0cacd
@ -8,6 +8,7 @@
|
|||||||
- I18n key nesting will now escape every delimiter within a section layer (can be inverted via option)
|
- I18n key nesting will now escape every delimiter within a section layer (can be inverted via option)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- Filter functionality for translations with missing values
|
||||||
- Full keyboard shortcut support inside tool-window
|
- Full keyboard shortcut support inside tool-window
|
||||||
- Support for dots within key nodes in YAML files
|
- Support for dots within key nodes in YAML files
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class DataBus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFocusKey(@Nullable KeyPath key) {
|
public void onFocusKey(@NotNull KeyPath key) {
|
||||||
listener.forEach(li -> li.onFocusKey(key));
|
listener.forEach(li -> li.onFocusKey(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +51,11 @@ public class DataBus {
|
|||||||
public void onSearchQuery(@Nullable String query) {
|
public void onSearchQuery(@Nullable String query) {
|
||||||
listener.forEach(li -> li.onSearchQuery(query));
|
listener.forEach(li -> li.onSearchQuery(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFilterMissingTranslations(boolean filter) {
|
||||||
|
listener.forEach(li -> li.onFilterMissingTranslations(filter));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package de.marhali.easyi18n.action;
|
||||||
|
|
||||||
|
import com.intellij.icons.AllIcons;
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import de.marhali.easyi18n.InstanceManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action which toggles translation filter on missing values.
|
||||||
|
* @author marhali
|
||||||
|
*/
|
||||||
|
public class FilterMissingTranslationsAction extends AnAction {
|
||||||
|
public FilterMissingTranslationsAction() {
|
||||||
|
super(ResourceBundle.getBundle("messages").getString("action.toggle-missing"),
|
||||||
|
null, AllIcons.General.ShowWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||||
|
Project project = Objects.requireNonNull(e.getProject());
|
||||||
|
boolean enable = e.getPresentation().getIcon() == AllIcons.General.ShowWarning;
|
||||||
|
e.getPresentation().setIcon(enable ? AllIcons.General.Warning : AllIcons.General.ShowWarning);
|
||||||
|
InstanceManager.get(project).bus().propagate().onFilterMissingTranslations(enable);
|
||||||
|
}
|
||||||
|
}
|
@ -5,4 +5,5 @@ package de.marhali.easyi18n.model.bus;
|
|||||||
* Every listener needs to be registered manually via {@link de.marhali.easyi18n.DataBus}.
|
* Every listener needs to be registered manually via {@link de.marhali.easyi18n.DataBus}.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
public interface BusListener extends UpdateDataListener, FocusKeyListener, SearchQueryListener {}
|
public interface BusListener extends UpdateDataListener, FocusKeyListener,
|
||||||
|
SearchQueryListener, FilterMissingTranslationsListener {}
|
@ -0,0 +1,13 @@
|
|||||||
|
package de.marhali.easyi18n.model.bus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single event listener.
|
||||||
|
* @author marhali
|
||||||
|
*/
|
||||||
|
public interface FilterMissingTranslationsListener {
|
||||||
|
/**
|
||||||
|
* Toggles filter of missing translations
|
||||||
|
* @param filter True if only translations with missing values should bw shown
|
||||||
|
*/
|
||||||
|
void onFilterMissingTranslations(boolean filter);
|
||||||
|
}
|
@ -46,6 +46,7 @@ public class TranslatorToolWindowFactory implements ToolWindowFactory, DumbAware
|
|||||||
// ToolWindow Actions (Can be used for every view)
|
// ToolWindow Actions (Can be used for every view)
|
||||||
List<AnAction> actions = new ArrayList<>();
|
List<AnAction> actions = new ArrayList<>();
|
||||||
actions.add(new AddAction());
|
actions.add(new AddAction());
|
||||||
|
actions.add(new FilterMissingTranslationsAction());
|
||||||
actions.add(new ReloadAction());
|
actions.add(new ReloadAction());
|
||||||
actions.add(new SettingsAction());
|
actions.add(new SettingsAction());
|
||||||
actions.add(new SearchAction((query) -> InstanceManager.get(project).bus().propagate().onSearchQuery(query)));
|
actions.add(new SearchAction((query) -> InstanceManager.get(project).bus().propagate().onSearchQuery(query)));
|
||||||
|
@ -107,6 +107,14 @@ public class TableView implements BusListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFilterMissingTranslations(boolean filter) {
|
||||||
|
if(this.currentMapper != null) {
|
||||||
|
this.currentMapper.onFilterMissingTranslations(filter);
|
||||||
|
this.table.updateUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public JPanel getRootPanel() {
|
public JPanel getRootPanel() {
|
||||||
return rootPanel;
|
return rootPanel;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,15 @@ public class TreeView implements BusListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFilterMissingTranslations(boolean filter) {
|
||||||
|
if (this.currentMapper != null) {
|
||||||
|
this.currentMapper.onFilterMissingTranslations(filter);
|
||||||
|
this.expandAll();
|
||||||
|
this.tree.updateUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showEditPopup(@Nullable TreePath path) {
|
private void showEditPopup(@Nullable TreePath path) {
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.marhali.easyi18n.tabs.mapper;
|
package de.marhali.easyi18n.tabs.mapper;
|
||||||
|
|
||||||
import de.marhali.easyi18n.model.*;
|
import de.marhali.easyi18n.model.*;
|
||||||
|
import de.marhali.easyi18n.model.bus.FilterMissingTranslationsListener;
|
||||||
import de.marhali.easyi18n.model.bus.SearchQueryListener;
|
import de.marhali.easyi18n.model.bus.SearchQueryListener;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nls;
|
import org.jetbrains.annotations.Nls;
|
||||||
@ -17,7 +18,7 @@ import java.util.function.Consumer;
|
|||||||
* Mapping {@link TranslationData} to {@link TableModel}.
|
* Mapping {@link TranslationData} to {@link TableModel}.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
public class TableModelMapper implements TableModel, SearchQueryListener {
|
public class TableModelMapper implements TableModel, SearchQueryListener, FilterMissingTranslationsListener {
|
||||||
|
|
||||||
private final @NotNull TranslationData data;
|
private final @NotNull TranslationData data;
|
||||||
private final @NotNull KeyPathConverter converter;
|
private final @NotNull KeyPathConverter converter;
|
||||||
@ -63,6 +64,24 @@ public class TableModelMapper implements TableModel, SearchQueryListener {
|
|||||||
this.fullKeys = matches;
|
this.fullKeys = matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFilterMissingTranslations(boolean filter) {
|
||||||
|
if(!filter) { // Reset
|
||||||
|
this.fullKeys = new ArrayList<>(this.data.getFullKeys());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<KeyPath> matches = new ArrayList<>();
|
||||||
|
|
||||||
|
for(KeyPath key : this.data.getFullKeys()) {
|
||||||
|
if(this.data.getTranslation(key).values().size() != this.locales.size()) {
|
||||||
|
matches.add(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fullKeys = matches;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return this.fullKeys.size();
|
return this.fullKeys.size();
|
||||||
|
@ -4,6 +4,7 @@ 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.*;
|
||||||
|
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.util.UiUtil;
|
import de.marhali.easyi18n.util.UiUtil;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ import java.util.Map;
|
|||||||
* Mapping {@link TranslationData} to {@link TreeModel}.
|
* Mapping {@link TranslationData} to {@link TreeModel}.
|
||||||
* @author marhali
|
* @author marhali
|
||||||
*/
|
*/
|
||||||
public class TreeModelMapper extends DefaultTreeModel implements SearchQueryListener {
|
public class TreeModelMapper extends DefaultTreeModel implements SearchQueryListener, FilterMissingTranslationsListener {
|
||||||
|
|
||||||
private final TranslationData data;
|
private final TranslationData data;
|
||||||
private final KeyPathConverter converter;
|
private final KeyPathConverter converter;
|
||||||
@ -42,7 +43,7 @@ public class TreeModelMapper extends DefaultTreeModel implements SearchQueryList
|
|||||||
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
|
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
|
||||||
TranslationData shadow = new TranslationData(this.state.isSortKeys());
|
TranslationData shadow = new TranslationData(this.state.isSortKeys());
|
||||||
|
|
||||||
if(query == null) {
|
if(query == null) { // Reset
|
||||||
this.generateNodes(rootNode, this.data.getRootNode());
|
this.generateNodes(rootNode, this.data.getRootNode());
|
||||||
super.setRoot(rootNode);
|
super.setRoot(rootNode);
|
||||||
return;
|
return;
|
||||||
@ -71,6 +72,29 @@ public class TreeModelMapper extends DefaultTreeModel implements SearchQueryList
|
|||||||
super.setRoot(rootNode);
|
super.setRoot(rootNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFilterMissingTranslations(boolean filter) {
|
||||||
|
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
|
||||||
|
TranslationData shadow = new TranslationData(this.state.isSortKeys());
|
||||||
|
|
||||||
|
if(!filter) { // Reset
|
||||||
|
this.generateNodes(rootNode, this.data.getRootNode());
|
||||||
|
super.setRoot(rootNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(KeyPath currentKey : this.data.getFullKeys()) {
|
||||||
|
Translation translation = this.data.getTranslation(currentKey);
|
||||||
|
|
||||||
|
if(translation.values().size() != this.data.getLocales().size()) {
|
||||||
|
shadow.setTranslation(currentKey, translation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.generateNodes(rootNode, shadow.getRootNode());
|
||||||
|
super.setRoot(rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parent Parent tree node
|
* @param parent Parent tree node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user