Skip to content

Commit

Permalink
MID-7484 more detail for message template UI, almost ready
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 11, 2022
1 parent 9794efc commit 09c7ddd
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5286,8 +5286,7 @@ public static <T extends ObjectType> Panel createPanel(Class<? extends Panel> pa
panel.setOutputMarkupId(true);
return panel;
} catch (Throwable e) {
e.printStackTrace();
LOGGER.trace("No constructor found for (String, LoadableModel, ContainerPanelConfigurationType). Continue with lookup.");
LOGGER.trace("No constructor found for (String, LoadableModel, ContainerPanelConfigurationType). Continue with lookup.", e);
}
}

Expand All @@ -5297,7 +5296,7 @@ public static <T extends ObjectType> Panel createPanel(Class<? extends Panel> pa
return panel;
} catch (Throwable e) {
e.printStackTrace();
LOGGER.trace("No constructor found for (String, LoadableModel, ContainerPanelConfigurationType). Continue with lookup.");
LOGGER.trace("No constructor found for (String, LoadableModel, ContainerPanelConfigurationType). Continue with lookup.", e);
}
return null;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,36 @@

package com.evolveum.midpoint.gui.impl.page.admin.messagetemplate;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import java.util.Arrays;
import java.util.List;

import com.evolveum.midpoint.gui.impl.component.data.column.AbstractItemWrapperColumn;
import com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel;
import com.evolveum.midpoint.web.application.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType;

import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.component.assignmentType.AbstractAssignmentTypePanel;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel;
import com.evolveum.midpoint.gui.impl.component.data.column.PrismContainerWrapperColumn;
import com.evolveum.midpoint.web.application.Counter;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LocalizedMessageTemplateContentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MessageTemplateType;

/**
Expand All @@ -38,16 +62,54 @@
)
)
@Counter(provider = LocalizedContentCounter.class)
public class MessageTemplateLocalizedContentPanel extends AbstractObjectMainPanel<MessageTemplateType, AssignmentHolderDetailsModel<MessageTemplateType>> {
public class MessageTemplateLocalizedContentPanel extends MultivalueContainerListPanelWithDetailsPanel<LocalizedMessageTemplateContentType> {

public MessageTemplateLocalizedContentPanel(String id, AssignmentHolderDetailsModel<MessageTemplateType> model, ContainerPanelConfigurationType config) {
super(id, model, config);
private IModel<PrismContainerWrapper<LocalizedMessageTemplateContentType>> model;

public MessageTemplateLocalizedContentPanel(String id, AssignmentHolderDetailsModel model, ContainerPanelConfigurationType configurationType) {
super(id, LocalizedMessageTemplateContentType.class, configurationType);

this.model = PrismContainerWrapperModel.fromContainerWrapper(model.getObjectWrapperModel(), MessageTemplateType.F_LOCALIZED_CONTENT);
}

@Override
protected IColumn<PrismContainerValueWrapper<LocalizedMessageTemplateContentType>, String> createCheckboxColumn() {
return new CheckBoxHeaderColumn<>();
}

@Override
protected void initLayout() {
setOutputMarkupId(true);
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_MESSAGE_TEMPLATE_LOCALIZED_CONTENT_PANEL;
}

@Override
protected List<IColumn<PrismContainerValueWrapper<LocalizedMessageTemplateContentType>, String>> createDefaultColumns() {
return Arrays.asList(
new PrismPropertyWrapperColumn<>(getContainerModel(), LocalizedMessageTemplateContentType.F_LANGUAGE,
AbstractItemWrapperColumn.ColumnType.LINK, getPageBase()) {

@Override
protected void onClick(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<LocalizedMessageTemplateContentType>> model) {
MessageTemplateLocalizedContentPanel.this.itemDetailsPerformed(target, model);
}
}
);
}

@Override
protected boolean isCreateNewObjectVisible() {
return true;
}

@Override
protected IModel<PrismContainerWrapper<LocalizedMessageTemplateContentType>> getContainerModel() {
return model;
}

@Override
protected MultivalueContainerDetailsPanel<LocalizedMessageTemplateContentType> getMultivalueContainerDetailsPanel(
ListItem<PrismContainerValueWrapper<LocalizedMessageTemplateContentType>> item) {

return new TemplateContentDetailsPanel(MultivalueContainerListPanelWithDetailsPanel.ID_ITEM_DETAILS, item.getModel(), true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2010-2022 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.gui.impl.page.admin.messagetemplate;

import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.evolveum.midpoint.gui.api.component.DisplayNamePanel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LocalizedMessageTemplateContentType;

/**
* Created by Viliam Repan (lazyman).
*/
public class TemplateContentDetailsPanel extends MultivalueContainerDetailsPanel<LocalizedMessageTemplateContentType> {

public TemplateContentDetailsPanel(String id, IModel<PrismContainerValueWrapper<LocalizedMessageTemplateContentType>> model, boolean addDefaultPanel) {
super(id, model, addDefaultPanel);
}

public TemplateContentDetailsPanel(String id, IModel<PrismContainerValueWrapper<LocalizedMessageTemplateContentType>> model, boolean addDefaultPanel, ContainerPanelConfigurationType config) {
super(id, model, addDefaultPanel, config);
}

@Override
protected DisplayNamePanel<LocalizedMessageTemplateContentType> createDisplayNamePanel(String displayNamePanelId) {
return new DisplayNamePanel<>(displayNamePanelId, Model.of(getModelObject().getRealValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ <ID extends ItemDefinition> ItemWrapper getItemWrapperForHeader(Class<ID> type,
return null;
}

// TODO this should most definitely add parent wrapper to newly created item wrapper otherwise localization
// keys are mostly useless (unless nicely specified in XSD, which is not very often)
return createItemWrapper(def.instantiate(), pageBase);
} catch (SchemaException e) {
LOGGER.error("Cannot get {} with path {} from parent {}\nReason: {}", ItemWrapper.class, path,
this.parent.getObject(), e.getMessage(), e);
return null;
}
}

private ItemWrapper createItemWrapper(Item i, PageBase pageBase) throws SchemaException {
Task task = pageBase.createSimpleTask("Create wrapper for column header");
return pageBase.createItemWrapper(i, ItemStatus.NOT_CHANGED, new WrapperContext(task, task.getResult()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public enum TableId {
PAGE_RESOURCE_PANEL,
PAGE_RESOURCES_PANEL,
PAGE_RESOURCE_TASKS_PANEL,
PAGE_MESSAGE_TEMPLATE_LOCALIZED_CONTENT_PANEL,
PAGE_RESOURCE_ACCOUNTS_PANEL_REPOSITORY_MODE,
PAGE_RESOURCE_ACCOUNTS_PANEL_RESOURCE_MODE,
PAGE_RESOURCE_ENTITLEMENT_PANEL_REPOSITORY_MODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
<xsd:documentation>
How to construct the subject of the message that is to be sent.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.subjectExpression</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="subjectPrefix" type="xsd:string" minOccurs="0">
Expand All @@ -136,34 +139,49 @@
Simpler alternative to subjectExpression: the subject itself will be constructed by the notifier,
but it will be prefixed by value specified here.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.subjectPrefix</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="bodyExpression" type="c:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
How to construct the body (text) of the message that is to be sent.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.bodyExpression</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="contentType" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Body content type, e.g. text/plain (the default), text/html, and so on.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.contentType</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="contentTypeExpression" type="c:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expression returning body content type, e.g. text/plain (the default), text/html, and so on.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.contentTypeExpression</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="attachment" type="tns:NotificationMessageAttachmentType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Message attachment(s) to be sent out.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.attachment</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="attachmentExpression" type="tns:ExpressionType" minOccurs="0">
Expand All @@ -172,6 +190,9 @@
An expression that returns message attachment(s) to be sent out.
Returned objects should be of type NotificationMessageAttachmentType.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MessageTemplateContentType.attachmentExpression</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
Expand Down Expand Up @@ -202,6 +223,9 @@
a two-letter country code ("sk", "cs", "tr").
Languages with country-specific variants have country-specific subtags ("pt_BR", "zn_CN").
</xsd:documentation>
<xsd:appinfo>
<a:displayName>LocalizedMessageTemplateContentType.language</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
Expand Down

0 comments on commit 09c7ddd

Please sign in to comment.