Skip to content

Commit

Permalink
adding support for layer icons
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Dec 14, 2018
1 parent bca9bee commit d94a869
Show file tree
Hide file tree
Showing 17 changed files with 701 additions and 18 deletions.
Expand Up @@ -173,4 +173,21 @@ public class GuiStyleConstants {
public static final String CLASS_ADD_NEW_OBJECT = "fa fa-plus";
public static final String CLASS_UPLOAD = "fa fa-upload";
public static final String CLASS_CREATE_FOCUS = "fa fa-user-plus";

public static final String EVO_CROW_ICON = "fe fe-crown-object";
public static final String EVO_ASSIGNMENT_ICON = "fe fe-assignment";
public static final String EVO_OFFICER_CAP_ICON = "fe fe-officer-cap-object";
public static final String EVO_ASSIGNMENT_STRAIGHT_THICKER_ICON = "fe fe-assignment-straight-thicker-object";
public static final String EVO_ASSIGNMENT_STRAIGHT_ICON = "fe fe-assignment-straight-object";
public static final String EVO_UNEMPLOYER_ICON = "fe fe-unemployer-icon";
public static final String EVO_EMPLOYER_ICON = "fe fe-employer-icon";
public static final String EVO_APPROVER_ICON = "fe fe-approver-object";
public static final String EVO_MP_SHORTER_LINES = "fe fe-midpoint-shorter-lines";
public static final String EVO_MP_WHEEL_ICON = "fe fe-midpoint-wheel";
public static final String EVO_MP_WITH_LINES_ICON = "fe fe-midpoint-with-lines";
public static final String EVO_ROLE_HAT_ICON = "fe fe-role-hat";
public static final String EVO_ROLE_TIE_ICON = "fe fe-role-tie";
public static final String EVO_ROLE_TOP_HAT_ICON = "fe fe-role-top-hat";
public static final String EVO_ASSIGNMENT_THICKER_ICON = "fe assignment-thicker";

}
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2010-2017 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;

import java.util.Map.Entry;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.parser.XmlTag;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon;

/**
* @author Viliam Repan (lazyman)
*/
public abstract class AjaxCompositedIconButton extends AjaxLink<String> {

private static final long serialVersionUID = 1L;

private IModel<String> title;
private CompositedIcon icon;

public AjaxCompositedIconButton(String id, CompositedIcon icon, IModel<String> title) {
super(id);

this.title = title;
this.icon =icon;

add(AttributeAppender.append("class", new IModel<String>() {

private static final long serialVersionUID = 1L;

@Override
public String getObject() {
return !AjaxCompositedIconButton.this.isEnabled() ? "disabled" : "";
}
}));
}

@Override
protected void onInitialize() {
super.onInitialize();

if (title != null) {
add(AttributeModifier.replace("title", title));
}
}

@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
StringBuilder sb = new StringBuilder();

CompositedIcon icon = this.icon;
if(icon.hasBasicIcon()) {
sb.append("<i class=\"").append(icon.getBasicIcon()).append("\"");
sb.append("></i> ");
}

if(icon.hasLayerIcons()) {
for(String entry : icon.getLayerIcons()) {
if (StringUtils.isNotEmpty(entry)) {
sb.append("<i class=\"").append(entry).append("\"");
sb.append("></i> ");
}
}
}

replaceComponentTagBody(markupStream, openTag, sb.toString());
}

@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);

if (tag.isOpenClose()) {
tag.setType(XmlTag.TagType.OPEN);
}
}
}
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2010-2018 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;

/**
* @author skublik
*/
public class BottomLeftIconCssStyle implements LayeredIconCssStyle {

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

@Override
public String getBasicLayerCssClass() {
return "icon-basic-layer";
}

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

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

}
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2010-2018 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;

/**
* @author skublik
*/
public class BottomRightIconCssStyle implements LayeredIconCssStyle {

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

@Override
public String getBasicLayerCssClass() {
return "icon-basic-layer";
}

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

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

}
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2010-2018 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;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;

/**
* @author skublik
*/
public class CompositedIcon {

private String basicIcon;
private List<String> layerIcons;


public CompositedIcon(String basicIcon, List<String> layerIcons){
this.basicIcon = basicIcon;
this.layerIcons = layerIcons;
}

public String getBasicIcon() {
return basicIcon;
}

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

public boolean hasLayerIcons(){
return getLayerIcons() != null && !getLayerIcons().isEmpty();
}
public boolean hasBasicIcon() {
return StringUtils.isNotEmpty(getBasicIcon());
}
}

0 comments on commit d94a869

Please sign in to comment.