Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jan 18, 2017
2 parents 0e8c009 + f678bc3 commit 496162b
Show file tree
Hide file tree
Showing 15 changed files with 1,346 additions and 100 deletions.
Expand Up @@ -119,6 +119,9 @@ public class GuiStyleConstants {
public static final String CLASS_OP_RESULT_STATUS_ICON_NOT_APPLICABLE_COLORED = "fa fa-check-circle text-muted";
public static final String CLASS_OP_RESULT_STATUS_ICON_IN_PROGRESS_COLORED = "fa fa-clock-o text-info";

//menu items icons classes
public static final String CLASS_THREE_DOTS = "fa fa-ellipsis-h";

public static final String CLASS_BUTTON_TOGGLE_OFF = "btn-default";
public static final String CLASS_BUTTON_TOGGLE_ON = "btn-info";

Expand Down
@@ -0,0 +1,39 @@
<!--
~ Copyright (c) 2010-2015 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.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<table>
<tr>
<td>
<span wicket:id="buttons"/>
</td>
<td style="padding-left: 5px;">
<span class="dropdown" wicket:id="menuButtonContainer">
<a href="#" class="dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown">
<b class="fa fa-ellipsis-h"></b>
</a>
<ul class="dropdown-menu pull-right" style="width: 50px; !important" role="menu">
<li wicket:id="menuItem">
<div wicket:id="menuItemBody"/>
</li>
</ul>
</span>
</td>
</tr>
</table>
</wicket:panel>
</html>
@@ -0,0 +1,115 @@
/*
* 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.web.component.data;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.web.component.data.column.ColumnMenuAction;
import com.evolveum.midpoint.web.component.data.column.InlineMenuable;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenu;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.MenuDividerPanel;
import com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar
*/
public class MenuMultiButtonPanel<T extends Serializable> extends MultiButtonPanel<T> {
private static final String ID_MENU_ITEM = "menuItem";
private static final String ID_MENU_ITEM_BODY = "menuItemBody";
private static final String ID_MENU_BUTTON_CONTAINER = "menuButtonContainer";

public MenuMultiButtonPanel(String id, IModel<T> model, IModel<List<InlineMenuItem>> menuItemsModel) {
super(id, 2, model, menuItemsModel);
}

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

WebMarkupContainer menuButtonContainer = new WebMarkupContainer(ID_MENU_BUTTON_CONTAINER);
menuButtonContainer.setOutputMarkupId(true);
add(menuButtonContainer);

ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, menuItemsModel) {

@Override
protected void populateItem(ListItem<InlineMenuItem> item) {
initMenuItem(item);
}
};
li.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
return menuItemsModel != null && menuItemsModel.getObject() != null &&
!menuItemsModel.getObject().isEmpty();
}
});
menuButtonContainer.add(li);

}

private void initMenuItem(ListItem<InlineMenuItem> menuItem) {
InlineMenuItem item = menuItem.getModelObject();

// menuItem.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
//
// @Override
// public String getObject() {
// if (item.isMenuHeader()) {
// return "dropdown-header";
// } else if (item.isDivider()) {
// return "divider";
// }
//
// return getBoolean(item.getEnabled(), true) ? null : "disabled";
// }
// }));

if (item.getVisible() != null && item.getVisible().getObject() != null) {
menuItem.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return item.getVisible().getObject();
}
});
}

WebMarkupContainer menuItemBody;
if (item.isMenuHeader() || item.isDivider()) {
menuItemBody = new MenuDividerPanel(ID_MENU_ITEM_BODY, menuItem.getModel());
} else {
menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, menuItem.getModel());
}
menuItemBody.setRenderBodyOnly(true);
menuItem.add(menuItemBody);

}

}
Expand Up @@ -20,12 +20,16 @@
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.data.column.DoubleButtonColumn;

import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;

import java.util.List;

/**
* @author shood
* @author mederly
Expand All @@ -34,25 +38,38 @@ public class MultiButtonPanel<T> extends BasePanel<T> {

private static final String ID_BUTTONS = "buttons";

protected IModel<List<InlineMenuItem>> menuItemsModel = null;
int numberOfButtons;

public MultiButtonPanel(String id, int numberOfButtons, IModel<T> model, IModel<List<InlineMenuItem>> menuItemsModel){
super(id, model);
this.numberOfButtons = numberOfButtons;
this.menuItemsModel = menuItemsModel;
initLayout();
}

public MultiButtonPanel(String id, int numberOfButtons, IModel<T> model) {
super(id, model);
this.numberOfButtons = numberOfButtons;
initLayout();
}

private void initLayout() {
protected void initLayout() {
RepeatingView buttons = new RepeatingView(ID_BUTTONS);
add(buttons);
for (int id = 0; id < numberOfButtons; id++) {
final int finalId = id;
final int finalId = getButtonId(id);
AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) {
@Override
public void onClick(AjaxRequestTarget target) {
clickPerformed(finalId, target, MultiButtonPanel.this.getModel());
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
}
@Override
public boolean isEnabled(){
return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel());
}
Expand Down Expand Up @@ -92,6 +109,10 @@ public String getButtonSizeCssClass(int id) {
return DoubleButtonColumn.BUTTON_SIZE_CLASS.DEFAULT.toString();
}

protected int getButtonId(int id){
return id;
}

public String getButtonTitle(int id) {
return "";
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ public class ColumnMenuAction<T extends Serializable> extends InlineMenuItemActi

private IModel<T> rowModel;

void setRowModel(IModel<T> rowModel) {
public void setRowModel(IModel<T> rowModel) {
this.rowModel = rowModel;
}

Expand Down

0 comments on commit 496162b

Please sign in to comment.