feat: Add case format to ProjectSettingsState and fromSelector method to NamingConvention

This commit adds a new attribute, `caseFormat`, to the `ProjectSettingsState` class. It also introduces a static method `fromSelector` in the `NamingConvention` class to transform a string into a NamingConvention enum. The transformation in `ProjectSettingsComponentState` has been updated  to use this new method.
This commit is contained in:
JPilson 2024-04-18 20:48:40 +02:00
parent 667b748614
commit b7b3563080
3 changed files with 8 additions and 1 deletions

View File

@ -15,4 +15,8 @@ public enum NamingConvention {
public String toString() {
return super.name().toLowerCase();
}
static public NamingConvention fromSelector(String name) {
String formated = name.replace(" ","_");
return valueOf(formated.toUpperCase());
}
}

View File

@ -9,6 +9,7 @@ import de.marhali.easyi18n.io.folder.FolderStrategyType;
import de.marhali.easyi18n.settings.presets.Preset;
import javax.swing.*;
import java.util.Objects;
/**
* Mandatory for state management for the project settings component.
@ -68,9 +69,10 @@ public class ProjectSettingsComponentState {
state.setAssistance(assistance.isSelected());
state.setAlwaysFold(alwaysFold.isSelected());
state.setFlavorTemplate(flavorTemplate.getText());
state.setCaseFormat(NamingConvention.valueOf(KeyCaseFormater.getSelectedItem().toString().replace("Case", "").trim()));
state.setCaseFormat(NamingConvention.fromSelector(KeyCaseFormater.getSelectedItem().toString()));
return state;
}

View File

@ -95,6 +95,7 @@ public class ProjectSettingsState implements ProjectSettings {
this.alwaysFold = defaults.isAlwaysFold();
this.flavorTemplate = defaults.getFlavorTemplate();
this.caseFormat = defaults.getCaseFormat();
}
@Override