Skip to content

Commit

Permalink
some more fixed -system config page
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Apr 26, 2019
1 parent c5f9bda commit 3a9a07d
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 156 deletions.
Expand Up @@ -58,10 +58,11 @@ protected void onInitialize() {
private void initLayout() {
ListView<VW> listView = new ListView<VW>(ID_VALUES, new PropertyModel<>(getModel(), "values")) {

private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<VW> item) {
populate(item);

}
};
listView.setReuseItems(true);
Expand Down
Expand Up @@ -48,7 +48,7 @@ public PrismPropertyColumn(IModel<PrismContainerWrapper<C>> mainModel, ItemPath

@Override
public IModel<?> getDataModel(IModel<PrismContainerValueWrapper<C>> rowModel) {
return Model.of(PrismPropertyWrapperModel.fromContainerValueWrapper(rowModel, itemName));
return PrismPropertyWrapperModel.fromContainerValueWrapper(rowModel, itemName);
}

@Override
Expand All @@ -61,6 +61,8 @@ protected Component createHeader(String componentId, IModel<PrismContainerWrappe
protected <IW extends ItemWrapper> Component createColumnPanel(String componentId, IModel<IW> rowModel) {
return new PrismPropertyWrapperColumnPanel<T>(componentId, (IModel<PrismPropertyWrapper<T>>) rowModel, getColumnType()) {

private static final long serialVersionUID = 1L;

@Override
protected void onClick(AjaxRequestTarget target, PrismContainerValueWrapper<?> rowModel) {
PrismPropertyColumn.this.onClick(target, (IModel) Model.of(rowModel));
Expand Down
Expand Up @@ -25,7 +25,6 @@
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand All @@ -46,7 +45,8 @@ public class PrismPropertyWrapperColumnPanel<T> extends AbstractItemWrapperColum

@Override
protected String createLabel(PrismPropertyValueWrapper<T> object) {
return object.getRealValue().toString();
return object.toShortString();

}

@Override
Expand All @@ -64,17 +64,6 @@ protected Panel createValuePanel(String id, IModel<PrismPropertyWrapper<T>> mode
}

return panel;
// GuiComponentFactory<PrismPropertyPanelContext<T>> factory = getPageBase().getRegistry().findValuePanelFactory((PrismPropertyWrapper<T>) headerModel.getObject());
//
// FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
//
//
// PrismPropertyPanelContext<T> panelCtx = new PrismPropertyPanelContext<>((IModel<PrismPropertyWrapper<T>>)headerModel);
// panelCtx.setForm(new Form("form"));
// panelCtx.setFeedbackPanel(feedbackPanel);
// panelCtx.setComponentId(ID_INPUT);
// panelCtx.setRealValueModel(new ItemRealValueModel((IModel<PrismPropertyWrapper<T>>) headerModel));
// return factory.createPanel(panelCtx);
}

@Override
Expand Down
Expand Up @@ -23,13 +23,15 @@
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.gui.api.factory.GuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.api.registry.GuiComponentRegistry;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.page.admin.configuration.component.ProfilingLevel;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
Expand All @@ -39,6 +41,7 @@
import com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingLevelType;

/**
* @author katkav
Expand Down Expand Up @@ -68,13 +71,13 @@ public Panel createPanel(PrismPropertyPanelContext<QName> panelCtx) {
typesList = WebComponentUtil.createObjectTypeList();
}


DropDownChoicePanel<QName> typePanel = new DropDownChoicePanel<QName>(panelCtx.getComponentId(), (IModel<QName>) panelCtx.getRealValueModel(),
Model.ofList(typesList), new QNameObjectTypeChoiceRenderer(), true);
typePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
typePanel.setOutputMarkupId(true);
return typePanel;
}


@Override
public Integer getOrder() {
Expand Down
Expand Up @@ -81,7 +81,4 @@ protected Panel getPanel(PrismPropertyPanelContext<T> panelCtx) {

}




}
Expand Up @@ -47,7 +47,7 @@ public void register() {

@Override
public <IW extends ItemWrapper> boolean match(IW wrapper) {
return FocusType.F_DESCRIPTION.equals(wrapper.getName()) || QueryType.COMPLEX_TYPE.equals(wrapper.getTypeName()) || CleanupPoliciesType.COMPLEX_TYPE.equals(wrapper.getTypeName());
return FocusType.F_DESCRIPTION.equals(wrapper.getName()) || QueryType.COMPLEX_TYPE.equals(wrapper.getTypeName()); // || CleanupPoliciesType.COMPLEX_TYPE.equals(wrapper.getTypeName());
}

@Override
Expand Down
Expand Up @@ -18,19 +18,17 @@

import javax.xml.namespace.QName;

import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.prism.PrismObjectWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerPanel;
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.prism.ItemVisibility;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PcpAspectConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PrimaryChangeProcessorConfigurationType;
Expand All @@ -40,18 +38,18 @@
/**
* @author skublik
*/
public class ContainerOfSystemConfigurationPanel<C extends Containerable> extends BasePanel<PrismObjectWrapper<SystemConfigurationType>> {
public class ContainerOfSystemConfigurationPanel<C extends Containerable> extends BasePanel<PrismContainerWrapper<C>> {

private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(ContainerOfSystemConfigurationPanel.class);

private static final String ID_CONTAINER = "container";
private ItemName qNameContainer;
private QName typeName = null;

public ContainerOfSystemConfigurationPanel(String id, IModel<PrismObjectWrapper<SystemConfigurationType>> model, QName qNameContainer) {
public ContainerOfSystemConfigurationPanel(String id, IModel<PrismContainerWrapper<C>> model, QName typeName) {
super(id, model);
this.qNameContainer = ItemName.fromQName(qNameContainer);
this.typeName = typeName;
}

@Override
Expand All @@ -62,12 +60,13 @@ protected void onInitialize() {

protected void initLayout() {

Form form = new Form<>("form");

PrismContainerWrapperModel<SystemConfigurationType, C> model = PrismContainerWrapperModel.fromContainerWrapper(getModel(), qNameContainer);
PrismContainerPanel<C> panel = new PrismContainerPanel<>(ID_CONTAINER, model);
// PrismContainerPanelOld<C> panel = new PrismContainerPanelOld<>(ID_CONTAINER, model, form, itemWrapper -> getVisibity(itemWrapper.getPath()));
add(panel);
try {
Panel panel = getPageBase().initPanel(ID_CONTAINER, typeName, getModel(), false);
add(panel);
} catch (SchemaException e) {
getSession().error("Cannot create panel for " + typeName); // TODO opertion result? localization?

}

}

Expand Down
Expand Up @@ -36,6 +36,7 @@
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
Expand Down Expand Up @@ -66,6 +67,7 @@
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.AjaxSubmitButton;
Expand Down Expand Up @@ -127,10 +129,18 @@ protected void onInitialize() {
}

protected void initLayout() {
PrismContainerPanel<LoggingConfigurationType> loggingPanel = new PrismContainerPanel<>(ID_LOGGING, getModel());
try {
Panel loggingPanel = getPageBase().initPanel(ID_LOGGING, LoggingConfigurationType.COMPLEX_TYPE, getModel(), false);
add(loggingPanel);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for logging: {}", e.getMessage(), e);
getSession().error("Cannot create panle for logging");
}

// PrismContainerPanel<LoggingConfigurationType> loggingPanel = new PrismContainerPanel<>(ID_LOGGING, getModel());
// PrismContainerPanelOld<LoggingConfigurationType> loggingPanel = (PrismContainerPanelOld<LoggingConfigurationType>) getModelObject().createPanel(ID_LOGGING, new Form("form"), itemWrapper -> getLoggingVisibility(itemWrapper.getPath()));
// PrismContainerPanel<LoggingConfigurationType> loggingPanel = new PrismContainerPanel<LoggingConfigurationType>(ID_LOGGING, getModel(), true, new Form<>("form"), itemWrapper -> getLoggingVisibility(itemWrapper.getPath()), getPageBase());
add(loggingPanel);



TableId tableIdLoggers = UserProfileStorage.TableId.LOGGING_TAB_LOGGER_TABLE;
Expand Down Expand Up @@ -317,13 +327,20 @@ public boolean isEnabled() {
add(appendersMultivalueContainerListPanel);

IModel<PrismContainerWrapper<AuditingConfigurationType>> auditModel = PrismContainerWrapperModel.fromContainerWrapper(getModel(), LoggingConfigurationType.F_AUDITING);
try {
Panel auditPanel = getPageBase().initPanel(ID_AUDITING, AuditingConfigurationType.COMPLEX_TYPE, auditModel, false);
add(auditPanel);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for auditing: {}", e.getMessage(), e);
getSession().error("Cannot create panel for auditing.");
}
// new ContainerWrapperFromObjectWrapperModel<AuditingConfigurationType, SystemConfigurationType>(Model.of(getModelObject().getObjectWrapper()),
// ItemPath.create(SystemConfigurationType.F_LOGGING, LoggingConfigurationType.F_AUDITING));
PrismContainerPanel<AuditingConfigurationType> auditPanel = new PrismContainerPanel<>(ID_AUDITING, auditModel);
// PrismContainerPanel<AuditingConfigurationType> auditPanel = new PrismContainerPanel<>(ID_AUDITING, auditModel);
// PrismContainerPanelOld<AuditingConfigurationType> auditPanel = (PrismContainerPanelOld<AuditingConfigurationType>) auditModel.getObject().createPanel(ID_AUDITING, new Form("form"), null);
// PrismContainerPanel<AuditingConfigurationType> auditPanel = new PrismContainerPanel<>(ID_AUDITING, auditModel, true,
// new Form<>("form"), null, getPageBase());
add(auditPanel);

setOutputMarkupId(true);
}

Expand Down
Expand Up @@ -52,6 +52,7 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.component.data.column.EditableColumn;
import com.evolveum.midpoint.gui.impl.component.form.TriStateFormGroup;
import com.evolveum.midpoint.gui.impl.factory.ItemRealValueModel;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyHeaderPanel;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
Expand Down Expand Up @@ -115,8 +116,8 @@ public class NotificationConfigTabPanel extends BasePanel<PrismContainerWrapper<
private static final String ID_FILE_PATH = "filePath";
private static final String ID_REMOVE_BUTTON = "removeButton";

private MailConfigurationType mailConfigType;
private List<MailServerConfiguration> mailServers;
// private MailConfigurationType mailConfigType;
// private List<MailServerConfiguration> mailServers;

public NotificationConfigTabPanel(String id, IModel<PrismContainerWrapper<NotificationConfigurationType>> model) {
super(id, model);
Expand Down Expand Up @@ -148,14 +149,16 @@ protected void initLayout() {
Form form = new Form<>("form");


if(mailConfig != null) {
mailConfigType = new PropertyModel<MailConfigurationType>(mailConfig, "values[0].value.value").getObject();
}
// if(mailConfig != null) {
// mailConfigType = new PropertyModel<MailConfigurationType>(mailConfig, "values[0].value.value").getObject();
// }
//
// if(mailConfigType == null) {
// mailConfigType = new MailConfigurationType();
// ((PrismPropertyValue<MailConfigurationType>)((List<PrismPropertyValueWrapper<MailConfigurationType>>)mailConfig.getObject().getValues()).get(0)).setValue(mailConfigType);
// }

if(mailConfigType == null) {
mailConfigType = new MailConfigurationType();
((PrismPropertyValue<MailConfigurationType>)((List<PrismPropertyValueWrapper<MailConfigurationType>>)mailConfig.getObject().getValues()).get(0)).setValue(mailConfigType);
}
PropertyModel<MailConfigurationType> mailConfigType = new ItemRealValueModel<>(new PropertyModel<>(mailConfig, "value"));

add(new TextFormGroup(ID_DEFAULT_FROM, new PropertyModel<String>(mailConfigType, "defaultFrom"), createStringResource(mailConfig.getObject().getTypeName().getLocalPart() + ".defaultFrom"), "", getInputCssClass(), false, true));

Expand All @@ -167,7 +170,7 @@ protected void initLayout() {

add(createHeader(ID_MAIL_SERVER_CONFIG_HEADER, MailServerConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));

add(initServersTable());
add(initServersTable(mailConfigType));

add(createHeader(ID_FILE_CONFIG_HEADER, FileConfigurationType.COMPLEX_TYPE.getLocalPart() + ".details"));

Expand Down Expand Up @@ -253,9 +256,9 @@ public void onClick(AjaxRequestTarget target) {

}

private BoxedTablePanel<MailServerConfiguration> initServersTable() {
private BoxedTablePanel<MailServerConfiguration> initServersTable(PropertyModel<MailConfigurationType> mailConfigType) {

mailServers = getListOfMailServerConfiguration(mailConfigType.getServer());
List<MailServerConfiguration> mailServers = getListOfMailServerConfiguration(mailConfigType.getObject().getServer());
PageStorage pageStorage = getPageBase().getSessionStorage().getNotificationConfigurationTabMailServerTableStorage();
ISortableDataProvider<MailServerConfiguration, String> provider = new ListDataProvider<MailServerConfiguration>(this,
new ListModel<MailServerConfiguration>(mailServers) {
Expand All @@ -265,9 +268,9 @@ private BoxedTablePanel<MailServerConfiguration> initServersTable() {
@Override
public void setObject(List<MailServerConfiguration> object) {
super.setObject(object);
mailConfigType.getServer().clear();
mailConfigType.getObject().getServer().clear();
for(MailServerConfiguration value : object) {
mailConfigType.server(value.getValue());
mailConfigType.getObject().server(value.getValue());
}

}
Expand Down Expand Up @@ -304,7 +307,7 @@ protected WebMarkupContainer createButtonToolbar(String id) {

@Override
public void onClick(AjaxRequestTarget target) {
newItemPerformed(target);
newItemPerformed(target, mailServers, mailConfigType);
}
};
newObjectIcon.add(AttributeModifier.append("class", Model.of("btn btn-success btn-sm")));
Expand Down Expand Up @@ -340,9 +343,9 @@ private Label createHeader(String id, String displayName) {
return header;
}

private void newItemPerformed(AjaxRequestTarget target) {
private void newItemPerformed(AjaxRequestTarget target, List<MailServerConfiguration> mailServers, PropertyModel<MailConfigurationType> mailConfigType) {
MailServerConfigurationType newServerType = new MailServerConfigurationType();
mailConfigType.server(newServerType);
mailConfigType.getObject().server(newServerType);
MailServerConfiguration newServer = new MailServerConfiguration(newServerType);
mailServers.add(newServer);
mailServerEditPerformed(target, Model.of(newServer), null);
Expand Down Expand Up @@ -518,13 +521,13 @@ private void deleteItemPerformed(AjaxRequestTarget target, List<MailServerConfig
PrismPropertyWrapperModel<NotificationConfigurationType, MailConfigurationType> mailConfigModel = PrismPropertyWrapperModel.fromContainerWrapper(getModel(), NotificationConfigurationType.F_MAIL);

PropertyModel<MailConfigurationType> mailConfigType =
new PropertyModel<MailConfigurationType>(mailConfigModel, "values[0].value.value");
new ItemRealValueModel<>(new PropertyModel<>(mailConfigModel, "value"));
List<MailServerConfigurationType> servers = mailConfigType.getObject().getServer();

toDelete.forEach(value -> {
servers.remove(value.getValue());
});
target.add(this.addOrReplace(initServersTable()));
target.add(this.addOrReplace(initServersTable(mailConfigType)));
reloadSavePreviewButtons(target);
}

Expand Down
Expand Up @@ -241,6 +241,8 @@ protected DisplayType getIconDisplayType(IModel<PrismContainerValueWrapper<Objec

columns.add(new PrismPropertyColumn<ObjectPolicyConfigurationType, QName>(getModel(), ObjectPolicyConfigurationType.F_TYPE, ColumnType.LINK) {

private static final long serialVersionUID = 1L;

@Override
protected void onClick(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ObjectPolicyConfigurationType>> rowModel) {
getMultivalueContainerListPanel().itemDetailsPerformed(target, rowModel);
Expand Down
Expand Up @@ -40,7 +40,7 @@ <h3 class="box-title"><wicket:message key="Note"/></h3>
</div>
<div class="prism-properties">
<div class="row prism-property" wicket:id="profilingLoggerAppenders"/>
<div class="row prism-property" wicket:id="profilingLoggerLevel"/>
<!-- <div class="row prism-property" wicket:id="profilingLoggerLevel"/> -->
</div>
</div>
</div>
Expand Down

0 comments on commit 3a9a07d

Please sign in to comment.