protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setHeight(610);
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("url");
column.setHeader(Messages.get("label_url", "URL"));
TextField<String> text = new TextField<String>();
text.setAllowBlank(false);
text.setRegex("^/?(?!.*/{2,})[a-zA-Z_0-9\\-\\./]+$");
text.setMaxLength(250);
text.getMessages().setRegexText(Messages.get("failure.invalid.urlmapping.label", "The vanity URL can only contain letters, digits, dots (.), dashes (-) and no consecutive slashes (/)"));
CellEditor ce = new CellEditor(text);
ce.addListener(Events.BeforeComplete, new Listener<EditorEvent>() {
public void handleEvent(EditorEvent be) {
Window.alert((String) be.getValue());
be.stopEvent();
}
});
column.setEditor(ce);
configs.add(column);
final CheckColumnConfig defaultColumn;
final CheckColumnConfig activeColumn;
if (editable) {
defaultColumn = new CheckColumnConfig("default", Messages.get("label.urlmapping.default", "Default"), 70);
defaultColumn.setEditor(new CellEditor(new CheckBox()));
activeColumn = new CheckColumnConfig("active", Messages.get("label.urlmapping.active", "Active"), 55);
activeColumn.setEditor(new CellEditor(new CheckBox()));
} else {
defaultColumn = new CheckColumnConfig("default", Messages.get("label.urlmapping.default", "Default"), 70){
protected String getCheckState(ModelData model, String property, int rowIndex,
int colIndex) {
return "-disabled";
}
};
activeColumn = new CheckColumnConfig("active", Messages.get("label.urlmapping.active", "Active"), 55){
protected String getCheckState(ModelData model, String property, int rowIndex,
int colIndex) {
return "-disabled";
}
};
}
configs.add(defaultColumn);
configs.add(activeColumn);
column = new ColumnConfig("actions", "", 100);
column.setAlignment(HorizontalAlignment.CENTER);
column.setRenderer(new GridCellRenderer<GWTJahiaUrlMapping>() {
public Object render(GWTJahiaUrlMapping modelData, String s, ColumnData columnData, final int rowIndex,
final int colIndex, ListStore<GWTJahiaUrlMapping> listStore, Grid<GWTJahiaUrlMapping> grid) {
Button button = new Button(Messages.get("label_remove", "Remove"),
new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent buttonEvent) {
store.remove(store.getAt(rowIndex));
}
});
button.setIcon(StandardIconsProvider.STANDARD_ICONS.minusRound());
button.setEnabled(editable);
return button;
}
});
column.setFixed(true);
configs.add(column);
final RowEditor<GWTJahiaUrlMapping> re = new RowEditor<GWTJahiaUrlMapping>();
// Add a cancel edit event listener to remove empty line