From 670e00936571e36a40d96b7a539902b6177a7c0e Mon Sep 17 00:00:00 2001 From: jensp Date: Tue, 17 May 2016 13:14:59 +0000 Subject: [PATCH] CCM NG: Some minor work for the setting editor(s) git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4078 8810af33-2d31-482b-a856-94f89814c4df --- .../configuration/ConfigurationTable.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/configuration/ConfigurationTable.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/configuration/ConfigurationTable.java index d5020d8a0..f82657002 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/configuration/ConfigurationTable.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/configuration/ConfigurationTable.java @@ -63,6 +63,7 @@ public class ConfigurationTable extends Table { private static final int COL_EDIT_SETTING = 3; private ParameterSingleSelectionModel selectedConf; + private ParameterSingleSelectionModel selectedSetting; public ConfigurationTable( final ConfigurationTab configurationTab, @@ -74,6 +75,7 @@ public class ConfigurationTable extends Table { setIdAttr("configurationTable"); this.selectedConf = selectedConf; + this.selectedSetting = selectedSetting; setEmptyView(new Label(new GlobalizedMessage( "ui.admin.configuration.settings.none", ADMIN_BUNDLE))); @@ -126,6 +128,37 @@ public class ConfigurationTable extends Table { final String settingName = (String) event.getRowKey(); selectedSetting.setSelectedKey(state, settingName); + switch (getTypeOfSelectedSetting(state)) { + case "boolean": + LOGGER.debug("Setting is of type boolean"); + break; + case "long": + LOGGER.debug("Setting is of type long"); + break; + case "double": + LOGGER.debug("Setting is of type double"); + break; + case "java.math.BigDecimal": + LOGGER.debug("Setting is of type BigDecimal"); + break; + case "org.libreccm.l10n.LocalizedString": + LOGGER.debug("Setting is of type LocalizedString"); + break; + case "java.lang.String": + LOGGER.debug("Setting is of type String"); + break; + case "java.util.Set": + LOGGER.debug("Setting is of type Enum"); + break; + case "java.util.List": + LOGGER.debug("Setting is of type List"); + break; + default: + throw new IllegalArgumentException(String.format( + "Unknown setting type \"%s\".", + getTypeOfSelectedSetting(state))); + } + } } @@ -139,6 +172,29 @@ public class ConfigurationTable extends Table { setModelBuilder(new ConfigurationTableModelBuilder()); } + private String getTypeOfSelectedSetting(final PageState state) { + final Class confClass; + try { + confClass = Class.forName(selectedConf.getSelectedKey(state)); + } catch (ClassNotFoundException ex) { + LOGGER.error("Configuration class '{}' not found.", + selectedConf.getSelectedKey(state)); + throw new UncheckedWrapperException(String.format( + "Configuration class '%s not found'", + selectedConf.getSelectedKey(state)), ex); + } + + final SettingManager settingManager = CdiUtil.createCdiUtil().findBean( + SettingManager.class); + final SettingInfo info = settingManager.getSettingInfo(confClass, + selectedSetting. + getSelectedKey( + state)); + + return info.getValueType(); + + } + private class ConfigurationTableModelBuilder extends LockableImpl implements TableModelBuilder {