Home /Modules/ide-workbench/ide-workbench-gui-demo.sleela

ide-workbench-gui-demo.sleela

lib/ide-workbench/ide-workbench-gui-demo.sleela · 108 line(s) · sleela

<< lib/ide-workbench/ide-workbench-gui-demo.sleela
   SLeeLa Standard Library Definition.
   Definition: Runnable demonstrator that raises the SLeeLa IDE as a REAL
     SleelaUI window — the whole GUI authored in SLeeLa. It boots
     SLIdeWorkbenchUI, populates the project tree, opens a couple of files into
     SLTextView code editors inside the SLNotebook, publishes a sample
     diagnostic, and runs the SleelaUI event loop. On a headless host (no X11
     display) boot() returns false and the demo exits cleanly, exactly like
     SLGalleryDemo.
   
   Family: ide-workbench. The user interface is SleelaUI; this file proves the
   IDE shell is usable from the language itself. >>
#sleela 2.5
material;
class IdeWorkbenchGuiDemo {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 11018;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-13";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }

  int run() {
    SLIdeWorkbenchUI ide = new SLIdeWorkbenchUI();
    if (!ide.boot("com.mearvk.SleelaIDE", "SLeeLa IDE - MEARVK LLC",
                  1280, 800, "/work/project")) {
      < headless: no display >
      return 1;
    }

    < Project explorer: a root with two source files (SST Nordshrit + SLeeLa). >
    ide.addTreeNode("root", "project", null, false);
    ide.addTreeNode("f1", "main.sst", "root", true);
    ide.addTreeNode("f2", "util.sleela", "root", true);
    < expand the root so children show >
    ide.tree.toggle("root");
    ide.rebuildTree();

    < Open main.sst into a code editor tab. >
    String[] sst = new String[3];
    sst[0] = "system Demo {";
    sst[1] = "  symbol Greeting";
    sst[2] = "}";
    ide.openFile("f1", "/work/project/main.sst", sst, 3, "r1");

    < Open util.sleela into a second tab. >
    String[] sl = new String[4];
    sl[0] = "#sleela 1.5";
    sl[1] = "class Util {";
    sl[2] = "  int answer() { return 42; }";
    sl[3] = "}";
    ide.openFile("f2", "/work/project/util.sleela", sl, 4, "r1");

    < A sample diagnostic from a compile (host would publish real ones). >
    ide.publishDiagnostic("f1", SLIdeDiagnosticsPanel.SEV_WARNING, 2, 3,
                          "symbol 'Greeting' is never referenced");
    ide.finishCompile();

    < Content-control interactions now flow through the DOM event bus too: a >
    < tab switch raises TOGGLE("ide-notebook", idx) and a tree selection raises >
    < CHANGE("ide-tree", id), handled by onTabChange / onTreeActivate. >
    < focus the first editor tab >
    ide.onTabChange("0");
    < selecting a leaf names a file >
    String opened = ide.onTreeActivate("f2");

    < Hand control to the SleelaUI event loop (polls the command buttons). >
    int code = ide.runLoop();
    ide.shutdown();
    return code;
  }
}