BrightSide Workbench Full Report + Source Code
org.turro.financials.handshake.HandshakeControl Class Reference
Inheritance diagram for org.turro.financials.handshake.HandshakeControl:
Collaboration diagram for org.turro.financials.handshake.HandshakeControl:

Public Member Functions

void setContract (Contract contract)
 
boolean isMustSave ()
 
void afterCompose ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 42 of file HandshakeControl.java.

Member Function Documentation

◆ afterCompose()

void org.turro.financials.handshake.HandshakeControl.afterCompose ( )

Definition at line 57 of file HandshakeControl.java.

57  {
58  if(contract == null || contract.getContractDefinition() == null) {
59  setVisible(false);
60  return;
61  }
62  if((contract.getContractDefinition().getId() == 47L) || (contract.getContractDefinition().getId() == 56L)) {
63  setImage(Images.getImage("handshake"));
64  if(onClick == null) {
65  onClick = new EventListener() {
66  @Override
67  public void onEvent(Event event) throws Exception {
68  ContractHandshake handshake = contract.getContractHandshake();
69  if(handshake != null) {
70  ElephantResponse er = HandshakeUtil.checkStatus(contract);
71  if(ElephantResponse.isCorrect(er)) {
72  HandshakeStatus status = HandshakeStatus.getStatus(er);
73  Clients.showNotification(er.message + ": " + er.code);
74  updateImage(status);
75  } else {
76  Clients.showNotification("Handshake server not found");
77  }
78  Events.postEvent(new Event(Events.ON_CHANGE, HandshakeControl.this));
79  } else {
80  InputDialog.getInput(getPage(), "Handshake", "Remote server", "", null, 0,
81  new Command() {
82  @Override
83  public Object execute(Context context) {
84  String remoteUrl = (String) context.get("value");
85  remoteUrl = URLUtil.checkAppServer(remoteUrl, true);
86  if(!Strings.isBlank(remoteUrl)) {
87  ElephantResponse er = HandshakeUtil.sendPetition(contract, remoteUrl);
88  if(ElephantResponse.isCorrect(er)) {
89  ContractHandshake handshake = new ContractHandshake();
90  handshake.setContract(contract);
91  handshake.setRemoteServer(remoteUrl);
92  contract.setContractHandshake(handshake);
93  HandshakeStatus status = HandshakeStatus.getStatus(er);
94  Clients.showNotification(I_.get("Save before continue") + "<br/>" + er.message + ": " + er.code);
95  mustSave = true;
96  updateImage(status);
97  } else {
98  Clients.showNotification("Handshake server not found");
99  contract.setContractHandshake(null);
100  }
101  }
102  Events.postEvent(new Event(Events.ON_CHANGE, HandshakeControl.this));
103  return null;
104  }
105  });
106  }
107  }
108  };
109  addEventListener(Events.ON_CLICK, onClick);
110  }
111  } else if((contract.getContractDefinition().getId() == 48L) || (contract.getContractDefinition().getId() == 55L)) {
112  setImage(Images.getImage("handshake"));
113  if(onClick == null) {
114  onClick = new EventListener() {
115  @Override
116  public void onEvent(Event event) throws Exception {
117  ContractHandshake handshake = contract.getContractHandshake();
118  if(handshake != null) {
119  ElephantResponse er = HandshakeUtil.checkStatus(contract);
120  if(ElephantResponse.isCorrect(er)) {
121  HandshakeStatus status = HandshakeStatus.getStatus(er);
122  Clients.showNotification(er.message + ": " + er.code);
123  updateImage(status);
124  } else {
125  Clients.showNotification("Handshake server not found");
126  }
127  } else {
128  updateImage(HandshakeStatus.HS_NO_HANDSHAKE);
129  }
130  Events.postEvent(new Event(Events.ON_CHANGE, HandshakeControl.this));
131  }
132  };
133  addEventListener(Events.ON_CLICK, onClick);
134  }
135  } else {
136  setVisible(false);
137  }
138  }
ContractHandshake getContractHandshake()
Definition: Contract.java:328
ContractDefinition getContractDefinition()
Definition: Contract.java:125
void setContractHandshake(ContractHandshake contractHandshake)
Definition: Contract.java:332
Here is the call graph for this function:

◆ isMustSave()

boolean org.turro.financials.handshake.HandshakeControl.isMustSave ( )

Definition at line 52 of file HandshakeControl.java.

52  {
53  return mustSave;
54  }
Here is the caller graph for this function:

◆ setContract()

void org.turro.financials.handshake.HandshakeControl.setContract ( Contract  contract)

Definition at line 48 of file HandshakeControl.java.

48  {
49  this.contract = contract;
50  }

The documentation for this class was generated from the following file: