use of com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel in project midpoint by Evolveum.
the class SwitchablePropertyValuePanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
WebMarkupContainer valueContainer = new WebMarkupContainer(ID_PROPERTY_VALUE_PANEL);
valueContainer.setOutputMarkupId(true);
add(valueContainer);
Component valueField = getValueField(ID_VALUE_FIELD);
valueField.add(new VisibleBehaviour(() -> !isExpressionMode));
valueContainer.add(valueField);
ExpressionWrapper expression = getExpressionWrapper();
ExpressionType expressionType = null;
if (expression != null) {
Object expressionValue = expression.getExpression();
if (expressionValue instanceof ExpressionType) {
expressionType = (ExpressionType) expressionValue;
}
}
AceEditorPanel expressionField = new AceEditorPanel(ID_EXPRESSION_FIELD, null, new ExpressionModel(Model.of(expressionType), getPageBase()), 200);
expressionField.getEditor().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
getModelObject().getValue().setExpression(new ExpressionWrapper(getPropertyItemDefinition().getItemName(), ((ExpressionModel) expressionField.getModel()).getBaseModel().getObject()));
}
});
expressionField.getEditor().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
expressionField.add(new VisibleBehaviour(() -> isExpressionMode));
valueContainer.add(expressionField);
AjaxButton switchButton = new AjaxButton(ID_SWITCH_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
if (isExpressionMode) {
tempExpressionWrapper = SwitchablePropertyValuePanel.this.getModelObject().getValue().getExpression();
SwitchablePropertyValuePanel.this.getModelObject().getValue().setExpression(null);
SwitchablePropertyValuePanel.this.getModelObject().getValue().setValue(tempValue);
// if (isReferenceFilterValue()) {
// SwitchablePropertyValuePanel.this.getModelObject().getValue().setValue(new ObjectReferenceType());
// }
} else {
tempValue = SwitchablePropertyValuePanel.this.getModelObject().getValue().getValue();
SwitchablePropertyValuePanel.this.getModelObject().getValue().setExpression(tempExpressionWrapper);
SwitchablePropertyValuePanel.this.getModelObject().getValue().setValue(null);
}
isExpressionMode = !isExpressionMode;
target.add(SwitchablePropertyValuePanel.this);
}
};
switchButton.setOutputMarkupId(true);
switchButton.add(new VisibleBehaviour(() -> {
ItemDefinition propertyDef = getPropertyItemDefinition();
return propertyDef == null || propertyDef.getTypeClass() != null && !boolean.class.equals(propertyDef.getTypeClass()) && !Boolean.class.isAssignableFrom(propertyDef.getTypeClass());
}));
switchButton.add(AttributeAppender.append("title", new LoadableModel<String>() {
@Override
protected String load() {
// todo
return "";
}
}));
valueContainer.add(switchButton);
}
use of com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel in project midpoint by Evolveum.
the class PageXmlDataReview method initLayout.
private void initLayout(IModel<String> title, IModel<String> data) {
WebMarkupContainer container = new WebMarkupContainer(ID_ACE_EDITOR_CONTAINER);
container.setOutputMarkupId(true);
add(container);
AceEditorPanel aceEditorPanel = new AceEditorPanel(ID_ACE_EDITOR_PANEL, title, data);
aceEditorPanel.getEditor().setReadonly(true);
aceEditorPanel.setOutputMarkupId(true);
container.add(aceEditorPanel);
AjaxButton back = new AjaxButton(ID_BUTTON_BACK, createStringResource("PageBase.button.back")) {
@Override
public void onClick(AjaxRequestTarget target) {
redirectBack();
}
};
add(back);
}
Aggregations