use of org.eclipse.kapua.app.console.client.account.AccountDetailsView in project kapua by eclipse.
the class WestNavigationView method onRender.
protected void onRender(final Element parent, int index) {
super.onRender(parent, index);
setLayout(new FitLayout());
setBorders(false);
//
// accordion
m_accordionLayout = new AccordionLayout();
m_accordionLayout.setFill(true);
m_accordionPanel = new ContentPanel();
m_accordionPanel.setBorders(false);
m_accordionPanel.setBodyBorder(false);
m_accordionPanel.setLayout(m_accordionLayout);
m_accordionPanel.setHeaderVisible(false);
m_accordionPanel.setId("accordion-panel");
add(m_accordionPanel);
//
// Top managing panel
m_accountPanel = new ContentPanel();
m_accountPanel.setBorders(false);
m_accountPanel.setBodyBorder(true);
m_accountPanel.setAnimCollapse(true);
m_accountPanel.setHeaderVisible(false);
m_accountPanel.setScrollMode(Scroll.AUTOY);
//
// Bottom manage panel
m_managePanel = new ContentPanel();
m_managePanel.setBorders(false);
m_managePanel.setBodyBorder(false);
m_managePanel.setHeading(MSGS.manageHeading());
m_managePanel.setHeaderVisible(true);
m_accountStore = new TreeStore<ModelData>();
m_manageStore = new TreeStore<ModelData>();
//
// Adding item to stores
//
addMenuItems();
ColumnConfig name = new ColumnConfig("name", "Name", 100);
name.setRenderer(new WidgetTreeGridCellRenderer<ModelData>() {
@Override
public Widget getWidget(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
Label label = new Label((String) model.get(property));
label.setStyleAttribute("padding-left", "5px");
if (((String) model.get(property)).equals("Dashboard")) {
// Adding refresh button
label.setStyleAttribute("padding-right", "50px");
label.setStyleAttribute("background-color", "transparent");
ContentPanel dashboardLabelPanel = new ContentPanel();
dashboardLabelPanel.setHeaderVisible(false);
dashboardLabelPanel.setBorders(false);
dashboardLabelPanel.setBodyBorder(false);
dashboardLabelPanel.setLayout(new FitLayout());
dashboardLabelPanel.setStyleAttribute("background-color", "transparent");
dashboardLabelPanel.add(label);
imgRefreshLabel = new Label("<image src=\"eclipse/org/eclipse/kapua/app/console/icon/refresh.png\" " + "width=\"15\" height=\"15\" " + "style=\"vertical-align: middle\" title=\"" + MSGS.refreshButton() + "\"/>");
dashboardLabelPanel.add(imgRefreshLabel);
dashboardLabelPanel.setBodyStyle("background-color:transparent");
imgRefreshLabel.addListener(Events.OnClick, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
if (dashboardSelected) {
m_dashboardView.refresh();
}
}
});
return dashboardLabelPanel;
}
return label;
}
});
ColumnModel cm = new ColumnModel(Arrays.asList(name));
m_accountTree = new TreeGrid<ModelData>(m_accountStore, cm);
m_accountTree.setBorders(false);
m_accountTree.setHideHeaders(true);
m_accountTree.setAutoExpandColumn("name");
m_accountTree.getTreeView().setRowHeight(36);
m_accountTree.getTreeView().setForceFit(true);
m_accountTree.setIconProvider(new ModelIconProvider<ModelData>() {
public AbstractImagePrototype getIcon(ModelData model) {
if (model.get("icon") != null) {
ImageResource ir = (ImageResource) model.get("icon");
return AbstractImagePrototype.create(ir);
} else {
return null;
}
}
});
m_accountTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
m_accountTree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
@Override
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
ModelData selected = se.getSelectedItem();
if (selected == null)
return;
if (dashboardSelected && ((String) selected.get("id")).equals("dashboard")) {
return;
}
m_manageTree.getSelectionModel().deselectAll();
m_centerPanel.removeAll();
ContentPanel panel = new ContentPanel(new FitLayout());
panel.setBorders(false);
panel.setBodyBorder(false);
String selectedId = (String) selected.get("id");
if ("dashboard".equals(selectedId)) {
panel.setHeaderVisible(false);
m_dashboardView = new DashboardView(m_currentSession);
panel.add(m_dashboardView);
m_centerPanel.add(panel);
m_centerPanel.layout();
dashboardSelected = true;
} else if ("devices".equals(selectedId)) {
panel.setHeaderVisible(false);
panel.add(new DevicesView(m_currentSession));
m_centerPanel.add(panel);
m_centerPanel.layout();
dashboardSelected = false;
} else if ("user".equals(selectedId)) {
panel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.users16()));
panel.setHeading(MSGS.users());
UserView userView = new UserView(m_currentSession);
userView.setAccount(m_currentSession.getSelectedAccount());
panel.add(userView);
m_centerPanel.add(panel);
m_centerPanel.layout();
userView.refresh();
dashboardSelected = false;
} else if ("mysettings".equals(selectedId)) {
panel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.settings()));
panel.setHeading(MSGS.settings());
AccountDetailsView settingView = new AccountDetailsView(null, m_currentSession);
settingView.setAccount(m_currentSession.getSelectedAccount());
panel.add(settingView);
m_centerPanel.add(panel);
m_centerPanel.layout();
settingView.refresh();
}
imgRefreshLabel.setVisible(dashboardSelected);
}
});
ColumnConfig name1 = new ColumnConfig("name", "Name", 100);
name1.setRenderer(new WidgetTreeGridCellRenderer<ModelData>() {
@Override
public Widget getWidget(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
Label label = new Label((String) model.get(property));
label.setStyleAttribute("padding-left", "5px");
return label;
}
});
ColumnModel cm1 = new ColumnModel(Arrays.asList(name1));
m_manageTree = new TreeGrid<ModelData>(m_manageStore, cm1);
m_manageTree.setBorders(false);
m_manageTree.setHideHeaders(true);
m_manageTree.setAutoExpandColumn("name");
m_manageTree.getTreeView().setRowHeight(36);
m_manageTree.getTreeView().setForceFit(true);
m_manageTree.setIconProvider(new ModelIconProvider<ModelData>() {
public AbstractImagePrototype getIcon(ModelData model) {
if (model.get("icon") != null) {
ImageResource ir = (ImageResource) model.get("icon");
return AbstractImagePrototype.create(ir);
} else {
return null;
}
}
});
m_manageTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
m_manageTree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
@Override
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
ModelData selected = se.getSelectedItem();
if (selected == null)
return;
m_accountTree.getSelectionModel().deselectAll();
m_centerPanel.removeAll();
ContentPanel panel = new ContentPanel(new FitLayout());
panel.setBorders(false);
panel.setBodyBorder(false);
String selectedId = (String) selected.get("id");
if ("childaccounts".equals(selectedId)) {
panel.setIcon(AbstractImagePrototype.create(Resources.INSTANCE.childAccounts16()));
panel.setHeading(MSGS.childaccounts());
AccountView accountView = new AccountView(m_currentSession);
panel.add(accountView);
dashboardSelected = false;
}
imgRefreshLabel.setVisible(dashboardSelected);
m_centerPanel.add(panel);
m_centerPanel.layout();
}
});
m_accountPanel.add(m_accountTree);
m_accountPanel.add(m_managePanel);
m_accountPanel.add(m_manageTree);
m_accountTree.getSelectionModel().select(0, false);
m_accordionPanel.add(m_accountPanel);
}
Aggregations