Merge branch 'master' into design2015-user-management

# Conflicts:
#	java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CellTablePO.java
This commit is contained in:
Steffen Schaefer committed 2016-02-29 11:21:44 +01:00
commit 55342b7877
186 files changed
+1174 -5177

No files matched your search

@@ -0,0 +1,122 @@
package com.sap.sse.gwt.client.celltable;
import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.dom.builder.shared.DivBuilder;
import com.google.gwt.dom.builder.shared.TableCellBuilder;
import com.google.gwt.dom.builder.shared.TableRowBuilder;
import com.google.gwt.dom.client.Style.OutlineStyle;
import com.google.gwt.user.cellview.client.AbstractCellTable;
import com.google.gwt.user.cellview.client.AbstractCellTable.Style;
import com.google.gwt.user.cellview.client.AbstractCellTableBuilder;
import com.google.gwt.user.cellview.client.CellTableBuilder;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.DefaultCellTableBuilder;
import com.google.gwt.user.cellview.client.RowStyles;
import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;
import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;
import com.google.gwt.view.client.SelectionModel;
/**
* This {@link CellTableBuilder} is a copy of the {@link DefaultCellTableBuilder} that adds the aria selected role to
* the selected row.
*
* As for now, no other aria roles are placed to the table builder.
*
* @param <T>
*/
public class BaseCellTableBuilder<T> extends AbstractCellTableBuilder<T> {
private final String evenRowStyle;
private final String oddRowStyle;
private final String selectedRowStyle;
private final String cellStyle;
private final String evenCellStyle;
private final String oddCellStyle;
private final String firstColumnStyle;
private final String lastColumnStyle;
private final String selectedCellStyle;
public BaseCellTableBuilder(AbstractCellTable<T> cellTable) {
super(cellTable);
// Cache styles for faster access.
Style style = cellTable.getResources().style();
evenRowStyle = style.evenRow();
oddRowStyle = style.oddRow();
selectedRowStyle = " " + style.selectedRow();
cellStyle = style.cell();
evenCellStyle = " " + style.evenRowCell();
oddCellStyle = " " + style.oddRowCell();
firstColumnStyle = " " + style.firstColumn();
lastColumnStyle = " " + style.lastColumn();
selectedCellStyle = " " + style.selectedRowCell();
}
@Override
public void buildRowImpl(T rowValue, int absRowIndex) {
// Calculate the row styles.
SelectionModel<? super T> selectionModel = cellTable.getSelectionModel();
boolean isSelected = (selectionModel == null || rowValue == null) ? false : selectionModel.isSelected(rowValue);
boolean isEven = absRowIndex % 2 == 0;
StringBuilder trClasses = new StringBuilder(isEven ? evenRowStyle : oddRowStyle);
if (isSelected) {
trClasses.append(selectedRowStyle);
}
// Add custom row styles.
RowStyles<T> rowStyles = cellTable.getRowStyles();
if (rowStyles != null) {
String extraRowStyles = rowStyles.getStyleNames(rowValue, absRowIndex);
if (extraRowStyles != null) {
trClasses.append(" ").append(extraRowStyles);
}
}
// Build the row.
TableRowBuilder tr = startRow();
tr.attribute("aria-selected", isSelected ? "true" : "false");
tr.className(trClasses.toString());
// Build the columns.
int columnCount = cellTable.getColumnCount();
for (int curColumn = 0; curColumn < columnCount; curColumn++) {
Column<T, ?> column = cellTable.getColumn(curColumn);
// Create the cell styles.
StringBuilder tdClasses = new StringBuilder(cellStyle);
tdClasses.append(isEven ? evenCellStyle : oddCellStyle);
if (curColumn == 0) {
tdClasses.append(firstColumnStyle);
}
if (isSelected) {
tdClasses.append(selectedCellStyle);
}
// The first and last column could be the same column.
if (curColumn == columnCount - 1) {
tdClasses.append(lastColumnStyle);
}
// Add class names specific to the cell.
Context context = new Context(absRowIndex, curColumn, cellTable.getValueKey(rowValue));
String cellStyles = column.getCellStyleNames(context, rowValue);
if (cellStyles != null) {
tdClasses.append(" " + cellStyles);
}
// Build the cell.
HorizontalAlignmentConstant hAlign = column.getHorizontalAlignment();
VerticalAlignmentConstant vAlign = column.getVerticalAlignment();
TableCellBuilder td = tr.startTD();
td.className(tdClasses.toString());
if (hAlign != null) {
td.align(hAlign.getTextAlignString());
}
if (vAlign != null) {
td.vAlign(vAlign.getVerticalAlignString());
}
// Add the inner div.
DivBuilder div = td.startDiv();
div.style().outlineStyle(OutlineStyle.NONE).endStyle();
// Render the cell into the div.
renderCell(div, context, column, rowValue);
// End the cell.
div.endDiv();
td.endTD();
}
// End the row.
tr.endTR();
}
}
@@ -0,0 +1,50 @@
package com.sap.sse.gwt.client.celltable;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ProvidesKey;
public class BaseCelltable<T> extends CellTable<T> {
public BaseCelltable() {
super();
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(int pageSize, ProvidesKey<T> keyProvider) {
super(pageSize, keyProvider);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(int pageSize, com.google.gwt.user.cellview.client.CellTable.Resources resources,
ProvidesKey<T> keyProvider, Widget loadingIndicator, boolean enableColGroup, boolean attachLoadingPanel) {
super(pageSize, resources, keyProvider, loadingIndicator, enableColGroup, attachLoadingPanel);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(int pageSize, com.google.gwt.user.cellview.client.CellTable.Resources resources,
ProvidesKey<T> keyProvider, Widget loadingIndicator) {
super(pageSize, resources, keyProvider, loadingIndicator);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(int pageSize, com.google.gwt.user.cellview.client.CellTable.Resources resources,
ProvidesKey<T> keyProvider) {
super(pageSize, resources, keyProvider);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(int pageSize, com.google.gwt.user.cellview.client.CellTable.Resources resources) {
super(pageSize, resources);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(int pageSize) {
super(pageSize);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
public BaseCelltable(ProvidesKey<T> keyProvider) {
super(keyProvider);
setTableBuilder(new BaseCellTableBuilder<T>(this));
}
}
@@ -29,6 +29,7 @@ import com.google.gwt.view.client.ListDataProvider;
import com.sap.sse.filestorage.FileStorageManagementService;
import com.sap.sse.filestorage.FileStorageService;
import com.sap.sse.gwt.client.ErrorReporter;
import com.sap.sse.gwt.client.celltable.BaseCelltable;
import com.sap.sse.gwt.client.controls.TabbingTextInputCell;
import com.sap.sse.gwt.client.filestorage.FileStorageManagementGwtServiceAsync;
import com.sap.sse.gwt.shared.filestorage.FileStorageServiceDTO;
@@ -93,7 +94,7 @@ public class FileStoragePanel extends FlowPanel {
serviceDescriptionLabel = new Label();
editServicePanelContent.add(serviceDescriptionLabel);
propertiesTable = new CellTable<>();
propertiesTable = new BaseCelltable<>();
propertiesTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); //allow for default tabbing behaviour
propertiesListDataProvider = new ListDataProvider<>(new ArrayList<FileStorageServicePropertyDTO>());
properties = propertiesListDataProvider.getList();