private void refresh() { this.platformConfigurationConfiguredResource = new PlatformConfigurationConfiguredResource(); this.platformConfiguration = this.configurationManagement.getConfiguration(this.platformConfigurationConfiguredResource); // create the configuration if it does not already exist! if (platformConfiguration == null) { this.platformConfigurationConfiguredResource.setConfiguration(new PlatformConfiguration()); platformConfiguration = this.configurationManagement.createConfiguration(platformConfigurationConfiguredResource); } final List<ConfigurationParameter> parameters = (List<ConfigurationParameter>) platformConfiguration.getParameters(); GridLayout layout = new GridLayout(); layout.setWidth("100%"); layout.setSpacing(true); Panel userPanel = null; Panel passwordPanel = null; Panel mapPanel = null; for (ConfigurationParameter parameter : parameters) { if (parameter.getName().equals("webServiceUserAccount")) { userParam = parameter; userPanel = this.createTextFieldPanel( parameter, new NonZeroLengthStringValidator("The web service user account must be entered!")); } else if (parameter.getName().equals("webServiceUserPassword")) { passwordParam = parameter; passwordPanel = this.createPasswordFieldPanel( parameter, new NonZeroLengthStringValidator("The web service user password must be entered!")); } if (parameter.getName().equals("configurationMap")) { mapPanel = this.createMapPanel((ConfigurationParameterMapImpl) parameter); } } layout.addComponent(userPanel); layout.addComponent(passwordPanel); layout.addComponent(mapPanel); this.setContent(layout); }
protected Panel createTextFieldPanel(ConfigurationParameter parameter, Validator validator) { Panel paramPanel = new Panel(); paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(3, 3); paramLayout.setSpacing(true); paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label configLabel = new Label("Platform Configuration"); configLabel.addStyleName(ValoTheme.LABEL_HUGE); configLabel.setSizeUndefined(); paramLayout.addComponent(configLabel, 0, 0, 1, 0); paramLayout.setComponentAlignment(configLabel, Alignment.TOP_LEFT); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 1, 1, 1); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); logger.info(parameter.getName() + " " + parameter.getValue()); Label valueLabel = new Label("Value:"); valueLabel.setSizeUndefined(); usernameField = new TextField(); usernameField.addValidator(validator); usernameField.setNullSettingAllowed(true); usernameField.setNullRepresentation(""); usernameField.setValidationVisible(false); usernameField.setWidth("80%"); usernameField.setId(parameter.getName()); if (parameter instanceof ConfigurationParameterIntegerImpl) { StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields usernameField.setConverter(plainIntegerConverter); } else if (parameter instanceof ConfigurationParameterLongImpl) { StringToLongConverter plainLongConverter = new StringToLongConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields usernameField.setConverter(plainLongConverter); } BeanItem<ConfigurationParameter> parameterItem = new BeanItem<ConfigurationParameter>(parameter); if (parameter.getValue() != null) { usernameField.setPropertyDataSource(parameterItem.getItemProperty("value")); } paramLayout.addComponent(valueLabel, 0, 2); paramLayout.addComponent(usernameField, 1, 2); paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT); paramPanel.setContent(paramLayout); return paramPanel; }