Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

91
LINES

< > BotCompany Repo | #1016702 // Loaded Module Search [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (10804L/55K).

!7

abstract !include #1016674 // Module List

cmodule LoadedModuleSearch > ModuleList {
  transient S query;
  transient new RestartableCountdown autoHide;
  transient S moduleDescForSearch;
  transient O[] quickSearchParams;
  
  transient int yesPopupOffsetY = -13;
  
  start {
    moduleDescForSearch = "Loaded";
    calculateWhenHidden = true;
    dm_onTopInput_q(voidfunc(S s) { doSearch(s, false) });
    dm_onTopInputChange_q(voidfunc(S s) { if (neq(s, query)) doSearch(s, false) });
    dm_vmBus_onMessage_q hideQuickSearchModules(r dm_hideModule);
    
    quickSearchParams = new O[] {
      defaultAction := voidfunc(S s) {
        dm_showModule(getModule(s))
      }, popupItems := toObjectArray(concatMap(dm_moduleMenuItems(), func(final Pair<S, VF1<O>> p) -> L { ll(p.a, voidfunc(S s) enter {
        callF(p.b, getModule(s))
      }) }))
    };
  }
  
  afterVisualize {
    onDoubleClickOrEnter(list, rEnter dm_hideQuickSearchModules);
  }
  
  void doSearch(S s, bool withYesPopup) enter {
    if "yes" {
      if (dm_hasYesPopupForComponent(list)) {
        print("HAVE POPUP");
        print("Clicked? " + jlist_doubleClickOnItem(list, 0));
        ret;
      }
    }
    
    if (dm_dontQuickSearch_combined(s)) ret;
    query = s;
    O qsm = dm_quickSearchManager();
    if (qsm != null) {
      results = calc();
      dm_call(qsm, 'setResultsForModule, dm_moduleID(), moduleDescForSearch, query, map(results, func(S s) -> Pair<S> {
        S moduleID = firstIntAsString(s);
        ret pair(dm_programID(moduleID) + " - " + dm_moduleName(moduleID), moduleID);
      }), quickSearchParams);
    } else {
      super.update();
      if (nempty(query) && nempty(results)) {
        dm_placeModuleUnderAIBar_v2(this, query);
        if (withYesPopup && !dm_hasYesToAcceptPopup()) {
          dm_showYesToAcceptPopupWithParams(list,
            imageID := #1101462,
            height := 247/2,
            mover := voidfunc(Component c, Component popup) enter {
              JList list = cast c;
              Rect r = boundsInParent(c, dm_desktopPane());
              if (r == null) ret;
              Rect item = jlist_itemBounds(list, 0);
              setLocation(popup, r.x+item.x-popup.getWidth(), r.y+item.y+yesPopupOffsetY);
            });
        }
        dm_autoHide(autoHide);
      } else
        dm_hideModule();
    }
  }
  
  L<O> modulesToList() {
    if (empty(query)) ret emptyList();
    L modules = super.modulesToList();
    L<S> results = scoredSearch_eachTerm(dm_getInterestingString(),
      map(modules, func(fO m) -> S {
        "[" + dm_moduleID(m) + "] "
          + pcallF(func -> S { dm_moduleName(m) })
          + " / " + shortClassName(m)
          + " / " + getProgramID(m) }));
    ret map(results, func(S s) -> O { dm_getModule(leadingSquareBracketStuff(s)) });
  }
  
  void selectFirstEntry() { selectRow(list, 0); }
  
  void enhanceFrame(Container f) {
    super.enhanceFrame(f);
    setClosable(f, false);
  }
}

Author comment

Began life as a copy of #1016674

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, unoaxrwscvea, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1016702
Snippet name: Loaded Module Search [Dyn Module]
Eternal ID of this version: #1016702/65
Text MD5: 27e82e02b229f0daf84dd371e1462ca1
Transpilation MD5: b7b9512d491c945f1e9b4e4faef7976a
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-22 16:06:32
Source code size: 3068 bytes / 91 lines
Pitched / IR pitched: No / No
Views / Downloads: 573 / 584598
Version history: 64 change(s)
Referenced in: #1016478 - Stefan's OS v6
#1016932 - Server Module Search [Dyn Module]
#1022729 - Stefan's OS v6 - copy for transpiler test
#1024922 - programPackager_standardExcludedSnippets
#1024932 - Stefan's OS v7 [LIVE]
#1031320 - Stefan's OS v7 [backup before allowing dynamic main classes]