Skip to content

Commit

Permalink
ViewChangesCollector.collectRowChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Sep 7, 2017
1 parent fb7e2a7 commit 83ae06d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/main/java/de/metas/ui/web/view/event/ViewChanges.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.metas.ui.web.view.ViewId;
import de.metas.ui.web.window.datatypes.DocumentId;
import de.metas.ui.web.window.datatypes.DocumentIdsSelection;
import lombok.NonNull;

/*
* #%L
Expand Down Expand Up @@ -86,30 +87,30 @@ public boolean isFullyChanged()
{
return fullyChanged;
}

public boolean hasChanges()
{
if(fullyChanged)
if (fullyChanged)
{
return true;
}

return changedRowIds != null && !changedRowIds.isEmpty();
}

public void addChangedRowIds(final DocumentIdsSelection rowIds)
{
// Don't collect rowIds if this was already flagged as fully changed.
if(fullyChanged)
if (fullyChanged)
{
return;
}

if (rowIds == null || rowIds.isEmpty())
{
return;
}

else if (rowIds.isAll())
{
fullyChanged = true;
Expand All @@ -125,6 +126,15 @@ else if (rowIds.isAll())
}
}

public void addChangedRowId(@NonNull final DocumentId rowId)
{
if (changedRowIds == null)
{
changedRowIds = new HashSet<>();
}
changedRowIds.add(rowId);
}

public DocumentIdsSelection getChangedRowIds()
{
final boolean fullyChanged = this.fullyChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import de.metas.ui.web.view.ViewId;
import de.metas.ui.web.websocket.WebSocketConfig;
import de.metas.ui.web.websocket.WebsocketSender;
import de.metas.ui.web.window.datatypes.DocumentId;
import de.metas.ui.web.window.datatypes.DocumentIdsSelection;

/*
Expand Down Expand Up @@ -178,6 +179,13 @@ public void collectRowsChanged(final IView view, final DocumentIdsSelection rowI

autoflushIfEnabled();
}

public void collectRowChanged(final IView view, final DocumentId rowId)
{
viewChanges(view).addChangedRowId(rowId);

autoflushIfEnabled();
}

private void collectFromChanges(final ViewChanges changes)
{
Expand Down

0 comments on commit 83ae06d

Please sign in to comment.