From 3f675210773d342b4b92cebfe8ad19c3620ef898 Mon Sep 17 00:00:00 2001 From: Paulo Dias Date: Fri, 18 Oct 2024 18:16:08 +0100 Subject: [PATCH] plugins/oplimits/OperationLimitsSubPanel: Added send by Iridium if not active (user consent). --- .../oplimits/OperationLimitsSubPanel.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins-dev/oplimits/src/java/pt/lsts/neptus/plugins/oplimits/OperationLimitsSubPanel.java b/plugins-dev/oplimits/src/java/pt/lsts/neptus/plugins/oplimits/OperationLimitsSubPanel.java index d77d53bf3e..7e2b2993cd 100644 --- a/plugins-dev/oplimits/src/java/pt/lsts/neptus/plugins/oplimits/OperationLimitsSubPanel.java +++ b/plugins-dev/oplimits/src/java/pt/lsts/neptus/plugins/oplimits/OperationLimitsSubPanel.java @@ -53,7 +53,9 @@ import java.awt.geom.Rectangle2D; import java.io.File; import java.text.NumberFormat; +import java.time.Duration; import java.util.Arrays; +import java.util.Date; import java.util.Vector; import javax.swing.AbstractAction; @@ -158,7 +160,9 @@ public class OperationLimitsSubPanel extends ConsolePanel implements Configurati protected int clickCount = 0; protected Point2D lastDragPoint = null; protected boolean dragging = false; - + + private Date lastRequest = new Date(0); + protected JLabel label = new JLabel(""); { label.setOpaque(true); @@ -341,6 +345,27 @@ protected OperationalLimits getLimitsMessage() { return oplimits; } + @Override + public boolean send(IMCMessage message) { + String destination = getConsole().getMainSystem(); + if (destination == null) + return false; + ImcSystem sysL = ImcSystemsHolder.lookupSystemByName(destination); + if (sysL != null && !sysL.isActive()) { + boolean userAproved = true; + if (lastRequest.getTime() + Duration.ofSeconds(30).toMillis() < System.currentTimeMillis()) { + userAproved = (GuiUtils.confirmDialog(getConsole(), I18n.text("Send by Iridium"), + I18n.text("Systems is not active. Do you want to send by Iridium?")) == JOptionPane.YES_OPTION); + lastRequest = new Date(); + } + if (userAproved) { + sendViaIridium(destination, message); + return true; + } + } + return super.send(message); + } + @Subscribe public void onOperationalLimits(OperationalLimits message) { if (!message.getSourceName().equalsIgnoreCase(getConsole().getMainSystem()))