rename strategy enum types
This commit is contained in:
parent
3d6806053e
commit
4d11319217
@ -13,9 +13,9 @@ import com.intellij.ui.components.JBTextField;
|
||||
|
||||
import de.marhali.easyi18n.InstanceManager;
|
||||
import de.marhali.easyi18n.io.ArrayMapper;
|
||||
import de.marhali.easyi18n.model.FolderStrategy;
|
||||
import de.marhali.easyi18n.model.FolderStrategyType;
|
||||
import de.marhali.easyi18n.model.SettingsState;
|
||||
import de.marhali.easyi18n.model.bus.ParserStrategy;
|
||||
import de.marhali.easyi18n.model.ParserStrategyType;
|
||||
import de.marhali.easyi18n.service.SettingsService;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -51,8 +51,8 @@ public class SettingsDialog {
|
||||
|
||||
if(prepare(state).show() == DialogWrapper.OK_EXIT_CODE) { // Save changes
|
||||
state.setLocalesPath(pathText.getText());
|
||||
state.setFolderStrategy(FolderStrategy.fromIndex(folderStrategyComboBox.getSelectedIndex()));
|
||||
state.setParserStrategy(ParserStrategy.fromIndex(parserStrategyComboBox.getSelectedIndex()));
|
||||
state.setFolderStrategy(FolderStrategyType.fromIndex(folderStrategyComboBox.getSelectedIndex()));
|
||||
state.setParserStrategy(ParserStrategyType.fromIndex(parserStrategyComboBox.getSelectedIndex()));
|
||||
state.setFilePattern(filePatternText.getText());
|
||||
state.setPreviewLocale(previewLocaleText.getText());
|
||||
state.setPathPrefix(pathPrefixText.getText());
|
||||
@ -165,7 +165,7 @@ public class SettingsDialog {
|
||||
return e -> {
|
||||
if(e.getStateChange() == ItemEvent.SELECTED) {
|
||||
// Automatically suggest file pattern option on parser change
|
||||
ParserStrategy newStrategy = ParserStrategy.fromIndex(parserStrategyComboBox.getSelectedIndex());
|
||||
ParserStrategyType newStrategy = ParserStrategyType.fromIndex(parserStrategyComboBox.getSelectedIndex());
|
||||
filePatternText.setText(newStrategy.getExampleFilePattern());
|
||||
}
|
||||
};
|
||||
|
@ -1,29 +0,0 @@
|
||||
package de.marhali.easyi18n.model;
|
||||
|
||||
/**
|
||||
* Represents all supported folder strategies.
|
||||
* @author marhali
|
||||
*/
|
||||
public enum FolderStrategy {
|
||||
SINGLE,
|
||||
MODULARIZED_LOCALE,
|
||||
MODULARIZED_NAMESPACE;
|
||||
|
||||
public int toIndex() {
|
||||
int index = 0;
|
||||
|
||||
for(FolderStrategy strategy : values()) {
|
||||
if(strategy == this) {
|
||||
return index;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
public static FolderStrategy fromIndex(int index) {
|
||||
return values()[index];
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package de.marhali.easyi18n.model;
|
||||
|
||||
import de.marhali.easyi18n.ionext.folder.FolderStrategy;
|
||||
import de.marhali.easyi18n.ionext.folder.ModularLocaleFolderStrategy;
|
||||
import de.marhali.easyi18n.ionext.folder.ModularNamespaceFolderStrategy;
|
||||
import de.marhali.easyi18n.ionext.folder.SingleFolderStrategy;
|
||||
|
||||
/**
|
||||
* Represents all supported folder strategies.
|
||||
* @author marhali
|
||||
*/
|
||||
public enum FolderStrategyType {
|
||||
SINGLE(SingleFolderStrategy.class),
|
||||
MODULARIZED_LOCALE(ModularLocaleFolderStrategy.class),
|
||||
MODULARIZED_NAMESPACE(ModularNamespaceFolderStrategy.class);
|
||||
|
||||
private final Class<? extends FolderStrategy> strategy;
|
||||
|
||||
FolderStrategyType(Class<? extends FolderStrategy> strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public Class<? extends FolderStrategy> getStrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
public int toIndex() {
|
||||
int index = 0;
|
||||
|
||||
for(FolderStrategyType strategy : values()) {
|
||||
if(strategy == this) {
|
||||
return index;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
public static FolderStrategyType fromIndex(int index) {
|
||||
return values()[index];
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package de.marhali.easyi18n.model.bus;
|
||||
package de.marhali.easyi18n.model;
|
||||
|
||||
/**
|
||||
* Represents all supported file parser strategies.
|
||||
* @author marhali
|
||||
*/
|
||||
public enum ParserStrategy {
|
||||
public enum ParserStrategyType {
|
||||
JSON,
|
||||
YAML,
|
||||
PROPERTIES;
|
||||
@ -16,7 +16,7 @@ public enum ParserStrategy {
|
||||
public int toIndex() {
|
||||
int index = 0;
|
||||
|
||||
for(ParserStrategy strategy : values()) {
|
||||
for(ParserStrategyType strategy : values()) {
|
||||
if(strategy == this) {
|
||||
return index;
|
||||
}
|
||||
@ -27,7 +27,7 @@ public enum ParserStrategy {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
public static ParserStrategy fromIndex(int index) {
|
||||
public static ParserStrategyType fromIndex(int index) {
|
||||
return values()[index];
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package de.marhali.easyi18n.model;
|
||||
|
||||
import de.marhali.easyi18n.model.bus.ParserStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -11,8 +10,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
public class SettingsState {
|
||||
|
||||
public static final String DEFAULT_PREVIEW_LOCALE = "en";
|
||||
public static final FolderStrategy DEFAULT_FOLDER_STRATEGY = FolderStrategy.SINGLE;
|
||||
public static final ParserStrategy DEFAULT_PARSER_STRATEGY = ParserStrategy.JSON;
|
||||
public static final FolderStrategyType DEFAULT_FOLDER_STRATEGY = FolderStrategyType.SINGLE;
|
||||
public static final ParserStrategyType DEFAULT_PARSER_STRATEGY = ParserStrategyType.JSON;
|
||||
public static final String DEFAULT_FILE_PATTERN = "*.*";
|
||||
public static final String DEFAULT_PATH_PREFIX = "";
|
||||
public static final boolean DEFAULT_SORT_KEYS = true;
|
||||
@ -20,8 +19,8 @@ public class SettingsState {
|
||||
public static final boolean DEFAULT_CODE_ASSISTANCE = true;
|
||||
|
||||
private String localesPath;
|
||||
private FolderStrategy folderStrategy;
|
||||
private ParserStrategy parserStrategy;
|
||||
private FolderStrategyType folderStrategy;
|
||||
private ParserStrategyType parserStrategy;
|
||||
private String filePattern;
|
||||
private String previewLocale;
|
||||
private String pathPrefix;
|
||||
@ -39,19 +38,19 @@ public class SettingsState {
|
||||
this.localesPath = localesPath;
|
||||
}
|
||||
|
||||
public @NotNull FolderStrategy getFolderStrategy() {
|
||||
public @NotNull FolderStrategyType getFolderStrategy() {
|
||||
return folderStrategy != null ? folderStrategy : DEFAULT_FOLDER_STRATEGY;
|
||||
}
|
||||
|
||||
public void setFolderStrategy(FolderStrategy folderStrategy) {
|
||||
public void setFolderStrategy(FolderStrategyType folderStrategy) {
|
||||
this.folderStrategy = folderStrategy;
|
||||
}
|
||||
|
||||
public @NotNull ParserStrategy getParserStrategy() {
|
||||
public @NotNull ParserStrategyType getParserStrategy() {
|
||||
return parserStrategy != null ? parserStrategy : DEFAULT_PARSER_STRATEGY;
|
||||
}
|
||||
|
||||
public void setParserStrategy(ParserStrategy parserStrategy) {
|
||||
public void setParserStrategy(ParserStrategyType parserStrategy) {
|
||||
this.parserStrategy = parserStrategy;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user