From 9267d34d3a17813df3ff70fd6d02d7b68e4b4750 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 30 Nov 2020 08:49:47 +0100 Subject: [PATCH] notification --- .../session/ClientConnectionTable.java | 37 ++++++++++++++---- .../sebserver/gui/widget/WidgetFactory.java | 3 +- src/main/resources/messages.properties | 15 ++++--- .../resources/static/images/notification.png | Bin 0 -> 182 bytes 4 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/static/images/notification.png diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java index f1232557..91e5434a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionTable.java @@ -25,6 +25,7 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -33,6 +34,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; @@ -136,7 +138,7 @@ public final class ClientConnectionTable { loadStatusFilter(); this.table = this.widgetFactory.tableLocalized(tableRoot, SWT.MULTI | SWT.V_SCROLL); - final GridLayout gridLayout = new GridLayout(3 + indicators.size(), true); + final GridLayout gridLayout = new GridLayout(3 + indicators.size(), false); gridLayout.horizontalSpacing = 100; gridLayout.marginWidth = 100; gridLayout.marginRight = 100; @@ -147,6 +149,7 @@ public final class ClientConnectionTable { this.table.setLinesVisible(true); this.table.addListener(SWT.Selection, event -> this.notifySelectionChange()); + this.table.addListener(SWT.MouseUp, this::notifyTableInfoClick); this.widgetFactory.tableColumnLocalized( this.table, @@ -432,6 +435,10 @@ public final class ClientConnectionTable { this.selectionListener.accept(this.getSelection()); } + private void notifyTableInfoClick(final Event event) { + // TODO if right click get selected item and show additional information (notification) + } + private final class UpdatableTableItem implements Comparable { final Long connectionId; @@ -445,14 +452,14 @@ public final class ClientConnectionTable { this.connectionId = connectionId; } - void update(final TableItem tableItem, final boolean force) { + private void update(final TableItem tableItem, final boolean force) { if (force || this.changed) { update(tableItem); } this.changed = false; } - void update(final TableItem tableItem) { + private void update(final TableItem tableItem) { if (ClientConnectionTable.this.statusFilter.contains(this.connectionData.clientConnection.status)) { tableItem.dispose(); return; @@ -462,23 +469,35 @@ public final class ClientConnectionTable { updateConnectionStatusColor(tableItem); updateIndicatorValues(tableItem); updateDuplicateColor(tableItem); + updateNotifications(tableItem); } } - void updateData(final TableItem tableItem) { + private void updateNotifications(final TableItem tableItem) { + if (BooleanUtils.isTrue(this.connectionData.pendingNotification())) { + tableItem.setImage(0, + WidgetFactory.ImageIcon.NOTIFICATION.getImage(ClientConnectionTable.this.table.getDisplay())); + } else { + if (tableItem.getImage(0) != null) { + tableItem.setImage(0, null); + } + } + } + + private void updateData(final TableItem tableItem) { tableItem.setText(0, getConnectionIdentifier()); tableItem.setText(1, getConnectionAddress()); tableItem.setText(2, getStatusName()); } - void updateConnectionStatusColor(final TableItem tableItem) { + private void updateConnectionStatusColor(final TableItem tableItem) { final Color statusColor = ClientConnectionTable.this.colorData.getStatusColor(this.connectionData); final Color statusTextColor = ClientConnectionTable.this.colorData.getStatusTextColor(statusColor); tableItem.setBackground(2, statusColor); tableItem.setForeground(2, statusTextColor); } - void updateDuplicateColor(final TableItem tableItem) { + private void updateDuplicateColor(final TableItem tableItem) { tableItem.setBackground(0, null); tableItem.setForeground(0, ClientConnectionTable.this.darkFontColor); @@ -494,14 +513,18 @@ public final class ClientConnectionTable { if (list != null && list.size() > 1) { tableItem.setBackground(0, ClientConnectionTable.this.colorData.color3); tableItem.setForeground(0, ClientConnectionTable.this.lightFontColor); + tableItem.setImage(1, + WidgetFactory.ImageIcon.ADD.getImage(ClientConnectionTable.this.table.getDisplay())); } else { tableItem.setBackground(0, null); tableItem.setForeground(0, ClientConnectionTable.this.darkFontColor); + tableItem.setImage(0, null); + } } } - void updateIndicatorValues(final TableItem tableItem) { + private void updateIndicatorValues(final TableItem tableItem) { if (this.connectionData == null || this.indicatorWeights == null) { return; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java index adc7862c..e7e2de2f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java @@ -120,7 +120,8 @@ public class WidgetFactory { UNLOCK("unlock.png"), RESTRICTION("restriction.png"), VISIBILITY("visibility.png"), - VISIBILITY_OFF("visibility_off.png"); + VISIBILITY_OFF("visibility_off.png"), + NOTIFICATION("notification.png"); public String fileName; private ImageData image = null; diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 9c1806ef..f6fd99f2 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -576,12 +576,17 @@ sebserver.exam.indicator.list.empty=There is currently no indicator defined for sebserver.exam.indicator.list.pleaseSelect=At first please select an indicator from the list sebserver.exam.indicator.type.LAST_PING=Last Ping Time -sebserver.exam.indicator.type.ERROR_COUNT=Errors -sebserver.exam.indicator.type.WARN_COUNT=Warnings +sebserver.exam.indicator.type.ERROR_COUNT=Error-Log Counter +sebserver.exam.indicator.type.WARN_COUNT=Warning-Log Counter +sebserver.exam.indicator.type.INFO_COUNT=Info-Log Counter +sebserver.exam.indicator.type.BATTERY_STATUS=Battery Status +sebserver.exam.indicator.type.WLAN_STATUS=WiFi Status sebserver.exam.indicator.type.description.LAST_PING=This indicator shows the time in milliseconds since
the last ping has been received from a SEB Client.
This indicator can be used to track a SEB Client connection and indicate connection loss.

The value is in milliseconds. -sebserver.exam.indicator.type.description.ERROR_COUNT=This indicator shows the number of error log messages that
has been received from a SEB Client.
This indicator can be used to track errors of connected SEB Clients

The value is natural numbers. -sebserver.exam.indicator.type.description.WARN_COUNT=This indicator shows the number of warn log messages that
has been received from a SEB Client.
This indicator can be used to track warnings of connected SEB Clients

The value is natural numbers. - +sebserver.exam.indicator.type.description.ERROR_COUNT=This indicator shows the number of error log messages that
has been received from a SEB Client.
This indicator can be used to track errors of connected SEB Clients

The value is a natural number. +sebserver.exam.indicator.type.description.WARN_COUNT=This indicator shows the number of warn log messages that
has been received from a SEB Client.
This indicator can be used to track warnings of connected SEB Clients

The value is a natural number. +sebserver.exam.indicator.type.description.INFO_COUNT=This indicator shows the number of warn log messages that
has been received from a SEB Client.
This indicator can be used to track warnings of connected SEB Clients

The value is a natural number. +sebserver.exam.indicator.type.description.BATTERY_STATUS=This indicator shows the percentage of the battery load level of a SEB Client. +sebserver.exam.indicator.type.description.WLAN_STATUS=This indicator shows the percentage of the WiFi connection status of a SEB Client. sebserver.exam.indicator.info.pleaseSelect=At first please select an indicator from the list diff --git a/src/main/resources/static/images/notification.png b/src/main/resources/static/images/notification.png new file mode 100644 index 0000000000000000000000000000000000000000..722b317183ba572f14d0ae561956094cda6c8426 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@RheT2B|pkP60RiAf9Odo)=tI{cCE z`g_vQfvMyCVP3}vcOA|+cR3z^ILq*3Q4;S)$ICAmj&c0UR|r!$wjgN^n__{1A=_2q z!~n~SY=Q^AK9MkyZ@I|3XxjBxou2mBJ3rhi-4Jz$A(11n?I9zdN}`a1%_QzQnkTpD g1RQRXe8I{vc}~>%vaf~@fDU2sboFyt=akR{0GhZ%X8-^I literal 0 HcmV?d00001