Search in sources :

Example 6 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 = getObjectWrapper().getObject();
    // ResourceType resource = resourceObject.asObjectable();
    add(createLastAvailabilityStatusInfo());
    add(createSourceTargetInfo());
    add(createSchemaStatusInfo());
    CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
    add(capabilities);
    ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<>(ResourceDetailsTabPanel.this, createResourceConfigListModel());
    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) CapabilitiesPanel(com.evolveum.midpoint.web.page.admin.resources.CapabilitiesPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Model(org.apache.wicket.model.Model) ResourceDetailsModel(com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 7 with AjaxLinkPanel

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

the class SceneItemValuePanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return hasValidReferenceValue(object);
        }
    };
    final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return !hasValidReferenceValue(object);
        }
    };
    IModel<DisplayType> displayModel = (IModel) () -> {
        ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor();
        String cssClass = ObjectTypeGuiDescriptor.ERROR_ICON;
        String title = null;
        if (guiDescriptor != null) {
            cssClass = guiDescriptor.getBlackIcon();
            title = createStringResource(guiDescriptor.getLocalizationKey()).getObject();
        }
        return GuiDisplayTypeUtil.createDisplayType(cssClass, "", title);
    };
    final ImagePanel icon = new ImagePanel(ID_ICON, displayModel);
    icon.add(visibleIfReference);
    add(icon);
    final Label label = new Label(ID_LABEL, new LabelModel());
    label.add(visibleIfNotReference);
    add(label);
    final AjaxLinkPanel link = new AjaxLinkPanel(ID_LINK, new LabelModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
                return;
            }
            PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
            if (refValue == null) {
                return;
            }
            ObjectReferenceType ort = new ObjectReferenceType();
            ort.setupReferenceValue(refValue);
            WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
        }
    };
    link.add(visibleIfReference);
    add(link);
    final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new IModel<String>() {

        @Override
        public String getObject() {
            return getModelObject() != null ? getModelObject().getAdditionalText() : null;
        }
    });
    add(additionalText);
}
Also used : SceneItemValue(com.evolveum.midpoint.model.api.visualizer.SceneItemValue) IModel(org.apache.wicket.model.IModel) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 8 with AjaxLinkPanel

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

the class SearchObjectCollectionPanel method initSearchItemField.

protected void initSearchItemField(WebMarkupContainer searchItemContainer) {
    IModel<String> nameModel = super.createLabelModel();
    String oid = null;
    ObjectCollectionSearchItem item = getModelObject();
    if (item != null && item.getObjectCollectionView().getCollection() != null && item.getObjectCollectionView().getCollection().getCollectionRef() != null) {
        oid = item.getObjectCollectionView().getCollection().getCollectionRef().getOid();
    }
    String finalOid = oid;
    AjaxLinkPanel ajaxLinkPanel = new AjaxLinkPanel(ID_CLICKABLE_NAME, nameModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            WebComponentUtil.dispatchToObjectDetailsPage(ObjectCollectionType.class, finalOid, this, true);
        }

        @Override
        public boolean isEnabled() {
            return StringUtils.isNotEmpty(finalOid) && WebComponentUtil.isAuthorized(ObjectCollectionType.class);
        }
    };
    ajaxLinkPanel.setOutputMarkupId(true);
    searchItemContainer.add(ajaxLinkPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) ObjectCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectCollectionType)

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