Search in sources :

Example 41 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class SingleContainerPanel method initLayout.

private void initLayout() {
    try {
        ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(wrapper -> getVisibility(wrapper)).editabilityHandler(getEditabilityHandler()).mandatoryHandler(getMandatoryHandler());
        if (config == null) {
            Panel panel = getPageBase().initItemPanel(ID_CONTAINER, getTypeName(), getModel(), builder.build());
            add(panel);
        } else {
            RepeatingView view = new RepeatingView(ID_CONTAINER);
            List<VirtualContainersSpecificationType> virtualContainers = config.getContainer();
            for (VirtualContainersSpecificationType virtualContainer : virtualContainers) {
                if (!WebComponentUtil.getElementVisibility(virtualContainer.getVisibility())) {
                    continue;
                }
                IModel<PrismContainerWrapper<C>> virtualContainerModel = createVirtualContainerModel(virtualContainer);
                if (virtualContainerModel == null) {
                    continue;
                }
                ItemPanelSettings settings = builder.build();
                Panel virtualPanel = new PrismContainerPanel<>(view.newChildId(), virtualContainerModel, settings);
                view.add(virtualPanel);
            }
            QName typeName = getTypeName();
            if (typeName != null) {
                Panel panel = getPageBase().initItemPanel(view.newChildId(), typeName, getModel(), builder.build());
                view.add(panel);
            }
            add(view);
        }
    } catch (SchemaException e) {
        LOGGER.error("Cannot create panel for {}, {}", getTypeName(), e.getMessage(), e);
        // TODO opertion result? localization?
        getSession().error("Cannot create panel for " + getTypeName());
    }
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) VirtualContainersSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.VirtualContainersSpecificationType)

Example 42 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class DefaultContainerablePanel method populateNonContainer.

private void populateNonContainer(ListItem<? extends ItemWrapper<?, ?>> item) {
    item.setOutputMarkupId(true);
    ItemWrapper<?, ?> itemWrapper = item.getModelObject();
    try {
        QName typeName = itemWrapper.getTypeName();
        if (item.getModelObject() instanceof ResourceAttributeWrapper) {
            typeName = new QName("ResourceAttributeDefinition");
        }
        ItemPanelSettings settings = getSettings() != null ? getSettings().copy() : null;
        Panel panel = getPageBase().initItemPanel("property", typeName, item.getModel(), settings);
        panel.setOutputMarkupId(true);
        item.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isVisible() {
                return itemWrapper.isVisible(getModelObject(), getVisibilityHandler());
            }
        });
        item.add(panel);
    } catch (SchemaException e1) {
        throw new SystemException("Cannot instantiate " + itemWrapper.getTypeName());
    }
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) QName(javax.xml.namespace.QName) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 43 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class DefaultContainerablePanel method populateContainer.

private void populateContainer(ListItem<PrismContainerWrapper<?>> container) {
    PrismContainerWrapper<?> itemWrapper = container.getModelObject();
    try {
        ItemPanelSettings settings = getSettings() != null ? getSettings().copy() : null;
        Panel panel = getPageBase().initItemPanel("container", itemWrapper.getTypeName(), container.getModel(), settings);
        panel.setOutputMarkupId(true);
        container.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isVisible() {
                return itemWrapper.isVisible(getModelObject(), getVisibilityHandler());
            }

            @Override
            public boolean isEnabled() {
                // TODO hack isMetadata - beacuse all links are then disabled.
                return !itemWrapper.isReadOnly() || itemWrapper.isMetadata();
            }
        });
        container.add(panel);
    } catch (SchemaException e) {
        throw new SystemException("Cannot instantiate panel for: " + itemWrapper.getDisplayName());
    }
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 44 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class ShadowPanel method initLayout.

private void initLayout() {
    try {
        if (config != null) {
            SingleContainerPanel attributesContainer = new SingleContainerPanel(ID_ATTRIBUTES, getModel(), config) {

                @Override
                protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
                    return checkShadowContainerVisibility(itemWrapper, ShadowPanel.this.getModel());
                }
            };
            add(attributesContainer);
        } else {
            ItemPanelSettingsBuilder attributesSettingsBuilder = new ItemPanelSettingsBuilder().visibilityHandler(itemWrapper -> checkShadowContainerVisibility(itemWrapper, getModel()));
            Panel attributesPanel = getPageBase().initItemPanel(ID_ATTRIBUTES, ShadowAttributesType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ShadowType.F_ATTRIBUTES), attributesSettingsBuilder.build());
            add(attributesPanel);
        }
        ItemPanelSettingsBuilder associationBuilder = new ItemPanelSettingsBuilder().visibilityHandler(itemWrapper -> checkShadowContainerVisibility(itemWrapper, getModel()));
        Panel associationsPanel = getPageBase().initItemPanel(ID_ASSOCIATIONS, ShadowAssociationType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ShadowType.F_ASSOCIATION), associationBuilder.build());
        associationsPanel.add(new VisibleBehaviour(() -> checkAssociationsVisibility()));
        add(associationsPanel);
        ItemPanelSettingsBuilder activationBuilder = new ItemPanelSettingsBuilder().visibilityHandler(itemWrapper -> checkShadowContainerVisibility(itemWrapper, getModel()));
        Panel activationPanel = getPageBase().initItemPanel(ID_ACTIVATION, ActivationType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ShadowType.F_ACTIVATION), activationBuilder.build());
        activationPanel.add(new VisibleBehaviour(() -> isActivationSupported()));
        add(activationPanel);
        ItemPanelSettingsBuilder passwordSettingsBuilder = new ItemPanelSettingsBuilder().visibilityHandler(itemWrapper -> checkShadowContainerVisibility(itemWrapper, getModel()));
        Panel passwordPanel = getPageBase().initItemPanel(ID_PASSWORD, PasswordType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ItemPath.create(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD)), passwordSettingsBuilder.build());
        passwordPanel.add(new VisibleBehaviour(() -> isCredentialsSupported()));
        add(passwordPanel);
    } catch (SchemaException e) {
        getSession().error("Cannot create panels for shadow, reason: " + e.getMessage());
        LOGGER.trace("Cannot create panels for shadow, reason: {}", e.getMessage(), e);
    }
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour)

Example 45 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project midpoint by Evolveum.

the class PrismValuePanel method createInputComponent.

private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
    ValueWrapper valueWrapper = valueWrapperModel.getObject();
    ObjectWrapper objectWrapper = null;
    if (valueWrapper.getItem().getContainer() != null) {
        objectWrapper = valueWrapper.getItem().getContainer().getObject();
    }
    Item property = valueWrapper.getItem().getItem();
    boolean required = property.getDefinition().getMinOccurs() > 0;
    Panel component = createTypedInputComponent(id);
    if (component instanceof InputPanel) {
        InputPanel inputPanel = (InputPanel) component;
        //adding valid from/to date range validator, if necessary
        ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
        if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
        } else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
        }
        final List<FormComponent> formComponents = inputPanel.getFormComponents();
        for (FormComponent formComponent : formComponents) {
            formComponent.setLabel(labelModel);
            formComponent.setRequired(required);
            if (formComponent instanceof TextField) {
                formComponent.add(new AttributeModifier("size", "42"));
            }
            formComponent.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
        // Validation occurs when submitting the form
        //            if (form != null) {
        //                AjaxFormValidatingBehavior validator = new AjaxFormValidatingBehavior(form, "Blur"); 
        //                 
        //                formComponent.add(validator);
        //            }
        }
    }
    if (component == null) {
        throw new RuntimeException("Cannot create input component for item " + property + " (" + valueWrapper + ") in " + objectWrapper);
    }
    return component;
}
Also used : DateValidator(com.evolveum.midpoint.web.util.DateValidator) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) FormComponent(org.apache.wicket.markup.html.form.FormComponent) DateTimeField(org.apache.wicket.extensions.yui.calendar.DateTimeField) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) ModificationsPanel(com.evolveum.midpoint.web.component.model.delta.ModificationsPanel) Panel(org.apache.wicket.markup.html.panel.Panel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

Panel (org.apache.wicket.markup.html.panel.Panel)76 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)27 ArrayList (java.util.ArrayList)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)16 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)16 Before (org.junit.Before)16 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)15 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)12 ResourceModel (org.apache.wicket.model.ResourceModel)11 DivTestPanel (org.odlabs.wiquery.ui.DivTestPanel)11 ItemPanelSettingsBuilder (com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder)10 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)10 List (java.util.List)9 Test (org.junit.Test)9 IModel (org.apache.wicket.model.IModel)8 Model (org.apache.wicket.model.Model)6 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)5 Label (org.apache.wicket.markup.html.basic.Label)5