/
AccountTabConfiguration.java
89 lines (73 loc) · 3.21 KB
/
AccountTabConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
* Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.app.console.module.account.client;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Element;
import org.eclipse.kapua.app.console.module.account.shared.model.GwtAccount;
import org.eclipse.kapua.app.console.module.api.client.messages.ConsoleMessages;
import org.eclipse.kapua.app.console.module.api.client.resources.icons.IconSet;
import org.eclipse.kapua.app.console.module.api.client.resources.icons.KapuaIcon;
import org.eclipse.kapua.app.console.module.api.client.ui.tab.KapuaTabItem;
import org.eclipse.kapua.app.console.module.api.shared.model.session.GwtSession;
public class AccountTabConfiguration extends KapuaTabItem<GwtAccount> {
private static final ConsoleMessages MSGS = GWT.create(ConsoleMessages.class);
private AccountConfigComponents configComponents;
private AccountDetailsView accountDetailsView;
private AccountDetailsTabDescription accountDetailsTabDescription;
public AccountTabConfiguration(GwtSession currentSession, AccountDetailsView accountDetailsView) {
super(currentSession, MSGS.settingsTabTitle(), new KapuaIcon(IconSet.COG));
this.accountDetailsView = accountDetailsView;
configComponents = new AccountConfigComponents(currentSession, this);
setEnabled(false);
setBorders(false);
setLayout(new FitLayout());
addListener(Events.Select, new Listener<ComponentEvent>() {
@Override
public void handleEvent(ComponentEvent be) {
refresh();
}
});
}
@Override
public void setEntity(GwtAccount selectedAccount) {
super.setEntity(selectedAccount);
if (selectedAccount != null) {
setEnabled(true);
} else {
setEnabled(false);
}
configComponents.setAccount(selectedAccount);
}
@Override
protected void doRefresh() {
configComponents.refresh();
}
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setId("AccountTabsContainer");
setLayout(new FitLayout());
add(configComponents);
}
public void setDescriptionTab(AccountDetailsTabDescription accountDetailsTabDescription) {
this.accountDetailsTabDescription = accountDetailsTabDescription;
configComponents.setDescriptionTab(accountDetailsTabDescription);
}
public void removeElements(){
configComponents.removeApplyAndResetButtons();
}
}