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

39
LINES

< > BotCompany Repo | #1021001 // dm_placeModuleUnderAIBar_v2

JavaX fragment (include)

1  
static int dm_placeModuleUnderAIBar_expiry = 4000;
2  
3  
svoid dm_placeModuleUnderAIBar_v2(O moduleOrID, fS query) {
4  
  fO module = dm_getModule(moduleOrID);
5  
  fS moduleID = dm_moduleID(moduleOrID);
6  
  dm_showModule_noFocus(module);
7  
  swing {
8  
    JTextComponent aiBar = cast getCreatorOpt('tfTopInput);
9  
    Rect mr = dm_getBounds(module);
10  
    if (aiBar == null || mr == null) ret;
11  
    
12  
    Rectangle r = getBounds(aiBar);
13  
    
14  
    QuickSearchPlacement p = optCastAndQuickImport(QuickSearchPlacement, dm_generalMap_get('modulesUnderAIBar));
15  
    
16  
    // new query?
17  
    if (p != null && !eq(p.query, query)) p = null;
18  
    
19  
    // too old?
20  
    if (p != null && elapsedMS(p.lastAdded) > dm_placeModuleUnderAIBar_expiry) p = null;
21  
    
22  
    // already contained? do nothing
23  
    if (p != null && contains(p.modules, moduleID)) ret;
24  
    
25  
    if (p == null) p = new QuickSearchPlacement;
26  
    p.query = query;
27  
    
28  
    // place below
29  
    int y = p.height;
30  
    p.height += mr.h;
31  
    p.modules.add(moduleID);
32  
    if (p.firstAdded == 0) p.firstAdded = now();
33  
    p.lastAdded = now();
34  
35  
    //print("dm_place: " + p + " / " + y);
36  
    dm_setBounds(module, r.x, y, r.width, mr.h);
37  
    dm_generalMap_put('modulesUnderAIBar, p);
38  
  }
39  
}

Author comment

Began life as a copy of #1016704

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021001
Snippet name: dm_placeModuleUnderAIBar_v2
Eternal ID of this version: #1021001/5
Text MD5: 74ec4308930a88b974d739149a13ab6c
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-17 14:56:21
Source code size: 1245 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 233 / 289
Version history: 4 change(s)
Referenced in: [show references]