mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 19:57:36 +08:00
PL-5210 UI testing - cuba-id implementation for Table columns
This commit is contained in:
parent
fccec57b18
commit
30caa625cc
@ -79,7 +79,7 @@ org.hibernate/hibernate-core = 3.3.1.GA
|
||||
org.hibernate/hibernate-validator = 5.3.0.Final
|
||||
org.glassfish.web/javax.el = 2.2.6
|
||||
|
||||
com.vaadin = 7.7.8.cuba.4
|
||||
com.vaadin = 7.7.8.cuba.5
|
||||
com.vaadin/vaadin-shared = ${com.vaadin}
|
||||
com.vaadin/vaadin-server = ${com.vaadin}
|
||||
com.vaadin/vaadin-client = ${com.vaadin}
|
||||
|
@ -38,9 +38,7 @@ import com.haulmont.cuba.web.toolkit.ui.client.tableshared.TableWidgetDelegate;
|
||||
import com.vaadin.client.*;
|
||||
import com.vaadin.client.ui.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static com.haulmont.cuba.web.toolkit.ui.client.Tools.isAnyModifierKeyPressed;
|
||||
import static com.haulmont.cuba.web.toolkit.ui.client.tableshared.TableWidgetDelegate.*;
|
||||
@ -379,6 +377,20 @@ public class CubaScrollTableWidget extends VScrollTable implements TableWidget {
|
||||
protected HeaderCell createHeaderCell(String cid, String caption) {
|
||||
return new CubaScrollTableHeaderCell(cid, caption);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCustomHtmlAttributes(TableHead.VisibleColumnAction action) {
|
||||
String colKey = action.getColKey();
|
||||
HeaderCell headerCell = getHeaderCell(colKey);
|
||||
if (headerCell != null) {
|
||||
String cubaId = headerCell.getElement().getAttribute("cuba-id");
|
||||
if (cubaId != null) {
|
||||
return "cuba-id=\"cc-" + cubaId + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCustomHtmlAttributes(action);
|
||||
}
|
||||
}
|
||||
|
||||
protected class CubaScrollTableHeaderCell extends HeaderCell {
|
||||
@ -817,4 +829,36 @@ public class CubaScrollTableWidget extends VScrollTable implements TableWidget {
|
||||
protected boolean isColumnCollapsingEnabled() {
|
||||
return visibleColOrder.length > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateColumnProperties(UIDL uidl) {
|
||||
super.updateColumnProperties(uidl);
|
||||
|
||||
if (uidl.hasAttribute("colcubaids")
|
||||
&& uidl.hasAttribute("vcolorder")) {
|
||||
try {
|
||||
String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
|
||||
String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");
|
||||
|
||||
Map<String, HeaderCell> headerCellMap = new HashMap<>();
|
||||
for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
|
||||
HeaderCell headerCell = getHead().getHeaderCell(i);
|
||||
if (headerCell.getColKey() != null) {
|
||||
headerCellMap.put(headerCell.getColKey(), headerCell);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < vcolorder.length; i++) {
|
||||
String key = vcolorder[i];
|
||||
HeaderCell headerCell = headerCellMap.get(key);
|
||||
|
||||
if (headerCell != null) {
|
||||
headerCell.getElement().setAttribute("cuba-id", colcubaids[i]);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
VConsole.error("Unable to init cuba-ids for columns " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -35,15 +35,10 @@ import com.haulmont.cuba.web.toolkit.ui.client.aggregation.TableAggregationRow;
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.profiler.ScreenClientProfiler;
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.tableshared.TableWidget;
|
||||
import com.haulmont.cuba.web.toolkit.ui.client.tableshared.TableWidgetDelegate;
|
||||
import com.vaadin.client.BrowserInfo;
|
||||
import com.vaadin.client.ComputedStyle;
|
||||
import com.vaadin.client.UIDL;
|
||||
import com.vaadin.client.WidgetUtil;
|
||||
import com.vaadin.client.*;
|
||||
import com.vaadin.client.ui.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static com.haulmont.cuba.web.toolkit.ui.client.Tools.isAnyModifierKeyPressed;
|
||||
import static com.haulmont.cuba.web.toolkit.ui.client.tableshared.TableWidgetDelegate.*;
|
||||
@ -366,6 +361,20 @@ public class CubaTreeTableWidget extends VTreeTable implements TableWidget {
|
||||
protected HeaderCell createHeaderCell(String cid, String caption) {
|
||||
return new CubaTreeTableHeaderCell(cid, caption);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCustomHtmlAttributes(TableHead.VisibleColumnAction action) {
|
||||
String colKey = action.getColKey();
|
||||
HeaderCell headerCell = getHeaderCell(colKey);
|
||||
if (headerCell != null) {
|
||||
String cubaId = headerCell.getElement().getAttribute("cuba-id");
|
||||
if (cubaId != null) {
|
||||
return "cuba-id=\"cc-" + cubaId + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCustomHtmlAttributes(action);
|
||||
}
|
||||
}
|
||||
|
||||
protected class CubaTreeTableHeaderCell extends HeaderCell {
|
||||
@ -780,4 +789,36 @@ public class CubaTreeTableWidget extends VTreeTable implements TableWidget {
|
||||
protected boolean isColumnCollapsingEnabled() {
|
||||
return visibleColOrder.length > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateColumnProperties(UIDL uidl) {
|
||||
super.updateColumnProperties(uidl);
|
||||
|
||||
if (uidl.hasAttribute("colcubaids")
|
||||
&& uidl.hasAttribute("vcolorder")) {
|
||||
try {
|
||||
String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
|
||||
String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");
|
||||
|
||||
Map<String, HeaderCell> headerCellMap = new HashMap<>();
|
||||
for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
|
||||
HeaderCell headerCell = getHead().getHeaderCell(i);
|
||||
if (headerCell.getColKey() != null) {
|
||||
headerCellMap.put(headerCell.getColKey(), headerCell);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < vcolorder.length; i++) {
|
||||
String key = vcolorder[i];
|
||||
HeaderCell headerCell = headerCellMap.get(key);
|
||||
|
||||
if (headerCell != null) {
|
||||
headerCell.getElement().setAttribute("cuba-id", colcubaids[i]);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
VConsole.error("Unable to init cuba-ids for columns " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -545,6 +545,19 @@ public class CubaTable extends com.vaadin.ui.Table implements TableContainer, Cu
|
||||
paintAggregationRow(target, ((AggregationContainer) items).aggregate(context));
|
||||
}
|
||||
}
|
||||
|
||||
// paint cuba-ids
|
||||
|
||||
AppUI current = AppUI.getCurrent();
|
||||
if (current != null && current.isTestMode()) {
|
||||
ArrayList<String> visibleColOrder = new ArrayList<>();
|
||||
for (Object columnId : visibleColumns) {
|
||||
if (!isColumnCollapsed(columnId)) {
|
||||
visibleColOrder.add(columnId.toString());
|
||||
}
|
||||
}
|
||||
target.addAttribute("colcubaids", visibleColOrder.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<?> getAggregationItemIds() {
|
||||
|
@ -634,6 +634,19 @@ public class CubaTreeTable extends com.vaadin.ui.TreeTable implements TreeTableC
|
||||
&& Table.AggregationStyle.TOP.equals(getAggregationStyle())) {
|
||||
paintAggregationRow(target, ((AggregationContainer) items).aggregate(new Context(items.getItemIds())));
|
||||
}
|
||||
|
||||
// paint cuba-ids
|
||||
|
||||
AppUI current = AppUI.getCurrent();
|
||||
if (current != null && current.isTestMode()) {
|
||||
ArrayList<String> visibleColOrder = new ArrayList<>();
|
||||
for (Object columnId : visibleColumns) {
|
||||
if (!isColumnCollapsed(columnId)) {
|
||||
visibleColOrder.add(columnId.toString());
|
||||
}
|
||||
}
|
||||
target.addAttribute("colcubaids", visibleColOrder.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintAggregationRow(PaintTarget target, Map<Object, Object> aggregations) throws PaintException {
|
||||
|
Loading…
Reference in New Issue
Block a user