Skip to content

Commit

Permalink
Further refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma authored and Coduz committed Oct 10, 2018
1 parent 3999146 commit 424aee0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
Expand Up @@ -86,8 +86,8 @@ public void handleEvent(ComponentEvent be) {
accountsToolBar.add(editButton);
accountsToolBar.add(new SeparatorToolItem());

if (currentSession.hasPermission(AccountSessionPermission.write())) {
editButton.setEnabled(true);
if (!currentSession.hasPermission(AccountSessionPermission.write())) {
editButton.disable();
}
return accountsToolBar;
}
Expand Down
Expand Up @@ -42,29 +42,14 @@ protected void onRender(Element parent, int pos) {
setScrollMode(Scroll.AUTO);

fieldSet.remove(accountNameField);
fieldSet.remove(parentAccountNameLabel);

accountNameLabel.setVisible(true);
accountNameLabel.setToolTip(MSGS.accountFormParentAccountNameEditDialogTooltip());

accountNameLabel.setValue(selectedAccount.getName());
accountNameField.setValue(selectedAccount.getName());

if (selectedAccount.getParentAccountId() != null) {
GWT_ACCOUNT_SERVICE.find(selectedAccount.getParentAccountId(), new AsyncCallback<GwtAccount>() {

@Override
public void onSuccess(GwtAccount result) {
if (parentAccountNameLabel != null) {
parentAccountNameLabel.setValue(result.getName());
}
}

@Override
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
}
});
}

expirationDateField.setValue(selectedAccount.getExpirationDate());
expirationDateField.setOriginalValue(selectedAccount.getExpirationDate());

Expand Down
Expand Up @@ -232,12 +232,14 @@ public User call() throws Exception {
accountPropertiesPairs.add(new GwtGroupedNVPair(entityInfo, "accountModifiedBy", userModifiedBy != null ? userModifiedBy.getName() : null));

if (account.getScopeId() != null) {
try {
Account parentAccount = ACCOUNT_SERVICE.find(account.getScopeId());
accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountParent", parentAccount != null ? parentAccount.getName() : null));
} catch (SubjectUnauthorizedException suex) {
accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountParent", null));
}
Account parentAccount = KapuaSecurityUtils.doPrivileged(new Callable<Account>() {

@Override
public Account call() throws Exception {
return ACCOUNT_SERVICE.find(account.getScopeId());
}
});
accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountParent", parentAccount != null ? parentAccount.getName() : null));
}
accountPropertiesPairs.add(new GwtGroupedNVPair("accountInfo", "accountName", account.getName()));

Expand Down

0 comments on commit 424aee0

Please sign in to comment.