Skip to content

Commit

Permalink
Merge branch 'master' into feature/multiaccounts
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed May 6, 2019
2 parents 532bea8 + 6d9e57c commit 0a49770
Show file tree
Hide file tree
Showing 27 changed files with 373 additions and 103 deletions.
Expand Up @@ -185,6 +185,7 @@ public class GuiStyleConstants {
public static final String EVO_CROW_ICON = "fe fe-crown-object";
public static final String EVO_RIGHT_TOP_ARROW_ICON = "fe fe-arrow";
public static final String EVO_ASSIGNMENT_ICON = "fe fe-assignment";
public static final String EVO_ASSIGNMENT_ARROW_ICON = "fe fe-action-assign";
public static final String EVO_ASSIGNMENT_ICON_A_PIECE = "fe fe-assign_horizontal_A_piece";
public static final String EVO_ASSIGNMENT_ICON_B_PIECE = "fe fe-assign_horizontal_B_piece";
public static final String EVO_OFFICER_CAP_ICON = "fe fe-officer-cap-object";
Expand Down
Expand Up @@ -3293,35 +3293,62 @@ public static DisplayType createDisplayType(String iconCssClass, String iconColo
return displayType;
}

public static CompositedIconBuilder getAssignmentRelationIconBuilder(PageBase pageBase, AssignmentObjectRelation relationSpec, DisplayType additionalButtonDisplayType){

public static IconType createIconType(String iconStyle){
return createIconType(iconStyle, "");
}

public static IconType createIconType(String iconStyle, String color){
IconType icon = new IconType();
icon.setCssClass(iconStyle);
icon.setColor(color);
return icon;
}


public static CompositedIconBuilder getAssignmentRelationIconBuilder(PageBase pageBase, AssignmentObjectRelation relationSpec,
IconType relationIcon, IconType actionButtonIcon){
CompositedIconBuilder builder = new CompositedIconBuilder();
if (relationSpec == null){
return null;
if (actionButtonIcon == null){
return null;
}
builder.setBasicIcon(actionButtonIcon, IconCssStyle.CENTER_STYLE_WITH_RIGHT_SHIFT)
.appendColorHtmlValue(actionButtonIcon.getColor());
return builder;
}
CompositedIconBuilder builder = new CompositedIconBuilder();
String typeIconStyle = "";
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(relationSpec.getArchetypeRefs())){
DisplayType objectTypeDisplay = null;
if (CollectionUtils.isNotEmpty(relationSpec.getArchetypeRefs())){
try {
String operation = pageBase.getClass().getSimpleName() + "." + "loadArchetypeObject";
ArchetypeType archetype = pageBase.getModelObjectResolver().resolve(relationSpec.getArchetypeRefs().get(0), ArchetypeType.class,
null, null, pageBase.createSimpleTask(operation),
new OperationResult(operation));
if (archetype != null && archetype.getArchetypePolicy() != null){
DisplayType archetypeDisplayType = archetype.getArchetypePolicy().getDisplay();
typeIconStyle = WebComponentUtil.getIconCssClass(archetypeDisplayType);
objectTypeDisplay = archetype.getArchetypePolicy().getDisplay();
}
} catch (Exception ex){
LOGGER.error("Couldn't load archetype object, " + ex.getLocalizedMessage());
}
}
QName objectType = org.apache.commons.collections.CollectionUtils.isNotEmpty(relationSpec.getObjectTypes()) ? relationSpec.getObjectTypes().get(0) : null;
if (StringUtils.isEmpty(typeIconStyle) && objectType != null){
typeIconStyle = WebComponentUtil.createDefaultBlackIcon(objectType);
if (objectTypeDisplay == null){
objectTypeDisplay = new DisplayType();
}
builder.setBasicIcon(WebComponentUtil.getIconCssClass(additionalButtonDisplayType), IconCssStyle.IN_ROW_STYLE)
.appendColorHtmlValue(WebComponentUtil.getIconColor(additionalButtonDisplayType))
.appendLayerIcon(GuiStyleConstants.CLASS_PLUS_CIRCLE, IconCssStyle.BOTTOM_RIGHT_STYLE, GuiStyleConstants.GREEN_COLOR);
if (StringUtils.isNotEmpty(typeIconStyle)){
builder.appendLayerIcon(typeIconStyle, IconCssStyle.BOTTOM_LEFT_STYLE);
if (objectTypeDisplay.getIcon() == null){
objectTypeDisplay.setIcon(new IconType());
}
QName objectType = org.apache.commons.collections.CollectionUtils.isNotEmpty(relationSpec.getObjectTypes()) ? relationSpec.getObjectTypes().get(0) : null;
if (StringUtils.isEmpty(WebComponentUtil.getIconCssClass(objectTypeDisplay)) && objectType != null){
objectTypeDisplay.getIcon().setCssClass(WebComponentUtil.createDefaultBlackIcon(objectType));
}
if (StringUtils.isNotEmpty(WebComponentUtil.getIconCssClass(objectTypeDisplay))) {
builder.setBasicIcon(objectTypeDisplay.getIcon(), IconCssStyle.CENTER_STYLE_WITH_RIGHT_SHIFT)
.appendColorHtmlValue(WebComponentUtil.getIconColor(objectTypeDisplay))
.appendLayerIcon(actionButtonIcon, IconCssStyle.BOTTOM_RIGHT_STYLE)
.appendLayerIcon(relationIcon, IconCssStyle.TOP_RIGHT_STYLE);
} else {
builder.setBasicIcon(actionButtonIcon, IconCssStyle.CENTER_STYLE_WITH_RIGHT_SHIFT)
.appendColorHtmlValue(actionButtonIcon.getColor());
}
return builder;
}
Expand Down Expand Up @@ -3520,26 +3547,32 @@ public static DisplayType getAssignmentObjectRelationDisplayType(PageBase pageBa
if (relation != null){
RelationDefinitionType def = WebComponentUtil.getRelationDefinition(relation);
if (def != null){
DisplayType displayType = def.getDisplay();
if (displayType == null){
DisplayType displayType = null;
if (def.getDisplay() == null){
displayType = new DisplayType();
} else {
displayType = createDisplayType(def.getDisplay().getCssClass());
if (def.getDisplay().getIcon() != null){
displayType.setIcon(new IconType());
displayType.getIcon().setCssClass(def.getDisplay().getIcon().getCssClass());
displayType.getIcon().setColor(def.getDisplay().getIcon().getColor());
}
}
if (displayType.getLabel() != null && StringUtils.isNotEmpty(displayType.getLabel().getOrig())){
relationValue = pageBase.createStringResource(displayType.getLabel().getOrig()).getString();
} else {
String relationKey = "RelationTypes." + RelationTypes.getRelationTypeByRelationValue(relation);
relationValue = pageBase.createStringResource(relationValue).getString();
if (relationKey.equals(relationValue)){
if (StringUtils.isEmpty(relationValue) || relationKey.equals(relationValue)){
relationValue = relation.getLocalPart();
}
}

relationTitle = pageBase.createStringResource("abstractRoleMemberPanel.withRelation", relationValue).getString();


if (displayType.getIcon() == null){
displayType = createDisplayType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green",
pageBase.createStringResource(defaultTitleKey, typeTitle, relationTitle).getString());
if (displayType.getIcon() == null || StringUtils.isEmpty(displayType.getIcon().getCssClass())){
displayType.setIcon(createIconType(""));
}
displayType.setTooltip(createPolyFromOrigString(pageBase.createStringResource(defaultTitleKey, typeTitle, relationTitle).getString()));
return displayType;
Expand Down
Expand Up @@ -18,6 +18,7 @@

import java.util.Map.Entry;

import com.evolveum.midpoint.xml.ns._public.common.common_3.IconType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.markup.html.AjaxLink;
Expand Down Expand Up @@ -91,9 +92,15 @@ public void onComponentTagBody(final MarkupStream markupStream, final ComponentT
}

if(icon.hasLayerIcons()) {
for(String entry : icon.getLayerIcons()) {
if (StringUtils.isNotEmpty(entry)) {
sb.append("<i class=\"").append(entry).append("\"");
for(IconType entry : icon.getLayerIcons()) {
if (entry == null){
continue;
}
if (StringUtils.isNotEmpty(entry.getCssClass())) {
sb.append("<i class=\"").append(entry.getCssClass()).append("\"");
if (StringUtils.isNotEmpty(entry.getColor())) {
sb.append(" style=\"color: ").append(entry.getColor()).append(";\"");
}
sb.append("></i> ");
}
}
Expand Down
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2010-2019 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.component.icon;

/**
* Created by honchar
*/
public class CenterWithRightShiftCssStyle implements LayeredIconCssStyle {

@Override
public String getBasicCssClass() {
return "icon-basic-transparent";
}

@Override
public String getBasicLayerCssClass() {
return "center-with-right-shift-layer";
}

@Override
public String getLayerCssClass() {
return "center-layer";
}

@Override
public String getStrokeLayerCssClass() {
return "center-icon-stroke-layer";
}

}

Expand Up @@ -19,6 +19,7 @@
import java.io.Serializable;
import java.util.List;

import com.evolveum.midpoint.xml.ns._public.common.common_3.IconType;
import org.apache.commons.lang.StringUtils;

/**
Expand All @@ -29,11 +30,11 @@ public class CompositedIcon implements Serializable {
private static final long serialVersionUID = 1L;

private String basicIcon;
private List<String> layerIcons;
private List<IconType> layerIcons;
private String basicIconHtmlColor = "";


public CompositedIcon(String basicIcon, List<String> layerIcons, String basicIconHtmlColor){
public CompositedIcon(String basicIcon, List<IconType> layerIcons, String basicIconHtmlColor){
this.basicIcon = basicIcon;
this.layerIcons = layerIcons;
this.basicIconHtmlColor = basicIconHtmlColor;
Expand All @@ -43,7 +44,7 @@ public String getBasicIcon() {
return basicIcon;
}

public List<String> getLayerIcons() {
public List<IconType> getLayerIcons() {
return layerIcons;
}

Expand Down
Expand Up @@ -20,6 +20,9 @@
import java.util.List;
import java.util.Map.Entry;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IconType;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;

Expand All @@ -31,7 +34,7 @@
public class CompositedIconBuilder {

private String basicIcon = "";
private List<String> layerIcons = new ArrayList<String>();
private List<IconType> layerIcons = new ArrayList<IconType>();
private String colorHtmlValue = "";

public CompositedIcon build() {
Expand All @@ -47,11 +50,11 @@ private void setBasicIcon(String icon, String style) {
basicIcon = sb.toString();
}

private void appendLayerIcon(String icon) {
private void appendLayerIcon(IconType icon) {
layerIcons.add(icon);
}

private void appendLayerIcon(int index, String icon) {
private void appendLayerIcon(int index, IconType icon) {
layerIcons.add(index, icon);
}

Expand Down Expand Up @@ -81,7 +84,19 @@ public CompositedIconBuilder setBasicIcon(String icon, LayeredIconCssStyle style
if(StringUtils.isNotEmpty(additionalCssClass)) {
sb.append(" ").append(additionalCssClass);
}
appendLayerIcon(0, sb.toString());
appendLayerIcon(0, WebComponentUtil.createIconType(sb.toString()));
return this;
}

public CompositedIconBuilder setBasicIcon(IconType icon, LayeredIconCssStyle style) {
Validate.notNull(icon, "no icon object");
Validate.notNull(icon.getCssClass(), "no icon class");
Validate.notNull(style, "no icon style");

setBasicIcon(icon.getCssClass(), style.getBasicCssClass());
StringBuilder sb = new StringBuilder(icon.getCssClass());
sb.append(" ").append(style.getBasicLayerCssClass());
appendLayerIcon(0, WebComponentUtil.createIconType(sb.toString(), icon.getColor()));
return this;
}

Expand All @@ -106,40 +121,38 @@ public CompositedIconBuilder appendLayerIcon(String icon, CompositedIconCssStyle
if(StringUtils.isNotEmpty(additionalCssClass)) {
sb.append(" ").append(additionalCssClass);
}
appendLayerIcon(sb.toString());
appendLayerIcon(WebComponentUtil.createIconType(sb.toString()));
return this;
}

public CompositedIconBuilder appendLayerIcon(String icon, LayeredIconCssStyle style) {
return appendLayerIcon(icon, style, "");
}

public CompositedIconBuilder appendLayerIcon(String icon, LayeredIconCssStyle style, String additionalCssClass) {
additionalCssClass = additionalCssClass + " " + validateInput(icon, style, false);
StringBuilder sb = new StringBuilder(icon);

public CompositedIconBuilder appendLayerIcon(IconType icon, LayeredIconCssStyle style) {
Validate.notNull(icon, "no icon object");
Validate.notNull(icon.getCssClass(), "no icon class");
Validate.notNull(style, "no icon style");

StringBuilder sb = new StringBuilder(icon.getCssClass());
sb.append(" ").append(style.getLayerCssClass());
if(StringUtils.isNotEmpty(additionalCssClass)) {
sb.append(" ").append(additionalCssClass);
if(StringUtils.isNotEmpty(icon.getColor())) {
sb.append(" ").append(icon.getColor()).append(" ");
}
String layerIconClass = sb.toString();
sb.append(" ").append(style.getStrokeLayerCssClass());
appendLayerIcon(sb.toString());
appendLayerIcon(layerIconClass);
appendLayerIcon(WebComponentUtil.createIconType(sb.toString(), icon.getColor()));
appendLayerIcon(WebComponentUtil.createIconType(layerIconClass, icon.getColor()));
return this;
}

public CompositedIconBuilder appendLayerIcon(String icon, IconCssStyle style) {
return appendLayerIcon(icon, style, "");
}

public CompositedIconBuilder appendLayerIcon(String icon, IconCssStyle style, String additionalCssClass) {
additionalCssClass = additionalCssClass + " " + validateInput(icon, style, false);
StringBuilder sb = new StringBuilder(icon);

public CompositedIconBuilder appendLayerIcon(IconType icon, IconCssStyle style) {
Validate.notNull(icon, "no icon object");
Validate.notNull(icon.getCssClass(), "no icon class");
Validate.notNull(style, "no icon style");

StringBuilder sb = new StringBuilder(icon.getCssClass());
sb.append(" ").append(style.getLayerCssClass());
if(StringUtils.isNotEmpty(additionalCssClass)) {
sb.append(" ").append(additionalCssClass);
if(StringUtils.isNotEmpty(icon.getColor())) {
sb.append(" ").append(icon.getColor());
}
appendLayerIcon(sb.toString());
appendLayerIcon(WebComponentUtil.createIconType(sb.toString(), icon.getColor()));
return this;
}

Expand Down
Expand Up @@ -24,8 +24,10 @@ public interface IconCssStyle {
public static final BottomLeftIconCssStyle BOTTOM_LEFT_STYLE = new BottomLeftIconCssStyle();
public static final BottomRightIconCssStyle BOTTOM_RIGHT_STYLE = new BottomRightIconCssStyle();
public static final CenterIconCssStyle CENTER_STYLE = new CenterIconCssStyle();
public static final CenterWithRightShiftCssStyle CENTER_STYLE_WITH_RIGHT_SHIFT = new CenterWithRightShiftCssStyle();
public static final InRowIconCssStyle IN_ROW_STYLE = new InRowIconCssStyle();
public static final TopLeftIconCssStyle TOP_LEFT_STYLE = new TopLeftIconCssStyle();
public static final TopRightIconCssStyle TOP_RIGHT_STYLE = new TopRightIconCssStyle();

public String getBasicCssClass();

Expand Down

0 comments on commit 0a49770

Please sign in to comment.