column.setHeader("Name");
column.setWidth(100);
column.setRenderer(new GridCellRenderer() {
public Object render(ModelData model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore listStore, Grid grid) {
GWTJahiaNodeVersion version = (GWTJahiaNodeVersion) model;
String value = Messages.get("label.version", "Version") + " ";
if (version.getLabel() != null && !"".equals(version.getLabel())) {
String[] strings = version.getLabel().split("_at_");
if (strings.length == 2) {
String s1;
if (strings[0].contains("published")) {
s1 = Messages.get("label.version.published", "published at");
} else if (strings[0].contains("uploaded")) {
s1 = Messages.get("label.version.uploaded", "uploaded at");
} else {
s1 = Messages.get("label.version." + strings[0], strings[0]);
}
Date date = DateTimeFormat.getFormat("yyyy_MM_dd_HH_mm_ss").parse(
strings[1]);
value = value + s1 + " " + DateTimeFormat.getMediumDateTimeFormat()
.format(date);
} else {
value = version.getLabel();
}
}
return value;
}
});
configs.add(column);
if (PermissionsUtils.isPermitted("jcr:write", engine.getNode()) && !engine.getNode().isLocked()) {
column = new ColumnConfig();
column.setSortable(false);
column.setHeader("Action");
column.setWidth(200);
column.setRenderer(new GridCellRenderer() {
public Object render(ModelData model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore listStore, Grid grid) {
ButtonBar buttonBar = new ButtonBar();
Button button = new Button(Messages.get("label.compare.with.staging.engine", "Compare With Staging"));
final GWTJahiaNodeVersion version = (GWTJahiaNodeVersion) model;
button.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// add 30s to the date to be sure to display the right version
new CompareEngine(version.getNode().getUUID(), VersioningTabItem.this.locale, false, version.getNode().getPath(), new Date(version.getDate().getTime() + (30l * 1000l)), engine, version.getWorkspace(), version.getLabel()).show();
}
});
buttonBar.add(button);
return buttonBar;
}