use of com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn in project midpoint by Evolveum.
the class LoggingConfigPanel method initLoggerColumns.
private List<IColumn<LoggerConfiguration, String>> initLoggerColumns() {
List<IColumn<LoggerConfiguration, String>> columns = new ArrayList<>();
IColumn column = new CheckBoxHeaderColumn<LoggerConfiguration>();
columns.add(column);
//name editing column
columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.logger"), "name") {
@Override
protected Component createInputPanel(String componentId, final IModel<LoggerConfiguration> model) {
if (model.getObject() instanceof StandardLogger) {
DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "logger"), WebComponentUtil.createReadonlyModelFromEnum(StandardLoggerType.class), new EnumChoiceRenderer<StandardLoggerType>());
FormComponent<StandardLoggerType> input = dropDownChoicePanel.getBaseFormComponent();
input.add(new NotNullValidator<StandardLoggerType>("logger.emptyLogger"));
input.add(new AttributeAppender("style", "width: 100%"));
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
addAjaxFormComponentUpdatingBehavior(input);
return dropDownChoicePanel;
} else if (model.getObject() instanceof ComponentLogger) {
DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "component"), WebComponentUtil.createReadonlyModelFromEnum(LoggingComponentType.class), new EnumChoiceRenderer<LoggingComponentType>());
FormComponent<LoggingComponentType> input = dropDownChoicePanel.getBaseFormComponent();
input.add(new NotNullValidator<LoggingComponentType>("logger.emptyLogger"));
input.add(new AttributeAppender("style", "width: 100%"));
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
addAjaxFormComponentUpdatingBehavior(input);
return dropDownChoicePanel;
} else {
TextPanel textPanel = new TextPanel<>(componentId, new PropertyModel<String>(model, getPropertyExpression()));
FormComponent input = textPanel.getBaseFormComponent();
addAjaxFormComponentUpdatingBehavior(input);
input.add(new AttributeAppender("style", "width: 100%"));
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
input.add(new NotNullValidator<StandardLoggerType>("message.emptyString"));
return textPanel;
}
}
@Override
public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
loggerEditPerformed(target, rowModel);
}
});
//level editing column
columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersLevel"), "level") {
@Override
protected Component createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, getPropertyExpression()), WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
FormComponent<LoggingLevelType> input = dropDownChoicePanel.getBaseFormComponent();
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
input.add(new NotNullValidator<LoggingLevelType>("message.emptyLevel"));
addAjaxFormComponentUpdatingBehavior(input);
return dropDownChoicePanel;
}
@Override
public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
loggerEditPerformed(target, rowModel);
}
@Override
protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
LoggerConfiguration configuration = rowModel.getObject();
return WebComponentUtil.createLocalizedModelForEnum(configuration.getLevel(), getPageBase());
}
});
//appender editing column
columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersAppender"), "appenders") {
@Override
protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
final LoggerConfiguration configuration = rowModel.getObject();
if (configuration.getAppenders().isEmpty()) {
return createStringResource("LoggingConfigPanel.appenders.Inherit");
} else {
return new LoadableModel<String>() {
@Override
protected String load() {
StringBuilder builder = new StringBuilder();
for (String appender : configuration.getAppenders()) {
if (configuration.getAppenders().indexOf(appender) != 0) {
builder.append(", ");
}
builder.append(appender);
}
return builder.toString();
}
};
}
}
@Override
protected InputPanel createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
IModel<Map<String, String>> options = new Model(null);
Map<String, String> optionsMap = new HashMap<String, String>();
optionsMap.put("nonSelectedText", createStringResource("LoggingConfigPanel.appenders.Inherit").getString());
options.setObject(optionsMap);
ListMultipleChoicePanel panel = new ListMultipleChoicePanel<>(componentId, new PropertyModel<List<String>>(model, getPropertyExpression()), createNewLoggerAppendersListModel(), new StringChoiceRenderer(null), options);
FormComponent<AppenderConfigurationType> input = panel.getBaseFormComponent();
input.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
addAjaxFormComponentUpdatingBehavior(input);
return panel;
}
public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
loggerEditPerformed(target, rowModel);
}
});
return columns;
}
use of com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn in project midpoint by Evolveum.
the class LoggingConfigPanel method initAppenderColumns.
private List<IColumn<AppenderConfiguration, String>> initAppenderColumns() {
List<IColumn<AppenderConfiguration, String>> columns = new ArrayList<>();
IColumn column = new CheckBoxHeaderColumn<AppenderConfiguration>();
columns.add(column);
//name columns (editable)
column = new EditableLinkColumn<AppenderConfiguration>(createStringResource("LoggingConfigPanel.appenders.name"), "name") {
@Override
public void onClick(AjaxRequestTarget target, IModel<AppenderConfiguration> rowModel) {
appenderEditPerformed(target, rowModel);
}
@Override
protected Component createInputPanel(String componentId, IModel<AppenderConfiguration> model) {
TextPanel<String> panel = new TextPanel<String>(componentId, new PropertyModel(model, getPropertyExpression()));
panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
panel.getBaseFormComponent().add(new NotNullValidator<String>("message.emptyString"));
addAjaxFormComponentUpdatingBehavior(panel.getBaseFormComponent());
return panel;
}
};
columns.add(column);
//pattern column (editable)
column = new EditablePropertyColumn(createStringResource("LoggingConfigPanel.appenders.pattern"), "pattern") {
@Override
protected InputPanel createInputPanel(String componentId, IModel model) {
InputPanel panel = super.createInputPanel(componentId, model);
panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
panel.getBaseFormComponent().add(new NotNullValidator<String>("message.emptyString"));
addAjaxFormComponentUpdatingBehavior(panel.getBaseFormComponent());
return panel;
}
};
columns.add(column);
//file path column (editable)
column = new FileAppenderColumn(createStringResource("LoggingConfigPanel.appenders.filePath"), "filePath");
columns.add(column);
//file pattern column (editable) jj
column = new FileAppenderColumn(createStringResource("LoggingConfigPanel.appenders.filePattern"), "filePattern");
columns.add(column);
//max history column (editable)
column = new FileAppenderColumn(createStringResource("LoggingConfigPanel.appenders.maxHistory"), "maxHistory") {
@Override
protected InputPanel createInputPanel(String componentId, IModel model) {
TextPanel panel = new TextPanel<>(componentId, new PropertyModel<String>(model, getPropertyExpression()));
FormComponent component = panel.getBaseFormComponent();
component.add(new AttributeModifier("size", 5));
component.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
addAjaxFormComponentUpdatingBehavior(component);
return panel;
}
};
columns.add(column);
//max file size column (editable)
column = new FileAppenderColumn(createStringResource("LoggingConfigPanel.appenders.maxFileSize"), "maxFileSize") {
@Override
protected InputPanel createInputPanel(String componentId, IModel model) {
TextPanel<String> panel = new TextPanel<>(componentId, new PropertyModel<String>(model, getPropertyExpression()));
FormComponent component = panel.getBaseFormComponent();
component.add(new AttributeModifier("size", 5));
component.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
component.add(new NotNullValidator<String>("message.emptyString"));
addAjaxFormComponentUpdatingBehavior(component);
return panel;
}
};
columns.add(column);
CheckBoxColumn check = new EditableCheckboxColumn(createStringResource("LoggingConfigPanel.appenders.appending"), "appending") {
@Override
protected InputPanel createInputPanel(String componentId, IModel model) {
InputPanel panel = super.createInputPanel(componentId, model);
panel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
panel.getBaseFormComponent().add(new NotNullValidator<String>("message.emptyString"));
addAjaxFormComponentUpdatingBehavior(panel.getBaseFormComponent());
return panel;
}
};
check.setEnabled(false);
columns.add(check);
return columns;
}
Aggregations