Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Aug 21, 2019
2 parents 6736ec7 + 8880f63 commit 43c199e
Show file tree
Hide file tree
Showing 48 changed files with 378 additions and 193 deletions.
Expand Up @@ -31,7 +31,7 @@ public class GuiStyleConstants {
public static final String CLASS_OBJECT_USER_BOX_CSS_CLASSES = "object-user-box";
public static final String CLASS_OBJECT_USER_BOX_THIN_CSS_CLASSES = "object-user-box-thin";

public static final String CLASS_OBJECT_ROLE_ICON = "fa fa-street-view";
public static final String CLASS_OBJECT_ROLE_ICON = "fe fe-role_icon";
public static final String CLASS_OBJECT_ROLE_BG = "object-role-bg";
public static final String CLASS_DISABLED_OBJECT_ROLE_BG = "object-disabled-bg";
public static final String CLASS_OBJECT_ROLE_ICON_COLORED = CLASS_OBJECT_ROLE_ICON + " object-role-color";
Expand Down
Expand Up @@ -32,8 +32,8 @@ public class PasswordPropertyPanel extends PrismPropertyPanel<ProtectedStringTy

private static final String ID_PASSWORD_PANEL= "passwordPanel";

public PasswordPropertyPanel(String id, IModel<PrismPropertyWrapper<ProtectedStringType>> model, ItemVisibilityHandler visibilitytHandler){
super(id, model, visibilitytHandler);
public PasswordPropertyPanel(String id, IModel<PrismPropertyWrapper<ProtectedStringType>> model, ItemPanelSettings settings){
super(id, model, settings);
}

@Override
Expand Down
Expand Up @@ -30,7 +30,6 @@
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.registry.GuiComponentRegistry;
import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
Expand All @@ -39,11 +38,7 @@
import com.evolveum.midpoint.gui.impl.factory.ItemWrapperFactory;
import com.evolveum.midpoint.gui.impl.factory.PrismObjectWrapperFactory;
import com.evolveum.midpoint.gui.impl.factory.WrapperContext;
import com.evolveum.midpoint.gui.impl.prism.ItemVisibilityHandler;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValuePanel;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismValueWrapper;
import com.evolveum.midpoint.gui.impl.registry.GuiComponentRegistryImpl;
import com.evolveum.midpoint.gui.impl.prism.*;
import com.evolveum.midpoint.model.api.*;
import com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
Expand Down Expand Up @@ -106,7 +101,6 @@
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.web.page.admin.PageAdmin;
import com.evolveum.midpoint.web.page.admin.PageAdminFocus;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectList;
Expand Down Expand Up @@ -134,7 +128,6 @@
import com.evolveum.midpoint.web.page.admin.valuePolicy.PageValuePolicies;
import com.evolveum.midpoint.web.page.admin.valuePolicy.PageValuePolicy;
import com.evolveum.midpoint.web.page.admin.workflow.*;
import com.evolveum.midpoint.web.page.error.PageError;
import com.evolveum.midpoint.web.page.login.PageLogin;
import com.evolveum.midpoint.web.page.self.*;
import com.evolveum.midpoint.web.security.MidPointApplication;
Expand Down Expand Up @@ -188,7 +181,6 @@
import org.apache.wicket.util.string.StringValue;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

Expand Down Expand Up @@ -2690,15 +2682,8 @@ private Class<?> getWrapperPanel(QName typeName) {
return registry.getPanelClass(typeName);
}

public <IW extends ItemWrapper> Panel initItemPanel(String panelId, QName typeName, IModel<IW> wrapperModel, ItemVisibilityHandler visibilityHandler) throws SchemaException{
return initItemPanel(panelId, typeName, wrapperModel, visibilityHandler, false);
}

public <IW extends ItemWrapper> Panel initItemPanel(String panelId, QName typeName, IModel<IW> wrapperModel, ItemVisibilityHandler visibilityHandler, boolean isOnTopLevel) throws SchemaException{
if (wrapperModel.getObject() instanceof PrismContainerWrapper) {
((PrismContainerWrapper)wrapperModel.getObject()).setShowOnTopLevel(isOnTopLevel);
}


public <IW extends ItemWrapper> Panel initItemPanel(String panelId, QName typeName, IModel<IW> wrapperModel, ItemPanelSettings itemPanelSettings) throws SchemaException{
Class<?> panelClass = getWrapperPanel(typeName);
if (panelClass == null) {
ErrorPanel errorPanel = new ErrorPanel(panelId, () -> "Cannot create panel for " + typeName);
Expand All @@ -2708,8 +2693,8 @@ public <IW extends ItemWrapper> Panel initItemPanel(String panelId, QName typeNa

Constructor<?> constructor;
try {
constructor = panelClass.getConstructor(String.class, IModel.class, ItemVisibilityHandler.class);
Panel panel = (Panel) constructor.newInstance(panelId, wrapperModel, visibilityHandler);
constructor = panelClass.getConstructor(String.class, IModel.class, ItemPanelSettings.class);
Panel panel = (Panel) constructor.newInstance(panelId, wrapperModel, itemPanelSettings);
return panel;
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new SystemException("Cannot instantiate " + panelClass, e);
Expand Down
Expand Up @@ -41,17 +41,13 @@ public interface PrismContainerWrapper<C extends Containerable> extends ItemWrap

boolean isExpanded();

void setShowOnTopLevel(boolean setShowOnTopLevel);

boolean isShowOnTopLevel();


ItemStatus getStatus();

void setVirtual(boolean virtual);
boolean isVirtual();

// ItemWrapper<?, ?, ?,?> findItem(ItemPath path);



<T extends Containerable> PrismContainerWrapper<T> findContainer(ItemPath path) throws SchemaException;
<X> PrismPropertyWrapper<X> findProperty(ItemPath propertyPath) throws SchemaException;
<R extends Referencable> PrismReferenceWrapper<R> findReference(ItemPath path) throws SchemaException;
Expand Down
Expand Up @@ -16,6 +16,7 @@
package com.evolveum.midpoint.gui.api.util;

import com.evolveum.midpoint.common.LocalizationService;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.api.registry.GuiComponentRegistry;
import com.evolveum.midpoint.gui.impl.factory.PrismObjectWrapperFactory;
Expand All @@ -26,6 +27,7 @@
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.model.api.authentication.CompiledUserProfile;
import com.evolveum.midpoint.model.api.interaction.DashboardService;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.PrismValue;
Expand Down Expand Up @@ -94,11 +96,13 @@ default ObjectResolver getModelObjectResolver() {
return null;
}

public Locale getLocale();
Locale getLocale();

GuiComponentRegistry getRegistry();

<O extends ObjectType> PrismObjectWrapperFactory<O> findObjectWrapperFactory(PrismObjectDefinition<O> objectDef);

public <IW extends ItemWrapper, VW extends PrismValueWrapper, PV extends PrismValue> VW createValueWrapper(IW parentWrapper, PV newValue, ValueStatus status, WrapperContext context) throws SchemaException;
<I extends Item, IW extends ItemWrapper> IW createItemWrapper(I item, ItemStatus status, WrapperContext ctx) throws SchemaException;

<IW extends ItemWrapper, VW extends PrismValueWrapper, PV extends PrismValue> VW createValueWrapper(IW parentWrapper, PV newValue, ValueStatus status, WrapperContext context) throws SchemaException;
}
Expand Up @@ -1186,7 +1186,17 @@ public static <C extends Containerable> String getDisplayName(PrismContainerValu
} else if (prismContainerValue.canRepresent(UserInterfaceFeatureType.class)) {
UserInterfaceFeatureType userInterfaceFeature = (UserInterfaceFeatureType) prismContainerValue.asContainerable();
String identifier = userInterfaceFeature.getIdentifier();
if (StringUtils.isNotEmpty(identifier)) {

if (StringUtils.isBlank(identifier)) {
DisplayType uifDisplay = userInterfaceFeature.getDisplay();
if (uifDisplay != null) {
displayName = WebComponentUtil.getOrigStringFromPoly(uifDisplay.getLabel());
}

if (displayName == null) {
displayName = "UserInterfaceFeatureType.containerTitle";
}
} else {
displayName = identifier;
}
} else if (prismContainerValue.canRepresent(GuiObjectColumnType.class)) {
Expand Down
Expand Up @@ -93,6 +93,8 @@ public PrismContainerValueWrapper<C> createValueWrapper(PrismContainerWrapper<C>
PrismContainerValue<C> value, ValueStatus status, WrapperContext context)
throws SchemaException {
PrismContainerValueWrapper<C> containerValueWrapper = new PrismContainerValueWrapperImpl<C>(parent, value, status);
containerValueWrapper.setShowEmpty(context.isShowEmpty());
containerValueWrapper.setExpanded(shouldBeExpanded(parent, value, context));
containerValueWrapper.setHeterogenous(true);

List<ItemWrapper<?,?,?,?>> wrappers = new ArrayList<>();
Expand All @@ -117,6 +119,24 @@ public PrismContainerValueWrapper<C> createValueWrapper(PrismContainerWrapper<C>
containerValueWrapper.getItems().addAll((Collection) wrappers);
return containerValueWrapper;
}

protected boolean shouldBeExpanded(PrismContainerWrapper<C> parent, PrismContainerValue<C> value, WrapperContext context) {
if (value.isEmpty()) {
return context.isShowEmpty() || containsEmphasizedItems(parent.getDefinitions());
}

return true;
}

private boolean containsEmphasizedItems(List<? extends ItemDefinition> definitions) {
for (ItemDefinition def : definitions) {
if (def.isEmphasized()) {
return true;
}
}

return false;
}

protected List<PrismContainerValueWrapper<C>> createValuesWrapper(PrismContainerWrapper<C> itemWrapper, PrismContainer<C> item, WrapperContext context) throws SchemaException {
List<PrismContainerValueWrapper<C>> pvWrappers = new ArrayList<>();
Expand Down
Expand Up @@ -86,10 +86,8 @@ public int getOrder() {
public PrismContainerValueWrapper<C> createValueWrapper(PrismContainerWrapper<C> parent, PrismContainerValue<C> value, ValueStatus status, WrapperContext context)
throws SchemaException {
PrismContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(parent, value, status);
containerValueWrapper.setExpanded(shouldBeExpanded(parent, value, context));
containerValueWrapper.setShowEmpty(context.isShowEmpty());


List<ItemWrapper<?,?,?,?>> wrappers = new ArrayList<>();
for (ItemDefinition<?> def : getItemDefinitions(parent, value)) {
addItemWrapper(def, containerValueWrapper, context, wrappers);
Expand All @@ -98,6 +96,7 @@ public PrismContainerValueWrapper<C> createValueWrapper(PrismContainerWrapper<C>
containerValueWrapper.getItems().addAll((Collection) wrappers);
containerValueWrapper.setVirtualContainerItems(context.getVirtualItemSpecification());
parent.setVirtual(context.getVirtualItemSpecification() != null);
containerValueWrapper.setExpanded(shouldBeExpanded(parent, value, context));
return containerValueWrapper;
}

Expand Down Expand Up @@ -147,7 +146,12 @@ public PrismContainerValueWrapper<C> createContainerValueWrapper(PrismContainerW
}

protected boolean shouldBeExpanded(PrismContainerWrapper<C> parent, PrismContainerValue<C> value, WrapperContext context) {
if (value.isEmpty()) {

if (context.getVirtualItemSpecification() != null) {
return true;
}

if (value.isEmpty()) {
return context.isShowEmpty() || containsEmphasizedItems(parent.getDefinitions());
}

Expand Down
Expand Up @@ -87,7 +87,7 @@ public PrismObjectWrapper<O> createObjectWrapper(PrismObject<O> object, ItemStat
PrismContainerValueWrapper<O> valueWrapper = createValueWrapper(objectWrapper, object.getValue(), ItemStatus.ADDED == status ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, context);
objectWrapper.getValues().add(valueWrapper);

registry.registerWrapperPanel(object.getDefinition().getTypeName(), PrismObjectValuePanel.class);
registry.registerWrapperPanel(object.getDefinition().getTypeName(), PrismContainerPanel.class);
return objectWrapper;

}
Expand Down
Expand Up @@ -18,6 +18,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettingsBuilder;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

Expand Down Expand Up @@ -61,8 +62,9 @@ protected void onInitialize() {
protected void initLayout() {

try {
Panel panel = getPageBase().initItemPanel(ID_CONTAINER, typeName, getModel(), wrapper -> getVisibity(wrapper.getPath()));
getModelObject().setShowOnTopLevel(true);
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(wrapper -> getVisibity(wrapper.getPath())).showOnTopLevel(true);
Panel panel = getPageBase().initItemPanel(ID_CONTAINER, typeName, getModel(), builder.build());
// getModelObject().setShowOnTopLevel(true);
add(panel);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for {}, {}", typeName, e.getMessage(), e);
Expand Down
Expand Up @@ -23,6 +23,8 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettings;
import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettingsBuilder;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -117,8 +119,10 @@ protected void onInitialize() {

protected void initLayout() {
try {
getModelObject().setShowOnTopLevel(true);
Panel loggingPanel = getPageBase().initItemPanel(ID_LOGGING, LoggingConfigurationType.COMPLEX_TYPE, getModel(), itemWrapper -> getLoggingVisibility(itemWrapper.getPath()));
// getModelObject().setShowOnTopLevel(true);
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder();
builder.visibilityHandler(itemWrapper -> getLoggingVisibility(itemWrapper.getPath())).showOnTopLevel(true);
Panel loggingPanel = getPageBase().initItemPanel(ID_LOGGING, LoggingConfigurationType.COMPLEX_TYPE, getModel(), builder.build());
add(loggingPanel);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel for logging: {}", e.getMessage(), e);
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.gui.impl.page.admin.configuration.component;

import com.evolveum.midpoint.common.configuration.api.ProfilingMode;
import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettingsBuilder;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Panel;
Expand Down Expand Up @@ -101,8 +102,8 @@ public boolean isVisible() {
add(profilingEnabledNote);

try {
getProfilingModel().getObject().setShowOnTopLevel(true);
Panel panel = getPageBase().initItemPanel(ID_PROFILING, ProfilingConfigurationType.COMPLEX_TYPE, getProfilingModel(), null);
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().showOnTopLevel(true);
Panel panel = getPageBase().initItemPanel(ID_PROFILING, ProfilingConfigurationType.COMPLEX_TYPE, getProfilingModel(), builder.build());
add(panel);
} catch (SchemaException e) {
LOGGER.error("Cannot create profiling panel. Reason: {}", e.getMessage(), e);
Expand All @@ -111,8 +112,8 @@ public boolean isVisible() {

PrismContainerWrapperModel<LoggingConfigurationType, ClassLoggerConfigurationType> profilingLogger = PrismContainerWrapperModel.fromContainerWrapper(getLoggingModel(), ItemPath.create(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH));
try {
profilingLogger.getObject().setShowOnTopLevel(true);
Panel logger = getPageBase().initItemPanel(ID_PROFILING_LOGGER, ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH, profilingLogger, null);
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().showOnTopLevel(true);
Panel logger = getPageBase().initItemPanel(ID_PROFILING_LOGGER, ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH, profilingLogger, builder.build());
add(logger);
} catch (SchemaException e) {
LOGGER.error("Cannot create profiling panel. Reason: {}", e.getMessage(), e);
Expand Down
Expand Up @@ -16,6 +16,7 @@

package com.evolveum.midpoint.gui.impl.page.admin.configuration.component;

import com.evolveum.midpoint.gui.impl.prism.ItemPanelSettingsBuilder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -58,7 +59,8 @@ protected void onInitialize() {

protected void initLayout() {
try {
Panel panel = getPageBase().initItemPanel(ID_SYSTEM_CONFIG, SystemConfigurationType.COMPLEX_TYPE, getModel(), itemWrapper -> getBasicTabVisibity(itemWrapper));
ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(itemWrapper -> getBasicTabVisibity(itemWrapper));
Panel panel = getPageBase().initItemPanel(ID_SYSTEM_CONFIG, SystemConfigurationType.COMPLEX_TYPE, getModel(), builder.build());
add(panel);
} catch (SchemaException e) {
LOGGER.error("Cannot create basic panel for system configuration.");
Expand Down
Expand Up @@ -61,12 +61,12 @@ public abstract class ItemPanel<VW extends PrismValueWrapper, IW extends ItemWra
private static final String ID_REMOVE_BUTTON = "removeButton";
private static final String ID_BUTTON_CONTAINER = "buttonContainer";

private ItemVisibilityHandler visibilityHandler;
private ItemPanelSettings itemPanelSettings;


public ItemPanel(String id, IModel<IW> model, ItemVisibilityHandler visibilityHandler) {
public ItemPanel(String id, IModel<IW> model, ItemPanelSettings itemPanelSettings) {
super(id, model);
this.visibilityHandler = visibilityHandler;
this.itemPanelSettings = itemPanelSettings;
}

@Override
Expand All @@ -88,6 +88,9 @@ private void initLayout() {
}

protected boolean getHeaderVisibility() {
if (!isHeaderVisible()) {
return false;
}
return getParent().findParent(AbstractItemWrapperColumnPanel.class) == null;
}

Expand All @@ -104,7 +107,7 @@ protected void populateItem(ListItem<VW> item) {
GuiComponentFactory componentFactory = getPageBase().getRegistry()
.findValuePanelFactory(ItemPanel.this.getModelObject());

Component panel = createValuePanel(item, componentFactory, visibilityHandler);
Component panel = createValuePanel(item, componentFactory, getVisibilityHandler());
panel.add(new EnableBehaviour(() -> !ItemPanel.this.getModelObject().isReadOnly()));
createButtons(item);
}
Expand Down Expand Up @@ -287,6 +290,29 @@ private boolean isVisibleValue(IModel<VW> model) {
}

public ItemVisibilityHandler getVisibilityHandler() {
return visibilityHandler;
if (itemPanelSettings == null) {
return null;
}
return itemPanelSettings.getVisibilityHandler();
}

protected boolean isShowOnTopLevel() {
if (itemPanelSettings == null) {
return false;
}
return itemPanelSettings.isShowOnTopLevel();
}


protected boolean isHeaderVisible() {
if (itemPanelSettings == null) {
return true;
}

return itemPanelSettings.isHeaderVisible();
}

public ItemPanelSettings getSettings() {
return itemPanelSettings;
}
}

0 comments on commit 43c199e

Please sign in to comment.