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

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

Introduction

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

Prototype

public static void scrollTo(int left, int top) 

Source Link

Usage

From source file:org.unitime.timetable.gwt.client.admin.TasksPage.java

License:Apache License

public TasksPage() {
    iForm = new SimpleForm(2);
    iForm.removeStyleName("unitime-NotPrintableBottomLine");

    iHeader = new UniTimeHeaderPanel(MESSAGES.sectScheduledTasks("..."));
    iHeader.addButton("add", MESSAGES.buttonAddNewTask(), 75, new ClickHandler() {
        @Override/*from  w  ww . ja v a 2  s. c o  m*/
        public void onClick(ClickEvent event) {
            new TaskEditor(null, iOptions) {
                @Override
                protected void doSave(final TaskInterface task) {
                    LoadingWidget.getInstance().show(task.getId() == null ? MESSAGES.waitCreate(task.getName())
                            : MESSAGES.waitUpdate(task.getName()));
                    RPC.execute(new SaveTaskDetailsRpcRequest(task), new AsyncCallback<TaskInterface>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            LoadingWidget.getInstance().hide();
                            if (task.getId() == null) {
                                setErrorMessage(MESSAGES.failedCreate(task.getName(), caught.getMessage()));
                                UniTimeNotifications.error(
                                        MESSAGES.failedCreate(task.getName(), caught.getMessage()), caught);
                            } else {
                                setErrorMessage(MESSAGES.failedUpdate(task.getName(), caught.getMessage()));
                                UniTimeNotifications.error(
                                        MESSAGES.failedUpdate(task.getName(), caught.getMessage()), caught);
                            }
                            center();
                        }

                        @Override
                        public void onSuccess(TaskInterface result) {
                            LoadingWidget.getInstance().hide();
                            loadTasks(result == null ? null : result.getId());
                        }
                    });
                }
            }.center();
        }
    });
    iHeader.setEnabled("add", false);
    iHeader.addButton("refresh", MESSAGES.buttonRefresh(), 75, new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            loadTasks(null);
        }
    });
    iForm.addHeaderRow(iHeader);

    iTasksTable = new TasksTable();
    iForm.addRow(iTasksTable);

    iFooter = iHeader.clonePanel("");
    iForm.addBottomRow(iFooter);

    iPanel = new SimplePanel(iForm);
    initWidget(iPanel);

    iHeader.showLoading();
    RPC.execute(new GetTaskOptionsRpcRequest(), new AsyncCallback<TaskOptionsInterface>() {
        @Override
        public void onFailure(Throwable caught) {
            iHeader.setErrorMessage(MESSAGES.failedLoadData(caught.getMessage()));
            UniTimeNotifications.error(MESSAGES.failedLoadData(caught.getMessage()), caught);
        }

        @Override
        public void onSuccess(TaskOptionsInterface result) {
            iOptions = result;
            iTasksTable.setOptions(result);
            iHeader.setEnabled("add", iOptions.canAdd());
            iHeader.setHeaderTitle(MESSAGES.sectScheduledTasks(iOptions.getSession().getName()));
            loadTasks(null);
        }
    });

    iTasksTable.addMouseClickListener(new MouseClickListener<TaskInterface>() {
        @Override
        public void onMouseClick(final TableEvent<TaskInterface> event) {
            /*
            if (event.getData() != null && event.getData().canEdit()) {
               new TaskEditor(new TaskInterface(event.getData())).center();
            }
            */
            if (event.getData() != null && event.getData().canView()) {
                iTaskDetail.setValue(event.getData());
                UniTimePageLabel.getInstance().setPageName(MESSAGES.pageTaskDetails());
                iPanel.setWidget(iTaskDetail);
                Window.scrollTo(0, 0);
                GwtHint.hideHint();
            }
        }
    });

    iTaskDetail = new TaskDetail() {
        protected void doBack() {
            iPanel.setWidget(iForm);
            UniTimePageLabel.getInstance().setPageName(MESSAGES.pageTasks());
            loadTasks(getValue() == null ? null : getValue().getId());
        }

        protected void doEdit() {
            new TaskEditor(getValue(), iOptions) {
                @Override
                protected void doSave(final TaskInterface task) {
                    LoadingWidget.getInstance().show(task.getId() == null ? MESSAGES.waitCreate(task.getName())
                            : MESSAGES.waitUpdate(task.getName()));
                    RPC.execute(new SaveTaskDetailsRpcRequest(task), new AsyncCallback<TaskInterface>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            LoadingWidget.getInstance().hide();
                            if (task.getId() == null) {
                                setErrorMessage(MESSAGES.failedCreate(task.getName(), caught.getMessage()));
                                UniTimeNotifications.error(
                                        MESSAGES.failedCreate(task.getName(), caught.getMessage()), caught);
                            } else {
                                setErrorMessage(MESSAGES.failedUpdate(task.getName(), caught.getMessage()));
                                UniTimeNotifications.error(
                                        MESSAGES.failedUpdate(task.getName(), caught.getMessage()), caught);
                            }
                            center();
                        }

                        @Override
                        public void onSuccess(TaskInterface result) {
                            LoadingWidget.getInstance().hide();
                            if (result != null)
                                setValue(result);
                            else
                                doBack();
                        }
                    });
                }
            }.center();
        }
    };
}

From source file:org.unitime.timetable.gwt.client.events.EventAdd.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance()/*from www.  jav  a2s .  c  o m*/
            .setPageName(iEvent.getId() == null ? MESSAGES.pageAddEvent() : MESSAGES.pageEditEvent());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
    if (iForm.getRowFormatter().isVisible(iSessionRow)) {
        iSession.setFilter(this);
        iForm.setWidget(iSessionRow, 1, iSession);
    }
    iFileUpload.check();
}

From source file:org.unitime.timetable.gwt.client.events.EventAdd.java

License:Apache License

public void hide() {
    setVisible(false);
    onHide();
    Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}

From source file:org.unitime.timetable.gwt.client.events.EventDetail.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance().setPageName(MESSAGES.pageEventDetail());
    setVisible(true);//from   w ww.jav  a2  s. co m
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.instructor.InstructorAttributeEdit.java

License:Apache License

private void hide(boolean refresh, AttributeInterface attribute) {
    setVisible(false);
    onHide(refresh, attribute);
    Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}

From source file:org.unitime.timetable.gwt.client.instructor.InstructorAttributeEdit.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance()/*from  w  ww  .j  a  v  a  2 s  .c  om*/
            .setPageName(iAttribute.getId() == null ? MESSAGES.pageAddInstructorAttribute()
                    : MESSAGES.pageEditInstructorAttribute());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.page.Refresh.java

License:Apache License

public static void scrollDown() {
    String hash = Window.Location.getHash();
    if (hash != null && hash.matches("#[0-9]+:[0-9]+")) {
        String[] scroll = hash.substring(1).split(":");
        Window.scrollTo(Integer.parseInt(scroll[0]), Integer.parseInt(scroll[1]));
    }//  www .  j a  va 2 s. co  m
}

From source file:org.unitime.timetable.gwt.client.rooms.RoomDepartmentsEdit.java

License:Apache License

private void hide(boolean refresh) {
    setVisible(false);
    onHide(refresh);
    Window.scrollTo(iLastScrollLeft, iLastScrollTop);
}

From source file:org.unitime.timetable.gwt.client.rooms.RoomDepartmentsEdit.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance().setPageName(MESSAGES.pageEditRoomsDepartments());
    setVisible(true);/*from  w  w  w  .ja  v  a  2  s.  c o m*/
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.rooms.RoomDetail.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance().setPageName(MESSAGES.pageRoomDetail());
    setVisible(true);/*from  w ww  .j a va2  s  .com*/
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}