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:next.tablet.client.black.NotificationPage.java

License:Apache License

public void doShow() {
    if (!isHidden) {
        return;/*www  . ja v a  2 s  .co  m*/
    }
    // this.getElement().getStyle().setOpacity(1);
    setPopupPosition(0, 601);

    // NMorphStyle eff = CUtil.opacityEffect(this.getElement(), null, 0, 100);
    // eff.play();
    NMorphStyle eff = CUtil.moveVerticalEffect(600, POSITION, this.getElement(), null);
    eff.play();

    notifIcon1.doShow();

    Timer t = new Timer() {
        public void run() {
            notifIcon2.doShow();

            Timer t = new Timer() {
                public void run() {
                    notifIcon3.doShow();
                }
            };
            t.schedule(10000);
        }
    };
    t.schedule(13000);

    isHidden = false;
}

From source file:next.tablet.client.TabletEntryPoint.java

License:Apache License

public void initModuleLoad() {
    final RootPanel rootPanel = RootPanel.get("root");
    rootPanel.setVisible(false);/*  w  w w  .j a  va 2  s. c o  m*/

    final UiGinjector ctx = UiGinjector.INSTANCE;

    // init and make it visible
    ctx.getUiSingleton().getWalletLeftMenu().show();
    ctx.getUiSingleton().getTopMenu().show();
    ctx.getUiSingleton().getTopMenu().getBackCommand().execute();
    ctx.getUiSingleton().getImagePage(); // init
    ctx.getEventBus().fireEvent(new ShowBackButtonEvent(Type.GAMES));

    rootPanel.setVisible(true);

    RootPanel loadingPanel = RootPanel.get("loading");
    loadingPanel.setVisible(false);

    // Used for debuggin only
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            int cH = Window.getClientHeight();
            int cW = Window.getClientWidth();

            int scH = Window.getScrollTop();
            int scL = Window.getScrollLeft();
            Logger.debug("clientHeight:" + cH + ", clientWidth:" + cW + "| scrollTop:" + scH + ", scrollLeft:"
                    + scL);
        }
    });

    // listenForEventUpdates();

    // ctx.getEventBus().fireEvent(new LsShowSportsEvent(true));
    // RootPanel.get("root").setVisible(false);

    Timer t2 = new Timer() {
        public void run() {
            ctx.getUiSingleton().getNotificationPage().doShow();
        }
    };
    t2.schedule(5000);

}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractColourReportPresenter.java

License:Open Source License

public void submitTestResults(final MetadataField emailAddressMetadataField,
        final TimedStimulusListener onError, final TimedStimulusListener onSuccess) {
    StringBuilder stringBuilder = new StringBuilder();
    final DateTimeFormat format = DateTimeFormat.getFormat(messages.reportDateFormat());
    final ScoreCalculator scoreCalculator = new ScoreCalculator(userResults);

    for (final StimulusResponseGroup stimuliGroup : userResults.getStimulusResponseGroups()) {
        final GroupScoreData calculatedScores = scoreCalculator.calculateScores(stimuliGroup);
        stringBuilder.append("\t");
        stringBuilder.append(stimuliGroup.getPostName());
        stringBuilder.append("\t");
        stringBuilder.append(format.format(new Date()));
        stringBuilder.append("\t");
        stringBuilder.append(calculatedScores.getScore());
        stringBuilder.append("\t");
        stringBuilder.append(calculatedScores.getMeanReactionTime());
        stringBuilder.append("\t");
        stringBuilder.append(calculatedScores.getReactionTimeDeviation());
        stringBuilder.append("\n");
    }/*from ww w. j  a va2  s  . c o  m*/

    final String scoreLog = stringBuilder.toString();
    //        submissionService.submitTagValue(userResults.getUserData().getUserId(), "ScoreLog", scoreLog.replaceAll("\t", ","), 0);
    new RegistrationService().submitRegistration(userResults, new RegistrationListener() {
        @Override
        public void registrationFailed(RegistrationException exception) {
            onError.postLoadTimerFired();
            ((ReportView) simpleView).addText("Could not connect to the server.");
            ((ReportView) simpleView).addOptionButton(new PresenterEventListner() {
                @Override
                public String getLabel() {
                    return "Retry";
                }

                @Override
                public void eventFired(ButtonBase button, SingleShotEventListner shotEventListner) {
                    Timer timer = new Timer() {
                        @Override
                        public void run() {
                            ((ReportView) simpleView).clearPageAndTimers(null);
                            submitTestResults(emailAddressMetadataField, onError, onSuccess);
                        }
                    };
                    timer.schedule(1000);
                }

                @Override
                public String getStyleName() {
                    return null;
                }

                @Override
                public int getHotKey() {
                    return -1;
                }
            });
        }

        @Override
        public void registrationComplete() {
            onSuccess.postLoadTimerFired();
        }
    }, messages.reportDateFormat(), emailAddressMetadataField, scoreLog);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractDataSubmissionPresenter.java

License:Open Source License

protected void pause(int postLoadMs, final TimedStimulusListener timedStimulusListener) {
    final Timer timer = new Timer() {
        @Override//w ww. j  a v a  2s .  co  m
        public void run() {
            timedStimulusListener.postLoadTimerFired();
        }
    };
    timer.schedule(postLoadMs);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractKinDiagramPresenter.java

License:Open Source License

public void kinTypeStringDiagram(final AppEventListner appEventListner, final int postLoadMs,
        final TimedStimulusListener timedStimulusListener, String kinTypeString) {
    final DiagramSettings diagramSettings = new DiagramSettingsGwt();
    final SvgDiagram svgDiagram = new SvgDiagram(diagramSettings, new EntitySvg());
    final SvgUpdateHandler svgUpdateHandler = new SvgUpdateHandler(svgDiagram);
    final KinDocumentGwt kinDocument = new KinDocumentGwt(svgUpdateHandler);
    final GraphSorter graphSorter = new DefaultSorter();

    //        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, UriUtils.fromString("http://ems12.mpi.nl:80/kinoath-rest/kinoath/getkin/svg?kts=" + kinTypeString).asString());
    try {//from w w w. j a va2s  . c  o m
        svgDiagram.generateDefaultSvg(kinDocument, graphSorter);
        if (kinTypeString != null) {
            KinTypeStringConverter kinTypeStringConverter = new KinTypeStringConverter(RHOMBUS,
                    KinType.getReferenceKinTypes());
            final String[] kinTypeStringArray = kinTypeString.split("\\|");
            //            kinTypeAllStrings.addAll(Arrays.asList(this.kinTypeString.split("\\|")));
            final DefaultSorter graphData = new DefaultSorter();
            final ArrayList<KinTypeStringProvider> arrayList = new ArrayList<>();
            arrayList.add(new KinTypeStringProvider() {

                @Override
                public String[] getCurrentStrings() {
                    return kinTypeStringArray;
                }

                @Override
                public int getTotalLength() {
                    return kinTypeStringArray.length;
                }

                @Override
                public void highlightKinTypeStrings(ParserHighlight[] parserHighlight,
                        String[] kinTypeStrings) {
                }
            });
            kinTypeStringConverter.readKinTypes(arrayList, graphData);
            svgDiagram.graphData.setEntitys(graphData.getDataNodes());
        } else {
            final EntityData entityData1 = new EntityData(
                    new UniqueIdentifier(UniqueIdentifier.IdentifierType.tid, kinDocument.getUUID()),
                    new String[] { "one" }, EntityData.SymbolType.square, true, null, null);
            final EntityData entityData2 = new EntityData(
                    new UniqueIdentifier(UniqueIdentifier.IdentifierType.lid, kinDocument.getUUID()),
                    new String[] { "two" }, EntityData.SymbolType.triangle, true, null, null);
            final EntityData entityData3 = new EntityData(
                    new UniqueIdentifier(UniqueIdentifier.IdentifierType.lid, kinDocument.getUUID()));
            final EntityData entityData4 = new EntityData(
                    new UniqueIdentifier(UniqueIdentifier.IdentifierType.lid, kinDocument.getUUID()),
                    new String[] { "one" }, EntityData.SymbolType.circle, true, new EntityDate("1212/12/12"),
                    new EntityDate("2121/21/12"));
            final EntityData entityData5 = new EntityData(
                    new UniqueIdentifier(UniqueIdentifier.IdentifierType.tid, kinDocument.getUUID()),
                    new String[] { "two" }, EntityData.SymbolType.triangle, true, null,
                    new EntityDate("1250/10/10"));
            final EntityData entityData6 = new EntityData(
                    new UniqueIdentifier(UniqueIdentifier.IdentifierType.lid, kinDocument.getUUID()),
                    new String[] { "three" }, EntityData.SymbolType.square, true, new EntityDate("1300/12/12"),
                    new EntityDate("1390/05/20"));
            entityData1.addRelatedNode(entityData6, DataTypes.RelationType.ancestor, "orange", null, null,
                    null);
            entityData2.addRelatedNode(entityData6, DataTypes.RelationType.ancestor, "black", null, null, null);
            entityData3.addRelatedNode(entityData2, DataTypes.RelationType.ancestor, "black", null, null, null);
            entityData5.addRelatedNode(entityData4, DataTypes.RelationType.ancestor, "black", null, null, null);
            entityData6.addRelatedNode(entityData4, DataTypes.RelationType.ancestor, "black", null, null, null);
            svgDiagram.graphData.setEntitys(new EntityData[] { entityData1, entityData2, entityData3,
                    entityData4, entityData5, entityData6 });
        }
        svgUpdateHandler.drawEntities(new KinRectangle(800, 600));
        ((TimedStimulusView) simpleView).addWidget(kinDocument.getHtmlDoc());
        Timer timer = new Timer() {
            public void run() {
                timedStimulusListener.postLoadTimerFired();
            }
        };
        timer.schedule(postLoadMs);
        //        ((TimedStimulusView) simpleView).addTimedImage(UriUtils.fromString("http://ems12.mpi.nl:80/kinoath-rest/kinoath/getkin/svg?kts=" + kinTypeString), 100, postLoadMs, timedStimulusListener);
        //        ((TimedStimulusView) simpleView).addSvgImage(UriUtils.fromString("http://ems12.mpi.nl:80/kinoath-rest/kinoath/getkin/svg?kts=" + kinTypeString), 100, postLoadMs, timedStimulusListener);        
    } catch (IOException | KinElementException | OldFormatException | UnsortablePointsException exception) {
        //            // todo: handle such errors in a more user friendly way
        ((TimedStimulusView) simpleView).addHtmlText(exception.getMessage(), null);
    }
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractMenuPresenter.java

License:Open Source License

public void activateRandomItem(final AppEventListner appEventListner) {
    final ApplicationController.ApplicationState target;
    if (nonCompletedScreens.isEmpty()) {
        target = nextState;//from  www .  ja va2 s  . co  m
    } else {
        target = nonCompletedScreens.get(new Random().nextInt(nonCompletedScreens.size()));
    }
    Timer timer = new Timer() {
        public void run() {
            appEventListner.requestApplicationState(target);
        }
    };
    timer.schedule(100);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractPresenter.java

License:Open Source License

protected void gotoNextPresenter(final AppEventListner appEventListner) {
    savePresenterState();//from  w w w. j  a va  2s .  co  m
    Timer timer = new Timer() {
        public void run() {
            appEventListner.requestApplicationState(nextState);
        }
    };
    timer.schedule(100);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractPresenter.java

License:Open Source License

protected void gotoPresenter(final AppEventListner appEventListner, final ApplicationState targetState) {
    savePresenterState();/*  w  w w.  j  a v a  2  s .  co  m*/
    Timer timer = new Timer() {
        public void run() {
            appEventListner.requestApplicationState(targetState);
        }
    };
    timer.schedule(100);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractPresenter.java

License:Open Source License

public void hasGetParameter(final AppEventListner appEventListner, final TimedStimulusListener conditionTrue,
        final TimedStimulusListener conditionFalse, final String getParamName) {
    Timer timer = new Timer() {
        public void run() {
            String paramValue = Window.Location.getParameter(getParamName);
            if (paramValue != null) {
                conditionTrue.postLoadTimerFired();
            } else {
                conditionFalse.postLoadTimerFired();
            }/*from ww  w . j  ava  2 s.co m*/
        }
    };
    timer.schedule(100);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractStimulusPresenter.java

License:Open Source License

protected void timerLabel(final String styleName, final int postLoadMs, final String listenerId,
        final String msLabelFormat) {
    final DateTimeFormat formatter = DateTimeFormat.getFormat(msLabelFormat);
    final HTML html = timedStimulusView.addHtmlText("", styleName);
    Timer labelTimer = new Timer() {
        @Override/*from w w  w .  j a v a  2s  .co m*/
        public void run() {
            final int timerValue = timerService.getTimerValue(listenerId);
            final long remainingMs;
            if (postLoadMs > 0) {
                if (postLoadMs > timerValue) {
                    remainingMs = (long) postLoadMs - timerValue;
                } else {
                    remainingMs = 0;
                }
            } else {
                remainingMs = (long) timerValue;
            }
            Date msBasedDate = new Date(remainingMs);
            String labelText = formatter.format(msBasedDate);
            html.setHTML(labelText);
            schedule(500);
        }
    };
    labelTimer.schedule(5);
}