MCPcopy
hub / github.com/Col-E/Recaf / GuiController

Class GuiController

src/main/java/me/coley/recaf/control/gui/GuiController.java:23–142  ·  view source on GitHub ↗

Gui controller. @author Matt

Source from the content-addressed store, hash-verified

21 * @author Matt
22 */
23public class GuiController extends Controller {
24 private WindowManager windows;
25
26 /**
27 * @param workspace
28 * Initial workspace path. Can point to a file to load <i>(class, jar)</i> or a workspace
29 * configuration <i>(json)</i>.
30 */
31 public GuiController(Path workspace) {
32 super(workspace);
33 }
34
35 @Override
36 public boolean setup() {
37 boolean succeed = super.setup();
38 windows = new WindowManager(this);
39 return succeed;
40 }
41
42 @Override
43 public void run() {
44 windows.setMainWindow(MainWindow.get(this));
45 super.run();
46 PluginKeybinds.getInstance().setup();
47 }
48
49
50 /**
51 * Asynchronously load a workspace from the given file.
52 *
53 * @param path
54 * Path to workspace file.
55 * @param action
56 * Additional action to run with success/fail result.
57 */
58 public void loadWorkspace(Path path, Consumer<Boolean> action) {
59 Task<?> loadTask = loadWorkspace(path);
60 MainWindow main = windows.getMainWindow();
61 loadTask.messageProperty().addListener((n, o, v) -> main.status(v));
62 loadTask.setOnRunning(e -> {
63 // Clear current items since we want to load a new workspace
64 main.clear();
65 main.disable(true);
66 });
67 loadTask.setOnSucceeded(e -> {
68 // Load success
69 main.disable(false);
70 if (action != null)
71 action.accept(true);
72 // Update recently loaded
73 config().backend().onLoad(path, config().display().getMaxRecent());
74 main.getMenubar().updateRecent();
75 });
76 loadTask.setOnFailed(e -> {
77 // Log failure reason
78 Throwable t = e.getSource().getException();
79 if (t != null) {
80 error(t, "Failed to open file: {}", path.getFileName());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected