Example usage for com.google.gwt.user.client Window alert

List of usage examples for com.google.gwt.user.client Window alert

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window alert.

Prototype

public static void alert(String msg) 

Source Link

Usage

From source file:com.chinarewards.gwt.license.client.mvp.impl.WindowAlertErrorHandler.java

public void alert(String message) {
    Window.alert(message);
}

From source file:com.chinarewards.gwt.license.client.mvp.impl.WindowAlertErrorHandler.java

public void alert(String message, Throwable e) {
    // custom alert message
    Window.alert(message + "\n\n" + e.toString());
}

From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java

public void authenticate(String username, String password, String verifyCode) {
    if (null == username || username.trim().equals("")) {
        // Window.alert("??!");
        final AlertErrorWidget ae = new AlertErrorWidget();
        final DialogBox dialogBoxae = new DialogBox();
        ae.getOkBtn().addClickHandler(new ClickHandler() {
            @Override/*  w  ww .j av  a2 s  .  com*/
            public void onClick(ClickEvent arg0) {
                dialogBoxae.hide();
            }
        });
        ae.setMessage("??!");
        dialogBoxae.setWidget(ae);
        dialogBoxae.setGlassEnabled(true);
        dialogBoxae.setAnimationEnabled(true);
        dialogBoxae.setWidth("350px");
        dialogBoxae.setText("??");
        dialogBoxae.center();
        dialogBoxae.show();
        return;
    }
    if (null == password || password.trim().equals("")) {
        // Window.alert("??!");
        final AlertErrorWidget ae = new AlertErrorWidget();
        final DialogBox dialogBoxae = new DialogBox();
        ae.getOkBtn().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent arg0) {
                dialogBoxae.hide();
            }
        });
        ae.setMessage("??!");
        dialogBoxae.setWidget(ae);
        dialogBoxae.setGlassEnabled(true);
        dialogBoxae.setAnimationEnabled(true);
        dialogBoxae.setWidth("350px");
        dialogBoxae.setText("??");
        dialogBoxae.center();
        dialogBoxae.show();
        return;
    }
    if (null == verifyCode || verifyCode.trim().equals("")) {
        // Window.alert("??!");
        final AlertErrorWidget ae = new AlertErrorWidget();
        final DialogBox dialogBoxae = new DialogBox();
        ae.getOkBtn().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent arg0) {
                dialogBoxae.hide();
            }
        });
        ae.setMessage("???!");
        dialogBoxae.setWidget(ae);
        dialogBoxae.setGlassEnabled(true);
        dialogBoxae.setAnimationEnabled(true);
        dialogBoxae.setWidth("350px");
        dialogBoxae.setText("??");
        dialogBoxae.center();
        dialogBoxae.show();
        return;
    }
    loginService.authLogin(username, password, verifyCode, new AsyncCallback<UserSession>() {

        @Override
        public void onSuccess(UserSession resp) {
            // TODO Auto-generated method stub
            tokenObtained(resp);

            UserRoleVo role = resp.getLastLoginRole();
            // ????
            List<UserRoleVo> roleslt = new ArrayList<UserRoleVo>();
            UserRoleVo[] roles = resp.getUserRoles();
            if (roles.length > 0) {
                for (UserRoleVo r : roles) {
                    roleslt.add(r);
                }

                if (role != null && roleslt.contains(role)) {
                    if (role == UserRoleVo.CORP_ADMIN)
                        eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK));
                    else if (role == UserRoleVo.STAFF)
                        eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK_STAFF));
                } else {
                    if (roleslt.contains(UserRoleVo.CORP_ADMIN)) {
                        role = UserRoleVo.CORP_ADMIN;
                        session.setLastLoginRole(role);
                        eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK));
                    } else if (roleslt.contains(UserRoleVo.STAFF)) {
                        role = UserRoleVo.STAFF;
                        session.setLastLoginRole(role);
                        eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK_STAFF));
                    } else
                        Window.alert("");
                }

                if (role != null) {
                    dispatchAsync.execute(new LastLoginRoleRequest(resp.getToken(), role),
                            new AsyncCallback<LastLoginRoleResponse>() {

                                @Override
                                public void onFailure(Throwable e) {
                                    tokenObtained(null);
                                    eventBus.fireEvent(new PlatformInitEvent(false));
                                }

                                @Override
                                public void onSuccess(LastLoginRoleResponse resp) {
                                    // ?
                                    if ("success".equals(resp.getFal()))
                                        GWT.log("success update last login role ");

                                }
                            });

                }

            }
        }

        @Override
        public void onFailure(Throwable e) {
            tokenObtained(null);

            final AlertErrorWidget ae = new AlertErrorWidget();
            final DialogBox dialogBoxae = new DialogBox();
            ae.getOkBtn().addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent arg0) {
                    dialogBoxae.hide();
                }
            });
            ae.setMessage(e.getMessage());
            dialogBoxae.setWidget(ae);
            dialogBoxae.setGlassEnabled(true);
            dialogBoxae.setAnimationEnabled(true);
            dialogBoxae.setWidth("350px");
            dialogBoxae.setText("??");
            dialogBoxae.center();
            dialogBoxae.show();
            eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_FAILED, e));

        }
    });

    LoginRequest req = new LoginRequest(username, password, verifyCode);
    dispatchAsync.execute(req, new AsyncCallback<LoginResponse>() {

        @Override
        public void onFailure(Throwable e) {

        }

        @Override
        public void onSuccess(LoginResponse resp) {

        }
    });
}

From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java

@Override
public void initialize() {
    // Check Cookie Validity
    GWT.log("Initializing SessionManager...");
    String token = Cookies.getCookie("token");

    System.out.println("token==========" + token);
    if (null != token && !token.trim().equals("")) {
        // check the token value.
        dispatchAsync.execute(new TokenValidRequest(token), new AsyncCallback<TokenValidResponse>() {

            @Override//from ww  w.  ja  v a2  s.  co m
            public void onFailure(Throwable e) {
                tokenObtained(null);
                eventBus.fireEvent(new PlatformInitEvent(false));
            }

            @Override
            public void onSuccess(TokenValidResponse resp) {
                tokenObtainedToo(resp);

                UserRoleVo role = resp.getLastLoginRole();
                // ????
                List<UserRoleVo> roleslt = new ArrayList<UserRoleVo>();
                UserRoleVo[] roles = resp.getUserRoles();
                if (roles.length > 0) {
                    for (UserRoleVo r : roles) {
                        roleslt.add(r);
                    }

                    if (role != null && roleslt.contains(role)) {
                        if (role == UserRoleVo.CORP_ADMIN)
                            eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK));
                        else if (role == UserRoleVo.STAFF)
                            eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK_STAFF));
                    } else {
                        if (roleslt.contains(UserRoleVo.CORP_ADMIN)) {
                            role = UserRoleVo.CORP_ADMIN;
                            session.setLastLoginRole(role);
                            eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK));
                        }

                        else if (roleslt.contains(UserRoleVo.STAFF)) {
                            role = UserRoleVo.STAFF;
                            session.setLastLoginRole(role);
                            eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK_STAFF));
                        } else
                            Window.alert("");
                    }

                    if (role != null) {
                        dispatchAsync.execute(new LastLoginRoleRequest(resp.getToken(), role),
                                new AsyncCallback<LastLoginRoleResponse>() {

                                    @Override
                                    public void onFailure(Throwable e) {
                                        tokenObtained(null);
                                        eventBus.fireEvent(new PlatformInitEvent(false));
                                    }

                                    @Override
                                    public void onSuccess(LastLoginRoleResponse resp) {
                                        // ?
                                        if ("success".equals(resp.getFal()))
                                            GWT.log("success update last login role ");

                                    }
                                });

                    }

                }
            }
        });

    } else {
        eventBus.fireEvent(new PlatformInitEvent(false));
    }

}

From source file:com.chinarewards.gwt.license.util.PrintOut.java

public static void it(String html) {
    try {/*  w w  w.ja v  a  2  s .  c  o m*/
        buildFrame(html);
        DeferredCommand.addCommand(printFrameCommmand); // pring out
    } catch (Throwable exc) {
        Window.alert(exc.getMessage());
    }
}

From source file:com.cloudtask1.client.CloudTask1Widget.java

License:Open Source License

public CloudTask1Widget() {
    initWidget(uiBinder.createAndBindUi(this));
    sayHelloButton.getElement().setClassName("send centerbtn");
    sendMessageButton.getElement().setClassName("send");
    /* addTaskButton.getElement().setClassName("BUTTON_STYLE");
     updateTaskButton.getElement().setClassName("BUTTON_STYLE");
     queryTaskButton.getElement().setClassName("BUTTON_STYLE");
     deleteTaskButton.getElement().setClassName("BUTTON_STYLE");
     */// w  w  w .  j  a  v a 2  s.  c  o  m

    final EventBus eventBus = new SimpleEventBus();
    final MyRequestFactory requestFactory = GWT.create(MyRequestFactory.class);
    //final CloudTask1Request myCloudTasks = GWT.create(CloudTask1Request.class);

    requestFactory.initialize(eventBus);

    sendMessageButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String recipient = recipientArea.getValue();
            String message = messageArea.getValue();
            setStatus("Connecting...", false);
            sendMessageButton.setEnabled(false);

            // Send a message using RequestFactory
            MessageRequest request = requestFactory.messageRequest();
            MessageProxy messageProxy = request.create(MessageProxy.class);
            messageProxy.setRecipient(recipient);
            messageProxy.setMessage(message);
            Request<String> sendRequest = request.send().using(messageProxy);
            sendRequest.fire(new Receiver<String>() {
                @Override
                public void onFailure(ServerFailure error) {
                    sendMessageButton.setEnabled(true);
                    setStatus(error.getMessage(), true);
                }

                @Override
                public void onSuccess(String response) {
                    sendMessageButton.setEnabled(true);
                    setStatus(response, response.startsWith("Failure:"));
                }
            });
        }
    });

    sayHelloButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            sayHelloButton.setEnabled(false);
            HelloWorldRequest helloWorldRequest = requestFactory.helloWorldRequest();
            helloWorldRequest.getMessage().fire(new Receiver<String>() {
                @Override
                public void onFailure(ServerFailure error) {
                    sayHelloButton.setEnabled(true);
                    setStatus(error.getMessage(), true);
                }

                @Override
                public void onSuccess(String response) {
                    sayHelloButton.setEnabled(true);
                    setStatus(response, response.startsWith("Failure:"));
                }
            });
        }
    });

    //Add a task
    addTaskButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            addTaskButton.setEnabled(false);

            CloudTask1Request myCloudTasks = requestFactory.cloudTask1Request();
            myCloudTasks.createTask().fire(new Receiver<TaskProxy>() {

                @Override
                public void onSuccess(TaskProxy task) {
                    Window.alert("CREATE SUCCESS:(" + task.getId() + ")");
                    taskProxy = task;
                    id = task.getId();
                    ids.add(id);

                }

            });

        }
    });

    //Delete a task
    deleteTaskButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

            try {
                if (nameId.getValue().length() > 0) {

                    int temp;
                    String tempstr;

                    tempstr = nameId.getValue();

                    //temp =  tempstr;

                    //Window.alert("value of tmp str is : "+tempstr);

                    id = Long.valueOf(tempstr); //ids.get(temp);

                    Window.alert("value of id is : " + id);
                } else {
                    id = 1L;
                }
            } catch (Exception e) {

                Window.alert(e.toString());
            }

            requestFactory.cloudTask1Request().readTask(id).fire(new Receiver<TaskProxy>() {

                //Need to Implement
                //public void onFailure(){
                //}
                /*
                 * 
                */
                @Override
                public void onSuccess(TaskProxy response) {

                    requestFactory.cloudTask1Request().deleteTask(response).fire(new Receiver<Void>() {

                        @Override
                        public void onSuccess(Void response) {
                            Window.alert("Deleted Task: " + id);

                        }

                    });
                }

            });
        }
    });

    //Update a task
    updateTaskButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

            //get id number
            //name and notes from text fields
            try {
                if (nameId.getValue().length() > 0) {

                    int temp;
                    String tempstr;

                    tempstr = nameId.getValue();

                    //temp =  tempstr;

                    //Window.alert("value of tmp str is : "+tempstr);

                    id = Long.valueOf(tempstr); //ids.get(temp);

                    //Window.alert("value of id is : "+id);
                } else {
                    //id = 1L;
                    Window.alert("\nNO TASK WITH THIS ID\n");
                    Exception e = new Exception();

                    throw e;

                }
            } catch (Exception e) {

                Window.alert(e.toString());
            } finally {

                //id = 1L;
            }

            requestFactory.cloudTask1Request().readTask(id).fire(new Receiver<TaskProxy>() {

                //this is supposed to be the way to get the task to be updated
                @Override
                public void onSuccess(TaskProxy response) {

                    //String nameStr = name.getValue();
                    //requestFactory.cloudTask1Request().
                    //response.setNote(nameMessage.getValue());

                    taskProxy = response;

                    //Window.alert("UPDATED TASK:  "+response.getId()+" with "+
                    //name.getValue()+" and "+nameMessage.getValue());

                    update1(response);

                }

            });

            //we just passs in taskProxy for now to avoid errors...
            update1(taskProxy);

        }

        private void update1(TaskProxy task) {
            CloudTask1Request request = requestFactory.cloudTask1Request();

            //an exception is being thrown here....need to see if removing the line below still works....
            task = request.edit(task);

            //taskProxy.setName("");//name.getValue());

            //taskProxy.setNote(getTaskName());

            task.setName(name.getValue());
            task.setNote(nameMessage.getValue());

            request.updateTask(task).fire(new Receiver<TaskProxy>() {
                @Override
                public void onSuccess(TaskProxy task) {
                    Window.alert("UPDATE SUCCESS:(" + task.getId().toString() + "): " + task.getName());
                }
            });
        }

        private String getTaskName() {

            //String recipient = name.getValue();
            String message = nameMessage.getValue();

            return message;
        }

    });

    //Query Tasks added
    queryTaskButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

            query();

        }

        private void query() {

            requestFactory.cloudTask1Request().queryTasks().fire(new Receiver<List<TaskProxy>>() {
                @Override
                public void onSuccess(List<TaskProxy> taskList) {
                    String names = "\n";
                    for (TaskProxy task : taskList) {
                        names += " (" + task.getId().toString() + "): " + task.getName() + " is located at: ("
                                + task.getNote() + ")\n";

                        //   ids.add(task.getId().intValue(),task.getId());
                    }
                    Window.alert("QUERY SUCCESS: Count[" + taskList.size() + "] Values:" + names);
                }
            });
        }

    });

}

From source file:com.cms.gwt.fs.client.view.calendar.DefaultMonthField.java

License:Apache License

public void repaintPanel() {
    final Object theData = getData();

    if (theData != null) {
        if (theData instanceof EventData) {
            final EventData real = (EventData) theData;
            helper.setTime(real.getStartTime());
            if (helper.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
                super.setEventStyleName(Css.WHOLEDAY_PANEL_MONDAY);
            }//w w  w  .j  a v  a2  s .  co  m
            description.setText(real.getData().trim());
            description.setTitle(real.getData());
            super.setTitle(format.format(real.getStartTime()));
        } else {
            Window.alert("Programming error " + theData);
        }
    }

}

From source file:com.cms.gwt.fs.client.view.calendar.DefaultPanelRenderer.java

License:Apache License

private EventData getData(Object event) {
    if (event instanceof EventData) {
        return (EventData) event;
    } else {//from w ww .  j ava  2 s.c  om
        Window.alert("Not the Right type " + event.getClass());
        return null;
    }
}

From source file:com.cms.gwt.fs.client.view.calendar.DefaultPanelRenderer.java

License:Apache License

public boolean isWholeDayEvent(Object event) {
    final EventData data = getData(event);
    if (data != null) {
        return data.isAllDayEvent();
    } else {//from   www.j av a  2  s .  co m
        Window.alert("Programming Error " + event);
        return true;
    }
}

From source file:com.cms.gwt.fs.client.view.calendar.DefaultWholeDayField.java

License:Apache License

public void repaintPanel() {
    final Object theData = getData();
    if (theData != null) {
        if (theData instanceof EventData) {
            final EventData real = (EventData) theData;
            helper.setTime(real.getStartTime());
            if (helper.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
                super.setEventStyleName(Css.EVENT_HEADER_MONDAY);
            }/*from   w w  w .j  a va 2 s  .  c  om*/

            setTitle(real.getData());
        } else {
            Window.alert("Programming error " + theData);
        }
    }

}