Skip to content

Commit

Permalink
plugins/oplimits/OperationLimitsSubPanel: Added send by Iridium if no…
Browse files Browse the repository at this point in the history
…t active (user consent).
  • Loading branch information
paulosousadias committed Oct 18, 2024
1 parent 49d0553 commit 3f67521
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("<html></html>");
{
label.setOpaque(true);
Expand Down Expand Up @@ -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()))
Expand Down

0 comments on commit 3f67521

Please sign in to comment.