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

50
LINES

< > BotCompany Repo | #1015897 // DynBigNumber - does not persist the value by default

JavaX fragment (include) [tags: use-pretranspiled]

abstract sclass DynBigNumber extends DynModule {
  S description;
  O value;
  int fontSize = 40;
  S toolTip;
  
  transient JLabel label;
  transient SimpleLiveValue<S> lvText = new(S);
  transient SimpleLiveValue<S> lvDesc = new(S);
  
  // PUBLIC API
  
  // any Number, or anything persistable with toString
  bool setValue(O value) {
    bool changed = setField(+value);
    makeTexts();
    ret changed;
  }
  
  void setDescription(S desc) {
    setField('description, desc);
    makeTexts();
  }
  
  O getValue() { ret value; }
  S getDescription() { ret description; }
  void setToolTip(S toolTip) { setField(+toolTip); }
  
  void doPersist() {
    _persistenceInfo = mapMinusOrNull(_persistenceInfo, 'value);
  }
  
  // END PUBLIC API
  
  void makeTexts() {
    lvText.set(value == null ? "-" : str(value));
    lvDesc.set(description);
  }
  
  start {
    _persistenceInfo = mapPlus(_persistenceInfo, value := false);
    makeTexts();
  }

  visualize {
    ret bindToolTipToLiveValue(dm_fieldLiveValue('toolTip),
      jLiveValueSection(lvDesc,
        centerLabel(makeBold(setFontSize(fontSize, label = jLiveValueLabel(lvText))))));
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015897
Snippet name: DynBigNumber - does not persist the value by default
Eternal ID of this version: #1015897/22
Text MD5: cf273ad976fc8403d2bc97bf3a7ff706
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-01 15:25:12
Source code size: 1206 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 469 / 1145
Version history: 21 change(s)
Referenced in: [show references]