Search in sources :

Example 96 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class TableConfigurationPanel method initLayout.

// @Override
protected void initLayout() {
    WebMarkupContainer cogButton = new WebMarkupContainer(ID_COG_BUTTON);
    cogButton.setOutputMarkupId(true);
    add(cogButton);
    WebMarkupContainer pageSize = new WebMarkupContainer(ID_PAGE_SIZE);
    pageSize.setOutputMarkupId(true);
    cogButton.add(pageSize);
    AjaxLink<Void> tableColumns = new AjaxLink<Void>(ID_TABLE_COLUMNS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            tableColumnsPerformed(target);
        }
    };
    cogButton.add(tableColumns);
    // todo implement [lazyman]
    tableColumns.setVisible(false);
    initPopoverLayout();
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 97 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class LinkIconPanel method initLayout.

private void initLayout(IModel<String> model, IModel<String> titleModel) {
    setOutputMarkupId(true);
    AjaxLink<Void> link = new AjaxLink<Void>(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    Label image = new Label(ID_IMAGE);
    image.add(AttributeModifier.replace("class", model));
    if (titleModel != null) {
        image.add(AttributeModifier.replace("title", titleModel));
    }
    link.add(image);
    link.setOutputMarkupId(true);
    add(link);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 98 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class PageAccountActivation method initLayout.

private void initLayout() {
    WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
    activationContainer.setOutputMarkupId(true);
    add(activationContainer);
    activationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !activated;
        }
    });
    Form<?> form = new MidpointForm<>(ID_MAIN_FORM);
    activationContainer.add(form);
    Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", userModel != null && userModel.getObject() != null && userModel.getObject().getName() != null ? getLocalizationService().translate(userModel.getObject().getName().toPolyString()) : ""));
    usernamePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return false;
        }
    });
    form.add(usernamePanel);
    PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
    form.add(passwordPanel);
    AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            propagatePassword(target, getForm());
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            getSession().error(getString("PageAccountActivation.account.activation.failed"));
            target.add(getFeedbackPanel());
        }
    };
    form.setDefaultButton(confirmPasswrod);
    form.add(confirmPasswrod);
    WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
    confirmationContainer.setOutputMarkupId(true);
    confirmationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return activated;
        }
    });
    add(confirmationContainer);
    AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    confirmationContainer.add(linkToLogin);
    RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
    confirmationContainer.add(activatedShadows);
    List<ShadowType> shadowsToActivate = getShadowsToActivate();
    if (shadowsToActivate.isEmpty()) {
        LOGGER.error("No accounts to validate for user {}", userModel.getObject());
        getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
        throw new RestartResponseException(PageLogin.class);
    }
    for (ShadowType shadow : shadowsToActivate) {
        Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
        activatedShadows.add(shadowDesc);
    }
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 99 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class PageRegistrationConfirmation method initLayout.

private void initLayout(final OperationResult result) {
    WebMarkupContainer successPanel = new WebMarkupContainer(ID_SUCCESS_PANEL);
    add(successPanel);
    successPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return result.getStatus() != OperationResultStatus.FATAL_ERROR;
        }

        @Override
        public boolean isEnabled() {
            return result.getStatus() != OperationResultStatus.FATAL_ERROR;
        }
    });
    Label successMessage = new Label(ID_LABEL_SUCCESS, createStringResource("PageRegistrationConfirmation.confirmation.successful"));
    successPanel.add(successMessage);
    AjaxLink<String> continueToLogin = new AjaxLink<String>(ID_LINK_LOGIN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    successPanel.add(continueToLogin);
    WebMarkupContainer errorPanel = new WebMarkupContainer(ID_ERROR_PANEL);
    add(errorPanel);
    errorPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return result.getStatus() == OperationResultStatus.FATAL_ERROR;
        }

        @Override
        public boolean isVisible() {
            return result.getStatus() == OperationResultStatus.FATAL_ERROR;
        }
    });
    Label errorMessage = new Label(ID_LABEL_ERROR, createStringResource("PageRegistrationConfirmation.confirmation.error"));
    errorPanel.add(errorMessage);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 100 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class ResourceContentTabPanel method initLayout.

protected void initLayout() {
    setOutputMarkupId(true);
    final Form mainForm = new MidpointForm(ID_MAIN_FORM);
    mainForm.setOutputMarkupId(true);
    mainForm.addOrReplace(initTable(getObjectWrapperModel()));
    add(mainForm);
    AutoCompleteTextPanel<String> intent = new AutoCompleteTextPanel<String>(ID_INTENT, new PropertyModel<>(resourceContentSearch, "intent"), String.class, false, null) {

        private static final long serialVersionUID = 1L;

        @Override
        public Iterator<String> getIterator(String input) {
            ResourceSchema refinedSchema;
            try {
                refinedSchema = ResourceSchemaFactory.getCompleteSchema(getObjectWrapper().getObject());
                if (refinedSchema != null) {
                    return refinedSchema.getIntentsForKind(getKind()).iterator();
                } else {
                    return Collections.emptyIterator();
                }
            } catch (SchemaException e) {
                return Collections.emptyIterator();
            }
        }
    };
    intent.getBaseFormComponent().add(WebComponentUtil.preventSubmitOnEnterKeyDownBehavior());
    intent.getBaseFormComponent().add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_REAL_OBJECT_CLASS));
            updateResourceContentSearch();
            mainForm.addOrReplace(initTable(getObjectWrapperModel()));
            target.add(mainForm);
        }
    });
    intent.setOutputMarkupId(true);
    intent.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isUseObjectClass();
        }
    });
    add(intent);
    Label realObjectClassLabel = new Label(ID_REAL_OBJECT_CLASS, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            ResourceObjectDefinition ocDef;
            try {
                ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(getObjectWrapper().getObject());
                if (refinedSchema == null) {
                    return "NO SCHEMA DEFINED";
                }
                ocDef = refinedSchema.findObjectDefinition(getKind(), getIntent());
                if (ocDef != null) {
                    return ocDef.getObjectClassDefinition().getTypeName().getLocalPart();
                }
            } catch (SchemaException e) {
            // TODO?
            }
            return "NOT FOUND";
        }
    });
    realObjectClassLabel.setOutputMarkupId(true);
    add(realObjectClassLabel);
    AutoCompleteQNamePanel objectClassPanel = new AutoCompleteQNamePanel(ID_OBJECT_CLASS, new PropertyModel<>(resourceContentSearch, "objectClass")) {

        private static final long serialVersionUID = 1L;

        @Override
        public Collection<QName> loadChoices() {
            return createObjectClassChoices(getObjectWrapperModel());
        }

        @Override
        protected void onChange(AjaxRequestTarget target) {
            LOGGER.trace("Object class panel update: {}", isUseObjectClass());
            updateResourceContentSearch();
            mainForm.addOrReplace(initTable(getObjectWrapperModel()));
            target.add(mainForm);
        }
    };
    objectClassPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isUseObjectClass();
        }
    });
    add(objectClassPanel);
    AjaxLink<Boolean> repoSearch = new AjaxLink<Boolean>(ID_REPO_SEARCH, new PropertyModel<>(resourceContentSearch, "resourceSearch")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            isRepoSearch = true;
            getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).setResourceSearch(Boolean.FALSE);
            getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setResourceSearch(Boolean.FALSE);
            resourceContentSearch.getObject().setResourceSearch(Boolean.FALSE);
            updateResourceContentSearch();
            mainForm.addOrReplace(initRepoContent(ResourceContentTabPanel.this.getObjectWrapperModel()));
            target.add(getParent().addOrReplace(mainForm));
            target.add(this);
            target.add(getParent().get(ID_RESOURCE_SEARCH).add(AttributeModifier.replace("class", "btn btn-sm btn-default")));
        }

        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            if (!getModelObject().booleanValue())
                add(AttributeModifier.replace("class", "btn btn-sm btn-default active"));
        }
    };
    add(repoSearch);
    AjaxLink<Boolean> resourceSearch = new AjaxLink<Boolean>(ID_RESOURCE_SEARCH, new PropertyModel<>(resourceContentSearch, "resourceSearch")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            isRepoSearch = false;
            getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_REPOSITORY_CONTENT).setResourceSearch(Boolean.TRUE);
            getContentStorage(kind, SessionStorage.KEY_RESOURCE_PAGE_RESOURCE_CONTENT).setResourceSearch(Boolean.TRUE);
            updateResourceContentSearch();
            resourceContentSearch.getObject().setResourceSearch(Boolean.TRUE);
            mainForm.addOrReplace(initResourceContent(ResourceContentTabPanel.this.getObjectWrapperModel()));
            target.add(getParent().addOrReplace(mainForm));
            target.add(this.add(AttributeModifier.append("class", " active")));
            target.add(getParent().get(ID_REPO_SEARCH).add(AttributeModifier.replace("class", "btn btn-sm btn-default")));
        }

        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            getModelObject().booleanValue();
            if (getModelObject().booleanValue())
                add(AttributeModifier.replace("class", "btn btn-sm btn-default active"));
        }
    };
    add(resourceSearch);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) QName(javax.xml.namespace.QName) Label(org.apache.wicket.markup.html.basic.Label) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) AutoCompleteQNamePanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)115 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)111 Label (org.apache.wicket.markup.html.basic.Label)64 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)62 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)58 IModel (org.apache.wicket.model.IModel)38 ListItem (org.apache.wicket.markup.html.list.ListItem)25 ListView (org.apache.wicket.markup.html.list.ListView)21 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)19 TextField (org.apache.wicket.markup.html.form.TextField)18 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)16 ArrayList (java.util.ArrayList)13 AttributeModifier (org.apache.wicket.AttributeModifier)13 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)12 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)11 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)10 List (java.util.List)9 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)8 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)8 Test (org.junit.Test)8