adapt method name to label of checkbox
authorKatja Luther <k.luther@bgbm.org>
Thu, 9 Sep 2021 11:34:05 +0000 (13:34 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 9 Sep 2021 11:34:05 +0000 (13:34 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/in/GenericConfiguratorWizardPageE4.java

index 2ad5d8df67b0bc292474a62ea0d77ff11dcb6264..8d16488e3dd95d6173d9c64ef1338c0e61bfe15d 100644 (file)
@@ -19,7 +19,6 @@ import java.util.ResourceBundle;
 
 import javax.inject.Inject;
 
-import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -133,12 +132,7 @@ public class GenericConfiguratorWizardPageE4 extends WizardPage {
         final Button checkBox = new Button(parent, SWT.CHECK);
 
        // if(configurator.getClass().equals(Abcd206ImportConfigurator.class)){
-            String[] r = methodName.split("set")[1].split("(?=\\p{Upper})");
-            checkBox.setText(getLabel(StringUtils.join(r," ")));
-//        }
-//        else{
-//            checkBox.setText(getLabel(methodName));
-//        }
+        checkBox.setText(getLabel(splitMethodName(methodName)));
         // retrieve the default values and set the checkbox accordingly
         boolean defaultSelection = executeBooleanGetMethod(configurator, "is"
                 + methodName.substring(3));
@@ -248,4 +242,16 @@ public class GenericConfiguratorWizardPageE4 extends WizardPage {
 
         return booleanMethods;
     }
+
+    private String splitMethodName(String s) {
+        s = s.replace("set", "");
+        return s.replaceAll(
+           String.format("%s|%s|%s",
+              "(?<=[A-Z])(?=[A-Z][a-z])",
+              "(?<=[^A-Z])(?=[A-Z])",
+              "(?<=[A-Za-z])(?=[^A-Za-z])"
+           ),
+           " "
+        );
+     }
 }