});
return b;
}
}
}
return new Label(historyItem.<String>get("displayName"));
}
});
config.add(column);
column = new ColumnConfig("user", Messages.get("label.user", "User"), 70);
config.add(column);
column = new ColumnConfig("nodeWrapper", Messages.get("label.workflow.start.node", "Workflow Starting Node"),
150);
column.setRenderer(new GridCellRenderer<GWTJahiaWorkflowHistoryItem>() {
/**
* Returns the HTML to be used in a grid cell.
*
* @param model the model
* @param property the model property
* @param config the column config
* @param rowIndex the row index
* @param colIndex the cell index
* @param store the data store
* @param grid the grid
* @return the cell HTML or Component instance
*/
public Object render(GWTJahiaWorkflowHistoryItem model, String property, ColumnData config,
int rowIndex, int colIndex,
ListStore<GWTJahiaWorkflowHistoryItem> gwtJahiaWorkflowHistoryItemListStore,
Grid<GWTJahiaWorkflowHistoryItem> gwtJahiaWorkflowHistoryItemGrid) {
final GWTJahiaNode wrapper = (GWTJahiaNode) model.getProperties().get("nodeWrapper");
if (wrapper != null) {
return new Label(wrapper.getDisplayName() + " (" + wrapper.getPath() + ")");
}
List<GWTJahiaWorkflowHistoryItem> models = gwtJahiaWorkflowHistoryItemListStore.getModels();
for (final GWTJahiaWorkflowHistoryItem historyItem : models) {
final GWTJahiaNode nodewrapper = (GWTJahiaNode) historyItem.getProperties().get("nodeWrapper");
if (nodewrapper!=null && historyItem.getProcessId().equals(model.getProcessId()) &&
historyItem instanceof GWTJahiaWorkflowHistoryProcess) {
Button button = new Button(Messages.get("label.preview"));
button.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
String path = nodewrapper.getPath();
String locale = JahiaGWTParameters.getLanguage();
JahiaContentManagementService.App.getInstance().getNodeURL("render", path, null, null,
"default", locale, new BaseAsyncCallback<String>() {
public void onSuccess(String url) {
Window window = new Window();
window.setMaximizable(true);
window.setSize(800,600);
window.setUrl(url);
window.setPosition(engine.getPosition(true).x+50,engine.getPosition(true).y+50);
window.show();
}
});
}
});
return button;
}
}
return new Label("");
}
});
config.add(column);
column = new ColumnConfig("startDate", Messages.get("org.jahia.engines.processDisplay.tab.startdate",
"Start date"), 90);
column.setDateTimeFormat(Formatter.DEFAULT_DATETIME_FORMAT);
config.add(column);
column = new ColumnConfig("endDate", Messages.get("org.jahia.engines.processDisplay.tab.enddate", "End date"),
90);
column.setDateTimeFormat(Formatter.DEFAULT_DATETIME_FORMAT);
config.add(column);
column = new ColumnConfig("duration", Messages.get("org.jahia.engines.processDisplay.column.duration",
"Duration"), 60);
column.setRenderer(new GridCellRenderer<GWTJahiaWorkflowHistoryItem>() {
public Object render(GWTJahiaWorkflowHistoryItem historyItem, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<GWTJahiaWorkflowHistoryItem> store,
Grid<GWTJahiaWorkflowHistoryItem> grid) {
Long duration = historyItem.getDuration();
String display = "-";
if (duration != null) {
long time = duration.longValue();
if (time < 1000) {
display = time + " " + Messages.get("label.milliseconds", "ms");
} else if (time < 1000 * 60L) {
display = ((long) (time / 1000)) + " " + Messages.get("label.seconds", "sec");
} else if (time < 1000 * 60 * 60L) {
display = ((long) (time / (1000 * 60L))) + " " + Messages.get("label.minutes", "min") + " " +
((long) ((time % (1000 * 60L)) / 1000)) + " " + Messages.get("label.seconds", "sec");
} else {
display = ((long) (time / (1000 * 60 * 60L))) + " " + Messages.get("label_hours", "h") + " " +
((long) ((time % (1000 * 60 * 60L)) / (1000 * 60L))) + " " + Messages.get(
"label.minutes", "min");
}
}
return new Label(display);
}
});
config.add(column);
ColumnModel cm = new ColumnModel(config);