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

71
LINES

< > BotCompany Repo | #1019954 // Task Bar v3 [vertical only]

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

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

!7

cm TaskBar_dev > DynObjectTable<S> {
  S showWhat = "All modules";
  transient JLabel lblCount;
  
  start {
    dontPersist();
    defaultAction = voidfunc(S id) { dm_showModule(id) };
    itemToMap = itemToMap_calcSingleColumn("Module", func(O mod) -> S { or2(dm_moduleName(mod), "[...]") });
    ownResource(vmBus_onModulesListChange(rstUpdate()));
    rstUpdate().trigger();
    if (dm_bounds() == null) placeOnRight();
    onListChanged = syncListInitAndAdd(onListChanged, r { setText(lblCount, countText()) });
  }
  
  void update {
    data = null; // force update
    LS ids = containsWord(showWhat, "visible") ? dm_visibleModuleIDs()
      : containsWord(showWhat, "invisible") ? dm_invisibleModuleIDs()
      : dm_moduleIDs();
    setData(sortedByCalculatedFieldIC(func(O m) -> S { or2(dm_moduleName(m), unicodeCharacterLastInSortOrder()) }, ids));
  }
  
  visualize {
    JComponent theTable = super.visualize();
    
    // TODO: filter these
    for (final Pair<S, VF1<O>> p : dm_moduleMenuItems())
      tablePopupMenuItem(table,
        p.a, voidfunc(final int row) { thread { callF(p.b, _get(data, row)); } });
        
    tablePopupMenu(table, voidfunc(JPopupMenu menu, int row) {
      O mod = _get(data, row);
      Container frame = dm_frame(mod);
      if (frame cast JInternalFrame) {
        copyInternalFramePopupMenu(menu, frame);
        var titlePane = internalFrameTitleComponent(frame);
        if (titlePane != null)
          vmBus_send showingPopupMenu(titlePane, menu);
      } else {
        // TODO: get all the items even if module is not showing
        addMenuItem(menu, "ID: " + or(dm_moduleID(mod), mod) + "/" + dm_moduleLibID(mod), null);
      }
    });
    onCharDown(table, voidfunc(char c) {
      LS names = map dm_moduleName(data);
      int cur = selectedIndex();
      int i = swic(_get(names, cur+1), str(c))
        ? cur+1 // move through items with that characters
        : indexOfStartingWithIC(names, str(c));
      selectRowIfNotNegative(table, i);
    });
    
    ret northAndCenter(
      withMargin(westAndEast(
        lblCount = jlabel(countText()),
        dm_fieldComboBox('showWhat, ll("All modules", "Visible modules", "Invisible modules")))),
      theTable);
  }
  
  enhanceFrame {
    addTitlePopupMenuItems(f, "Place on the right", rThread placeOnRight);
  }
  
  void placeOnRight enter { dm_placeOnRight(); }

  S countText() {
    ret join(" of ", litorderedset(count(), dm_moduleCount()));
  }
}

Author comment

Began life as a copy of #1019172

download  show line numbers  debug dex  old transpilations   

Travelled to 11 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019954
Snippet name: Task Bar v3 [vertical only]
Eternal ID of this version: #1019954/44
Text MD5: 4eab160f71216fcd364ae43fa35ec278
Transpilation MD5: 126f7591433a86596cf348c7be640f2f
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-14 01:57:12
Source code size: 2548 bytes / 71 lines
Pitched / IR pitched: No / No
Views / Downloads: 356 / 490886
Version history: 43 change(s)
Referenced in: [show references]