From c3c31c3312bb5025259a803612c1c6dd85faa374 Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:59:59 +0100 Subject: [PATCH] FindGUI command Added terminal command to force GUI back onto primary monitor --- src/PamController/command/CommandManager.java | 1 + src/PamController/command/FindGUICommand.java | 27 +++++++++++++++++++ src/PamView/GuiFrameManager.java | 21 +++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/PamController/command/FindGUICommand.java diff --git a/src/PamController/command/CommandManager.java b/src/PamController/command/CommandManager.java index 87f4b888..d6b06fc0 100644 --- a/src/PamController/command/CommandManager.java +++ b/src/PamController/command/CommandManager.java @@ -42,6 +42,7 @@ public abstract class CommandManager extends PamControlledUnit { commandsList.add(new SetXMLSettings()); commandsList.add(new BatchStatusCommand()); commandsList.add(new BatchCommand(this)); + commandsList.add(new FindGUICommand()); } diff --git a/src/PamController/command/FindGUICommand.java b/src/PamController/command/FindGUICommand.java new file mode 100644 index 00000000..526e7e2f --- /dev/null +++ b/src/PamController/command/FindGUICommand.java @@ -0,0 +1,27 @@ +package PamController.command; + +import PamController.PamController; +import PamView.GuiFrameManager; + +public class FindGUICommand extends ExtCommand { + + public FindGUICommand() { + super("findgui", true); + } + + @Override + public String execute(String command) { + GuiFrameManager frameManager = PamController.getInstance().getGuiFrameManager(); + if (frameManager == null) { + return "No GUI to move"; + } + frameManager.findGUI(); + return "GUI Moved"; + } + + @Override + public String getHint() { + return "Move GUI components to the main monitor"; + } + +} diff --git a/src/PamView/GuiFrameManager.java b/src/PamView/GuiFrameManager.java index 030628c0..b49da8d7 100644 --- a/src/PamView/GuiFrameManager.java +++ b/src/PamView/GuiFrameManager.java @@ -633,5 +633,26 @@ public class GuiFrameManager implements PamSettings, PAMControllerGUI { return frameIcon; } + /** + * Function that can move GUI frames back onto the main window. + * Can be used to recover a GUI if it's on a monitor that is not present. + */ + public void findGUI() { + if (pamViewList == null) { + return; + } + int loc = 10; + for (PamViewInterface view : pamViewList) { + JFrame frame = view.getGuiFrame(); + if (frame == null) { + continue; + } + frame.setLocation(loc, loc); + frame.setState(JFrame.NORMAL); + frame.setVisible(true); + loc += 20; + } + } + }