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.edgenius.wiki.gwt.client.widgets.MessageWidget.java

License:Open Source License

private String show(final HorizontalPanel message, int timeout, int type, boolean append, boolean allowClose) {
    //if this message does not append to others, then clear whole panel
    if (!append) {
        cleanMessage();/* w  w  w . j a va 2 s  .  co m*/
    }

    final MessagePanel msgPanel = new MessagePanel(message, type, allowClose);
    msgContainer.add(msgPanel);
    msgContainer.setVisible(true);

    if (timeout > 0) {
        Timer timer = new Timer() {
            public void run() {
                removeMessage(msgPanel.getUuid());
            }
        };
        timer.schedule(timeout);
    }

    return msgPanel.getUuid();
}

From source file:com.edgenius.wiki.gwt.client.widgets.Popup.java

License:Open Source License

private void movein() {
    if (showTimer != null) {
        showTimer.cancel();//  w  ww .j  ava 2  s. co m
        showTimer = null;
    }

    if (hideTimer != null) {
        hideTimer.cancel();
        hideTimer = null;
    }
    if (this.isShowing())
        return;

    if (autoPopDeplyTime > 0) {
        showTimer = new Timer() {
            @Override
            public void run() {
                if (mouseHover)
                    pop();
            }
        };
        showTimer.schedule(autoPopDeplyTime);
    } else {
        pop();
    }
}

From source file:com.edgenius.wiki.gwt.client.widgets.Popup.java

License:Open Source License

private void moveout() {
    if (showTimer != null) {
        showTimer.cancel();/*from   w  w w.  j a va 2 s. c om*/
        showTimer = null;
    }

    if (hideTimer != null) {
        hideTimer.cancel();
        hideTimer = null;
    }
    if (!this.isShowing())
        return;
    if (autoHideDeplyTime > 0) {
        hideTimer = new Timer() {
            @Override
            public void run() {
                if (!mouseHover)
                    hide();
            }
        };
        hideTimer.schedule(autoHideDeplyTime);
    } else {
        hide();
    }
}

From source file:com.education.lessons.ui.client.login.utils.UIHelper.java

License:Open Source License

public static void reopenDialog(final Widget widget, final String text) {
    closeDialog();/*from www.  j  a v a 2s  .co  m*/

    Timer timer = new Timer() {

        @Override
        public void run() {
            openDialog(widget, text);
        }
    };

    timer.schedule(500);
}

From source file:com.eduworks.gwt.client.pagebuilder.screen.ScreenTemplate.java

License:Apache License

public static void setAlertBoxMessage(String message, AlertType type, final String containerName) {

    Element messageContainer = DOM.getElementById(containerName);

    if (messageContainer != null) {

        messageContainer.getFirstChildElement().setInnerText(message);

        clearAlertState();/*from  ww w . j a v a  2 s  .  co  m*/

        if (type == AlertType.WARNING) {
            messageContainer.addClassName("warning");
            messageContainer.getStyle().setColor("white");
        } else if (type == AlertType.ERROR) {
            messageContainer.addClassName("alert");
            messageContainer.getStyle().setColor("white");
        } else if (type == AlertType.INFO) {
            messageContainer.addClassName("info");
            messageContainer.getStyle().setColor("black");
        } else if (type == AlertType.SUCCESS) {
            messageContainer.addClassName("success");
            messageContainer.getStyle().setColor("white");
        } else if (type == AlertType.SECONDARY) {
            messageContainer.addClassName("secondary");
            messageContainer.getStyle().setColor("black");
        }

        messageContainer.addClassName("active");
        messageContainer.removeClassName("hidden");

        Timer timeoutTimer = new Timer() {
            public void run() {
                hideAlertBox(containerName);
            }
        };
        timeoutTimer.schedule(TIMER_STATUS_WINDOW_DELAY);
    }
}

From source file:com.eduworks.russel.ds.client.handler.ESBSearchHandler.java

License:Apache License

/**
 * hook Launches appropriate Alfresco query and assigns handlers for the response
 * @param seachbarID String Name of the search bar that informs the Alfresco query
 * @param objectPanel String Name of the target panel for Alfresco results
 * @param type String Name of the type of Alfresco search
 *///  w  ww .j  a v  a 2s.  c  o  m
public void hook(final String seachbarID, final String objectPanel, final String type) {
    searchType = type;
    customQuery = null;
    pendingEdits = new Vector<FileRecord>();
    t = new Timer() {
        @Override
        public void run() {
            String rawSearchText = ((TextBox) PageAssembler.elementToWidget(seachbarID, PageAssembler.TEXT))
                    .getText().trim();
            final ESBPacket ap = new ESBPacket();
            final String searchText = cleanQuery(rawSearchText);
            if (customQuery != null && !searchType.equals(ASSET_TYPE))
                ap.put("sq", customQuery + " ");
            else if (searchType.equals(ASSET_TYPE))
                ap.put("sq", EPSSEditScreen.buildQueryString() + " ");
            else if (searchText == "")
                ap.put("sq", "");
            else
                ap.put("sq", searchText + " ");
            ap.put("rows", "100");
            ap.put("sort", "");
            ap.put("pages", "0");

            if (searchType.equals(PROJECT_TYPE)) {
                ap.put("sort", "cm:modified|false");
                if (searchText == "")
                    ap.put("sq", "cm:name:rpf ");
                else
                    ap.put("sq", searchText + " cm:name:rpf ");
            }

            if (searchType.equals(SEARCH_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "" + util.buildSearchQueryString());
                else
                    ap.put("sq", searchText + " " + util.buildSearchQueryString());
                ap.put("sort", util.buildSearchSortString());
            }

            if (searchType.equals(COLLECTION_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "creator:" + ESBApi.username + " " + util.buildSearchQueryString());
                else
                    ap.put("sq",
                            searchText + " creator:" + ESBApi.username + " " + util.buildSearchQueryString());
                ap.put("sort", util.buildSearchSortString());
            }

            if (searchType.equals(FLR_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "cm:name:rlr " + util.buildSearchQueryString());
                else
                    ap.put("sq", searchText + " cm:name:rlr " + util.buildSearchQueryString());
                ap.put("sort", util.buildSearchSortString());
            }

            if (searchType.equals(STRATEGY_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "" + util.buildSearchQueryString());
                else
                    ap.put("sq", searchText + " " + util.buildSearchQueryString());
                ap.put("sort", util.buildSearchSortString());
            }

            if (searchText == "" && searchType.equals(RECENT_TYPE)) {
                Date currentDate = new Date();
                Date pastDate = new Date();
                pastDate.setDate(pastDate.getDate() - 10);
                String currentMonthPadded = ((currentDate.getMonth() + 1) < 10)
                        ? "0" + (currentDate.getMonth() + 1)
                        : "" + (currentDate.getMonth() + 1);
                String currentDayPadded = ((currentDate.getDate()) < 10) ? "0" + (currentDate.getDate())
                        : "" + (currentDate.getDate());
                String pastMonthPadded = ((pastDate.getMonth() + 1) < 10) ? "0" + (pastDate.getMonth() + 1)
                        : "" + (pastDate.getMonth() + 1);
                String pastDayPadded = ((pastDate.getDate()) < 10) ? "0" + (pastDate.getDate())
                        : "" + (pastDate.getDate());
                ap.put("sq",
                        "modified:[\"" + pastDate.getYear() + "-" + pastMonthPadded + "-" + pastDayPadded
                                + "\" to \"" + currentDate.getYear() + "-" + currentMonthPadded + "-"
                                + currentDayPadded + "\"] ");
                ap.put("sort", "cm:modified|false");
            }

            ESBApi.search(ap, new ESBCallback<ESBPacket>() {
                public void onFailure(Throwable caught) {
                    if (retries > 1) {
                        retries = 0;
                        tileHandlers.clear();
                        RootPanel rp = RootPanel.get(objectPanel);
                        rp.clear();
                        int childCount = rp.getElement().getChildCount();
                        int grabIndex = 0;
                        for (int childIndex = 0; childIndex < childCount
                                - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) {
                            Element removeCursor = null;
                            while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null)
                                    && removeCursor.getId().equals("r-newEntity"))
                                grabIndex++;
                            if (removeCursor != null)
                                rp.getElement().removeChild(removeCursor);
                        }
                        //StatusWindowHandler.createMessage(StatusWindowHandler.getSearchMessageError(searchText), StatusRecord.ALERT_ERROR);
                    } else {
                        //   t.schedule(500);
                        retries++;
                    }

                    pendingSearch = false;
                    customQuery = null;
                }

                public void onSuccess(final ESBPacket SearchTermPacket) {
                    tileHandlers.clear();
                    RootPanel rp = RootPanel.get(objectPanel);
                    rp.clear();
                    int childCount = rp.getElement().getChildCount();
                    int grabIndex = 0;
                    for (int childIndex = 0; childIndex < childCount
                            - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) {
                        Element removeCursor = null;
                        while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null)
                                && removeCursor.getId().equals("r-newEntity"))
                            grabIndex++;
                        if (removeCursor != null)
                            rp.getElement().removeChild(removeCursor);
                    }
                    //TODO Thumbnails
                    buildThumbnails(objectPanel, SearchTermPacket);
                    setWorkflowStates();
                    pendingSearch = false;
                    customQuery = null;
                }
            });
        }
    };

    PageAssembler.attachHandler(seachbarID, Event.ONKEYUP, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (event.getKeyCode() == KeyCodes.KEY_ENTER && type != ASSET_TYPE && type != PROJECT_TYPE
                    && type != STRATEGY_TYPE && type != SEARCH_TYPE) {
                if (searchType == RECENT_TYPE)
                    searchType = SEARCH_TYPE;
                view.loadResultsScreen(searchType);
            } else if (type != EDIT_TYPE) {
                if (!pendingSearch) {
                    pendingSearch = true;
                    t.schedule(600);
                } else {
                    t.cancel();
                    t.schedule(600);
                }
            }
        }
    });

    PageAssembler.attachHandler("r-objectEditSelected", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            //TODO FIX THIS
            //view.loadEditScreen(pendingEdits);
        }
    });

    if (type != EDIT_TYPE && type != ASSET_TYPE)
        t.schedule(250);
}

From source file:com.eduworks.russel.ui.client.handler.ESBSearchHandler.java

License:Apache License

/**
 * hook Launches appropriate Alfresco query and assigns handlers for the response
 * @param seachbarID String Name of the search bar that informs the Alfresco query
 * @param objectPanel String Name of the target panel for Alfresco results
 * @param type String Name of the type of Alfresco search
 *//*from  ww w .  j  a v a 2s.  c om*/
public void hook(final String seachbarID, final String objectPanel, final String type) {
    searchType = type;
    customQuery = null;
    pendingEdits = new Vector<RUSSELFileRecord>();
    t = new Timer() {
        @Override
        public void run() {
            String rawSearchText = ((TextBox) PageAssembler.elementToWidget(seachbarID, PageAssembler.TEXT))
                    .getText().trim();
            final ESBPacket ap = new ESBPacket();
            final String searchText = cleanQuery(rawSearchText);
            ESBPacket sortPack = new ESBPacket();
            sortPack.put("field", "updatedDate_l");
            sortPack.put("order", "desc");
            ap.put("sort", sortPack);

            if (customQuery != null && !searchType.equals(ASSET_TYPE))
                ap.put("sq", customQuery);
            else if (searchType.equals(ASSET_TYPE))
                ap.put("sq", EPSSEditScreen.buildQueryString());
            else if (searchText == "")
                ap.put("sq", "");
            else
                ap.put("sq", searchText);
            ap.put("rows", 100);

            if (searchType.equals(PROJECT_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "mimeType_t:russel/project");
                else
                    ap.put("sq", searchText + " AND mimeType_t:russel/project");
            }

            if (searchType.equals(SEARCH_TYPE) || searchType.equals(EDIT_TYPE)) {
                if (searchText == "")
                    ap.put("sq", util.buildSearchQueryString());
                else
                    ap.put("sq", searchText + util.buildSearchQueryString());
                //TODO fix sorting
                //ap.put("sort", util.buildSearchSortString());
            }

            if (searchType.equals(COLLECTION_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "uploadedBy_t:" + RusselApi.username + " " + util.buildSearchQueryString());
                else
                    ap.put("sq",
                            searchText + " uploadedBy_t:" + RusselApi.username + util.buildSearchQueryString());
                //ap.put("sort", util.buildSearchSortString());
            }

            if (searchType.equals(RusselApi.FLR_TYPE)) {
                if (searchText == "")
                    ap.put("sq", "*");
                else
                    ap.put("sq", searchText);
                //ap.put("sort", util.buildSearchSortString());
            }

            if (searchType.equals(STRATEGY_TYPE)) {
                if (searchText == "")
                    ap.put("sq", util.buildSearchQueryString());
                else
                    ap.put("sq", searchText + util.buildSearchQueryString());
                //ap.put("sort", util.buildSearchSortString());
            }

            if (searchText == "" && searchType.equals(RECENT_TYPE)) {
                Date currentDate = new Date();
                Date pastDate = new Date();
                pastDate.setDate(pastDate.getDate() - 10);
                ap.put("sq", "updatedDate_l:[" + pastDate.getTime() + " TO " + currentDate.getTime() + "]");
            }

            if (lastQuery != ap.getString("sq"))
                pagingTokens.clear();
            lastQuery = ap.getString("sq");

            if (pagingTokens.size() != 0 && flipSearchPage) {
                flipSearchPage = false;
                if (!searchType.equals(RusselApi.FLR_TYPE))
                    ap.put("cursor", pagingTokens.get(0));
                else
                    ap.put("cursor", pagingTokens.size());
            }

            ap.put("fields", new RUSSELFileRecord().getFieldList());

            RusselApi.search(ap, searchType, new ESBCallback<ESBPacket>() {
                public void onFailure(Throwable caught) {
                    if (retries > 2) {
                        retries = 0;
                        tileHandlers.clear();
                        RootPanel rp = RootPanel.get(objectPanel);
                        if (rp != null) {
                            rp.clear();
                            int childCount = rp.getElement().getChildCount();
                            int grabIndex = 0;
                            for (int childIndex = 0; childIndex < childCount
                                    - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) {
                                Element removeCursor = null;
                                while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null)
                                        && removeCursor.getId().equals("r-newEntity"))
                                    grabIndex++;
                                if (removeCursor != null)
                                    rp.getElement().removeChild(removeCursor);
                            }
                        }
                        StatusWindowHandler.createMessage(StatusWindowHandler.getSearchMessageError(searchText),
                                StatusRecord.ALERT_ERROR);
                    } else {
                        t.schedule(500);
                        retries++;
                    }

                    pendingSearch = false;
                    customQuery = null;
                }

                public void onSuccess(final ESBPacket searchTermPacket) {
                    tileHandlers.clear();
                    RootPanel rp = RootPanel.get(objectPanel);
                    if (searchType.equals("solr"))
                        pagingTokens.add(0, searchTermPacket.getObject("obj").getString("cursor"));
                    else
                        pagingTokens.add(0, "p");
                    if (rp != null) {
                        rp.clear();
                        int childCount = rp.getElement().getChildCount();
                        int grabIndex = 0;
                        for (int childIndex = 0; childIndex < childCount
                                - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) {
                            Element removeCursor = null;
                            while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null)
                                    && removeCursor.getId().equals("r-newEntity"))
                                grabIndex++;
                            if (removeCursor != null)
                                rp.getElement().removeChild(removeCursor);
                        }
                        buildThumbnails(objectPanel, searchTermPacket);
                        setWorkflowStates();
                    }
                    pendingSearch = false;
                    customQuery = null;
                }
            });
        }
    };

    PageAssembler.attachHandler(seachbarID, Event.ONKEYUP, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (event.getKeyCode() == KeyCodes.KEY_ENTER && type != ASSET_TYPE && type != PROJECT_TYPE
                    && type != STRATEGY_TYPE && type != SEARCH_TYPE) {
                if (searchType == RECENT_TYPE || searchType == EDIT_TYPE)
                    searchType = SEARCH_TYPE;
                Constants.dispatcher.loadResultsScreen(searchType);
            } else if (type != EDIT_TYPE) {
                if (!pendingSearch) {
                    pendingSearch = true;
                    t.schedule(600);
                } else {
                    t.cancel();
                    t.schedule(600);
                }
            }
        }
    });

    PageAssembler.attachHandler("r-objectEditSelected", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            Constants.dispatcher.loadEditScreen(pendingEdits);
        }
    });

    if (type != EDIT_TYPE && type != ASSET_TYPE)
        t.schedule(250);
}

From source file:com.eduworks.russel.ui.client.pagebuilder.screen.EditScreen.java

License:Apache License

/**
 * display Renders the EditScreen using appropriate templates and sets up handlers
 *//*from   w  w w .ja v a2s  .  c  om*/
public void display() {
    editIDs = new Vector<String>();
    thumbIDs = new HashMap<String, RUSSELFileRecord>();

    if (Browser.isBadIE()) {
        PageAssembler.ready(new HTML(Russel.htmlTemplates.getEditPanel().getText()));
        PageAssembler.buildContents();
    } else {
        final DropPanel dp = new DropPanel();
        dp.add(new HTML(Russel.htmlTemplates.getEditPanel().getText()));
        PageAssembler.ready(dp);
        PageAssembler.buildContents();
        hookDragDrop0(dp);
    }
    SearchHandler ash = new SearchHandler(this, false);

    PageAssembler.inject("flowContainer", "x", new HTML(Russel.htmlTemplates.getDetailModal().getText()), true);
    PageAssembler.inject("objDetailPanelWidget", "x", new HTML(Russel.htmlTemplates.getDetailPanel().getText()),
            true);

    ash.hookAndClear("r-menuSearchBar", "", SearchHandler.TYPE_EDIT);

    PageAssembler.attachHandler("r-editDelete", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (editIDs.size() == 1) {
                if (Window.confirm("Are you sure you wish to delete the selected item?"))
                    deleteObjects0();
            } else if (editIDs.size() >= 2) {
                if (Window.confirm("Are you sure you wish to delete " + editIDs.size() + " items?"))
                    deleteObjects0();
            }
        }
    });

    PageAssembler.attachHandler("r-editSelectAll", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            selectAllObjects0();
        }
    });

    PageAssembler.attachHandler("r-editSelectNone", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            selectionClear0();
        }
    });

    PageAssembler.attachHandler("r-editAddFile", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                    new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), true);
            final String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
            buildEmptyUploadTile0(idPrefix);
            PageAssembler.closePopup("addFileModal");

        }
    });

    PageAssembler.attachHandler("r-editAddFile-reset", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doFileReset0();
        }
    });
    PageAssembler.attachHandler("r-editAddFile-cancel", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doFileReset0();
            PageAssembler.closePopup("addFileModal");
        }
    });

    PageAssembler.attachHandler("r-editAddLink-reset", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doLinkReset0();
        }
    });
    PageAssembler.attachHandler("r-editAddLink-cancel", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            doLinkReset0();
            PageAssembler.closePopup("addLinkModal");
        }
    });

    PageAssembler.attachHandler("r-permissionModal", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            if (editIDs.size() > 0)
                Russel.screen.loadScreen(new PermissionScreen(PermissionScreen.TYPE_RESOURCE,
                        thumbIDs.get(editIDs.get(0)).getGuid()), false);
        }
    });

    PageAssembler.attachHandler("r-editAddLink", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            final StatusRecord status = StatusHandler.createMessage(StatusHandler.getFileMessageBusy(""),
                    StatusRecord.ALERT_BUSY);
            if (((TextBox) PageAssembler.elementToWidget("editTitleLinkField", PageAssembler.TEXT))
                    .getText() != "") {
                String rawFilename = ((TextBox) PageAssembler.elementToWidget("editTitleLinkField",
                        PageAssembler.TEXT)).getText();
                String filenameRaw = "";
                for (int filenameIndex = 0; filenameIndex < rawFilename.length(); filenameIndex++)
                    if ((rawFilename.codePointAt(filenameIndex) >= 48
                            && rawFilename.codePointAt(filenameIndex) <= 57)
                            || (rawFilename.codePointAt(filenameIndex) >= 65
                                    && rawFilename.codePointAt(filenameIndex) <= 90)
                            || (rawFilename.codePointAt(filenameIndex) >= 97
                                    && rawFilename.codePointAt(filenameIndex) <= 122))
                        filenameRaw += rawFilename.charAt(filenameIndex);
                final String filename = filenameRaw;
                String urlBody = ((TextBox) PageAssembler.elementToWidget("editLinkField", PageAssembler.TEXT))
                        .getText();
                if (urlBody.indexOf("://") == -1)
                    urlBody = "http://" + urlBody;
                status.setMessage(StatusHandler.getFileMessageBusy(filename + ".rlk"));
                StatusHandler.alterMessage(status);
                RusselApi.uploadResource(urlBody, filename + ".rlk", new ESBCallback<ESBPacket>() {
                    @Override
                    public void onSuccess(final ESBPacket esbPacket) {
                        RUSSELFileRecord fr = new RUSSELFileRecord();
                        fr.setGuid(esbPacket.getPayloadString());
                        fr.setFilename(filename + ".rlk");
                        Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                                new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), true);
                        final String idPrefix = iDs.firstElement().substring(0,
                                iDs.firstElement().indexOf("-"));
                        fillTemplateDetails0(fr, idPrefix);
                        PageAssembler.closePopup("addLinkModal");
                        status.setMessage(StatusHandler.getFileMessageDone(filename + ".rlk"));
                        status.setState(StatusRecord.ALERT_SUCCESS);
                        StatusHandler.alterMessage(status);
                    }

                    public void onFailure(Throwable caught) {
                        status.setMessage(StatusHandler.DUPLICATE_NAME);
                        status.setState(StatusRecord.ALERT_WARNING);
                        StatusHandler.alterMessage(status);
                    }
                });
            } else {
                status.setMessage(StatusHandler.INVALID_NAME);
                status.setState(StatusRecord.ALERT_WARNING);
                StatusHandler.alterMessage(status);
            }
        }
    });

    PageAssembler.attachHandler("r-editSave", Event.ONCLICK, new EventCallback() {
        @Override
        public void onEvent(Event event) {
            new Timer() {
                @Override
                public void run() {
                    if (editIDs.size() > 0) {
                        final String idNumPrefix = editIDs.firstElement().substring(0,
                                editIDs.firstElement().indexOf("-"));
                        final String filename = DOM.getElementById(idNumPrefix + "-objectTitle").getInnerText();
                        final StatusRecord status = StatusHandler.createMessage(
                                StatusHandler.getUpdateMetadataMessageBusy(filename), StatusRecord.ALERT_BUSY);

                        meta.saveMetadata(thumbIDs.get(editIDs.firstElement()), new ESBCallback<ESBPacket>() {
                            @Override
                            public void onSuccess(ESBPacket esbPacket) {
                                status.setMessage(StatusHandler.getUpdateMetadataMessageDone(filename));
                                status.setState(StatusRecord.ALERT_SUCCESS);
                                StatusHandler.alterMessage(status);
                                refreshInformation0();
                            }

                            public void onFailure(Throwable caught) {
                                status.setMessage(StatusHandler.getUpdateMetadataMessageError(filename));
                                status.setState(StatusRecord.ALERT_ERROR);
                                StatusHandler.alterMessage(status);
                            }
                        });
                    }
                }
            }.schedule(100);
        }
    });

    while (passedInEdits.size() > 0) {
        Vector<String> iDs = PageAssembler.inject("r-previewArea", "x",
                new HTML(Russel.htmlTemplates.getEditPanelWidget().getText()), false);
        final String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-"));
        fillTemplateDetails0(passedInEdits.remove(0), idPrefix);
    }
    refreshInformation0();
}

From source file:com.elasticgrid.admin.client.mvc.cluster.ClustersController.java

License:Open Source License

private void adjustWatchUpdateSpeed(int newSpeed) {
    watchUpdateSpeed = newSpeed;/*w ww  .  j a  v  a 2s. com*/
    watchUpdateCommand.execute();

    if (watchUpdater != null)
        watchUpdater.cancel();
    if (watchUpdateSpeed == 0) {
        return;
    }
    watchUpdater = new Timer() {
        @Override
        public void run() {
            watchUpdateCommand.execute();
        }
    };
    watchUpdater.scheduleRepeating(watchUpdateSpeed);
}

From source file:com.elasticgrid.admin.client.widget.cluster.AddNodeDialog.java

License:Open Source License

protected void onSubmit() {
    status.show();//from  w w  w . j  av  a 2s. co m
    getButtonBar().disable();
    Timer t = new Timer() {
        @Override
        public void run() {
            AddNodeDialog.this.hide();
        }
    };
    t.schedule(2000);
}