Example usage for org.apache.wicket.ajax.markup.html AjaxLink add

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink add.

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:com.doculibre.constellio.wicket.panels.results.tagging.SearchResultTaggingPanel.java

License:Open Source License

public SearchResultTaggingPanel(String id, final SolrDocument doc, final IDataProvider dataProviderParam) {
    super(id);//from   w w  w .  j  a va  2  s  .co m

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    final SimpleSearch simpleSearch;
    if (dataProviderParam instanceof FacetsDataProvider) {
        FacetsDataProvider dataProvider = (FacetsDataProvider) dataProviderParam;
        simpleSearch = dataProvider.getSimpleSearch();
    } else {
        SearchResultsDataProvider dataProvider = (SearchResultsDataProvider) dataProviderParam;
        simpleSearch = dataProvider.getSimpleSearch();
    }

    String collectionName = simpleSearch.getCollectionName();
    RecordCollection collection = collectionServices.get(collectionName);
    if (!collection.isOpenSearch()) {
        RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
        Record record = recordServices.get(doc);
        recordModel = new RecordModel(record);

        final ModalWindow taggingModal = new ModalWindow("taggingModal");
        taggingModal.setTitle(new StringResourceModel("tags", this, null));
        taggingModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        taggingModal.setInitialWidth(800);
        taggingModal.setInitialHeight(450);
        taggingModal.setCloseButtonCallback(new CloseButtonCallback() {
            @Override
            public boolean onCloseButtonClicked(AjaxRequestTarget target) {
                target.addComponent(SearchResultTaggingPanel.this);
                return true;
            }
        });
        add(taggingModal);

        IModel thesaurusListModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                List<Thesaurus> thesaurusList = new ArrayList<Thesaurus>();
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                String collectionName = simpleSearch.getCollectionName();
                RecordCollection collection = collectionServices.get(collectionName);
                thesaurusList.add(null);// free text tags
                if (collection.getThesaurus() != null) {
                    thesaurusList.add(collection.getThesaurus());
                }
                return thesaurusList;
            }
        };

        add(new ListView("taggingLinks", thesaurusListModel) {
            @Override
            protected void populateItem(ListItem item) {
                Thesaurus thesaurus = (Thesaurus) item.getModelObject();
                final ReloadableEntityModel<Thesaurus> thesaurusModel = new ReloadableEntityModel<Thesaurus>(
                        thesaurus);
                final String thesaurusName;
                if (thesaurus == null) {
                    thesaurusName = getLocalizer().getString("tags", this);
                } else {
                    thesaurusName = getLocalizer().getString("thesaurus", this);
                }

                AjaxLink link = new AjaxLink("taggingLink") {
                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Thesaurus thesaurus = thesaurusModel.getObject();
                        SearchResultEditTaggingPanel editTaggingPanel = new SearchResultEditTaggingPanel(
                                taggingModal.getContentId(), doc, dataProviderParam, thesaurus);
                        taggingModal.setContent(editTaggingPanel);
                        taggingModal.show(target);
                    }

                    @Override
                    public boolean isEnabled() {
                        boolean enabled = super.isEnabled();
                        if (enabled) {
                            Record record = recordModel.getObject();
                            if (record != null) {
                                ConstellioUser user = ConstellioSession.get().getUser();
                                if (user != null) {
                                    RecordCollection collection = record.getConnectorInstance()
                                            .getRecordCollection();
                                    enabled = user.hasCollaborationPermission(collection);
                                } else {
                                    enabled = false;
                                }
                            } else {
                                enabled = false;
                            }
                        }
                        return enabled;
                    }

                    @Override
                    public void detachModels() {
                        thesaurusModel.detach();
                        super.detachModels();
                    }
                };
                item.add(link);
                link.add(new Label("thesaurusName", thesaurusName));

                final IModel tagsModel = new LoadableDetachableModel() {
                    @Override
                    protected Object load() {
                        Record record = recordModel.getObject();
                        Thesaurus thesaurus = thesaurusModel.getObject();
                        return new ArrayList<RecordTag>(record.getIncludedRecordTags(thesaurus));
                    }
                };
                item.add(new ListView("tags", tagsModel) {
                    @SuppressWarnings("unchecked")
                    @Override
                    protected void populateItem(ListItem item) {
                        RecordTag recordTag = (RecordTag) item.getModelObject();
                        final RecordTagModel recordTagModel = new RecordTagModel(recordTag);
                        Link addTagLink = new Link("addTagLink") {
                            @Override
                            public void onClick() {
                                RecordTag recordTag = recordTagModel.getObject();
                                SimpleSearch clone = simpleSearch.clone();
                                clone.getTags().add(recordTag.getName(getLocale()));

                                PageFactoryPlugin pageFactoryPlugin = PluginFactory
                                        .getPlugin(PageFactoryPlugin.class);
                                if (StringUtils.isNotBlank(clone.getLuceneQuery())) {
                                    // ConstellioSession.get().addSearchHistory(clone);
                                    setResponsePage(pageFactoryPlugin.getSearchResultsPage(),
                                            SearchResultsPage.getParameters(clone));
                                } else {
                                    SimpleSearch newSearch = new SimpleSearch();
                                    newSearch.setCollectionName(simpleSearch.getCollectionName());
                                    newSearch.setSingleSearchLocale(simpleSearch.getSingleSearchLocale());
                                    setResponsePage(pageFactoryPlugin.getSearchFormPage(),
                                            SearchFormPage.getParameters(newSearch));
                                }
                            }

                            @Override
                            public void detachModels() {
                                recordTagModel.detach();
                                super.detachModels();
                            }
                        };
                        item.add(addTagLink);
                        List<RecordTag> recordTags = (List<RecordTag>) tagsModel.getObject();
                        String tag = recordTag.getName(getLocale());
                        if (item.getIndex() < recordTags.size() - 1) {
                            tag += ";";
                        }
                        addTagLink.add(new Label("tag", tag));
                        addTagLink.setEnabled(false);
                    }
                });
                item.add(new WebMarkupContainer("noTags") {
                    @SuppressWarnings("unchecked")
                    @Override
                    public boolean isVisible() {
                        List<RecordTag> recordTags = (List<RecordTag>) tagsModel.getObject();
                        return super.isVisible() && recordTags.isEmpty();
                    }
                });
            }
        });

    } else {
        setVisible(false);
    }
}

From source file:com.evolveum.midpoint.gui.api.component.password.PasswordPanel.java

License:Apache License

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly,
        boolean showRemoveButton) {
    setOutputMarkupId(true);/*from   w  ww.  j  a v  a  2 s. com*/

    passwordInputVisble = model.getObject() == null;
    // TODO: remove
    //       LOGGER.trace("PASSWORD model: {}", model.getObject());

    final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {
        @Override
        public boolean isVisible() {
            return passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    add(inputContainer);

    final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model));
    password1.setRequired(false);
    password1.setResetPassword(false);
    password1.setOutputMarkupId(true);
    password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password1);

    final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>());
    password2.setRequired(false);
    password2.setResetPassword(false);
    password2.setOutputMarkupId(true);
    password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password2);

    password1.add(new AjaxFormComponentUpdatingBehavior("change") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean required = !StringUtils.isEmpty(password1.getModel().getObject());
            password2.setRequired(required);
            //fix of MID-2463
            //            target.add(password2);
            //            target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()");
        }
    });
    password2.add(new PasswordValidator(password1, password2));

    final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {
        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    linkContainer.setOutputMarkupId(true);
    add(linkContainer);

    final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
    linkContainer.add(passwordSetLabel);

    final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE,
            new ResourceModel("passwordPanel.passwordRemoveLabel"));
    passwordRemoveLabel.setVisible(false);
    linkContainer.add(passwordRemoveLabel);

    AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            onLinkClick(target);
        }

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    link.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;

        }
    });
    link.setBody(new ResourceModel("passwordPanel.passwordChange"));
    link.setOutputMarkupId(true);
    linkContainer.add(link);

    final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
    AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            onRemovePassword(model, target);
        }

    };
    removePassword.setVisible(showRemoveButton);
    removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
    removePassword.setOutputMarkupId(true);
    removeButtonContainer.add(removePassword);
    add(removeButtonContainer);
}

From source file:com.evolveum.midpoint.gui.api.component.result.OperationResultPanel.java

License:Apache License

private void initHeader(WebMarkupContainer box) {
    WebMarkupContainer iconType = new WebMarkupContainer(ID_ICON_TYPE);
    iconType.setOutputMarkupId(true);/*from   w w  w.  j a v  a 2 s .c o  m*/
    iconType.add(new AttributeAppender("class", new AbstractReadOnlyModel<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());
            result.setAlreadyShown(false); // hack to be able to expand/collapse OpResult after rendered.
            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()) {
                return; // just for safety
            }
            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> showAll = new AjaxLink<String>(ID_SHOW_ALL) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(true, OperationResultPanel.this.getModelObject(), 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, OperationResultPanel.this.getModel().getObject(), 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 AbstractReadOnlyModel<File>() {
        private static final long serialVersionUID = 1L;

        @Override
        public File getObject() {
            String home = getPageBase().getMidpointConfiguration().getMidpointHome();
            File f = new File(home, "result");
            DataOutputStream dos = null;
            try {
                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);
            } finally {
                IOUtils.closeQuietly(dos);
            }

            return f;
        }

    });
    downloadXml.setDeleteAfterDownload(true);
    box.add(downloadXml);
}

From source file:com.evolveum.midpoint.gui.api.component.result.OperationResultPanel.java

License:Apache License

private void initError(WebMarkupContainer operationPanel, final IModel<OpResult> model, Page parentPage) {
    Label errorLabel = new Label("errorLabel", parentPage.getString("FeedbackAlertMessageDetails.error"));
    errorLabel.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override/*from   w  ww  .j av  a  2  s.c  o m*/
        public boolean isVisible() {
            // return true;
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());

        }
    });
    errorLabel.setOutputMarkupId(true);
    operationPanel.add(errorLabel);

    Label errorMessage = new Label("errorMessage", new PropertyModel<String>(model, "exceptionMessage"));
    errorMessage.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());

        }
    });
    errorMessage.setOutputMarkupId(true);
    operationPanel.add(errorMessage);

    final Label errorStackTrace = new Label(ID_ERROR_STACK_TRACE,
            new PropertyModel<String>(model, "exceptionsStackTrace"));
    errorStackTrace.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return model.getObject().isShowError();

        }
    });
    errorStackTrace.setOutputMarkupId(true);
    operationPanel.add(errorStackTrace);

    AjaxLink errorStackTraceLink = new AjaxLink("errorStackTraceLink") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowError(!model.getObject().isShowError());
            result.setAlreadyShown(false); // hack to be able to expand/collapse OpResult after rendered.
            //            model.getObject().setShowError(!model.getObject().isShowError());
            target.add(OperationResultPanel.this);
        }

    };
    errorStackTraceLink.setOutputMarkupId(true);
    errorStackTraceLink.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());

        }
    });
    operationPanel.add(errorStackTraceLink);

}

From source file:com.evolveum.midpoint.gui.api.page.PageBase.java

License:Apache License

private void initTitleLayout() {
    WebMarkupContainer pageTitleContainer = new WebMarkupContainer(ID_PAGE_TITLE_CONTAINER);
    pageTitleContainer.add(createUserStatusBehaviour(true));
    add(pageTitleContainer);//  w ww . j  av  a 2s . com

    WebMarkupContainer pageTitle = new WebMarkupContainer(ID_PAGE_TITLE);
    pageTitleContainer.add(pageTitle);
    Label pageTitleReal = new Label(ID_PAGE_TITLE_REAL, createPageTitleModel());
    pageTitleReal.setRenderBodyOnly(true);
    pageTitle.add(pageTitleReal);

    ListView breadcrumbs = new ListView<Breadcrumb>(ID_BREADCRUMB,
            new AbstractReadOnlyModel<List<Breadcrumb>>() {
                private static final long serialVersionUID = 1L;

                @Override
                public List<Breadcrumb> getObject() {
                    return getSessionStorage().getBreadcrumbs();
                }
            }) {

        @Override
        protected void populateItem(ListItem<Breadcrumb> item) {
            final Breadcrumb dto = item.getModelObject();

            AjaxLink bcLink = new AjaxLink(ID_BC_LINK) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    redirectBackToBreadcrumb(dto);
                }
            };
            item.add(bcLink);
            bcLink.add(new VisibleEnableBehaviour() {
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isEnabled() {
                    return dto.isUseLink();
                }
            });

            WebMarkupContainer bcIcon = new WebMarkupContainer(ID_BC_ICON);
            bcIcon.add(new VisibleEnableBehaviour() {
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return dto.getIcon() != null && dto.getIcon().getObject() != null;
                }
            });
            bcIcon.add(AttributeModifier.replace("class", dto.getIcon()));
            bcLink.add(bcIcon);

            Label bcName = new Label(ID_BC_NAME, dto.getLabel());
            bcLink.add(bcName);

            item.add(new VisibleEnableBehaviour() {
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return dto.isVisible();
                }
            });
        }
    };
    add(breadcrumbs);
}

From source file:com.evolveum.midpoint.web.component.assignment.ACAttributeValuePanel.java

License:Apache License

private void initPanel(Form form) {
    ACValueConstructionDto dto = getModel().getObject();
    PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
    boolean required = definition.getMinOccurs() > 0;

    InputPanel input = createTypedInputComponent(ID_INPUT, definition);
    for (FormComponent comp : input.getFormComponents()) {
        comp.setLabel(new PropertyModel(dto.getAttribute(), ACAttributeDto.F_NAME));
        comp.setRequired(required);//w  ww. j a v  a2s . c om

        comp.add(new AjaxFormComponentUpdatingBehavior("onBlur") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
            }
        });
    }

    add(input);

    AjaxLink addLink = new AjaxLink(ID_ADD) {

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

        @Override
        public boolean isVisible() {
            return isAddVisible();
        }
    });

    AjaxLink removeLink = new AjaxLink(ID_REMOVE) {

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

        @Override
        public boolean isVisible() {
            return isRemoveVisible();
        }
    });
}

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java

License:Apache License

private void initPanelLayout() {
    WebMarkupContainer headerRow = new WebMarkupContainer(ID_HEADER_ROW);
    headerRow.add(AttributeModifier.append("class", createHeaderClassModel(getModel())));
    headerRow.setOutputMarkupId(true);/*from w ww . j  av a2 s  . c  om*/
    add(headerRow);

    AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED,
            new PropertyModel<Boolean>(getModel(), AssignmentEditorDto.F_SELECTED)) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            //do we want to update something?
        }
    };
    headerRow.add(selected);

    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.add(AttributeModifier.replace("class", createImageTypeModel(
            new PropertyModel<AssignmentEditorDtoType>(getModel(), AssignmentEditorDto.F_TYPE))));
    headerRow.add(typeImage);

    AjaxLink name = new AjaxLink(ID_NAME) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(name);

    Label nameLabel = new Label(ID_NAME_LABEL,
            new PropertyModel<String>(getModel(), AssignmentEditorDto.F_NAME));
    name.add(nameLabel);

    Label activation = new Label(ID_ACTIVATION, createActivationModel());
    headerRow.add(activation);

    WebMarkupContainer main = new WebMarkupContainer(ID_MAIN);
    main.setOutputMarkupId(true);
    add(main);

    WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
    body.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
            return !editorDto.isMinimized();
        }
    });
    main.add(body);

    initBodyLayout(body);
}

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java

License:Apache License

private void initBodyLayout(WebMarkupContainer body) {
    TextArea description = new TextArea(ID_DESCRIPTION,
            new PropertyModel(getModel(), AssignmentEditorDto.F_DESCRIPTION));
    body.add(description);//  w  w  w.  j  a v  a2s .  co  m

    TextField relation = new TextField(ID_RELATION,
            new PropertyModel(getModel(), AssignmentEditorDto.F_RELATION));
    relation.setEnabled(false);
    body.add(relation);

    WebMarkupContainer activationBlock = new WebMarkupContainer(ID_ACTIVATION_BLOCK);
    activationBlock.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            //enabled activation in assignments for now.
            return true;
        }
    });
    body.add(activationBlock);

    DropDownChoicePanel administrativeStatus = WebMiscUtil.createActivationStatusPanel(ID_ADMINISTRATIVE_STATUS,
            new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "."
                    + ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()),
            this);
    activationBlock.add(administrativeStatus);

    DateInput validFrom = new DateInput(ID_VALID_FROM,
            createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
                    AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    activationBlock.add(validFrom);

    DateInput validTo = new DateInput(ID_VALID_TO,
            createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(),
                    AssignmentEditorDto.F_ACTIVATION + ".validTo")));
    activationBlock.add(validTo);
    WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER);
    targetContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return !AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION.equals(dto.getType());
        }
    });
    body.add(targetContainer);

    Label target = new Label(ID_TARGET, createTargetModel());
    targetContainer.add(target);

    WebMarkupContainer constructionContainer = new WebMarkupContainer(ID_CONSTRUCTION_CONTAINER);
    constructionContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION.equals(dto.getType());
        }
    });
    body.add(constructionContainer);

    AjaxLink showEmpty = new AjaxLink(ID_SHOW_EMPTY) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            showEmptyPerformed(target);
        }
    };
    constructionContainer.add(showEmpty);

    Label showEmptyLabel = new Label(ID_SHOW_EMPTY_LABEL, createShowEmptyLabel());
    showEmptyLabel.setOutputMarkupId(true);
    showEmpty.add(showEmptyLabel);

    initAttributesLayout(constructionContainer);

    addAjaxOnUpdateBehavior(body);
}

From source file:com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel.java

License:Apache License

@Override
protected void initHeaderRow() {
    PageBase pageBase = getPageBase();//w  ww  .j  a va2  s  . c o m
    if (delegatedToMe) {
        privilegesListModel = new LoadableModel<List<AssignmentInfoDto>>(false) {
            @Override
            protected List<AssignmentInfoDto> load() {
                return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList();
            }
        };
    }
    AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED,
            new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    selected.add(new VisibleEnableBehaviour() {
        @Override
        public boolean isVisible() {
            return !getModel().getObject().isSimpleView();
        }
    });
    headerRow.add(selected);
    Label arrowIcon = new Label(ID_ARROW_ICON);
    headerRow.add(arrowIcon);

    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
    headerRow.add(typeImage);

    AjaxLink name = new AjaxLink(ID_NAME) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(name);

    Label nameLabel;
    if (delegatedToMe) {
        OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME);
        Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME);
        nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils
                .resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result));
    } else {
        nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    }
    nameLabel.setOutputMarkupId(true);
    name.add(nameLabel);

    AssignmentEditorDto dto = getModelObject();
    dto.getTargetRef();

    WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
    if (delegatedToMe) {
        delegatedToTypeImage.add(AttributeModifier.append("class",
                WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject())));
    } else {
        if (getModelObject().getDelegationOwner() != null) {
            delegatedToTypeImage.add(AttributeModifier.append("class",
                    WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
        }
    }
    headerRow.add(delegatedToTypeImage);

    AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(delegatedToName);

    Label delegatedToNameLabel;
    if (delegatedToMe) {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL,
                pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    } else {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName());
    }
    delegatedToNameLabel.setOutputMarkupId(true);
    delegatedToName.add(delegatedToNameLabel);

    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND,
            GuiStyleConstants.CLASS_ICON_COLLAPSE) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !DelegationEditorPanel.this.getModelObject().isMinimized();
        }
    };
    headerRow.add(expandButton);
}

From source file:com.evolveum.midpoint.web.component.assignment.MultipleAssignmentSelector.java

License:Apache License

private void initLayout(PageBase pageBase) {
    setOutputMarkupId(true);/*from www .  j a  v a2s. c om*/

    WebMarkupContainer filterButtonContainer = new WebMarkupContainer(ID_FILTER_BUTTON_CONTAINER);
    AjaxLink<String> filterByUserButton = new AjaxLink<String>(ID_FILTER_BY_USER_BUTTON) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            if (showDialog) {
                labelValue = createStringResource("MultipleAssignmentSelector.filterByUser").getString();
                initUserDialog(createStringResource("MultipleAssignmentSelector.filterByUser"), target);
            }
            showDialog = true;
        }
    };
    filterButtonContainer.add(filterByUserButton);

    labelValue = pageBase.createStringResource("MultipleAssignmentSelector.filterByUser").getString();
    Label label = new Label(ID_LABEL, createLabelModel());
    label.setRenderBodyOnly(true);
    filterByUserButton.add(label);

    AjaxLink deleteButton = new AjaxLink(ID_DELETE_BUTTON) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            labelValue = createStringResource("MultipleAssignmentSelector.filterByUser").getString();
            showDialog = false;
            deleteFilterPerformed(target);
        }
    };
    filterByUserButton.add(deleteButton);
    add(filterButtonContainer);

    initSearchPanel();
    add(initTablePanel());
}