Search in sources :

Example 86 with AjaxLink

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

the class NavigatorPanel method initLast.

private void initLast() {
    WebMarkupContainer last = new WebMarkupContainer(ID_LAST);
    last.add(new AttributeModifier("class", new IModel<String>() {

        @Override
        public String getObject() {
            return isLastEnabled() ? "" : "disabled";
        }
    }));
    add(last);
    AjaxLink<Void> lastLink = new AjaxLink<Void>(ID_LAST_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            lastPerformed(target);
        }
    };
    lastLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return !isCountingDisabled() && BooleanUtils.isTrue(showPageListingModel.getObject()) && isLastEnabled();
        }
    });
    last.add(lastLink);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 87 with AjaxLink

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

the class CapabilitiesPanel method createCapabilityButton.

private void createCapabilityButton(String id) {
    AjaxLink<Boolean> button = new AjaxLink<Boolean>(id, new PropertyModel<>(getModel(), id)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
        // TODO:
        }
    };
    button.add(new AttributeModifier("class", button.getModelObject() ? "btn btn-app btn-resource-capability bg-light-blue" : "btn btn-app btn-resource-capability bg-gray text-light-blue"));
    button.add(new Label("label", new ResourceModel("CapabilitiesType." + id)));
    add(button);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) ResourceModel(org.apache.wicket.model.ResourceModel) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeModifier(org.apache.wicket.AttributeModifier)

Example 88 with AjaxLink

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

the class SearchFilterConfigurationPanel method initLayout.

private void initLayout() {
    WebMarkupContainer aceEditorContainer = new WebMarkupContainer(ID_ACE_EDITOR_XML_CONTAINER);
    aceEditorContainer.setOutputMarkupId(true);
    IModel<String> classGridModel = () -> {
        if (containerWrapper != null) {
            return "col-md-10";
        }
        return "col-md-12";
    };
    aceEditorContainer.add(AttributeAppender.append("class", classGridModel));
    aceEditorContainer.add(AttributeAppender.append("style", (IModel<?>) () -> {
        if (FiledType.XML.equals(fieldType)) {
            return "display: block;";
        }
        return "display: none;";
    }));
    add(aceEditorContainer);
    AceEditorPanel aceEditorField = new AceEditorPanel(ID_ACE_EDITOR_XML_FIELD, null, new SearchFilterTypeForXmlModel(getModel(), getPageBase()), 10);
    aceEditorField.setOutputMarkupId(true);
    aceEditorContainer.add(aceEditorField);
    WebMarkupContainer textFieldContainer = new WebMarkupContainer(ID_TEXT_DNS_CONTAINER);
    textFieldContainer.setOutputMarkupId(true);
    textFieldContainer.add(new VisibleBehaviour(() -> FiledType.QUERY.equals(fieldType)));
    textFieldContainer.add(AttributeAppender.append("class", classGridModel));
    textFieldContainer.add(AttributeAppender.append("style", (IModel<?>) () -> {
        if (FiledType.QUERY.equals(fieldType)) {
            return "display: block;";
        }
        return "display: none;";
    }));
    add(textFieldContainer);
    TextPanel textPanel = new TextPanel(ID_TEXT_DNS_FIELD, new SearchFilterTypeForQueryModel<O>(getModel(), getPageBase(), filterTypeModel, containerWrapper != null));
    textPanel.setOutputMarkupId(true);
    textFieldContainer.add(textPanel);
    AjaxButton searchConfigurationButton = new AjaxButton(ID_CONFIGURE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchConfigurationPerformed(target);
        }
    };
    searchConfigurationButton.setOutputMarkupId(true);
    searchConfigurationButton.add(new VisibleBehaviour(() -> containerWrapper != null));
    add(searchConfigurationButton);
    IModel<String> labelModel = (IModel) () -> {
        if (FiledType.XML.equals(fieldType)) {
            return getPageBase().createStringResource(SearchBoxModeType.AXIOM_QUERY).getString();
        }
        return getPageBase().createStringResource("SearchFilterConfigurationPanel.fieldType.xml").getString();
    };
    Label buttonLabel = new Label(ID_FILED_TYPE_BUTTON_LABEL, labelModel);
    buttonLabel.setOutputMarkupId(true);
    AjaxLink filedTypeButton = new AjaxLink<String>(ID_FILED_TYPE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (FiledType.QUERY.equals(fieldType)) {
                fieldType = FiledType.XML;
            } else {
                fieldType = FiledType.QUERY;
            }
            target.add(getAceEditorContainer());
            target.add(getTextFieldContainer());
            target.add(getPageBase().getFeedbackPanel());
            target.add(buttonLabel);
        }
    };
    filedTypeButton.setOutputMarkupId(true);
    add(filedTypeButton);
    filedTypeButton.add(buttonLabel);
}
Also used : IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SearchFilterTypeForXmlModel(com.evolveum.midpoint.gui.impl.factory.panel.SearchFilterTypeForXmlModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 89 with AjaxLink

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

the class StageEditorPanel method initPanelLayout.

private void initPanelLayout() {
    AjaxLink<Void> name = new AjaxLink<Void>(ID_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    Label nameLabel = new Label(ID_NAME_LABEL, getModel().getObject().getName() == null || getModel().getObject().getName().trim().equals("") ? "Stage definition #" + getModel().getObject().getNumber() : getModel().getObject().getName());
    name.add(nameLabel);
    add(name);
}
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 90 with AjaxLink

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

the class OperationResultPanel method initHeader.

private void initHeader(WebMarkupContainer box) {
    WebMarkupContainer iconType = new WebMarkupContainer(ID_ICON_TYPE);
    iconType.setOutputMarkupId(true);
    iconType.add(new AttributeAppender("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            OpResult message = getModelObject();
            switch(message.getStatus()) {
                case IN_PROGRESS:
                case NOT_APPLICABLE:
                    sb.append(" fa-info");
                    break;
                case SUCCESS:
                    sb.append(" fa-check");
                    break;
                case FATAL_ERROR:
                    sb.append(" fa-ban");
                    break;
                case PARTIAL_ERROR:
                case UNKNOWN:
                case WARNING:
                case HANDLED_ERROR:
                default:
                    sb.append(" fa-warning");
            }
            return sb.toString();
        }
    }));
    box.add(iconType);
    Label message = createMessage();
    AjaxLink<String> showMore = new AjaxLink<String>(ID_MESSAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowMore(!result.isShowMore());
            // hack to be able to expand/collapse OpResult after rendered.
            result.setAlreadyShown(false);
            target.add(OperationResultPanel.this);
        }
    };
    showMore.add(message);
    box.add(showMore);
    AjaxLink<String> backgroundTask = new AjaxLink<String>(ID_BACKGROUND_TASK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getBackgroundTaskOid();
            if (oid == null || !opResult.isBackgroundTaskVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.TASK);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    backgroundTask.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getBackgroundTaskOid() != null && getModelObject().isBackgroundTaskVisible();
        }
    });
    box.add(backgroundTask);
    AjaxLink<String> aCase = new AjaxLink<String>(ID_CASE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getCaseOid();
            if (oid == null || !opResult.isCaseVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.CASE);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    aCase.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getCaseOid() != null && getModelObject().isCaseVisible();
        }
    });
    box.add(aCase);
    AjaxLink<String> showAll = new AjaxLink<String>(ID_SHOW_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(true, target);
        }
    };
    showAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(showAll);
    AjaxLink<String> hideAll = new AjaxLink<String>(ID_HIDE_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(false, target);
        }
    };
    hideAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(hideAll);
    AjaxLink<String> close = new AjaxLink<String>("close") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            close(target);
        }
    };
    box.add(close);
    DownloadLink downloadXml = new DownloadLink("downloadXml", new IModel<File>() {

        private static final long serialVersionUID = 1L;

        @Override
        public File getObject() {
            String home = getPageBase().getMidpointConfiguration().getMidpointHome();
            File f = new File(home, "result");
            try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(f))) {
                dos.writeBytes(OperationResultPanel.this.getModel().getObject().getXml());
            } catch (IOException e) {
                LOGGER.error("Could not download result: {}", e.getMessage(), e);
            }
            return f;
        }
    });
    downloadXml.add(new VisibleBehaviour(() -> getModelObject().isParent()));
    downloadXml.setDeleteAfterDownload(true);
    box.add(downloadXml);
}
Also used : DownloadLink(org.apache.wicket.markup.html.link.DownloadLink) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) DataOutputStream(java.io.DataOutputStream) Label(org.apache.wicket.markup.html.basic.Label) IOException(java.io.IOException) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FileOutputStream(java.io.FileOutputStream) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) File(java.io.File) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

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