You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.8 KiB
55 lines
1.8 KiB
package com.fr.plugin.xxx.report.core; |
|
|
|
import com.fr.form.ui.Widget; |
|
import com.fr.main.TemplateWorkBook; |
|
import com.fr.report.cell.AbstractWidgetCellElement; |
|
import com.fr.report.worksheet.WorkSheet; |
|
import com.fr.stable.ArrayUtils; |
|
import com.fr.stable.StringUtils; |
|
import com.fr.web.request.ReportletRequest; |
|
|
|
import java.util.Iterator; |
|
import java.util.Map; |
|
|
|
/** |
|
* @author 秃破天际 |
|
* @version 10.0 |
|
* Created by 秃破天际 on 2020-04-03 |
|
**/ |
|
public class ViewWidgetBuilder extends RelationBuilder { |
|
|
|
public ViewWidgetBuilder(String dsName, String colKey, String colValue) { |
|
super(dsName, colKey, colValue); |
|
} |
|
|
|
@Override |
|
protected boolean accept(TemplateWorkBook book, ReportletRequest request) throws Exception { |
|
String groupId = (String)request.getParameter("__WIDGET_GROUP__"); |
|
return StringUtils.isNotEmpty( groupId ); |
|
} |
|
|
|
@Override |
|
protected void build(TemplateWorkBook book, ReportletRequest request, Map<String, String> relation) throws Exception { |
|
String groupId = (String)request.getParameter("__WIDGET_GROUP__"); |
|
String [] group = split( relation.get(groupId), ","); |
|
if( 0 == group.length ){ |
|
return; |
|
} |
|
int count = book.getReportCount(); |
|
for( int i=0; i<count; i++ ){ |
|
WorkSheet sheet = (WorkSheet)book.getReport(i); |
|
build( sheet, group ); |
|
} |
|
} |
|
|
|
private void build( WorkSheet sheet, String [] group ){ |
|
Iterator<AbstractWidgetCellElement> cells = sheet.cellIterator(); |
|
while (cells.hasNext() ){ |
|
AbstractWidgetCellElement cell = cells.next(); |
|
Widget widget = cell.getWidget(); |
|
if( null != widget && !ArrayUtils.contains(group,widget.getWidgetName())){ |
|
cell.setWidget(null); |
|
} |
|
} |
|
} |
|
}
|
|
|