Skip to content

Commit

Permalink
gh-3892 Add toggle btn for server tasks line wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
at055612 committed Nov 2, 2023
1 parent 1c8e707 commit b10178e
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 125 deletions.
2 changes: 1 addition & 1 deletion stroom-app/src/main/resources/ui/images/save.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions stroom-app/src/main/resources/ui/images/text-wrap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 2 additions & 40 deletions stroom-app/src/main/resources/ui/raw-images/save.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions stroom-app/src/main/resources/ui/raw-images/text-wrap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public class TaskManagerListPresenter
private final ButtonView collapseAllButton;
private final ButtonView warningsButton;
private final InlineSvgToggleButton autoRefreshButton;
private final InlineSvgToggleButton wrapToggleButton;

private String currentWarnings;
private Column<TaskProgress, Expander> expanderColumn;
Expand Down Expand Up @@ -148,6 +149,12 @@ public TaskManagerListPresenter(final EventBus eventBus,
warningsButton = getView().addButton(SvgPresets.ALERT.title("Show Warnings"));
warningsButton.setVisible(false);

wrapToggleButton = new InlineSvgToggleButton();
wrapToggleButton.setSvg(SvgImage.TEXT_WRAP);
wrapToggleButton.setTitle("Toggle wrapping of Info column");
wrapToggleButton.setOff();
getView().addButton(wrapToggleButton);

updateButtonStates();

initTableColumns();
Expand Down Expand Up @@ -213,6 +220,17 @@ protected void onBind() {
}
}
}));

registerHandler(wrapToggleButton.addClickHandler(event -> {
if ((event.getNativeButton() & NativeEvent.BUTTON_LEFT) != 0) {
if (wrapToggleButton.isOff()) {
wrapToggleButton.setTitle("Turn Cell Line Wrapping On");
} else {
wrapToggleButton.setTitle("Turn Cell Line Wrapping Off");
}
internalRefresh();
}
}));
}

private void showWarnings() {
Expand Down Expand Up @@ -308,12 +326,12 @@ protected void showInfo(final TaskProgress row, final PopupPosition popupPositio

// Name.
dataGrid.addResizableColumn(
DataGridUtil.htmlColumnBuilder(getColouredCellFunc(TaskProgress::getTaskName))
DataGridUtil.htmlColumnBuilder(getWrapableColouredCellFunc(TaskProgress::getTaskName))
.withSorting(FindTaskProgressCriteria.FIELD_NAME)
.withStyleName(MyDataGrid.RESOURCES.dataGridStyle().dataGridCellVerticalTop())
.build(),
FindTaskProgressCriteria.FIELD_NAME,
150);
250);

// User.
dataGrid.addResizableColumn(
Expand Down Expand Up @@ -346,9 +364,8 @@ protected void showInfo(final TaskProgress row, final PopupPosition popupPositio

// Info
dataGrid.addAutoResizableColumn(
DataGridUtil.htmlColumnBuilder(getColouredCellFunc(TaskProgress::getTaskInfo))
DataGridUtil.htmlColumnBuilder(getWrapableColouredCellFunc(TaskProgress::getTaskInfo))
.withSorting(FindTaskProgressCriteria.FIELD_INFO)
.withStyleName(MyDataGrid.RESOURCES.dataGridStyle().dataGridCellWrapText())
.withStyleName(MyDataGrid.RESOURCES.dataGridStyle().dataGridCellVerticalTop())
.build(),
FindTaskProgressCriteria.FIELD_INFO,
Expand Down Expand Up @@ -392,6 +409,23 @@ private Function<TaskProgress, SafeHtml> getColouredCellFunc(final Function<Task
TaskProgress::isMatchedInFilter);
}

private Function<TaskProgress, SafeHtml> getWrapableColouredCellFunc(final Function<TaskProgress, String> extractor) {
final Function<TaskProgress, SafeHtml> colouredCellFunc = getColouredCellFunc(extractor);

return (TaskProgress row) -> {
final Attribute wrapClassAttr = Attribute.className(
MyDataGrid.RESOURCES.dataGridStyle().dataGridCellWrapText());
final SafeHtml colouredText = colouredCellFunc.apply(row);
if (wrapToggleButton.isOn()) {
return HtmlBuilder.builder()
.div(htmlBuilder -> htmlBuilder.append(colouredText), wrapClassAttr)
.toSafeHtml();
} else {
return colouredText;
}
};
}

private Expander buildExpander(final TaskProgress row) {
return row.getExpander();
}
Expand Down
Loading

0 comments on commit b10178e

Please sign in to comment.