Issue #2375 - Only display the configured number
of messages in the notification center. Peer review comments Change-Id: I17c1f0a2d2cf910a52a0bdb655d39a08e47494ea Former-commit-id:179d7c38ca
[formerlydfd23d61fb
] [formerly08078bbd54
] [formerly4ee719b32c
[formerly08078bbd54
[formerly f4ac1c5a665346641cc9fcffa67aed522b1967e3]]] Former-commit-id:4ee719b32c
Former-commit-id: d0a801651f9c8ca642d546aa95b54479f0cfe2d5 [formerly7b1ff055d0
] Former-commit-id:848530acad
This commit is contained in:
parent
f0fc19d5e7
commit
152a54de8f
1 changed files with 46 additions and 3 deletions
|
@ -41,6 +41,7 @@ import org.eclipse.swt.widgets.TableColumn;
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
|
|
||||||
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
|
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
|
||||||
|
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||||
import com.raytheon.uf.viz.core.notification.NotificationMessage;
|
import com.raytheon.uf.viz.core.notification.NotificationMessage;
|
||||||
import com.raytheon.uf.viz.datadelivery.common.ui.ITableChange;
|
import com.raytheon.uf.viz.datadelivery.common.ui.ITableChange;
|
||||||
import com.raytheon.uf.viz.datadelivery.common.ui.ITableFind;
|
import com.raytheon.uf.viz.datadelivery.common.ui.ITableFind;
|
||||||
|
@ -793,14 +794,14 @@ public class NotificationTableComp extends TableComp implements ITableFind {
|
||||||
public void populateTableDataRows(
|
public void populateTableDataRows(
|
||||||
ArrayList<NotificationRecord> notificationRecords) {
|
ArrayList<NotificationRecord> notificationRecords) {
|
||||||
List<NotificationRecord> notificationList = new ArrayList<NotificationRecord>();
|
List<NotificationRecord> notificationList = new ArrayList<NotificationRecord>();
|
||||||
|
MessageLoadXML messageLoad = null;
|
||||||
NotificationConfigManager configMan = NotificationConfigManager
|
NotificationConfigManager configMan = NotificationConfigManager
|
||||||
.getInstance();
|
.getInstance();
|
||||||
ArrayList<String> users = configMan.getFilterXml().getUserFilterXml()
|
ArrayList<String> users = configMan.getFilterXml().getUserFilterXml()
|
||||||
.getUserList();
|
.getUserList();
|
||||||
|
|
||||||
if (notificationRecords == null) {
|
if (notificationRecords == null) {
|
||||||
MessageLoadXML messageLoad = msgLoadCallback.getMessageLoad();
|
messageLoad = msgLoadCallback.getMessageLoad();
|
||||||
handler = new NotificationHandler();
|
handler = new NotificationHandler();
|
||||||
notificationList = handler.intialLoad(messageLoad, users);
|
notificationList = handler.intialLoad(messageLoad, users);
|
||||||
masterTableList.clearAll();
|
masterTableList.clearAll();
|
||||||
|
@ -808,7 +809,7 @@ public class NotificationTableComp extends TableComp implements ITableFind {
|
||||||
} else {
|
} else {
|
||||||
for (NotificationRecord rec : notificationRecords) {
|
for (NotificationRecord rec : notificationRecords) {
|
||||||
// prevents duplicates
|
// prevents duplicates
|
||||||
if (currentRecordIds.contains(rec.getId()) == false) {
|
if (!currentRecordIds.contains(rec.getId())) {
|
||||||
notificationList.add(rec);
|
notificationList.add(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,10 +846,52 @@ public class NotificationTableComp extends TableComp implements ITableFind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
messageLoad = msgLoadCallback.getMessageLoad();
|
||||||
|
if (messageLoad != null) {
|
||||||
|
if (!messageLoad.isLoadAllMessages()) {
|
||||||
|
// Sort data by time
|
||||||
|
sortByTime(filteredTableList);
|
||||||
|
|
||||||
|
int loadLast = messageLoad.getLoadLast();
|
||||||
|
|
||||||
|
// Keep only the specified number of rows
|
||||||
|
if (messageLoad.isNumMessages()) {
|
||||||
|
int numRecs = filteredTableList.getDataArray().size();
|
||||||
|
if (numRecs > loadLast) {
|
||||||
|
for (int i = loadLast - 1; i < numRecs; i++) {
|
||||||
|
filteredTableList.removeDataRow(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
long backTime = loadLast * TimeUtil.MILLIS_PER_HOUR;
|
||||||
|
long currentTime = TimeUtil.currentTimeMillis();
|
||||||
|
List<NotificationRowData> dataList = filteredTableList
|
||||||
|
.getDataArray();
|
||||||
|
List<Integer> indicesToRemove = new ArrayList<Integer>();
|
||||||
|
for (int i = 0; i < dataList.size(); i++) {
|
||||||
|
if (currentTime - dataList.get(i).getDate().getTime() > backTime) {
|
||||||
|
indicesToRemove.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i : indicesToRemove) {
|
||||||
|
filteredTableList.removeDataRow(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now do the configured sort
|
||||||
updateSortDirection(this.sortedColumn, filteredTableList, false);
|
updateSortDirection(this.sortedColumn, filteredTableList, false);
|
||||||
filteredTableList.sortData();
|
filteredTableList.sortData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sortByTime(TableDataManager<NotificationRowData> data) {
|
||||||
|
data.setSortDirection(SortDirection.DESCENDING);
|
||||||
|
data.setSortColumn("Time");
|
||||||
|
data.sortData();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the table display.
|
* Clear the table display.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue