Search in sources :

Example 1 with AjaxLinkPanel

use of com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel in project midpoint by Evolveum.

the class PrismPropertyWrapperColumnPanel method createLink.

@Override
protected Panel createLink(String id, IModel<PrismPropertyValueWrapper<T>> object) {
    String humanReadableLinkName = getHumanReadableLinkName(object);
    IModel labelModel;
    if (StringUtils.isEmpty(humanReadableLinkName)) {
        labelModel = getPageBase().createStringResource("feedbackMessagePanel.message.undefined");
    } else {
        labelModel = new ReadOnlyModel(() -> humanReadableLinkName);
    }
    AjaxLinkPanel ajaxLinkPanel = new AjaxLinkPanel(id, labelModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismPropertyWrapperColumnPanel.this.onClick(target, getModelObject().getParent());
        }
    };
    return ajaxLinkPanel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)

Example 2 with AjaxLinkPanel

use of com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel in project midpoint by Evolveum.

the class CertDecisionHelper method createReviewerNameColumn.

public <T extends CertCaseOrWorkItemDto> IColumn<T, String> createReviewerNameColumn(final PageBase page, final String headerKey) {
    IColumn column;
    column = new AbstractColumn<T, String>(page.createStringResource(headerKey)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
            CertCaseOrWorkItemDto dto = rowModel.getObject();
            RepeatingView reviewersPanel = new RepeatingView(componentId);
            if (dto instanceof CertWorkItemDto) {
                List<ObjectReferenceType> reviewersList = ((CertWorkItemDto) dto).getReviewerRefList();
                if (CollectionUtils.isNotEmpty(reviewersList)) {
                    for (ObjectReferenceType reviewer : reviewersList) {
                        reviewersPanel.add(new AjaxLinkPanel(reviewersPanel.newChildId(), Model.of(WebComponentUtil.getDisplayNameOrName(reviewer))) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                dispatchToObjectDetailsPage(reviewer, page, false);
                            }
                        });
                    }
                }
            }
            cellItem.add(reviewersPanel);
        }
    };
    return column;
}
Also used : AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) List(java.util.List) CertWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto)

Example 3 with AjaxLinkPanel

use of com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel in project midpoint by Evolveum.

the class ScenePanel method initLayout.

private void initLayout() {
    final IModel<SceneDto> model = getModel();
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    box.add(AttributeModifier.append("class", new IModel<String>() {

        @Override
        public String getObject() {
            SceneDto dto = model.getObject();
            if (dto.getBoxClassOverride() != null) {
                return dto.getBoxClassOverride();
            }
            if (dto.getChangeType() == null) {
                return null;
            }
            switch(dto.getChangeType()) {
                case ADD:
                    return "box-success";
                case DELETE:
                    return "box-danger";
                case MODIFY:
                    return "box-info";
                default:
                    return null;
            }
        }
    }));
    add(box);
    WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
    box.add(headerPanel);
    headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {

        @Override
        public void minimizeOnClick(AjaxRequestTarget target) {
            headerOnClickPerformed(target, model);
        }
    });
    Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
    // headerChangeType.setRenderBodyOnly(true);
    Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
    // headerObjectType.setRenderBodyOnly(true);
    IModel<String> nameModel = new IModel<String>() {

        @Override
        public String getObject() {
            return model.getObject().getName(ScenePanel.this);
        }
    };
    Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
    AjaxLinkPanel headerNameLink = new AjaxLinkPanel(ID_HEADER_NAME_LINK, nameModel) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
            if (value != null && value.getParent() instanceof PrismObject) {
                PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
                WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object, getPageBase().getPrismContext()), getPageBase(), false);
            }
        }
    };
    Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new IModel<String>() {

        @Override
        public String getObject() {
            return model.getObject().getDescription(ScenePanel.this);
        }
    });
    Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new IModel<String>() {

        @Override
        public String getObject() {
            String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
            Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
            return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
        }
    });
    headerPanel.add(headerChangeType);
    headerPanel.add(headerObjectType);
    headerPanel.add(headerNameLabel);
    headerPanel.add(headerNameLink);
    headerPanel.add(headerDescription);
    headerPanel.add(headerWrapperDisplayName);
    headerChangeType.add(createHeaderOnClickBehaviour(model));
    headerObjectType.add(createHeaderOnClickBehaviour(model));
    headerNameLabel.add(createHeaderOnClickBehaviour(model));
    headerDescription.add(createHeaderOnClickBehaviour(model));
    headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
    VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModelObject().isWrapper();
        }
    };
    VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isWrapper();
        }
    };
    VisibleEnableBehaviour visibleIfExistingObjectAndAuthorized = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject().isWrapper()) {
                return false;
            }
            return isExistingViewableObject() && isAutorized();
        }
    };
    VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObjectAndNotAuthorized = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject().isWrapper()) {
                return false;
            }
            return !isExistingViewableObject() || !isAutorized();
        }
    };
    headerChangeType.add(visibleIfNotWrapper);
    headerObjectType.add(visibleIfNotWrapper);
    headerNameLabel.add(visibleIfNotWrapperAndNotExistingObjectAndNotAuthorized);
    headerNameLink.add(visibleIfExistingObjectAndAuthorized);
    headerDescription.add(visibleIfNotWrapper);
    headerWrapperDisplayName.add(visibleIfWrapper);
    WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
    body.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneDto wrapper = model.getObject();
            return !wrapper.isMinimized();
        }
    });
    box.add(body);
    WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
    itemsTable.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().getItems().isEmpty();
        }
    });
    itemsTable.setOutputMarkupId(true);
    ToggleIconButton<String> sortPropertiesButton = new ToggleIconButton<String>(ID_SORT_PROPERTIES, GuiStyleConstants.CLASS_ICON_SORT_ALPHA_ASC, GuiStyleConstants.CLASS_ICON_SORT_AMOUNT_ASC) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onSortClicked(model, target);
        }

        @Override
        public boolean isOn() {
            return model.getObject().isSorted();
        }
    };
    sortPropertiesButton.setOutputMarkupId(true);
    sortPropertiesButton.setOutputMarkupPlaceholderTag(true);
    itemsTable.add(sortPropertiesButton);
    WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
    oldValueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(oldValueLabel);
    WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
    newValueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(newValueLabel);
    WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
    valueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(valueLabel);
    ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<>(model, SceneDto.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<SceneItemDto> item) {
            SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
            panel.add(new VisibleBehaviour(() -> !isOperationalItem(item.getModel()) || isOperationalItemsVisible()));
            panel.setRenderBodyOnly(true);
            item.add(panel);
        }
    };
    items.setReuseItems(true);
    itemsTable.add(items);
    body.add(itemsTable);
    ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<>(model, SceneDto.F_PARTIAL_SCENES)) {

        @Override
        protected void populateItem(ListItem<SceneDto> item) {
            ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected boolean isOperationalItemsVisible() {
                    ScenePanel parentScenePanel = findParent(ScenePanel.class);
                    if (parentScenePanel != null) {
                        return parentScenePanel.isOperationalItemsVisible();
                    } else {
                        return ScenePanel.this.operationalItemsVisible;
                    }
                }
            };
            panel.add(new VisibleBehaviour(() -> !isOperationalPartialScene(item.getModel()) || operationalItemsVisible));
            panel.setOutputMarkupPlaceholderTag(true);
            item.add(panel);
        }
    };
    partialScenes.setReuseItems(true);
    body.add(partialScenes);
    AjaxButton showOperationalItemsLink = new AjaxButton(ID_SHOW_OPERATIONAL_ITEMS_LINK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setOperationalItemsVisible(!operationalItemsVisible);
            target.add(ScenePanel.this);
        }

        @Override
        public IModel<?> getBody() {
            return getShowOperationalItemsLinkLabel();
        }
    };
    showOperationalItemsLink.setOutputMarkupId(true);
    showOperationalItemsLink.add(AttributeAppender.append("style", "cursor: pointer;"));
    showOperationalItemsLink.add(new VisibleBehaviour(() -> showOperationalItems));
    body.add(showOperationalItemsLink);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 4 with AjaxLinkPanel

use of com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel in project midpoint by Evolveum.

the class ResourceDetailsTabPanel method initLayout.

protected void initLayout() {
    PrismObject<ResourceType> resourceObject = getModelObject();
    ResourceType resource = resourceObject.asObjectable();
    add(createLastAvailabilityStatusInfo(resource));
    add(createSourceTargetInfo(resource));
    add(createSchemaStatusInfo(resource));
    CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
    add(capabilities);
    List<ResourceConfigurationDto> resourceConfigList = createResourceConfigList(resource);
    ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<>(ResourceDetailsTabPanel.this, new ListModel<>(resourceConfigList));
    List<IColumn<SelectableBeanImpl<ResourceType>, String>> tableColumns = new ArrayList<>();
    tableColumns.add(ColumnUtils.createPropertyColumn(new ColumnTypeDto<>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart())));
    tableColumns.add(new PropertyColumn<>(createStringResource("ShadowType.objectClass"), "objectTypeDefinition.objectClass") {

        @Override
        public IModel<?> getDataModel(IModel<SelectableBeanImpl<ResourceType>> rowModel) {
            IModel<QName> model = (IModel<QName>) super.getDataModel(rowModel);
            if (model.getObject() != null) {
                return () -> model.getObject().getLocalPart();
            }
            return model;
        }
    });
    List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<>("ResourceType.isSync", "sync", null));
    tableColumns.addAll(ColumnUtils.createColumns(columns));
    PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {

        @Override
        public void populateItem(Item item, String componentId, final IModel rowModel) {
            ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
            RepeatingView repeater = new RepeatingView(componentId);
            for (final TaskType task : conf.getDefinedTasks()) {
                repeater.add(new AjaxLinkPanel(repeater.newChildId(), new Model<>(task.getName().getOrig())) {

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
                    }
                });
            }
            item.add(repeater);
        }
    };
    tableColumns.add(tasksColumn);
    BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
    resourceConfig.setAdditionalBoxCssClasses("box-success");
    add(resourceConfig);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto) ColumnTypeDto(com.evolveum.midpoint.web.component.data.column.ColumnTypeDto) Item(org.apache.wicket.markup.repeater.Item) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 5 with AjaxLinkPanel

use of com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel in project midpoint by Evolveum.

the class PageAuditLogDetails method createTaskLink.

private AjaxLinkPanel createTaskLink() {
    IModel<TaskType> taskModel = createTaskModel();
    AjaxLinkPanel taskOidLink = new AjaxLinkPanel(ID_PARAMETERS_TASK_OID_LINK, createTaskNameModel(taskModel)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            TaskType finalTask = taskModel.getObject();
            if (finalTask != null) {
                WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(finalTask, getPrismContext()), this, false);
            }
        }
    };
    taskOidLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return taskModel.getObject() != null;
        }
    });
    taskOidLink.setOutputMarkupId(true);
    return taskOidLink;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

AjaxLinkPanel (com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)8 IModel (org.apache.wicket.model.IModel)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 ColumnTypeDto (com.evolveum.midpoint.web.component.data.column.ColumnTypeDto)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)2 ResourceConfigurationDto (com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto)2 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)2 Label (org.apache.wicket.markup.html.basic.Label)2 Item (org.apache.wicket.markup.repeater.Item)2 Model (org.apache.wicket.model.Model)2