Skip to content

Commit

Permalink
force focus change
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinHerrmann committed Feb 25, 2025
1 parent 6be17d6 commit b9bda2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
6 changes: 6 additions & 0 deletions BlueJCode/Blockly/BlocklyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ public static BlocklyHandler Instance()
return instance == null ? (instance = new BlocklyHandler()) : instance;
}


private RestAPI restAPI;
private MainFrame frame;
public MainFrame Frame()
{
return frame;
}


protected BlocklyHandler()
Expand Down Expand Up @@ -57,6 +62,7 @@ public void openBlockly(double x, double y)
frame.setExtendedState(frame.getExtendedState() | Frame.MAXIMIZED_BOTH);
}
frame.setTitle("BlueJ-Blockly: " + CodeHandler.getActiveInstance().getClassName());
frame.requestFocus();
Logging.log("<<< Open Blockly(x,y) successful");
};
Thread thread = new Thread(runnable);
Expand Down
2 changes: 1 addition & 1 deletion BlueJCode/Blockly/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* For a more feature complete example have also a look onto the example code
* within the package "tests.detailed".
*/
class MainFrame extends JFrame
public class MainFrame extends JFrame
{
private static final long serialVersionUID = -5570653778104813836L;
//private final JTextField address_;
Expand Down
18 changes: 8 additions & 10 deletions BlueJCode/CodeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import BlueJCode.Blockly.BlocklyHandler;
import bluej.extensions2.BClass;
import bluej.extensions2.editor.JavaEditor;
import org.apache.velocity.runtime.directive.Block;

import java.awt.*;
import java.io.*;
import java.util.Map;
import java.util.stream.Collectors;

import static java.util.Arrays.stream;

// Multiton-Class
public class CodeHandler
{
Expand Down Expand Up @@ -92,7 +96,7 @@ public String getClassPrefix()
String p = "";
try
{
if (!editor.getBClass().getPackage().getName().equals("")) {
if (!editor.getBClass().getPackage().getName().equals("")) {
p = "package " + editor.getBClass().getPackage().getName() + ";" + System.lineSeparator() + System.lineSeparator();
}
}
Expand Down Expand Up @@ -123,16 +127,10 @@ public void writeJavaCodeToFile(String code)
Logging.log("Wrote java code to file: " + javaFilePath);

editor.loadFile();
// Try forcing the gui to update
if(editor.isVisible())
{
editor.loadFile();
editor.getBClass().compile(true);
Logging.log("Window: "+editor.getBClass().getPackage().getWindow().getTitle());
editor.getBClass().getPackage().getWindow().requestFocus();

//if(!javaEditor.getBClass().isCompiled())
//{
// runCompilation(javaEditor);
//}
}

Logging.log("<<< CodeHandler.writeJavaCodeToFile()");
}
Expand Down

0 comments on commit b9bda2a

Please sign in to comment.