Search in sources :

Example 1 with AceEditorPanel

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);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AceEditorPanel(com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel) ExpressionModel(com.evolveum.midpoint.gui.impl.factory.panel.ExpressionModel) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) Component(org.apache.wicket.Component) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)

Example 2 with AceEditorPanel

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AceEditorPanel(com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 AceEditorPanel (com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ExpressionModel (com.evolveum.midpoint.gui.impl.factory.panel.ExpressionModel)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)1 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)1 Component (org.apache.wicket.Component)1