FindGUI command

Added terminal command to force GUI back onto primary monitor
This commit is contained in:
Douglas Gillespie 2023-06-30 16:59:59 +01:00
parent 42bbf86f5a
commit c3c31c3312
3 changed files with 49 additions and 0 deletions

View File

@ -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());
}

View File

@ -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";
}
}

View File

@ -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;
}
}
}