Example usage for com.google.gwt.user.client Timer Timer

List of usage examples for com.google.gwt.user.client Timer Timer

Introduction

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

Prototype

Timer

Source Link

Usage

From source file:com.ikon.frontend.client.panel.center.Browser.java

License:Open Source License

/**
 * timeControl//  w  w w  .j  a  va 2  s  .co m
 */
private void timeControl() {
    if (TimeHelper.hasElapsedEnoughtTime(TIME_HELPER_KEY, REFRESH_WAITING_TIME)) {
        if (!finalResizeInProgess) {
            finalResizeInProgess = true;
            final int tmpHeight = topHeight;
            final int tmpbBottomHeight = bottomHeight;
            final int tmpWidth = width;

            // Solve some problems with chrome
            if (Util.getUserAgent().equals("chrome")) {
                if (topHeight - 20 > 0) {
                    topHeight -= 20;
                } else {
                    topHeight = 0;
                }
                if (bottomHeight - 20 > 0) {
                    bottomHeight -= 20;
                } else {
                    bottomHeight = 0;
                }
                if (width - 20 > 0) {
                    width -= 20;
                } else {
                    width = 0;
                }
                resize();
            }

            new Timer() {
                @Override
                public void run() {
                    topHeight = tmpHeight;
                    bottomHeight = tmpbBottomHeight;
                    width = tmpWidth;
                    resize();
                    TimeHelper.removeControlTime(TIME_HELPER_KEY);
                    finalResizeInProgess = false;
                }
            }.schedule(50);
        }
    } else {
        new Timer() {
            @Override
            public void run() {
                timeControl();
            }
        }.schedule(50);
    }
}

From source file:com.ikon.frontend.client.panel.center.Dashboard.java

License:Open Source License

/**
 * startRefreshingDashboard/*from  ww  w.  j  ava 2  s .c o m*/
 * 
 * @param scheduleTime
 */
public void startRefreshingDashboard(double scheduleTime) {
    dashboardRefreshing = new Timer() {
        public void run() {
            refreshAll();
        }
    };

    dashboardRefreshing.scheduleRepeating(new Double(scheduleTime).intValue());
}

From source file:com.ikon.frontend.client.panel.center.Desktop.java

License:Open Source License

/**
 * onSplitResize/*from  w ww  .ja  v a  2 s  .com*/
 */
public void onSplitResize() {
    final int resizeUpdatePeriod = 20; // ms ( Internally splitter is refreshing each 20 ms )
    if (isResizeInProgress) {
        new Timer() {
            @Override
            public void run() {
                resizePanels(); // Always making resize
                if (isResizeInProgress) {
                    onSplitResize();
                } else {
                    // On finishing in good idea to fill width column tables
                    browser.fileBrowser.table.fillWidth();

                    // Solve some problems with chrome
                    if (Util.getUserAgent().equals("chrome")) {
                        resizePanels();
                    }
                }
            }
        }.schedule(resizeUpdatePeriod);
    }
}

From source file:com.ikon.frontend.client.panel.center.Desktop.java

License:Open Source License

/**
 * timeControl/*from ww  w. j av  a  2  s.co m*/
 */
private void timeControl() {
    if (TimeHelper.hasElapsedEnoughtTime(TIME_HELPER_KEY, REFRESH_WAITING_TIME)) {
        if (!finalResizeInProgess) {
            finalResizeInProgess = true;
            int total = horizontalSplitPanel.getOffsetWidth();
            String value = DOM.getStyleAttribute(
                    DOM.getChild(DOM.getChild(horizontalSplitPanel.getSplitPanel().getElement(), 0), 0),
                    "width");
            if (value.contains("px")) {
                value = value.substring(0, value.indexOf("px"));
            }
            left = Integer.parseInt(value);
            value = DOM.getStyleAttribute(
                    DOM.getChild(DOM.getChild(horizontalSplitPanel.getSplitPanel().getElement(), 0), 2),
                    "left");
            if (value.contains("px")) {
                value = value.substring(0, value.indexOf("px"));
            }
            right = total - Integer.parseInt(value);

            // Solve some problems with chrome
            if (Util.getUserAgent().equals("chrome")) {
                int tmpLeft = left;
                int tmpHeight = height;
                int tmpRight = right;
                if (tmpLeft - 20 > 0) {
                    tmpLeft -= 20;
                } else {
                    tmpLeft = 0;
                }
                if (tmpHeight - 20 > 0) {
                    tmpHeight -= 20;
                } else {
                    tmpHeight = 0;
                }
                if (tmpRight - 20 > 0) {
                    tmpRight -= 20;
                } else {
                    tmpRight = 0;
                }
                navigator.setSize(tmpLeft, tmpHeight);
                browser.setWidth(tmpRight);
            }

            new Timer() {
                @Override
                public void run() {
                    navigator.setSize(left, height);
                    browser.setWidth(right);
                    TimeHelper.removeControlTime(TIME_HELPER_KEY);
                    finalResizeInProgess = false;
                }
            }.schedule(50);
        }
    } else {
        new Timer() {
            @Override
            public void run() {
                timeControl();
            }
        }.schedule(50);
    }
}

From source file:com.ikon.frontend.client.panel.center.Search.java

License:Open Source License

/**
 * timeControl//  w w  w . j av a2s  . c o m
 */
private void timeControl() {
    if (TimeHelper.hasElapsedEnoughtTime(TIME_HELPER_KEY, REFRESH_WAITING_TIME)) {
        if (!finalResizeInProgess) {
            finalResizeInProgess = true;
            int total = horizontalSplitPanel.getOffsetWidth();
            String value = DOM.getStyleAttribute(
                    DOM.getChild(DOM.getChild(horizontalSplitPanel.getSplitPanel().getElement(), 0), 0),
                    "width");
            if (value.contains("px")) {
                value = value.substring(0, value.indexOf("px"));
            }
            left = Integer.parseInt(value);
            value = DOM.getStyleAttribute(
                    DOM.getChild(DOM.getChild(horizontalSplitPanel.getSplitPanel().getElement(), 0), 2),
                    "left");
            if (value.contains("px")) {
                value = value.substring(0, value.indexOf("px"));
            }
            right = total - Integer.parseInt(value);

            // Solve some problems with chrome
            if (Util.getUserAgent().equals("chrome")) {
                int tmpLeft = left;
                int tmpHeight = height;
                int tmpRight = right;
                if (tmpLeft - 20 > 0) {
                    tmpLeft -= 20;
                } else {
                    tmpLeft = 0;
                }
                if (tmpHeight - 20 > 0) {
                    tmpHeight -= 20;
                } else {
                    tmpHeight = 0;
                }
                if (tmpRight - 20 > 0) {
                    tmpRight -= 20;
                } else {
                    tmpRight = 0;
                }
                historySearch.setSize(tmpLeft, tmpHeight);
                searchBrowser.setWidth(tmpRight);
            }

            new Timer() {
                @Override
                public void run() {
                    historySearch.setSize(left, height);
                    searchBrowser.setWidth(right);
                    TimeHelper.removeControlTime(TIME_HELPER_KEY);
                    finalResizeInProgess = false;
                }
            }.schedule(50);
        }
    } else {
        new Timer() {
            @Override
            public void run() {
                timeControl();
            }
        }.schedule(50);
    }
}

From source file:com.ikon.frontend.client.panel.left.ExtendedScrollPanel.java

License:Open Source License

/**
 * ScrollOnDragDrop/*from  w  ww . jav  a  2  s . co m*/
 * 
 * @param x position
 * @param y position
 */
public void ScrollOnDragDrop(int x, int y) {
    if (isOverlap(x, y)) {
        if (isAutoScrollUp(x, y)) {
            if (timer == null) {
                timer = new Timer() {
                    public void run() {
                        ScrollUp();
                    }
                };
                timer.scheduleRepeating(TIMER_SPEED);
            }
        } else if (isAutoScrollDown(x, y)) {
            if (timer == null) {
                timer = new Timer() {
                    public void run() {
                        ScrollDown();
                    }
                };
                timer.scheduleRepeating(TIMER_SPEED);
            }
        } else {
            destroyTimer();
        }
    } else {
        destroyTimer();
    }
}

From source file:com.ikon.frontend.client.util.ConversionStatus.java

License:Open Source License

/**
 * refreshStatus/*  ww  w  . j a  v  a  2  s.  c o m*/
 */
private void refreshStatus() {
    Timer refreshStatus = new Timer() {
        @Override
        public void run() {
            getStatus();
        }
    };

    refreshStatus.schedule(REFRESH_STATUS_DELAY);
}

From source file:com.ikon.frontend.client.util.WorkspaceUserProperties.java

License:Open Source License

/**
 * getUINotificationMessages/*from w  w  w. j a v a  2 s.  c  o m*/
 */
private void getUINotificationMessages(final int scheduleTime) {
    uINotificationService.get(new AsyncCallback<List<GWTUINotification>>() {
        @Override
        public void onSuccess(List<GWTUINotification> result) {
            Main.get().mainPanel.bottomPanel.userInfo.reset();
            boolean schedule = true;

            if (!result.isEmpty()) {
                for (GWTUINotification uin : result) {
                    Main.get().mainPanel.bottomPanel.userInfo.addUINotification(uin);

                    if (uin.getAction() == GWTUINotification.ACTION_LOGOUT) {
                        schedule = false;
                    }
                }
                Main.get().mainPanel.bottomPanel.userInfo.setLastUIId(result.get(result.size() - 1).getId());
            }

            if (schedule) {
                Timer timer = new Timer() {
                    @Override
                    public void run() {
                        getUINotificationMessages(scheduleTime);
                    }
                };

                timer.schedule(scheduleTime);
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            Main.get().showError("getUpdateMessage", caught);
        }
    });

}

From source file:com.ikon.frontend.client.widget.chat.ChatRoomPopup.java

License:Open Source License

/**
 * refreshUsersInRoom()//from w  ww. j a  va2  s  .c  om
 */
private void refreshUsersInRoom(final String room) {
    if (chatRoomActive) {
        chatService.usersInRoom(room, new AsyncCallback<String>() {

            @Override
            public void onSuccess(String result) {
                usersInRoomText.setHTML("(" + result + ") " + Main.i18n("chat.users.in.room"));
                Timer timer = new Timer() {
                    @Override
                    public void run() {
                        refreshUsersInRoom(room);
                    }
                };

                timer.schedule(DELAY_USERS_IN_ROOM);
            }

            @Override
            public void onFailure(Throwable caught) {
                Main.get().showError("UsersInRoom", caught);
            }
        });
    }
}

From source file:com.ikon.frontend.client.widget.chat.ChatRoomPopup.java

License:Open Source License

/**
 * getPendingMessage/*from  ww w  .  ja v  a2  s . c om*/
 */
public void getPendingMessage(final String room) {
    if (chatRoomActive) {
        chatService.getPendingMessage(room, new AsyncCallback<List<String>>() {

            @Override
            public void onSuccess(List<String> result) {
                for (Iterator<String> it = result.iterator(); it.hasNext();) {
                    addMessage(it.next());
                }

                Timer timer = new Timer() {
                    @Override
                    public void run() {
                        getPendingMessage(room);
                    }
                };

                timer.schedule(DELAY_PENDING_MESSAGE);
            }

            @Override
            public void onFailure(Throwable caught) {
                Main.get().showError("getPendingMessage", caught);
            }
        });
    }
}