Search in sources :

Example 31 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class DeltaPanel method initLayout.

protected void initLayout() {
    Label changeType = new Label(ID_CHANGE_TYPE, new PropertyModel<String>(getModel(), DeltaDto.F_CHANGE_TYPE));
    add(changeType);
    VisibleEnableBehaviour isAdd = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModel().getObject().isAdd();
        }
    };
    VisibleEnableBehaviour isNotAdd = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isAdd();
        }
    };
    Label oidLabel = new Label(ID_OID_LABEL, new ResourceModel("DeltaPanel.label.oid"));
    oidLabel.add(isNotAdd);
    add(oidLabel);
    Label oid = new Label(ID_OID, new PropertyModel<String>(getModel(), DeltaDto.F_OID));
    oid.add(isNotAdd);
    add(oid);
    VisibleEnableBehaviour never = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return false;
        }
    };
    Label objectToAddLabel = new Label(ID_OBJECT_TO_ADD_LABEL, new ResourceModel("DeltaPanel.label.objectToAdd"));
    //objectToAddLabel.add(isAdd);
    objectToAddLabel.add(never);
    add(objectToAddLabel);
    ContainerValuePanel objectToAddPanel = new ContainerValuePanel(ID_OBJECT_TO_ADD, new PropertyModel<ContainerValueDto>(getModel(), DeltaDto.F_OBJECT_TO_ADD));
    objectToAddPanel.add(isAdd);
    add(objectToAddPanel);
    Label modificationsLabel = new Label(ID_MODIFICATIONS_LABEL, new ResourceModel("DeltaPanel.label.modifications"));
    //modificationsLabel.add(isNotAdd);
    modificationsLabel.add(never);
    add(modificationsLabel);
    ModificationsPanel modificationsPanel = new ModificationsPanel(ID_MODIFICATIONS, getModel());
    modificationsPanel.add(isNotAdd);
    add(modificationsPanel);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) ResourceModel(org.apache.wicket.model.ResourceModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 32 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class ModelOperationStatusPanel method initLayout.

protected void initLayout() {
    add(new Label(ID_STATE, new StringResourceModel("ModelOperationStatusPanel.state.${}", new PropertyModel<ModelState>(getModel(), ModelOperationStatusDto.F_STATE))));
    //        add(new Label(ID_FOCUS_TYPE, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_TYPE)));
    //        add(new Label(ID_FOCUS_NAME, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_NAME)));
    ScenePanel deltaPanel = new ScenePanel(ID_PRIMARY_DELTA, new PropertyModel<SceneDto>(getModel(), ModelOperationStatusDto.F_PRIMARY_DELTA));
    deltaPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject() != null && getModelObject().getPrimaryDelta() != null;
        }
    });
    add(deltaPanel);
}
Also used : ScenePanel(com.evolveum.midpoint.web.component.prism.show.ScenePanel) SceneDto(com.evolveum.midpoint.web.component.prism.show.SceneDto) Label(org.apache.wicket.markup.html.basic.Label) ModelState(com.evolveum.midpoint.model.api.context.ModelState) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 33 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initLayout.

private void initLayout(final PageBase page) {
    final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
    shadows.setOutputMarkupId(true);
    add(shadows);
    InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
    accountMenu.setVisible(!getObjectWrapper().isReadonly());
    shadows.add(accountMenu);
    final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
            PackageResourceReference packageRef;
            final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
            final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
            final Panel shadowPanel;
            if (dto.isLoadedOK()) {
                packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
                shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
            } else {
                shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onShowMorePerformed(AjaxRequestTarget target) {
                        OperationResult fetchResult = dto.getResult();
                        if (fetchResult != null) {
                            showResult(fetchResult);
                            target.add(page.getFeedbackPanel());
                        }
                    }
                };
            }
            shadowPanel.setOutputMarkupId(true);
            shadowPanel.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
                    ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
                    return !shadowWrapper.isMinimalized();
                }
            });
            item.add(shadowPanel);
            CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClickPerformed(AjaxRequestTarget target) {
                    super.onClickPerformed(target);
                    onExpandCollapse(target, item.getModel());
                    target.add(shadows);
                }
            };
            if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
                shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
            }
            item.add(shadowHeader);
        }
    };
    AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
                if (dto.isLoadedOK()) {
                    ObjectWrapper<ShadowType> accModel = dto.getObject();
                    accModel.setSelected(getModelObject());
                }
            }
            target.add(shadows);
        }
    };
    shadows.add(accountCheckAll);
    shadows.add(projectionList);
}
Also used : Serializable(java.io.Serializable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ImgResources(com.evolveum.midpoint.web.resource.img.ImgResources) ListView(org.apache.wicket.markup.html.list.ListView) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) Panel(org.apache.wicket.markup.html.panel.Panel) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 34 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class UploadDownloadPanel method initLayout.

private void initLayout(final boolean isReadOnly) {
    final FileUploadField fileUpload = new FileUploadField(ID_INPUT_FILE);
    Form form = this.findParent(Form.class);
    fileUpload.add(new AjaxFormSubmitBehavior(form, "change") {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            super.onSubmit(target);
            UploadDownloadPanel.this.uploadFilePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            super.onError(target);
            UploadDownloadPanel.this.uploadFilePerformed(target);
        }
    });
    fileUpload.setOutputMarkupId(true);
    add(fileUpload);
    final AjaxDownloadBehaviorFromStream downloadBehavior = new AjaxDownloadBehaviorFromStream() {

        @Override
        protected InputStream initStream() {
            return getStream();
        }
    };
    add(downloadBehavior);
    add(new AjaxSubmitButton(ID_BUTTON_DOWNLOAD) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            downloadPerformed(downloadBehavior, target);
        }
    });
    add(new AjaxSubmitButton(ID_BUTTON_DELETE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            removeFilePerformed(target);
        }
    });
    add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) Form(org.apache.wicket.markup.html.form.Form) AjaxDownloadBehaviorFromStream(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField)

Example 35 with VisibleEnableBehaviour

use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.

the class MainMenuPanel method initLayout.

private void initLayout() {
    final MainMenuItem menu = getModelObject();
    WebMarkupContainer item = new WebMarkupContainer(ID_ITEM);
    item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (menu.isMenuActive((WebPage) getPage())) {
                return "active";
            }
            for (MenuItem item : menu.getItems()) {
                if (item.isMenuActive((WebPage) getPage())) {
                    return "active";
                }
            }
            return !menu.getItems().isEmpty() ? "treeview" : null;
        }
    }));
    add(item);
    WebMarkupContainer link;
    if (menu.getPageClass() != null) {
        link = new AjaxLink(ID_LINK) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                mainMenuPerformed(menu);
            }
        };
    } else if (menu instanceof AdditionalMenuItem) {
        link = new AjaxLink(ID_LINK) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                additionalMenuPerformed(menu);
            }
        };
    } else {
        link = new WebMarkupContainer(ID_LINK);
    }
    item.add(link);
    WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
    icon.add(AttributeModifier.replace("class", new PropertyModel<>(menu, MainMenuItem.F_ICON_CLASS)));
    link.add(icon);
    Label label = new Label(ID_LABEL, menu.getNameModel());
    link.add(label);
    final PropertyModel<String> bubbleModel = new PropertyModel<>(menu, MainMenuItem.F_BUBBLE_LABEL);
    Label bubble = new Label(ID_BUBBLE, bubbleModel);
    bubble.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return bubbleModel.getObject() != null;
        }
    });
    link.add(bubble);
    WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW);
    arrow.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !menu.getItems().isEmpty() && bubbleModel.getObject() == null;
        }
    });
    link.add(arrow);
    WebMarkupContainer submenu = new WebMarkupContainer(ID_SUBMENU);
    submenu.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !menu.getItems().isEmpty();
        }
    });
    item.add(submenu);
    ListView<MenuItem> subItem = new ListView<MenuItem>(ID_SUB_ITEM, new Model((Serializable) menu.getItems())) {

        @Override
        protected void populateItem(ListItem<MenuItem> listItem) {
            createSubmenu(listItem);
        }
    };
    submenu.add(subItem);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Serializable(java.io.Serializable) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)183 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)116 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)101 Label (org.apache.wicket.markup.html.basic.Label)89 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)51 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)44 List (java.util.List)32 ListItem (org.apache.wicket.markup.html.list.ListItem)29 PropertyModel (org.apache.wicket.model.PropertyModel)29 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)26 ArrayList (java.util.ArrayList)25 Form (org.apache.wicket.markup.html.form.Form)25 ListView (org.apache.wicket.markup.html.list.ListView)25 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)23 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)19 AttributeModifier (org.apache.wicket.AttributeModifier)18 IModel (org.apache.wicket.model.IModel)17 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)16 TextField (org.apache.wicket.markup.html.form.TextField)16 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)15