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:org.apache.syncope.console.pages.Resources.java

License:Apache License

private void setupResources() {
    List<IColumn<ResourceTO, String>> columns = new ArrayList<IColumn<ResourceTO, String>>();

    columns.add(new PropertyColumn<ResourceTO, String>(new StringResourceModel("name", this, null), "name",
            "name"));

    columns.add(new AbstractColumn<ResourceTO, String>(
            new StringResourceModel("connector", this, null, "connector")) {

        private static final long serialVersionUID = 8263694778917279290L;

        @Override// w  w  w .  j av  a 2 s  . co m
        public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId,
                final IModel<ResourceTO> rowModel) {

            final AjaxLink<String> editLink = new ClearIndicatingAjaxLink<String>("link", getPageReference()) {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                protected void onClickInternal(final AjaxRequestTarget target) {

                    editConnectorWin.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ConnectorModalPage(Resources.this.getPageReference(), editConnectorWin,
                                    connectorRestClient.read(rowModel.getObject().getConnectorId()));
                        }
                    });

                    editConnectorWin.show(target);
                }
            };
            editLink.add(new Label("linkTitle", rowModel.getObject().getConnectorDisplayName()));

            LinkPanel editConnPanel = new LinkPanel(componentId);
            editConnPanel.add(editLink);

            cellItem.add(editConnPanel);

            MetaDataRoleAuthorizationStrategy.authorize(editConnPanel, ENABLE,
                    xmlRolesReader.getAllAllowedRoles("Connectors", "read"));
        }
    });

    columns.add(
            new PropertyColumn<ResourceTO, String>(new StringResourceModel("propagationPrimary", this, null),
                    "propagationPrimary", "propagationPrimary"));
    columns.add(
            new PropertyColumn<ResourceTO, String>(new StringResourceModel("propagationPriority", this, null),
                    "propagationPriority", "propagationPriority"));

    columns.add(new AbstractColumn<ResourceTO, String>(new StringResourceModel("actions", this, null, "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public String getCssClass() {
            return "action";
        }

        @Override
        public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId,
                final IModel<ResourceTO> model) {

            final ResourceTO resourceTO = model.getObject();

            final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());
            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    statusmodal.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ProvisioningModalPage<UserTO>(getPageReference(), statusmodal,
                                    model.getObject(), UserTO.class);
                        }
                    });

                    statusmodal.show(target);
                }
            }, ActionLink.ActionType.MANAGE_USERS, "Resources");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {

                    statusmodal.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ProvisioningModalPage<RoleTO>(getPageReference(), statusmodal,
                                    model.getObject(), RoleTO.class);
                        }
                    });

                    statusmodal.show(target);
                }
            }, ActionLink.ActionType.MANAGE_ROLES, "Resources");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    resourceTO.setUsyncToken(null);
                    resourceTO.setRsyncToken(null);
                    try {
                        resourceRestClient.update(resourceTO);
                        info(getString(Constants.OPERATION_SUCCEEDED));
                    } catch (SyncopeClientException e) {
                        error(getString(Constants.ERROR) + ":" + e.getMessage());

                        LOG.error("While resetting sync token from " + resourceTO.getName(), e);
                    }

                    feedbackPanel.refresh(target);
                    target.add(resourceContainer);
                }
            }, ActionLink.ActionType.RESET, "Resources");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    editResourceWin.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            return new ResourceModalPage(Resources.this.getPageReference(), editResourceWin,
                                    resourceTO, false);
                        }
                    });

                    editResourceWin.show(target);
                }
            }, ActionLink.ActionType.EDIT, "Resources");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    try {
                        resourceRestClient.delete(resourceTO.getName());
                        info(getString(Constants.OPERATION_SUCCEEDED));
                    } catch (SyncopeClientException e) {
                        error(getString(Constants.ERROR) + ": " + e.getMessage());

                        LOG.error("While deleting resource " + resourceTO.getName(), e);
                    }

                    feedbackPanel.refresh(target);
                    target.add(resourceContainer);
                }
            }, ActionLink.ActionType.DELETE, "Resources");

            cellItem.add(panel);
        }
    });

    final AjaxDataTablePanel<ResourceTO, String> table = new AjaxDataTablePanel<ResourceTO, String>(
            "resourceDatatable", columns, (ISortableDataProvider<ResourceTO, String>) new ResourcesProvider(),
            resourcePaginatorRows, Arrays.asList(new ActionLink.ActionType[] { ActionLink.ActionType.DELETE }),
            resourceRestClient, "name", "Resources", getPageReference());

    resourceContainer = new WebMarkupContainer("resourceContainer");
    resourceContainer.add(table);
    resourceContainer.setOutputMarkupId(true);

    add(resourceContainer);

    setWindowClosedCallback(createResourceWin, resourceContainer);
    setWindowClosedCallback(editResourceWin, resourceContainer);

    createResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    createResourceWin.setInitialHeight(WIN_HEIGHT);
    createResourceWin.setInitialWidth(WIN_WIDTH);
    createResourceWin.setCookieName("create-res-modal");

    editResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editResourceWin.setInitialHeight(WIN_HEIGHT);
    editResourceWin.setInitialWidth(WIN_WIDTH);
    editResourceWin.setCookieName("edit-res-modal");

    AjaxLink<Void> createResourceLink = new ClearIndicatingAjaxLink<Void>("createResourceLink",
            getPageReference()) {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        protected void onClickInternal(final AjaxRequestTarget target) {
            createResourceWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    final ResourceModalPage windows = new ResourceModalPage(Resources.this.getPageReference(),
                            editResourceWin, new ResourceTO(), true);
                    return windows;
                }
            });

            createResourceWin.show(target);
        }
    };

    MetaDataRoleAuthorizationStrategy.authorize(createResourceLink, ENABLE,
            xmlRolesReader.getAllAllowedRoles("Resources", "create"));

    add(createResourceLink);

    @SuppressWarnings("rawtypes")
    final Form paginatorForm = new Form("resourcePaginatorForm");

    @SuppressWarnings({ "unchecked", "rawtypes" })
    final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser",
            new PropertyModel(this, "resourcePaginatorRows"), prefMan.getPaginatorChoices());

    rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            prefMan.set(getRequest(), getResponse(), Constants.PREF_RESOURCES_PAGINATOR_ROWS,
                    String.valueOf(resourcePaginatorRows));

            table.setItemsPerPage(resourcePaginatorRows);
            target.add(resourceContainer);
        }
    });

    paginatorForm.add(rowsChooser);
    add(paginatorForm);
}

From source file:org.apache.syncope.console.pages.ResultStatusModalPage.java

License:Apache License

private ResultStatusModalPage(final Builder builder) {
    super();/*from   www.ja v  a 2 s .c o  m*/
    this.subject = builder.subject;
    statusUtils = new StatusUtils(this.userRestClient);
    if (builder.mode == null) {
        this.mode = UserModalPage.Mode.ADMIN;
    } else {
        this.mode = builder.mode;
    }

    final BaseModalPage page = this;

    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    final Fragment fragment = new Fragment("resultFrag",
            mode == UserModalPage.Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this);
    fragment.setOutputMarkupId(true);
    container.add(fragment);

    if (mode == UserModalPage.Mode.ADMIN) {
        // add Syncope propagation status
        PropagationStatus syncope = new PropagationStatus();
        syncope.setResource("Syncope");
        syncope.setStatus(PropagationTaskExecStatus.SUCCESS);

        List<PropagationStatus> propagations = new ArrayList<PropagationStatus>();
        propagations.add(syncope);
        propagations.addAll(subject.getPropagationStatusTOs());

        fragment.add(new Label("info",
                ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null)
                        ? ((UserTO) subject).getUsername()
                        : ((subject instanceof RoleTO) && ((RoleTO) subject).getName() != null)
                                ? ((RoleTO) subject).getName()
                                : String.valueOf(subject.getId())));

        final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) {

            private static final long serialVersionUID = -1020475259727720708L;

            @Override
            protected void populateItem(final ListItem<PropagationStatus> item) {
                final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject();

                final ListView attributes = getConnObjectView(propTO);

                final Fragment attrhead;
                if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) {
                    attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page);
                } else {
                    attrhead = new Fragment("attrhead", "attrHeadFrag", page);
                }

                item.add(attrhead);
                item.add(attributes);

                attrhead.add(new Label("resource", propTO.getResource()));

                attrhead.add(new Label("propagation",
                        propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString()));

                final Image image;
                final String alt, title;
                final ModalWindow failureWindow = new ModalWindow("failureWindow");
                final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") {

                    private static final long serialVersionUID = -7978723352517770644L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        failureWindow.show(target);
                    }
                };

                switch (propTO.getStatus()) {

                case SUCCESS:
                case SUBMITTED:
                case CREATED:
                    image = new Image("icon", IMG_STATUSES + Status.ACTIVE.toString() + Constants.PNG_EXT);
                    alt = "success icon";
                    title = "success";
                    failureWindow.setVisible(false);
                    failureWindowLink.setEnabled(false);
                    break;

                default:
                    image = new Image("icon", IMG_STATUSES + Status.SUSPENDED.toString() + Constants.PNG_EXT);
                    alt = "failure icon";
                    title = "failure";
                }

                image.add(new Behavior() {

                    private static final long serialVersionUID = 1469628524240283489L;

                    @Override
                    public void onComponentTag(final Component component, final ComponentTag tag) {
                        tag.put("alt", alt);
                        tag.put("title", title);
                    }
                });
                final FailureMessageModalPage executionFailureMessagePage;
                if (propTO.getFailureReason() == null) {
                    executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
                            StringUtils.EMPTY);
                } else {
                    executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
                            propTO.getFailureReason());
                }

                failureWindow.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return executionFailureMessagePage;
                    }
                });
                failureWindow.setCookieName("failureWindow");
                failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
                failureWindowLink.add(image);
                attrhead.add(failureWindowLink);
                attrhead.add(failureWindow);
            }
        };
        fragment.add(propRes);
    }

    final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            if (mode == UserModalPage.Mode.SELF && anonymousUser.equals(SyncopeSession.get().getUsername())) {
                SyncopeSession.get().invalidate();
            }
            builder.window.close(target);
        }
    };
    container.add(close);

    setOutputMarkupId(true);
}

From source file:org.apache.syncope.console.pages.SchemaModalPage.java

License:Apache License

@Override
public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, final SchemaTO schemaTO,
        final boolean createFlag) {

    final SchemaTO schema = schemaTO == null ? new SchemaTO() : schemaTO;

    final Form<SchemaTO> schemaForm = new Form<SchemaTO>(FORM);

    schemaForm.setModel(new CompoundPropertyModel<SchemaTO>(schema));
    schemaForm.setOutputMarkupId(true);// www .  j av a 2s.co  m

    final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"),
            new PropertyModel<String>(schema, "name"));
    name.addRequiredLabel();
    name.setEnabled(createFlag);
    schemaForm.add(name);

    final AjaxDropDownChoicePanel<AttributeSchemaType> type = new AjaxDropDownChoicePanel<AttributeSchemaType>(
            "type", getString("type"), new PropertyModel<AttributeSchemaType>(schema, "type"));
    type.setChoices(Arrays.asList(AttributeSchemaType.values()));
    type.addRequiredLabel();
    schemaForm.add(type);

    // -- long, double, date
    final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern",
            getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern"));
    schemaForm.add(conversionPattern);

    final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams");
    conversionParams.setOutputMarkupPlaceholderTag(true);
    conversionParams.add(conversionPattern);
    schemaForm.add(conversionParams);

    // -- enum
    final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues",
            new Model<String>(null));
    @SuppressWarnings({ "unchecked", "rawtypes" })
    final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<String>("enumerationValues",
            new Model(), enumerationValuesPanel);
    enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues()));

    @SuppressWarnings({ "unchecked", "rawtypes" })
    final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<String>("enumerationKeys", new Model(),
            new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null)));
    enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys()));

    final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams");
    enumParams.setOutputMarkupPlaceholderTag(true);
    enumParams.add(enumerationValues);
    enumParams.add(enumerationKeys);
    schemaForm.add(enumParams);

    // -- encrypted
    final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"),
            new PropertyModel<String>(schema, "secretKey"));

    final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<CipherAlgorithm>(
            "cipherAlgorithm", getString("cipherAlgorithm"),
            new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm"));
    cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values()));

    final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams");
    encryptedParams.setOutputMarkupPlaceholderTag(true);
    encryptedParams.add(secretKey);
    encryptedParams.add(cipherAlgorithm);
    schemaForm.add(encryptedParams);

    // -- binary
    final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"),
            new PropertyModel<String>(schema, "mimeType"));
    mimeType.setChoices(mimeTypesInitializer.getMimeTypes());

    final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams");
    binaryParams.setOutputMarkupPlaceholderTag(true);
    binaryParams.add(mimeType);
    schemaForm.add(binaryParams);

    // -- show or hide
    showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel,
            enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams,
            mimeType);
    type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            SchemaModalPage.this.showHide(schema, type, conversionParams, conversionPattern, enumParams,
                    enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey,
                    cipherAlgorithm, binaryParams, mimeType);
            target.add(schemaForm);
        }
    });

    final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() {

        private static final long serialVersionUID = 5275935387613157437L;

        @Override
        protected List<String> load() {
            return schemaRestClient.getAllValidatorClasses();
        }
    };
    final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<String>("validatorClass",
            getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass"));
    ((DropDownChoice) validatorClass.getField()).setNullValid(true);
    validatorClass.setChoices(validatorsList.getObject());
    schemaForm.add(validatorClass);

    final AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>(
            "mandatoryCondition") {

        private static final long serialVersionUID = -2428903969518079100L;

        @Override
        protected Iterator<String> getChoices(final String input) {
            List<String> choices = new ArrayList<String>();

            if (Strings.isEmpty(input)) {
                choices = Collections.emptyList();
            } else if ("true".startsWith(input.toLowerCase())) {
                choices.add("true");
            } else if ("false".startsWith(input.toLowerCase())) {
                choices.add("false");
            }

            return choices.iterator();
        }
    };
    mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
        }
    });
    schemaForm.add(mandatoryCondition);

    final WebMarkupContainer pwdJexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp");

    final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtil.getAjaxLink(pwdJexlHelp,
            "questionMarkJexlHelp");
    schemaForm.add(pwdQuestionMarkJexlHelp);
    pwdQuestionMarkJexlHelp.add(pwdJexlHelp);

    final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"),
            new PropertyModel<Boolean>(schema, "multivalue"));
    schemaForm.add(multivalue);

    final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"),
            new PropertyModel<Boolean>(schema, "readonly"));
    schemaForm.add(readonly);

    final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint",
            getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint"));
    schemaForm.add(uniqueConstraint);

    final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            final SchemaTO schemaTO = (SchemaTO) form.getDefaultModelObject();

            schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject()));
            schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject()));

            if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) {
                error(getString("multivalueAndUniqueConstr.validation"));
                feedbackPanel.refresh(target);
                return;
            }

            try {
                if (createFlag) {
                    schemaRestClient.createSchema(kind, schemaTO);
                } else {
                    schemaRestClient.updateSchema(kind, schemaTO);
                }
                if (pageRef.getPage() instanceof BasePage) {
                    ((BasePage) pageRef.getPage()).setModalResult(true);
                }

                window.close(target);
            } catch (SyncopeClientException e) {
                error(getString(Constants.ERROR) + ": " + e.getMessage());
                feedbackPanel.refresh(target);
            }
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };
    schemaForm.add(submit);

    final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    };
    cancel.setDefaultFormProcessing(false);
    schemaForm.add(cancel);

    String allowedRoles = createFlag ? xmlRolesReader.getAllAllowedRoles("Schema", "create")
            : xmlRolesReader.getAllAllowedRoles("Schema", "update");

    MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles);

    add(schemaForm);
}

From source file:org.apache.syncope.console.SyncopeApplication.java

License:Apache License

public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) {
    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    page.add(editProfileModalWin);//from   www  .java 2  s  .c o m

    final AjaxLink<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {
            final UserTO userTO = SyncopeSession.get().isAuthenticated() ? userSelfRestClient.read()
                    : new UserTO();

            editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO);
                }
            });

            editProfileModalWin.show(target);
        }
    };

    editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));

    if ("admin".equals(SyncopeSession.get().getUsername())) {
        editProfileLink.setEnabled(false);
    }

    page.add(editProfileLink);
}

From source file:org.artifactory.webapp.wicket.page.build.tabs.PublishedModulesTabPanel.java

License:Open Source License

/**
 * Returns a link that redirects to the module info
 *
 * @param componentId ID to assign to the link
 * @param moduleId    ID of module to display
 * @return Module redirection link/* w w w . j  av  a  2  s  .co m*/
 */
private AjaxLink getModuleNameLink(String componentId, final String moduleId) {
    AjaxLink link = new AjaxLink<String>(componentId, Model.of(moduleId)) {

        @Override
        public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            replaceComponentTagBody(markupStream, openTag, moduleId);
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            PageParameters pageParameters = new PageParameters();
            pageParameters.set(BUILD_NAME, build.getName());
            pageParameters.set(BUILD_NUMBER, build.getNumber());
            pageParameters.set(BUILD_STARTED, build.getStarted());
            pageParameters.set(MODULE_ID, moduleId);
            setResponsePage(BuildBrowserRootPage.class, pageParameters);
        }
    };
    link.add(new CssClass("item-link"));
    return link;
}

From source file:org.cast.cwm.tag.component.TagList.java

License:Open Source License

public TagList(String id, final PersistedObject target, final User student) {
    super(id);//ww  w.j av a 2s. c o  m
    this.setOutputMarkupId(true);
    this.target = target;
    this.user = student == null ? CwmSession.get().getUser() : student;

    RefreshingView<Tag> list = new RefreshingView<Tag>("tag") {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        @Override
        protected Iterator getItemModels() {
            allUserTags = TagService.get().tagsForUser(user);

            List<Tag> tags = new ArrayList<Tag>(allUserTags);
            for (Tagging ting : TagService.get().taggingsForTarget(user, target)) {
                tags.remove(ting.getTag());
            }

            return new ModelIteratorAdapter<Tag>(tags.iterator()) {

                @Override
                protected IModel<Tag> model(Tag object) {
                    return new CompoundPropertyModel(object);
                }
            };
        }

        @Override
        protected void populateItem(Item<Tag> item) {
            final Tag t = item.getModelObject();
            AjaxLink<Void> link = new AjaxLink<Void>("link") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget ajaxtarget) {
                    TagService.get().findTaggingCreate(user, target, t.getName());
                    ajaxtarget.add(TagList.this);
                    ajaxtarget.addChildren(findParent(TagPanel.class), TaggingsListPanel.class);
                }
            };
            link.setEnabled(student == null);
            item.add(link);
            link.add(new TagLabel("name", t));
        }
    };
    add(list);
}

From source file:org.dcm4chee.web.war.ae.AEListPanel.java

License:LGPL

@SuppressWarnings("unchecked")
public AEListPanel(String id) {
    super(id);/*  ww  w . ja  v a 2 s.c o m*/

    if (AEListPanel.CSS != null)
        add(CSSPackageResource.getHeaderContribution(AEListPanel.CSS));

    add(modalWindow = new ModalWindow("modal-window"));

    setOutputMarkupId(true);
    dicomEchoWindow = new DicomEchoWindow("echoPanel", true);
    dicomEchoWindow.setWindowClosedCallback(new WindowClosedCallback() {

        private static final long serialVersionUID = 1L;

        public void onClose(AjaxRequestTarget target) {
            target.addComponent(AEListPanel.this);
        }
    });
    add(dicomEchoWindow);
    dicomEchoWindow.add(new SecurityBehavior(getModuleName() + ":dicomEchoWindow"));

    confirm = new ConfirmationWindow<AE>("confirm") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfirmation(AjaxRequestTarget target, AE ae) {
            removeAE(ae);
            AEListPanel.this.setOutputMarkupId(true);
            target.addComponent(AEListPanel.this);
        }
    };
    confirm.setInitialHeight(150);
    add(confirm);

    int[] winSize = WebCfgDelegate.getInstance().getWindowSize("aeEdit");
    ModalWindowLink newAET = new ModalWindowLink("newAET", modalWindow, winSize[0], winSize[1]) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            modalWindow.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = 1L;

                @Override
                public Page createPage() {
                    return new CreateOrEditAETPage(modalWindow, new AE(), AEListPanel.this);
                }
            });
            super.onClick(target);
        }
    };
    newAET.add(new Image("newAETImg", ImageManager.IMAGE_COMMON_ADD)
            .add(new ImageSizeBehaviour("vertical-align: middle;")));
    newAET.add(new TooltipBehaviour("ae."));
    newAET.add(new Label("newAETText", new ResourceModel("ae.newAET.text"))
            .add(new AttributeModifier("style", true, new Model<String>("vertical-align: middle"))));
    add(newAET);
    newAET.add(new SecurityBehavior(getModuleName() + ":newAETLink"));

    BaseForm form = new BaseForm("form");
    add(form);
    String aeManagementDefault = WebCfgDelegate.getInstance().getAEManagementDefault();

    Set<String> aetTypeSet = new LinkedHashSet<String>();
    AEHomeLocal aeHome = (AEHomeLocal) JNDIUtils.lookup(AEHomeLocal.JNDI_NAME);
    aetTypeSet.add("<NONE>");
    aetTypeSet.addAll(aeHome.listAeTypes());
    aetTypeSet.addAll(WebCfgDelegate.getInstance().getAETTypes());
    aetTypeSet.addAll(AELicenseProviderManager.get(null).getProvider()
            .getAETypes(WebCfgDelegate.getInstance().getAETTypes()));
    aetTypeSet.remove(null);
    List<String> aetTypes = new ArrayList<String>(aetTypeSet);

    if (!"ANY".equals(aeManagementDefault) && !"NONE".equals(aeManagementDefault))
        typeSelectionModel.setObject(aeManagementDefault);

    form.addComponent(new Label("type.filter.label",
            new StringResourceModel("ae.type.filter.label", AEListPanel.this, null, new Object[] { 1 })));
    DropDownChoice<String> typeSelection = form.addDropDownChoice("type-selection", typeSelectionModel,
            new Model<ArrayList<String>>(new ArrayList<String>(aetTypes)), null, false);
    typeSelection.setNullValid(true).add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            offset = 0;
            updateAETList();
            target.addComponent(AEListPanel.this);
        }
    });

    form.addComponent(new Label("titleSearch.label", new ResourceModel("ae.search.title.label")));
    form.addComponent(new TextField<String>("titleSearch", title));

    AjaxButton searchBtn = new AjaxButton("searchBtn") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) {
            offset = 0;
            updateAETList();
            target.addComponent(AEListPanel.this);
        }
    };
    searchBtn.add(new Image("searchImg", ImageManager.IMAGE_COMMON_SEARCH)
            .add(new ImageSizeBehaviour("vertical-align: middle;")));
    searchBtn.add(new Label("searchText", new ResourceModel("ae.searchBtn.text"))
            .add(new AttributeModifier("style", true, new Model<String>("vertical-align: middle;")))
            .setOutputMarkupId(true));
    form.addComponent(searchBtn);
    form.setDefaultButton(searchBtn);

    form.addComponent(new Label("pagesize.label", new ResourceModel("ae.pagesize.label")));
    form.addDropDownChoice("pagesize", pagesize,
            new Model<ArrayList<Integer>>(
                    new ArrayList<Integer>(WebCfgDelegate.getInstance().getPagesizeList())),
            null, false).setNullValid(false).add(new AjaxFormComponentUpdatingBehavior("onchange") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    offset = 0;
                    updateAETList();
                    target.addComponent(AEListPanel.this);
                }
            });
    form.addComponent(new Link<Object>("prev") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            offset = Math.max(0, offset - pagesize.getObject());
            updateAETList();
        }

        @Override
        public boolean isVisible() {
            return offset > 0;
        }
    }.add(new Image("prevImg", ImageManager.IMAGE_COMMON_BACK)
            .add(new ImageSizeBehaviour("vertical-align: middle;")).add(new TooltipBehaviour("ae.search."))));

    form.addComponent(new Link<Object>("next") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            offset = offset + pagesize.getObject();
            updateAETList();
        }

        @Override
        public boolean isVisible() {
            return total > -1 && total - offset > pagesize.getObject();
        }
    }.add(new Image("nextImg", ImageManager.IMAGE_COMMON_FORWARD)
            .add(new ImageSizeBehaviour("vertical-align: middle;")).add(new TooltipBehaviour("ae.search."))));

    //viewport label: use StringResourceModel with key substitution to select 
    //property key according notSearched and getTotal.
    Model<?> keySelectModel = new Model<Serializable>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Serializable getObject() {
            return total < 0 ? "ae.search.notSearched" : total == 0 ? "ae.search.noMatch" : "ae.search.found";
        }
    };
    form.addComponent(new Label("viewport",
            new StringResourceModel("${}", AEListPanel.this, keySelectModel, new Object[] { "dummy" }) {

                private static final long serialVersionUID = 1L;

                @Override
                protected Object[] getParameters() {
                    return new Object[] { offset + 1, Math.min(offset + pagesize.getObject(), total), total };
                }
            }).setEscapeModelStrings(false));

    add(new Label("titleHdr.label", new ResourceModel("ae.titleHdr.label")));
    add(new Label("typeHdr.label", new ResourceModel("ae.typeHdr.label")));
    add(new Label("hostHdr.label", new ResourceModel("ae.hostHdr.label")));
    add(new Label("portHdr.label", new ResourceModel("ae.portHdr.label")));
    add(new Label("descriptionHdr.label", new ResourceModel("ae.descriptionHdr.label")));
    add(new Label("cipherHdr.label", new ResourceModel("ae.cipherHdr.label")));
    add(new Label("emulatedHdr.label", new ResourceModel("ae.emulatedHdr.label")));
    add(new Label("stationHdr.label", new ResourceModel("ae.stationHdr.label")));
    add(new Label("institutionHdr.label", new ResourceModel("ae.institutionHdr.label")));
    add(new Label("departmentHdr.label", new ResourceModel("ae.departmentHdr.label")));

    final List<AETGroup> aetGroups = ((UserAccess) JNDIUtils.lookup(UserAccess.JNDI_NAME)).getAllAETGroups();
    add((list = new PropertyListView<AE>("list") {

        private static final long serialVersionUID = 1L;

        @Override
        protected ListItem<AE> newItem(final int index) {
            return new OddEvenListItem<AE>(index, getListItemModel(getModel(), index));
        }

        @Override
        protected void populateItem(final ListItem<AE> item) {
            StringBuffer tooltip = new StringBuffer();
            String name = item.getModelObject().getTitle();
            for (AETGroup aetGroup : aetGroups)
                if (aetGroup.getAets().contains(name))
                    tooltip.append(aetGroup.getGroupname()).append(" ");
            item.add(new Label("title")
                    .add(new AttributeModifier("title", true, new Model<String>(tooltip.toString()))));
            item.add(new Label("aeGroup"));
            item.add(new Label("hostName"));
            item.add(new Label("port"));
            item.add(new Label("description", new Model<String>(item.getModelObject().getDescription())));
            CheckBox cipherSuites = new CheckBox("cipherSuites");
            cipherSuites.setModel(new Model<Boolean>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Boolean getObject() {
                    for (String cipher : item.getModelObject().getCipherSuites())
                        if (!cipher.equals("-"))
                            return true;
                    return false;
                }
            });
            cipherSuites.setEnabled(false);
            item.add(cipherSuites);
            item.add(new CheckBox("emulated", new AbstractReadOnlyModel<Boolean>() {
                private static final long serialVersionUID = 1L;

                @Override
                public Boolean getObject() {
                    return getMppsEmulatedAETs().contains(item.getModelObject().getTitle());
                }
            }).setEnabled(false));
            item.add(new Label("stationName"));
            item.add(new Label("institution"));
            item.add(new Label("department"));

            int[] winSize = WebCfgDelegate.getInstance().getWindowSize("aeEdit");
            item.add(new ModalWindowLink("editAET", modalWindow, winSize[0], winSize[1]) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    modalWindow.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public Page createPage() {
                            return new CreateOrEditAETPage(modalWindow, item.getModelObject(),
                                    AEListPanel.this);
                        }
                    });
                    super.onClick(target);
                }
            }.add(new Image("ae.editAET.image", ImageManager.IMAGE_AE_EDIT)
                    .add(new ImageSizeBehaviour("vertical-align: middle;"))).add(new TooltipBehaviour("ae."))
                    .add(new SecurityBehavior(getModuleName() + ":editAETLink")));

            AjaxLink<?> removeAET = new AjaxLink<Object>("removeAET") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    confirm.confirm(target, new StringResourceModel("ae.confirmDelete", AEListPanel.this, null,
                            new Object[] { item.getModelObject() }), item.getModelObject());
                }
            };
            removeAET.add(new Image("ae.removeAET.image", ImageManager.IMAGE_COMMON_REMOVE)
                    .add(new ImageSizeBehaviour()));
            removeAET.add(new TooltipBehaviour("ae."));
            item.add(removeAET);
            removeAET.add(new SecurityBehavior(getModuleName() + ":removeAETLink"));

            item.add(new AjaxLink<Object>("echo") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    dicomEchoWindow.show(target, item.getModelObject());
                }
            }.add(new Image("ae.echoAET.image", ImageManager.IMAGE_AE_ECHO).add(new ImageSizeBehaviour()))
                    .add(new TooltipBehaviour("ae."))
                    .add(new SecurityBehavior(getModuleName() + ":dicomEchoLink")));
        }
    }));
    if (!"NONE".equals(aeManagementDefault)) {
        updateAETList();
    }
}

From source file:org.dcm4chee.web.war.tc.TCViewOverviewTab.java

License:LGPL

@SuppressWarnings("serial")
public TCViewOverviewTab(final String id, IModel<TCEditableObject> model,
        TCAttributeVisibilityStrategy attrVisibilityStrategy) {
    super(id, model, attrVisibilityStrategy);

    tcId = getTC().getId();//from w  ww  .  jav  a  2s . com

    AttributeModifier readonlyModifier = new AttributeAppender("readonly", true, new Model<String>("readonly"),
            " ") {
        @Override
        public boolean isEnabled(Component component) {
            return !isEditing();
        }
    };

    // TITLE
    final WebMarkupContainer titleRow = new WebMarkupContainer("tc-view-overview-title-row");
    titleRow.add(new Label("tc-view-overview-title-label", new InternalStringResourceModel("tc.title.text")));
    titleRow.add(new SelfUpdatingTextField("tc-view-overview-title-text", new Model<String>() {
        @Override
        public String getObject() {
            if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Title)) {
                return TCUtilities.getLocalizedString("tc.case.text") + " " + getTC().getId();
            }
            return getStringValue(TCQueryFilterKey.Title);
        }

        @Override
        public void setObject(String text) {
            if (isEditing()) {
                getTC().setTitle(text);
            }
        }
    }).add(readonlyModifier));

    // ABSTRACT
    final WebMarkupContainer abstractRow = new WebMarkupContainer("tc-view-overview-abstract-row");
    abstractRow.add(
            new Label("tc-view-overview-abstract-label", new InternalStringResourceModel("tc.abstract.text")));
    abstractRow.add(new SelfUpdatingTextArea("tc-view-overview-abstract-area", new Model<String>() {
        @Override
        public String getObject() {
            if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Abstract)) {
                return TCUtilities.getLocalizedString("tc.obfuscation.text");
            }
            return getStringValue(TCQueryFilterKey.Abstract);
        }

        @Override
        public void setObject(String text) {
            if (isEditing()) {
                getTC().setAbstract(text);
            }
        }
    }).add(readonlyModifier).setOutputMarkupId(true).setMarkupId("tc-view-overview-abstract-area"));

    // URL
    final WebMarkupContainer urlRow = new WebMarkupContainer("tc-view-overview-url-row");
    urlRow.add(new WebMarkupContainer("tc-view-overview-url-label")
            .add(new ExternalLink("tc-view-url-link", getTC().getURL())
                    .add(new Label("tc-view-url-link-title", new InternalStringResourceModel("tc.url.text")))
                    .add(new Image("tc-view-url-link-follow-image", ImageManager.IMAGE_TC_EXTERNAL))
                    .add(new TCToolTipAppender("tc.case.url.text"))));
    urlRow.add(new TextArea<String>("tc-view-overview-url-text", new Model<String>() {
        @Override
        public String getObject() {
            TCObject tc = getTC();
            return tc != null ? tc.getURL() : null;
        }
    }).add(new AttributeAppender("readonly", true, new Model<String>("readonly"), " ")));

    // AUTHOR NAME
    final WebMarkupContainer authorNameRow = new WebMarkupContainer("tc-view-overview-authorname-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorName);
        }
    };
    authorNameRow.add(new Label("tc-view-overview-authorname-label",
            new InternalStringResourceModel("tc.author.name.text")));
    authorNameRow.add(new SelfUpdatingTextField("tc-view-overview-authorname-text", new Model<String>() {
        @Override
        public String getObject() {
            if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorName)) {
                return TCUtilities.getLocalizedString("tc.obfuscation.text");
            }
            return getStringValue(TCQueryFilterKey.AuthorName);
        }

        @Override
        public void setObject(String text) {
            if (isEditing()) {
                getTC().setAuthorName(text);
            }
        }
    }).add(readonlyModifier));

    // AUTHOR AFFILIATION
    final WebMarkupContainer authorAffiliationRow = new WebMarkupContainer(
            "tc-view-overview-authoraffiliation-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorAffiliation);
        }
    };
    authorAffiliationRow.add(new Label("tc-view-overview-authoraffiliation-label",
            new InternalStringResourceModel("tc.author.affiliation.text")));
    authorAffiliationRow
            .add(new SelfUpdatingTextField("tc-view-overview-authoraffiliation-text", new Model<String>() {
                @Override
                public String getObject() {
                    if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorAffiliation)) {
                        return TCUtilities.getLocalizedString("tc.obfuscation.text");
                    }
                    return getStringValue(TCQueryFilterKey.AuthorAffiliation);
                }

                @Override
                public void setObject(String text) {
                    if (isEditing()) {
                        getTC().setAuthorAffiliation(text);
                    }
                }
            }).add(readonlyModifier));

    // AUTHOR CONTACT
    final WebMarkupContainer authorContactRow = new WebMarkupContainer("tc-view-overview-authorcontact-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorContact);
        }
    };
    authorContactRow.add(new Label("tc-view-overview-authorcontact-label",
            new InternalStringResourceModel("tc.author.contact.text")));
    authorContactRow.add(new SelfUpdatingTextArea("tc-view-overview-authorcontact-area", new Model<String>() {
        @Override
        public String getObject() {
            if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorContact)) {
                return TCUtilities.getLocalizedString("tc.obfuscation.text");
            }
            return getStringValue(TCQueryFilterKey.AuthorContact);
        }

        @Override
        public void setObject(String text) {
            if (isEditing()) {
                getTC().setAuthorContact(text);
            }
        }
    }).add(readonlyModifier));

    // KEYWORDS
    final boolean keywordCodeInput = isEditing()
            && TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Keyword);
    final KeywordsListModel keywordsModel = new KeywordsListModel();
    final WebMarkupContainer keywordCodesContainer = new WebMarkupContainer(
            "tc-view-overview-keyword-input-container");
    final ListView<ITextOrCode> keywordCodesView = new ListView<ITextOrCode>(
            "tc-view-overview-keyword-input-view", keywordsModel) {
        @Override
        protected void populateItem(final ListItem<ITextOrCode> item) {
            final int index = item.getIndex();

            AjaxLink<String> addBtn = new AjaxLink<String>("tc-view-overview-keyword-input-add") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    keywordsModel.addKeyword();
                    target.addComponent(keywordCodesContainer);
                }
            };
            addBtn.add(new Image("tc-view-overview-keyword-input-add-img", ImageManager.IMAGE_COMMON_ADD)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")));
            addBtn.add(new TooltipBehaviour("tc.view.overview.keyword.", "add"));
            addBtn.setOutputMarkupId(true);
            addBtn.setVisible(index == 0);

            AjaxLink<String> removeBtn = new AjaxLink<String>("tc-view-overview-keyword-input-remove") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    keywordsModel.removeKeyword(item.getModelObject());
                    target.addComponent(keywordCodesContainer);
                }
            };
            removeBtn.add(new Image("tc-view-overview-keyword-input-remove-img", ImageManager.IMAGE_TC_CANCEL)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")));
            removeBtn.add(new TooltipBehaviour("tc.view.overview.keyword.", "remove"));
            removeBtn.setOutputMarkupId(true);
            removeBtn.setVisible(index > 0);

            TCInput keywordInput = TCUtilities.createInput("tc-view-overview-keyword-input",
                    TCQueryFilterKey.Keyword, item.getModelObject(), false);
            keywordInput.addChangeListener(new ValueChangeListener() {
                @Override
                public void valueChanged(ITextOrCode[] values) {
                    keywordsModel.setKeywordAt(index, values != null && values.length > 0 ? values[0] : null);
                }
            });

            item.setOutputMarkupId(true);
            item.add(keywordInput.getComponent());
            item.add(addBtn);
            item.add(removeBtn);

            if (index > 0) {
                item.add(new AttributeModifier("style", true,
                        new Model<String>("border-top: 4px solid transparent")) {
                    @Override
                    protected String newValue(String currentValue, String newValue) {
                        if (currentValue == null) {
                            return newValue;
                        } else if (newValue == null) {
                            return currentValue;
                        } else {
                            return currentValue + ";" + newValue;
                        }
                    }
                });
            }
        }
    };
    keywordCodesView.setOutputMarkupId(true);
    keywordCodesContainer.setOutputMarkupId(true);
    keywordCodesContainer.setVisible(isEditing());
    keywordCodesContainer.add(keywordCodesView);
    final WebMarkupContainer keywordRow = new WebMarkupContainer("tc-view-overview-keyword-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Keyword);
        }
    };
    keywordRow.add(
            new Label("tc-view-overview-keyword-label", new InternalStringResourceModel("tc.keyword.text")));
    keywordRow.add(keywordCodesContainer);
    keywordRow.add(new SelfUpdatingTextArea("tc-view-overview-keyword-area", new Model<String>() {
        @Override
        public String getObject() {
            if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Keyword)) {
                return TCUtilities.getLocalizedString("tc.obfuscation.text");
            }
            return getShortStringValue(TCQueryFilterKey.Keyword);
        }

        @Override
        public void setObject(String text) {
            if (isEditing()) {
                String[] strings = text != null ? text.trim().split(";") : null;
                List<ITextOrCode> keywords = null;

                if (strings != null && strings.length > 0) {
                    keywords = new ArrayList<ITextOrCode>(strings.length);
                    for (String s : strings) {
                        keywords.add(TextOrCode.text(s));
                    }
                }

                getTC().setKeywords(keywords);
            }
        }
    }) {
        @Override
        public boolean isVisible() {
            return !keywordCodeInput;
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {
            tag.put("title", getStringValue(TCQueryFilterKey.Keyword)); //$NON-NLS-1$
        }
    }.add(readonlyModifier).setOutputMarkupId(true).setMarkupId("tc-view-overview-keyword-area"));

    // ANATOMY
    anatomyInput = TCUtilities.createInput("tc-view-overview-anatomy-input", TCQueryFilterKey.Anatomy,
            getTC().getValue(TCQueryFilterKey.Anatomy), true);
    anatomyInput.getComponent().setVisible(isEditing());
    anatomyInput.addChangeListener(new ValueChangeListener() {
        @Override
        public void valueChanged(ITextOrCode[] values) {
            getTC().setAnatomy(values != null && values.length > 0 ? values[0] : null);
        }
    });
    final WebMarkupContainer anatomyRow = new WebMarkupContainer("tc-view-overview-anatomy-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Anatomy);
        }
    };
    anatomyRow.add(
            new Label("tc-view-overview-anatomy-label", new InternalStringResourceModel("tc.anatomy.text")));
    anatomyRow.add(anatomyInput.getComponent());
    anatomyRow.add(new TextField<String>("tc-view-overview-anatomy-value-label", new Model<String>() {
        public String getObject() {
            return getShortStringValue(TCQueryFilterKey.Anatomy);
        }
    }) {
        private static final long serialVersionUID = 3465370488528419531L;

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.put("title", getStringValue(TCQueryFilterKey.Anatomy)); //$NON-NLS-1$
        }

        @Override
        public boolean isVisible() {
            return !isEditing();
        }
    }.add(readonlyModifier));

    // PATHOLOGY
    pathologyInput = TCUtilities.createInput("tc-view-overview-pathology-input", TCQueryFilterKey.Pathology,
            getTC().getValue(TCQueryFilterKey.Pathology), true);
    pathologyInput.getComponent().setVisible(isEditing());
    pathologyInput.addChangeListener(new ValueChangeListener() {
        @Override
        public void valueChanged(ITextOrCode[] values) {
            getTC().setPathology(values != null && values.length > 0 ? values[0] : null);
        }
    });
    final WebMarkupContainer pathologyRow = new WebMarkupContainer("tc-view-overview-pathology-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Pathology);
        }
    };
    pathologyRow.add(new Label("tc-view-overview-pathology-label",
            new InternalStringResourceModel("tc.pathology.text")));
    pathologyRow.add(pathologyInput.getComponent());
    pathologyRow.add(new TextField<String>("tc-view-overview-pathology-value-label", new Model<String>() {
        public String getObject() {
            return getShortStringValue(TCQueryFilterKey.Pathology);
        }
    }) {
        private static final long serialVersionUID = 3465370488528419531L;

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.put("title", getStringValue(TCQueryFilterKey.Pathology)); //$NON-NLS-1$
        }

        @Override
        public boolean isVisible() {
            return !isEditing();
        }
    }.add(readonlyModifier));

    // CATEGORY
    final TCComboBox<TCQueryFilterValue.Category> categoryCBox = TCUtilities
            .createEnumComboBox("tc-view-overview-category-select", new Model<Category>() {
                @Override
                public Category getObject() {
                    return getTC().getCategory();
                }

                @Override
                public void setObject(Category value) {
                    getTC().setCategory(value);
                }
            }, Arrays.asList(TCQueryFilterValue.Category.values()), true, "tc.category",
                    NullDropDownItem.Undefined, null);
    final WebMarkupContainer categoryRow = new WebMarkupContainer("tc-view-overview-category-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Category);
        }
    };
    categoryCBox.setVisible(isEditing());
    categoryRow.add(
            new Label("tc-view-overview-category-label", new InternalStringResourceModel("tc.category.text")));
    categoryRow.add(categoryCBox);
    categoryRow.add(new TextField<String>("tc-view-overview-category-value-label", new Model<String>() {
        @Override
        public String getObject() {
            return getStringValue(TCQueryFilterKey.Category);
        }
    }).add(readonlyModifier).setVisible(!isEditing()));

    // LEVEL
    final TCComboBox<TCQueryFilterValue.Level> levelCBox = TCUtilities
            .createEnumComboBox("tc-view-overview-level-select", new Model<Level>() {
                @Override
                public Level getObject() {
                    return getTC().getLevel();
                }

                @Override
                public void setObject(Level level) {
                    getTC().setLevel(level);
                }
            }, Arrays.asList(TCQueryFilterValue.Level.values()), true, "tc.level", NullDropDownItem.Undefined,
                    null);
    final WebMarkupContainer levelRow = new WebMarkupContainer("tc-view-overview-level-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Level);
        }
    };
    levelCBox.setVisible(isEditing());
    levelRow.add(new Label("tc-view-overview-level-label", new InternalStringResourceModel("tc.level.text")));
    levelRow.add(new TextField<String>("tc-view-overview-level-value-label", new Model<String>() {
        @Override
        public String getObject() {
            return getStringValue(TCQueryFilterKey.Level);
        }
    }).add(readonlyModifier).setVisible(!isEditing()));
    levelRow.add(levelCBox);

    // PATIENT SEX
    final TCComboBox<TCQueryFilterValue.PatientSex> patientSexCBox = TCUtilities
            .createEnumComboBox("tc-view-overview-patientsex-select", new Model<PatientSex>() {
                @Override
                public PatientSex getObject() {
                    return getTC().getPatientSex();
                }

                @Override
                public void setObject(PatientSex value) {
                    getTC().setPatientSex(value);
                }
            }, Arrays.asList(TCQueryFilterValue.PatientSex.values()), true, "tc.patientsex",
                    NullDropDownItem.Undefined, null);
    final WebMarkupContainer patientSexRow = new WebMarkupContainer("tc-view-overview-patientsex-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.PatientSex);
        }
    };
    patientSexCBox.setVisible(isEditing());
    patientSexRow.add(new Label("tc-view-overview-patientsex-label",
            new InternalStringResourceModel("tc.patient.sex.text")));
    patientSexRow.add(new TextField<String>("tc-view-overview-patientsex-value-label", new Model<String>() {
        public String getObject() {
            return getStringValue(TCQueryFilterKey.PatientSex);
        }
    }).add(readonlyModifier).setVisible(!isEditing()));
    patientSexRow.add(patientSexCBox);

    // PATIENT AGE
    final TCSpinner<Integer> patientAgeYearSpinner = TCSpinner
            .createYearSpinner("tc-view-overview-patientage-years-input", new Model<Integer>() {
                @Override
                public Integer getObject() {
                    return TCPatientAgeUtilities.toYears(getTC().getPatientAge());
                }

                @Override
                public void setObject(Integer years) {
                    getTC().setPatientAge(TCPatientAgeUtilities.toDays(years,
                            TCPatientAgeUtilities.toRemainingMonths(getTC().getPatientAge())));
                }
            }, null);
    final TCSpinner<Integer> patientAgeMonthSpinner = TCSpinner
            .createMonthSpinner("tc-view-overview-patientage-months-input", new Model<Integer>() {
                @Override
                public Integer getObject() {
                    return TCPatientAgeUtilities.toRemainingMonths(getTC().getPatientAge());
                }

                @Override
                public void setObject(Integer months) {
                    getTC().setPatientAge(TCPatientAgeUtilities
                            .toDays(TCPatientAgeUtilities.toYears(getTC().getPatientAge()), months));
                }
            }, null);
    final WebMarkupContainer patientAgeRow = new WebMarkupContainer("tc-view-overview-patientage-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.PatientAge);
        }
    };
    patientAgeYearSpinner.setVisible(isEditing());
    patientAgeMonthSpinner.setVisible(isEditing());
    patientAgeRow.add(new Label("tc-view-overview-patientage-label",
            new InternalStringResourceModel("tc.patient.age.text")));
    patientAgeRow.add(new TextField<String>("tc-view-overview-patientage-value-label", new Model<String>() {
        public String getObject() {
            return TCPatientAgeUtilities.format(getTC().getPatientAge());
        }
    }).add(readonlyModifier).setVisible(!isEditing()));
    patientAgeRow.add(patientAgeYearSpinner);
    patientAgeRow.add(patientAgeMonthSpinner);

    // PATIENT SPECIES
    List<String> ethnicGroups = WebCfgDelegate.getInstance().getTCEthnicGroups();
    boolean ethnicGroupsAvailable = ethnicGroups != null && !ethnicGroups.isEmpty();
    SelfUpdatingTextField patientSpeciesField = new SelfUpdatingTextField(
            "tc-view-overview-patientrace-value-label", new Model<String>() {
                @Override
                public String getObject() {
                    return getStringValue(TCQueryFilterKey.PatientSpecies);
                }

                @Override
                public void setObject(String text) {
                    if (isEditing()) {
                        getTC().setPatientSpecies(text);
                    }
                }
            });
    final WebMarkupContainer patientSpeciesRow = new WebMarkupContainer("tc-view-overview-patientrace-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.PatientSpecies);
        }
    };
    patientSpeciesRow.add(new Label("tc-view-overview-patientrace-label",
            new InternalStringResourceModel("tc.patient.species.text")));
    patientSpeciesRow.add(patientSpeciesField);
    patientSpeciesRow
            .add(TCUtilities.createEditableComboBox("tc-view-overview-patientrace-select", new Model<String>() {
                @Override
                public String getObject() {
                    return getTC().getValueAsLocalizedString(TCQueryFilterKey.PatientSpecies,
                            TCViewOverviewTab.this);
                }

                @Override
                public void setObject(String value) {
                    getTC().setValue(TCQueryFilterKey.PatientSpecies, value);
                }
            }, ethnicGroups, NullDropDownItem.Undefined, null).add(readonlyModifier)
                    .setVisible(isEditing() && ethnicGroupsAvailable));

    patientSpeciesField.setVisible(!isEditing() || !ethnicGroupsAvailable);
    if (!isEditing()) {
        patientSpeciesField.add(readonlyModifier);
    }

    // MODALITIES
    final WebMarkupContainer modalitiesRow = new WebMarkupContainer("tc-view-overview-modalities-row") {
        @Override
        public boolean isVisible() {
            return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AcquisitionModality);
        }
    };
    modalitiesRow.add(new Label("tc-view-overview-modalities-label",
            new InternalStringResourceModel("tc.modalities.text")));
    modalitiesRow.add(new SelfUpdatingTextField("tc-view-overview-modalities-text", new Model<String>() {
        @Override
        public String getObject() {
            return getStringValue(TCQueryFilterKey.AcquisitionModality);
        }

        @Override
        public void setObject(String value) {
            if (isEditing()) {
                String[] modalities = value != null ? value.trim().split(";") : null;
                getTC().setValue(TCQueryFilterKey.AcquisitionModality,
                        modalities != null ? Arrays.asList(modalities) : null);
            }
        }
    }).add(readonlyModifier));

    // FINDING
    findingInput = TCUtilities.createInput("tc-view-overview-finding-input", TCQueryFilterKey.Finding,
            getTC().getValue(TCQueryFilterKey.Finding), true);
    findingInput.getComponent().setVisible(isEditing());
    findingInput.addChangeListener(new ValueChangeListener() {
        @Override
        public void valueChanged(ITextOrCode[] values) {
            getTC().setFinding(values != null && values.length > 0 ? values[0] : null);
        }
    });
    final WebMarkupContainer findingRow = new WebMarkupContainer("tc-view-overview-finding-row") {
        @Override
        public boolean isVisible() {
            return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Finding)
                    && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Finding);
        }
    };
    findingRow.add(
            new Label("tc-view-overview-finding-label", new InternalStringResourceModel("tc.finding.text")));
    findingRow.add(findingInput.getComponent());
    findingRow.add(new TextField<String>("tc-view-overview-finding-value-label", new Model<String>() {
        @Override
        public String getObject() {
            return getShortStringValue(TCQueryFilterKey.Finding);
        }
    }) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.put("title", getStringValue(TCQueryFilterKey.Finding)); //$NON-NLS-1$
        }

        @Override
        public boolean isVisible() {
            return !isEditing();
        }
    });

    // DIAGNOSIS
    diagnosisInput = TCUtilities.createInput("tc-view-overview-diag-input", TCQueryFilterKey.Diagnosis,
            getTC().getValue(TCQueryFilterKey.Diagnosis), true);
    diagnosisInput.getComponent().setVisible(isEditing());
    diagnosisInput.addChangeListener(new ValueChangeListener() {
        @Override
        public void valueChanged(ITextOrCode[] values) {
            getTC().setDiagnosis(values != null && values.length > 0 ? values[0] : null);
        }
    });
    final WebMarkupContainer diagRow = new WebMarkupContainer("tc-view-overview-diag-row") {
        @Override
        public boolean isVisible() {
            return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Diagnosis)
                    && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Diagnosis);
        }
    };
    diagRow.add(new Label("tc-view-overview-diag-label", new InternalStringResourceModel("tc.diagnosis.text")));
    diagRow.add(diagnosisInput.getComponent());
    diagRow.add(new TextField<String>("tc-view-overview-diag-value-label", new Model<String>() {
        @Override
        public String getObject() {
            return getShortStringValue(TCQueryFilterKey.Diagnosis);
        }
    }) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.put("title", getStringValue(TCQueryFilterKey.Diagnosis)); //$NON-NLS-1$
        }

        @Override
        public boolean isVisible() {
            return !isEditing();
        }
    });

    // DIAGNOSIS CONFIRMED
    final WebMarkupContainer diagConfirmedRow = new WebMarkupContainer("tc-view-overview-diagconfirmed-row") {
        @Override
        public boolean isVisible() {
            return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Diagnosis)
                    && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Diagnosis);
        }
    };
    diagConfirmedRow.add(new Label("tc-view-overview-diagconfirmed-label",
            new InternalStringResourceModel("tc.diagnosis.confirmed.text")));
    diagConfirmedRow.add(new CheckBox("tc-view-overview-diagconfirmed-input", new Model<Boolean>() {
        @Override
        public Boolean getObject() {
            YesNo yesno = getTC().getDiagnosisConfirmed();
            if (yesno != null && YesNo.Yes.equals(yesno)) {
                return true;
            } else {
                return false;
            }
        }

        @Override
        public void setObject(Boolean value) {
            if (value != null && value == true) {
                getTC().setDiagnosisConfirmed(YesNo.Yes);
            } else {
                getTC().setDiagnosisConfirmed(null);
            }
        }
    }).setEnabled(isEditing()));

    // DIFFERENTIAL DIAGNOSIS
    diffDiagnosisInput = TCUtilities.createInput("tc-view-overview-diffdiag-input",
            TCQueryFilterKey.DifferentialDiagnosis, getTC().getValue(TCQueryFilterKey.DifferentialDiagnosis),
            true);
    diffDiagnosisInput.getComponent().setVisible(isEditing());
    diffDiagnosisInput.addChangeListener(new ValueChangeListener() {
        @Override
        public void valueChanged(ITextOrCode[] values) {
            getTC().setDiffDiagnosis(values != null && values.length > 0 ? values[0] : null);
        }
    });
    final WebMarkupContainer diffDiagRow = new WebMarkupContainer("tc-view-overview-diffdiag-row") {
        @Override
        public boolean isVisible() {
            return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.DifferentialDiagnosis)
                    && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.DifferentialDiagnosis);
        }
    };
    diffDiagRow.add(new Label("tc-view-overview-diffdiag-label",
            new InternalStringResourceModel("tc.diffdiagnosis.text")));
    diffDiagRow.add(diffDiagnosisInput.getComponent());
    diffDiagRow.add(new TextField<String>("tc-view-overview-diffdiag-value-label", new Model<String>() {
        @Override
        public String getObject() {
            return getShortStringValue(TCQueryFilterKey.DifferentialDiagnosis);
        }
    }) {
        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.put("title", getStringValue(TCQueryFilterKey.DifferentialDiagnosis)); //$NON-NLS-1$
        }

        @Override
        public boolean isVisible() {
            return !isEditing();
        }
    });

    // IMAGE COUNT
    final WebMarkupContainer imageCountRow = new WebMarkupContainer("tc-view-overview-imagecount-row");
    imageCountRow.add(new Label("tc-view-overview-imagecount-label",
            new InternalStringResourceModel("tc.view.images.count.text")));
    imageCountRow.add(new TextField<String>("tc-view-overview-imagecount-value-label", new Model<String>() {
        public String getObject() {
            return getTC().getReferencedImages() != null
                    ? Integer.toString(getTC().getReferencedImages().size())
                    : "0";
        }
    }).add(new AttributeAppender("readonly", true, new Model<String>("readonly"), " ")));

    add(titleRow);
    add(abstractRow);
    add(urlRow);
    add(authorNameRow);
    add(authorAffiliationRow);
    add(authorContactRow);
    add(keywordRow);
    add(anatomyRow);
    add(pathologyRow);
    add(findingRow);
    add(diffDiagRow);
    add(diagRow);
    add(diagConfirmedRow);
    add(categoryRow);
    add(levelRow);
    add(patientSexRow);
    add(patientAgeRow);
    add(patientSpeciesRow);
    add(modalitiesRow);
    add(imageCountRow);
}

From source file:org.dcm4chee.web.war.worklist.modality.ModalityWorklistPanel.java

License:LGPL

public void addMwlActions(final ListItem<MWLItemModel> item, WebMarkupContainer valueContainer,
        final MWLItemListView mwlListView) {

    final MWLItemModel mwlItemModel = item.getModelObject();
    valueContainer.add(new WebMarkupContainer("cell") {

        private static final long serialVersionUID = 1L;

        @Override//from   w  ww .j  av  a 2 s .  c  o m
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (item.getModelObject().isDetails())
                tag.put("rowspan", "2");
        }
    });

    WebMarkupContainer details = new WebMarkupContainer("details") {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return mwlItemModel.isDetails();
        }
    };
    DicomObject detailAttrs = new BasicDicomObject();
    mwlItemModel.getDataset().copyTo(detailAttrs);
    mwlItemModel.getPatientAttributes().copyTo(detailAttrs);
    item.add(details.add(new DicomObjectPanel("dicomobject", detailAttrs, false)));

    int[] winSize = WebCfgDelegate.getInstance().getWindowSize("mwEdit");
    valueContainer.add(new AjaxFallbackLink<Object>("toggledetails") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            mwlItemModel.setDetails(!mwlItemModel.isDetails());
            form.setOutputMarkupId(true);
            if (target != null) {
                addAfterQueryComponents(target);
            }
        }

    }.add(new Image("detailImg", ImageManager.IMAGE_COMMON_DICOM_DETAILS).add(new ImageSizeBehaviour())
            .add(new TooltipBehaviour("mw.", "detailImg"))))
            .add(new ModalWindowLink("edit", modalWindow, winSize[0], winSize[1]) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    modalWindow.setContent(new EditDicomObjectPanel("content", modalWindow,
                            (DicomObject) mwlItemModel.getDataset(), mwlItemModel.getClass().getSimpleName()) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void onSubmit() {
                            try {
                                mwlItemModel.update(getDicomObject());
                                logOrderRecord(mwlItemModel, AuditEvent.ActionCode.UPDATE, true);
                            } catch (RuntimeException x) {
                                logOrderRecord(mwlItemModel, AuditEvent.ActionCode.UPDATE, false);
                                throw x;
                            }
                            super.onCancel();
                        }
                    });
                    modalWindow.show(target);
                    super.onClick(target);
                }

                @Override
                public boolean isVisible() {
                    return mwlItemModel.getPk() != -1;
                }
            }.add(new Image("editImg", ImageManager.IMAGE_COMMON_DICOM_EDIT).add(new ImageSizeBehaviour())
                    .add(new TooltipBehaviour("mw.", "editImg")))
                    .add(new SecurityBehavior(getModuleName() + ":editMwlItem")));

    final boolean isLinked = ((ModalityWorklistLocal) JNDIUtils.lookup(ModalityWorklistLocal.JNDI_NAME))
            .hasMPPS(item.getModelObject().getAccessionNumber());

    AjaxLink<?> removeMWLItem = new AjaxLink<Object>("remove") {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return !isLinked;
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            confirm.confirm(target, new ResourceModel("mw.confirmRemove").wrapOnAssignment(this), mwlItemModel);
        }

        @Override
        public boolean isVisible() {
            return mwlItemModel.getPk() != -1;
        }
    };
    removeMWLItem
            .add(new Image("removeImg", ImageManager.IMAGE_COMMON_REMOVE)
                    .add(!isLinked ? new TooltipBehaviour("mw.", "removeImg")
                            : new AttributeModifier("title", true,
                                    new ResourceModel("mw.removeImg.isLinked.tooltip")))
                    .add(new ImageSizeBehaviour()));
    removeMWLItem.add(new SecurityBehavior(getModuleName() + ":removeMWLItem"));
    valueContainer.add(removeMWLItem);
}

From source file:org.dcm4chee.wizard.panel.BasicConfigurationPanel.java

License:LGPL

private void addCreateDevice() {
    AjaxLink<Object> createDevice = getCreateDeviceLink();
    Component createDeviceImg = new Image("createDeviceImg", ImageManager.IMAGE_WIZARD_DEVICE_ADD);
    createDeviceImg.add(new ImageSizeBehaviour("vertical-align: middle;"));
    createDevice.add(createDeviceImg);
    createDevice.add(new TooltipBehavior("dicom."));
    Component createDeviceText = new Label("createDeviceText", new ResourceModel("dicom.createDevice.text"));
    createDeviceText.add(new AttributeAppender("style", Model.of("vertical-align: middle"), " "));
    createDevice.add(createDeviceText);//from  w w w  .j  av  a  2 s .  c om
    form.add(createDevice);
}