suggest file pattern on parser change
This commit is contained in:
parent
5f16d14524
commit
73f8491582
@ -20,6 +20,8 @@ import de.marhali.easyi18n.service.SettingsService;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,6 +103,7 @@ public class SettingsDialog {
|
|||||||
parserStrategyComboBox = new ComboBox<>(bundle.getString("settings.strategy.parser").split(ArrayMapper.SPLITERATOR_REGEX));
|
parserStrategyComboBox = new ComboBox<>(bundle.getString("settings.strategy.parser").split(ArrayMapper.SPLITERATOR_REGEX));
|
||||||
parserStrategyComboBox.setSelectedIndex(state.getParserStrategy().toIndex());
|
parserStrategyComboBox.setSelectedIndex(state.getParserStrategy().toIndex());
|
||||||
parserStrategyComboBox.setToolTipText(bundle.getString("settings.strategy.parser.tooltip"));
|
parserStrategyComboBox.setToolTipText(bundle.getString("settings.strategy.parser.tooltip"));
|
||||||
|
parserStrategyComboBox.addItemListener(handleParserChange());
|
||||||
constraints.fill = GridBagConstraints.HORIZONTAL;
|
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
constraints.gridx = 1;
|
constraints.gridx = 1;
|
||||||
constraints.gridy = 0;
|
constraints.gridy = 0;
|
||||||
@ -157,4 +160,14 @@ public class SettingsDialog {
|
|||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemListener handleParserChange() {
|
||||||
|
return e -> {
|
||||||
|
if(e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
|
// Automatically suggest file pattern option on parser change
|
||||||
|
ParserStrategy newStrategy = ParserStrategy.fromIndex(parserStrategyComboBox.getSelectedIndex());
|
||||||
|
filePatternText.setText(newStrategy.getExampleFilePattern());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,6 +9,10 @@ public enum ParserStrategy {
|
|||||||
YAML,
|
YAML,
|
||||||
PROPERTIES;
|
PROPERTIES;
|
||||||
|
|
||||||
|
public String getExampleFilePattern() {
|
||||||
|
return "*." + toString().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
public int toIndex() {
|
public int toIndex() {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user