1 package gr.ebs.gss.admin.client;
3 import gr.ebs.gss.admin.client.ui.HeaderPanel;
4 import gr.ebs.gss.admin.client.ui.UserPanel;
5 import gr.ebs.gss.admin.client.ui.VisualizationPanel;
6 import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
8 import com.google.gwt.core.client.EntryPoint;
9 import com.google.gwt.core.client.GWT;
10 import com.google.gwt.event.dom.client.ClickEvent;
11 import com.google.gwt.event.dom.client.ClickHandler;
12 import com.google.gwt.event.logical.shared.ResizeEvent;
13 import com.google.gwt.event.logical.shared.ResizeHandler;
14 import com.google.gwt.event.logical.shared.SelectionEvent;
15 import com.google.gwt.event.logical.shared.SelectionHandler;
16 import com.google.gwt.uibinder.client.UiBinder;
17 import com.google.gwt.uibinder.client.UiField;
18 import com.google.gwt.user.client.Command;
19 import com.google.gwt.user.client.DeferredCommand;
20 import com.google.gwt.user.client.Window;
21 import com.google.gwt.user.client.rpc.AsyncCallback;
22 import com.google.gwt.user.client.ui.Button;
23 import com.google.gwt.user.client.ui.DialogBox;
24 import com.google.gwt.user.client.ui.DockLayoutPanel;
25 import com.google.gwt.user.client.ui.Label;
26 import com.google.gwt.user.client.ui.RootLayoutPanel;
27 import com.google.gwt.user.client.ui.TabLayoutPanel;
28 import com.google.gwt.user.client.ui.VerticalPanel;
31 * Entry point classes define <code>onModuleLoad()</code>.
33 public class TwoAdmin implements EntryPoint {
35 interface Binder extends UiBinder<DockLayoutPanel, TwoAdmin> {
38 private final AdminServiceAsync adminService = GWT.create(AdminService.class);
40 private static final Binder binder = GWT.create(Binder.class);
43 * The single TwoAdmin instance.
45 private static TwoAdmin singleton;
48 * Gets the singleton TwoAdmin instance.
50 * @return the TwoAdmin object
52 public static TwoAdmin get() {
53 if (TwoAdmin.singleton == null)
54 TwoAdmin.singleton = new TwoAdmin();
55 return TwoAdmin.singleton;
58 @UiField(provided = true)
59 HeaderPanel headerPanel = new HeaderPanel();
61 @UiField UserPanel userPanel;
64 TabLayoutPanel tabPanel;
66 @UiField VisualizationPanel chart2;
68 final DialogBox loadingBox = new DialogBox();
71 public void onModuleLoad() {
72 TwoAdmin.singleton=this;
73 loadingBox.setHTML("Loading data");
74 //scroll.setAlwaysShowScrollBars(true);
75 VerticalPanel vPanel = new VerticalPanel();
76 loadingBox.setSize("50%", "50%");
77 loadingBox.setWidget(vPanel);
78 vPanel.add(new Label("Fetching Requested Data"));
80 DockLayoutPanel outer = binder.createAndBindUi(this);
81 tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
84 public void onSelection(SelectionEvent<Integer> event) {
85 switch (event.getSelectedItem()) {
97 // Get rid of scrollbars, and clear out the window's built-in margin,
98 // because we want to take advantage of the entire client area.
99 //Window.enableScrolling(true);
100 //Window.setMargin("0px");
101 Window.addResizeHandler(new ResizeHandler(){
104 public void onResize(ResizeEvent event) {
105 int height=event.getHeight();
111 RootLayoutPanel root = RootLayoutPanel.get();
113 // RootPanel.get().add(outer);
115 tabPanel.selectTab(0);
117 resize(Window.getClientHeight());
120 private void resize(int height){
122 int newHeight = height - tabPanel.getAbsoluteTop()-100;
125 tabPanel.setHeight("" + newHeight);
126 GWT.log("New Height:"+ newHeight);
129 * Retrieve the adminService.
131 * @return the adminService
133 public AdminServiceAsync getAdminService() {
137 public void showErrorBox(String message) {
138 final DialogBox dialogBox = new DialogBox();
139 dialogBox.setHTML("An error occured");
140 VerticalPanel vPanel = new VerticalPanel();
141 dialogBox.setSize("50%", "50%");
142 ClickHandler cancelHandler = new ClickHandler() {
145 public void onClick(ClickEvent event) {
149 dialogBox.setWidget(vPanel);
150 vPanel.add(new Label(message));
151 Button close = new Button("Close");
152 close.addClickHandler(cancelHandler);
160 public void showLoadingBox() {
165 public void hideLoadingBox(){
170 public void loadStatistics(){
171 DeferredCommand.addCommand(new Command() {
174 public void execute() {
176 getAdminService().getSystemStatistics(new AsyncCallback<SystemStatsDTO>() {
179 public void onFailure(Throwable caught) {
181 // TODO Auto-generated method stub
186 public void onSuccess(SystemStatsDTO result) {
187 chart2.updateData(result);
195 public void searchUsers(String query){
196 tabPanel.selectTab(1);
197 userPanel.populateTable(query);