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

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

Introduction

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

Prototype

public synchronized void schedule(int delayMs) 

Source Link

Document

Schedules a timer to elapse in the future.

Usage

From source file:de.swm.commons.mobile.client.widgets.tab.TabPanel.java

License:Apache License

@Override
public void onClick(ClickEvent event) {
    if (this.showSpinnerBetweenTransitions) {
        if (!isSpinnerStarted) {
            final int index = getClickedTabHeaderIndex(event);
            this.startPopup(new ISpinnerStarted() {
                @Override/*from   www  . j  a  v a2s. c o  m*/
                public void spinnerStarted() {
                    isSpinnerStarted = true;
                    if (index != -1) {
                        selectTab(index);
                    }

                    Timer timer = new Timer() {
                        @Override
                        public void run() {
                            stopSpinnerIfRunning();
                        }
                    };
                    timer.schedule(SPINNER_DELAY_MILLIS);

                }
            });
        }
    } else {
        int index = getClickedTabHeaderIndex(event);
        if (index != -1) {
            selectTab(index);
        }
    }
}

From source file:de.swm.commons.mobile.client.widgets.tab.TabPanel.java

License:Apache License

/**
 * Starts a propgress bar./*from w w w.j  a  va 2s  . co  m*/
 *
 * @param spinnerStarted spinner is started
 * @return the loading indicator.
 */
private LoadingIndicatorPopup startPopup(final ISpinnerStarted spinnerStarted) {
    this.spinner.showCentered(true);
    final Timer timer = new Timer() {

        @Override
        public void run() {
            isSpinnerStarted = true;
            spinnerStarted.spinnerStarted();
        }
    };
    timer.schedule(50);
    return this.spinner;
}

From source file:edu.caltech.ipac.fftools.core.FFToolsImageCmd.java

private void prepare3ColorRequest(final String id, final WebPlotRequest red, final WebPlotRequest green,
        final WebPlotRequest blue) {

    Timer t = new Timer() { // layout is slow sometime so delay a little (this is a hack)
        @Override//  www .  j  av a 2 s  .  c o m
        public void run() {
            deferredPlot3Color(id, red, green, blue);
        }
    };
    t.schedule(100);
}

From source file:edu.caltech.ipac.firefly.commands.FitsInputCmd.java

private void analyze(final PlotWidgetOps ops, final ServerRequest req) {
    if (_listener == null) {
        _listener = new DialogListener();
        if (!added) {
            _hub.getCatalogDisplay().addPlotView(_mpw.getPlotView());
            added = true;//w ww.j  ava  2 s  .c o  m
        }
        AllPlots.getInstance().addListener(Name.SELECT_DIALOG_CANCEL, _listener);
    }
    AllPlots ap = AllPlots.getInstance();
    ap.showMenuBarPopup();

    boolean empty = !ops.isPlotShowing();

    if (empty) {
        if (req != null && req.containsParam(CommonParams.DO_PLOT) && req instanceof WebPlotRequest) {
            Timer t = new Timer() { // layout is slow sometime so delay a little (this is a hack)
                @Override
                public void run() {
                    deferredPlot(ops, req);
                }
            };
            t.schedule(100);
        } else {
            ops.showImageSelectDialog();
        }
    } else {
    }
}

From source file:edu.caltech.ipac.firefly.ui.background.BackgroundManager.java

private void animationIconCSS(int mills, int startX, int startY) {
    Image icon = new Image(ONE_GEAR_ICON_LARGE);
    final PopupPanel popup = new PopupPanel();
    popup.setStyleName("");
    popup.addStyleName("animationLevel");
    popup.setAnimationEnabled(false);/*  w w  w  .  j av  a2  s  . co m*/
    popup.setWidget(icon);
    Widget w = button.getIcon() != null ? button.getIcon() : button;
    int endX = w.getAbsoluteLeft();
    int endY = w.getAbsoluteTop();
    setupCssAnimation(startX, startY, endX, endY);
    int extra = 35;
    CssAnimation.setAnimationStyle(popup, "iconAnimate " + (mills + extra) + "ms ease-in-out 1 normal");
    popup.setPopupPosition(endX, endY);
    popup.show();
    Timer t = new Timer() {
        @Override
        public void run() {
            popup.hide();
        }
    };
    t.schedule(mills);
}

From source file:edu.caltech.ipac.firefly.ui.BaseDialog.java

public void show(int autoCloseSecs, PopupPane.Align alignAt) {
    setVisible(true, alignAt);//from   w  w  w  .  j  a va 2 s .  c o m
    if (autoCloseSecs > 0) {
        Timer t = new Timer() {
            public void run() {
                BaseDialog.this.setVisible(false);
            }
        };
        t.schedule(autoCloseSecs * 1000);
    }
}

From source file:edu.caltech.ipac.firefly.ui.catalog.CatalogSearchDropDown.java

private Widget createLoadCatalogFromVOContent() {
    voSearchUI = new LoadCatalogFromVOSearchUI();
    ButtonBase ok = GwtUtil.makeFormButton("Search", new ClickHandler() {
        public void onClick(ClickEvent ev) {
            if (!voSearchUI.validate()) {
                return;
            }/* www .  j  a va2  s  . c  o m*/
            voSearchUI.makeServerRequest(new AsyncCallback<ServerRequest>() {

                @Override
                public void onFailure(Throwable caught) {
                    if (caught != null)
                        PopupUtil.showSevereError(caught);
                }

                @Override
                public void onSuccess(ServerRequest request) {
                    final TableServerRequest treq = (TableServerRequest) request;

                    final DefaultWorkingWidget working = new DefaultWorkingWidget((ClickHandler) null);
                    working.setText("Retrieving VO Catalog...");
                    final MaskPane maskPane = new MaskPane(_mainPanel, working);
                    maskPane.show();

                    SearchServicesAsync serv = SearchServices.App.getInstance();
                    serv.submitBackgroundSearch(treq, null, 3000, new AsyncCallback<BackgroundStatus>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            if (caught != null)
                                PopupUtil.showSevereError(caught);
                            maskPane.hide();
                        }

                        @Override
                        public void onSuccess(BackgroundStatus bgStat) {
                            WebEventManager.getAppEvManager()
                                    .fireEvent(new WebEvent(this, Name.CATALOG_SEARCH_IN_PROCESS));
                            MonitorItem monItem = new MonitorItem(treq, voSearchUI.getSearchTitle(),
                                    BackgroundUIHint.CATALOG, false);
                            monItem.setStatus(bgStat);
                            monItem.setActivateOnCompletion(true);
                            if (bgStat.isSuccess()) {
                                ActivationFactory.getInstance().activate(monItem);
                                maskPane.hide();
                                hide();
                            } else {
                                handleBackgrounding(monItem);
                            }
                        }

                        private void handleBackgrounding(final MonitorItem monItem) {
                            working.setText("Backgrounding...");
                            Timer t = new Timer() {
                                @Override
                                public void run() {
                                    BackgroundMonitor monitor = Application.getInstance()
                                            .getBackgroundMonitor();
                                    Application.getInstance().getBackgroundManager().animateToManager(0, 0,
                                            1300);
                                    monItem.setWatchable(true);
                                    monitor.addItem(monItem);
                                    maskPane.hide();
                                    hide();
                                }
                            };
                            t.schedule(1000);
                        }
                    });
                }
            });
        }
    });
    ButtonBase cancel = GwtUtil.makeFormButton("Cancel", new ClickHandler() {
        public void onClick(ClickEvent ev) {
            _tabs.selectTab(0);
        }
    });
    Form.ButtonBar buttonBar = new Form.ButtonBar();
    buttonBar.setVisible(false);
    buttonBar.addStyleName("button-bar");
    buttonBar.addRight(ok);
    buttonBar.addRight(cancel);
    buttonBar.getHelpIcon().setHelpId("basics.loadcatalog");

    VerticalPanel vp = new VerticalPanel();
    vp.add(voSearchUI.createLoadCatalogsContent());
    vp.add(buttonBar);
    DOM.setStyleAttribute(vp.getElement(), "padding", "5px");
    SimplePanel sp = new SimplePanel();
    sp.add(vp);

    return sp;
}

From source file:edu.caltech.ipac.firefly.ui.catalog.IrsaCatalogTask.java

private void handleBackgrounding(final MonitorItem monItem) {
    DefaultWorkingWidget working = new DefaultWorkingWidget((ClickHandler) null);
    working.setText("Backgrounding...");
    final MaskPane maskPane = new MaskPane(getMaskWidget(), working);
    maskPane.show();//from  w  w w .j av a  2 s.com
    Timer t = new Timer() {
        @Override
        public void run() {
            BackgroundMonitor monitor = Application.getInstance().getBackgroundMonitor();
            if (doAnimation) {
                Application.getInstance().getBackgroundManager().animateToManager(_animationX, _animationY,
                        1300);
            }
            monItem.setWatchable(true);
            monItem.setImmediately(showImmediately);
            monitor.addItem(monItem);
            _response.status(CatalogSearchResponse.RequestStatus.BACKGROUNDING);
            maskPane.hide();
        }
    };
    t.schedule(1000);
}

From source file:edu.caltech.ipac.firefly.ui.MaskPane.java

public void showWhenUncovered() {
    waitingToMask = true;/* w  w w.  j a  v a2 s  . c  o m*/
    final Application app = Application.getInstance();
    final ToolbarDropdown dropdown = (app.getToolBar() != null) ? app.getToolBar().getDropdown() : null;
    if (dropdown == null) {
        show();
    } else if (GwtUtil.isParentOf(maskElement, dropdown.getElement())) {
        show();
    } else {
        Timer t = new Timer() {
            @Override
            public void run() {
                if (waitingToMask) {
                    if (dropdown.isOpen())
                        hide();
                    else
                        show();
                    if (!isShowing())
                        schedule(500);
                }
            }
        };
        t.schedule(100);
    }
}

From source file:edu.caltech.ipac.firefly.ui.PopupPane.java

private void animationDropdownCSS(final boolean show) {
    setAnimationStyle("none");
    Timer t = new Timer() {
        @Override/* ww  w . j a v  a2s . c  o m*/
        public void run() {
            int mills = _animationDuration;
            if (!show)
                mills -= 1;
            setupCssAnimation(_anStyleName, show);
            setAnimationStyle(_anStyleName + " " + (mills + 35) + "ms linear 1 normal");
            if (show)
                popup.show();
            Timer t = new Timer() {
                @Override
                public void run() {
                    if (!show && !visible)
                        popup.hide();
                }
            };
            t.schedule(_animationDuration + 20);
        }
    };
    t.schedule(10);
}