Search in sources :

Example 1 with RepeatingView

use of org.apache.wicket.markup.repeater.RepeatingView in project gitblit by gitblit.

the class BasePage method addBottomScriptInline.

/**
	 * Adds a HTML script element containing the given code.
	 *
	 * @param code
	 *            inline script code
	 */
protected void addBottomScriptInline(String code) {
    RepeatingView bottomScripts = getBottomScriptContainer();
    Label script = new Label(bottomScripts.newChildId(), "<script type='text/javascript'>/*<![CDATA[*/\n" + code + "\n//]]>\n</script>\n");
    bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));
}
Also used : RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label)

Example 2 with RepeatingView

use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.

the class DynamicFieldGroupPanel method initLayout.

private void initLayout(String groupName, List<AbstractFormItemType> formItems, Form<?> mainForm) {
    Label header = new Label(ID_HEADER, groupName);
    add(header);
    RepeatingView itemView = new RepeatingView(ID_PROPERTY);
    add(itemView);
    int i = 0;
    for (AbstractFormItemType formItem : formItems) {
        if (formItem instanceof FormFieldGroupType) {
            DynamicFieldGroupPanel<O> dynamicFieldGroupPanel = new DynamicFieldGroupPanel<O>(itemView.newChildId(), formItem.getName(), getModel(), FormTypeUtil.getFormItems(((FormFieldGroupType) formItem).getFormItems()), mainForm, getPageBase());
            dynamicFieldGroupPanel.setOutputMarkupId(true);
            itemView.add(dynamicFieldGroupPanel);
            continue;
        }
        ItemWrapper itemWrapper = createItemWrapper(formItem, getObjectWrapper());
        if (itemWrapper instanceof ContainerWrapper) {
            PrismContainerPanel containerPanel = new PrismContainerPanel(itemView.newChildId(), Model.of((ContainerWrapper) itemWrapper), true, mainForm, getPageBase());
            containerPanel.setOutputMarkupId(true);
            itemView.add(containerPanel);
        } else {
            PrismPropertyPanel<?> propertyPanel = new PrismPropertyPanel<>(itemView.newChildId(), Model.of(itemWrapper), mainForm, getPageBase());
            propertyPanel.setOutputMarkupId(true);
            propertyPanel.add(AttributeModifier.append("class", ((i % 2) == 0) ? "" : "stripe"));
            itemView.add(propertyPanel);
        }
        i++;
    }
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView)

Example 3 with RepeatingView

use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.

the class OrgMemberPanel method createManagerContainer.

private WebMarkupContainer createManagerContainer() {
    WebMarkupContainer managerContainer = new WebMarkupContainer(ID_CONTAINER_MANAGER);
    managerContainer.setOutputMarkupId(true);
    managerContainer.setOutputMarkupPlaceholderTag(true);
    RepeatingView view = new RepeatingView(ID_MANAGER_TABLE);
    view.setOutputMarkupId(true);
    ObjectQuery managersQuery = createManagerQuery();
    OperationResult searchManagersResult = new OperationResult(OPERATION_SEARCH_MANAGERS);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
    List<PrismObject<FocusType>> managers = WebModelServiceUtils.searchObjects(FocusType.class, managersQuery, options, searchManagersResult, getPageBase());
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_MANAGERS);
    for (PrismObject<FocusType> manager : managers) {
        ObjectWrapper<FocusType> managerWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(manager, RoleType.F_DISPLAY_NAME), "", manager, ContainerStatus.MODIFYING, task, getPageBase());
        WebMarkupContainer managerMarkup = new WebMarkupContainer(view.newChildId());
        AjaxLink<String> link = new AjaxLink<String>(ID_EDIT_MANAGER) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                detailsPerformed(target, summary.getModelObject());
            }
        };
        link.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, managerWrapper.getObject(), null, null, null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #read operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        if (manager.getCompileTimeClass().equals(UserType.class)) {
            managerMarkup.add(new UserSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(RoleType.class)) {
            managerMarkup.add(new RoleSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(OrgType.class)) {
            managerMarkup.add(new OrgSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(ServiceType.class)) {
            managerMarkup.add(new ServiceSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) managerWrapper)));
        }
        link.setOutputMarkupId(true);
        managerMarkup.setOutputMarkupId(true);
        managerMarkup.add(link);
        view.add(managerMarkup);
        AjaxButton removeManager = new AjaxButton(ID_REMOVE_MANAGER) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                removeManagerPerformed(summary.getModelObject(), target);
                getParent().setVisible(false);
                target.add(OrgMemberPanel.this);
            }
        };
        removeManager.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL, null, managerWrapper.getObject(), null, getModelObject().asPrismObject(), null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #unassign operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        removeManager.setOutputMarkupId(true);
        managerMarkup.add(removeManager);
        AjaxButton deleteManager = new AjaxButton(ID_DELETE_MANAGER) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                deleteManagerPerformed(summary.getModelObject(), this, target);
            }
        };
        deleteManager.setOutputMarkupId(true);
        deleteManager.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, null, managerWrapper.getObject(), null, null, null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #delete operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        managerMarkup.add(deleteManager);
    }
    managerContainer.add(view);
    InlineMenu menupanel = new InlineMenu(ID_MANAGER_MENU, new Model<Serializable>((Serializable) createManagersHeaderInlineMenu()));
    add(menupanel);
    menupanel.setOutputMarkupId(true);
    managerContainer.add(menupanel);
    return managerContainer;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Serializable(java.io.Serializable) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) FocusSummaryPanel(com.evolveum.midpoint.web.component.FocusSummaryPanel) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) RoleSummaryPanel(com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel)

Example 4 with RepeatingView

use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.

the class MultiButtonTable method initLayout.

private void initLayout() {
    itemsCount = getModel() != null ? (getModel().getObject() != null ? getModel().getObject().size() : 0) : 0;
    RepeatingView rows = new RepeatingView(ID_ROW);
    rows.setOutputMarkupId(true);
    if (itemsCount > 0 && itemsPerRow > 0) {
        int index = 0;
        List<AssignmentEditorDto> assignmentsList = getModelObject();
        long rowCount = itemsCount % itemsPerRow == 0 ? (itemsCount / itemsPerRow) : (itemsCount / itemsPerRow + 1);
        for (int rowNumber = 0; rowNumber < rowCount; rowNumber++) {
            WebMarkupContainer rowContainer = new WebMarkupContainer(rows.newChildId());
            rows.add(rowContainer);
            RepeatingView columns = new RepeatingView(ID_CELL);
            columns.setOutputMarkupId(true);
            rowContainer.add(columns);
            for (int colNumber = 0; colNumber < itemsPerRow; colNumber++) {
                WebMarkupContainer colContainer = new WebMarkupContainer(columns.newChildId());
                columns.add(colContainer);
                WebMarkupContainer itemButtonContainer = new WebMarkupContainer(ID_ITEM_BUTTON_CONTAINER);
                itemButtonContainer.setOutputMarkupId(true);
                itemButtonContainer.add(new AttributeAppender("class", getBackgroundClass(assignmentsList.get(index))));
                colContainer.add(itemButtonContainer);
                populateCell(itemButtonContainer, assignmentsList.get(index));
                index++;
                if (index >= assignmentsList.size()) {
                    break;
                }
            }
        }
    }
    add(rows);
}
Also used : RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 5 with RepeatingView

use of org.apache.wicket.markup.repeater.RepeatingView in project midpoint by Evolveum.

the class MultiButtonPanel method initLayout.

protected void initLayout() {
    RepeatingView buttons = new RepeatingView(ID_BUTTONS);
    add(buttons);
    for (int id = 0; id < numberOfButtons; id++) {
        final int finalId = getButtonId(id);
        AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                clickPerformed(finalId, target, MultiButtonPanel.this.getModel());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }

            @Override
            public boolean isEnabled() {
                return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel());
            }

            @Override
            public boolean isVisible() {
                return MultiButtonPanel.this.isButtonVisible(finalId, MultiButtonPanel.this.getModel());
            }
        };
        button.add(new AttributeAppender("class", getButtonCssClass(finalId)));
        button.add(new AttributeAppender("title", getButtonTitle(finalId)));
        buttons.add(button);
        buttons.add(new Label("label" + finalId, " "));
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)19 Label (org.apache.wicket.markup.html.basic.Label)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 IModel (org.apache.wicket.model.IModel)5 Model (org.apache.wicket.model.Model)5 ArrayList (java.util.ArrayList)4 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)3 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)3 Item (org.apache.wicket.markup.repeater.Item)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 ColumnTypeDto (com.evolveum.midpoint.web.component.data.column.ColumnTypeDto)2 ObjectWrapper (com.evolveum.midpoint.web.component.prism.ObjectWrapper)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 List (java.util.List)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2