com.google.gwt.user.client.Timer Java Examples

The following examples show how to use com.google.gwt.user.client.Timer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UniTimePageHeader.java    From unitime with Apache License 2.0 6 votes vote down vote up
private UniTimePageHeader() {
	iHeader = new PageHeader();

	getLeft().setCallback(new Callback() {
		@Override
		public void execute(Callback callback) {
			reloadSolverInfo(true, callback);
		}
	});

	reloadSessionInfo();
	reloadUserInfo();
	iTimer = new Timer() {
		@Override
		public void run() {
			reloadSolverInfo(getLeft().isPopupShowing(), null);
		}
	};
	iTimer.schedule(1000);
}
 
Example #2
Source File: TabDocumentWorkflow.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onChange(DocumentEventConstant event) {
	if (event.equals(HasDocumentEvent.DOCUMENT_CHANGED)) {
		Workflow.get().setTabDocumentSelected();
		workflowManager.findProcessInstancesByNode(Workflow.get().getUuid());
	} else if (event.equals(HasDocumentEvent.TAB_CHANGED)) {
		if (TabDocumentComunicator.isWidgetExtensionVisible(this)) {
			Timer timer = new Timer() {
				@Override
				public void run() {
					workflowManager.fillWidth();
				}
			};
			timer.schedule(100);
		}
	}
}
 
Example #3
Source File: GwtCookieModel.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public GwtCookieModel(boolean refresh) {
  listeners = new Listeners();
  cookies = new HashMap<String, String>();
  for (String name : Cookies.getCookieNames()) {
    cookies.put(name, Cookies.getCookie(name));
  }
  if (refresh) {
    refresher = new Timer() {
      @Override
      public void run() {
        refresh();
      }
    };
    refresher.scheduleRepeating(REFRESH_TIME);
  }
}
 
Example #4
Source File: GoogleDriveView.java    From gwt-material-patterns with Apache License 2.0 6 votes vote down vote up
@Inject
GoogleDriveView(Binder uiBinder) {
    initWidget(uiBinder.createAndBindUi(this));
    splash.show();
    Timer t = new Timer() {
        @Override
        public void run() {
            splash.hide();
        }
    };
    t.schedule(5000);
    search.addCloseHandler(event -> {
        appNav.setVisible(true);
        searchNav.setVisible(false);
    });
    search.addKeyUpHandler(event -> {
        List<DriveDTO> filteredFiles = DataHelper.getAllDrives().stream().filter(dto -> dto.getFileName().toLowerCase().contains(search.getText().toLowerCase())).collect(Collectors.toList());
        populateFiles(filteredFiles);
    });
    populateFiles(DataHelper.getAllDrives());
}
 
Example #5
Source File: TabFolderWorkflow.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onChange(FolderEventConstant event) {
	if (event.equals(HasFolderEvent.FOLDER_CHANGED)) {
		Workflow.get().setTabFolderSelected();
		workflowManager.findProcessInstancesByNode(Workflow.get().getUuid());
	} else if (event.equals(HasFolderEvent.TAB_CHANGED)) {
		if (TabFolderComunicator.isWidgetExtensionVisible(this)) {
			Timer timer = new Timer() {
				@Override
				public void run() {
					workflowManager.fillWidth();
				}
			};
			timer.schedule(100);
		}
	}
}
 
Example #6
Source File: EditorManager.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the editor manager.
 */
public EditorManager() {
  openProjectEditors = Maps.newHashMap();

  dirtyProjectSettings = new HashSet<ProjectSettings>();
  dirtyFileEditors = new HashSet<FileEditor>();

  autoSaveTimer = new Timer() {
    @Override
    public void run() {
      // When the timer goes off, save all dirtyProjectSettings and
      // dirtyFileEditors.
      Ode.getInstance().lockScreens(true); // Lock out changes
      saveDirtyEditors(new Command() {
          @Override
          public void execute() {
            Ode.getInstance().lockScreens(false); // I/O finished, unlock
          }
        });
    }
  };
}
 
Example #7
Source File: TabMailWorkflow.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onChange(MailEventConstant event) {
	if (event.equals(HasMailEvent.MAIL_CHANGED)) {
		Workflow.get().setTabMailSelected();
		workflowManager.findProcessInstancesByNode(Workflow.get().getUuid());
	} else if (event.equals(HasMailEvent.TAB_CHANGED)) {
		if (TabMailComunicator.isWidgetExtensionVisible(this)) {
			Timer timer = new Timer() {
				@Override
				public void run() {
					workflowManager.fillWidth();
				}
			};
			timer.schedule(100);
		}
	}
}
 
Example #8
Source File: MsgPopup.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * logout
 */
private void logout(final HTML countDown, final int seconds) {
	Timer timer = new Timer() {
		@Override
		public void run() {
			countDown.setHTML(Main.i18n("ui.logout") + " " + secondsToHTML(seconds));

			if (seconds > 1) {
				logout(countDown, seconds - 1);
			} else {
				hide();
				Main.get().logoutPopup.logout();
			}
		}
	};

	timer.schedule(1000);
}
 
Example #9
Source File: LogoutPopup.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * logoutAfterChat();
 */
private void logoutAfterChat() {
	Timer timer = new Timer() {
		@Override
		public void run() {
			if (!Main.get().mainPanel.bottomPanel.userInfo.isPendingToClose()) {
				authService.logout(callbackLogout);
			} else {
				logoutAfterChat();
			}
		}
	};

	timer.schedule(100); // Each minute seconds refreshing connected users
	Log.debug("Logout: void");
}
 
Example #10
Source File: MessageCenterView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void onMessage(final Message message) {
    if (!message.isTransient()) {

        // update the visible message count
        reflectMessageCount();

        final PopupPanel display = createDisplay(message);
        displayNotification(display, message);

        if (!message.isSticky()) {

            Timer hideTimer = new Timer() {
                @Override
                public void run() {
                    // hide message
                    messageDisplay.clear();
                    display.hide();
                }
            };

            hideTimer.schedule(4000);
        }

    }
}
 
Example #11
Source File: GanttWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
    GWT.log("onMouseDown(MouseDownEvent)");
    if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) {
        GanttWidget.this.onTouchOrMouseDown(event.getNativeEvent());
    } else {
        secondaryClickOnNextMouseUp = true;
        new Timer() {

            @Override
            public void run() {
                secondaryClickOnNextMouseUp = false;
            }
        }.schedule(CLICK_INTERVAL);
        event.stopPropagation();
    }
}
 
Example #12
Source File: ChatRoomPopup.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * refreshUsersInRoom()
 */
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);
			}
		});
	}
}
 
Example #13
Source File: DomPopupManager.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
@Override
protected Registration setPopupUpdate() {
  final Timer timer = new Timer() {
    @Override
    public void run() {
      updatePopupPositions();
    }
  };
  timer.scheduleRepeating(POPUPS_REFRESH_MILLIS);
  return new Registration() {
    @Override
    protected void doRemove() {
      timer.cancel();
    }
  };
}
 
Example #14
Source File: CubaFileDownloaderConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
 
Example #15
Source File: DefaultViewPortResizeHandler.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
@Override
public void load(Functions.Func1<ResizeEvent> callback) {
    // Optimize Window Resizing by just executing the callback once resizing is done.
    Timer timer = new Timer() {
        @Override
        public void run() {
            callback.call(event);
        }
    };

    resize = Window.addResizeHandler(event -> {
        this.event = event;

        timer.schedule(resizingDelayMillis);

        // Optimize the Resizing by turning of the animation
        RootPanel.get().addStyleName(RESIZE_ANIMATION_STOPPER);
        Scheduler.get().scheduleFixedDelay(() -> {
            RootPanel.get().removeStyleName(RESIZE_ANIMATION_STOPPER);
            return false;
        }, 400);
    });
}
 
Example #16
Source File: MaterialToastTest.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void testToastWithCallback() {
    final boolean[] isCallbackFired = new boolean[1];
    new MaterialToast(() -> {
        isCallbackFired[0] = true;
    }).toast("callback", 1000);
    Timer t = new Timer() {
        @Override
        public void run() {
            assertTrue(isCallbackFired[0]);
        }
    };
    t.schedule(1000);
    Element toastContainer = $("body").find("#toast-container").asElement();
    assertNotNull(toastContainer);
    toastContainer.setInnerHTML("");
}
 
Example #17
Source File: XhrConnection.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Sends an asynchronous UIDL request to the server using the given URI.
 *
 * @param payload
 *            The URI to use for the request. May includes GET parameters
 */
public void send(JsonObject payload) {
    XhrResponseHandler responseHandler = createResponseHandler();
    responseHandler.setPayload(payload);
    responseHandler.setRequestStartTime(Profiler.getRelativeTimeMillis());

    String payloadJson = WidgetUtil.stringify(payload);
    XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson,
            JsonConstants.JSON_CONTENT_TYPE, responseHandler);

    Console.log("Sending xhr message to server: " + payloadJson);

    if (webkitMaybeIgnoringRequests && BrowserInfo.get().isWebkit()) {
        final int retryTimeout = 250;
        new Timer() {
            @Override
            public void run() {
                // Use native js to access private field in Request
                if (resendRequest(xhr) && webkitMaybeIgnoringRequests) {
                    // Schedule retry if still needed
                    schedule(retryTimeout);
                }
            }
        }.schedule(retryTimeout);
    }
}
 
Example #18
Source File: DefaultConnectionStateHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Called after a problem occurred.
 *
 * This method is responsible for re-sending the payload to the server (if
 * not null) or re-send a heartbeat request at some point
 *
 * @param payload
 *            the payload that did not reach the server, null if the problem
 *            was detected by a heartbeat
 */
protected void scheduleReconnect(final JsonObject payload) {
    // Here and not in timer to avoid TB for getting in between

    // The request is still open at this point to avoid interference, so we
    // do not need to start a new one
    if (reconnectAttempt == 1) {
        // Try once immediately
        doReconnect(payload);
    } else {
        scheduledReconnect = new Timer() {
            @Override
            public void run() {
                scheduledReconnect = null;
                doReconnect(payload);
            }
        };
        scheduledReconnect
                .schedule(getConfiguration().getReconnectInterval());
    }
}
 
Example #19
Source File: GwtApplicationConnectionTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void test_should_addNavigationEvents_byDefault() {
    mockFlowBootstrapScript(false);

    JsonObject windowEvents = Json.createObject();
    addEventsObserver(Browser.getWindow(), windowEvents);

    JsonObject bodyEvents = Json.createObject();
    addEventsObserver(Browser.getDocument().getBody(), bodyEvents);

    new Bootstrapper().onModuleLoad();

    delayTestFinish(500);
    new Timer() {
        @Override
        public void run() {
            assertTrue(windowEvents.hasKey("popstate"));
            assertTrue(bodyEvents.hasKey("click"));
            finishTest();
        }
    }.schedule(100);
}
 
Example #20
Source File: GwtApplicationConnectionTest.java    From flow with Apache License 2.0 6 votes vote down vote up
public void test_should_not_addNavigationEvents_forWebComponents() {
    mockFlowBootstrapScript(true);

    JsonObject windowEvents = Json.createObject();
    addEventsObserver(Browser.getWindow(), windowEvents);

    JsonObject bodyEvents = Json.createObject();
    addEventsObserver(Browser.getDocument().getBody(), bodyEvents);

    new Bootstrapper().onModuleLoad();

    delayTestFinish(500);
    new Timer() {
        @Override
        public void run() {
            assertFalse(windowEvents.hasKey("popstate"));
            assertFalse(bodyEvents.hasKey("click"));
            finishTest();
        }
    }.schedule(100);
}
 
Example #21
Source File: FakeTestService.java    From gwt-material-demo with Apache License 2.0 6 votes vote down vote up
@Override
public void getPeople(int startIndex, int viewSize, AsyncCallback<People> async) {
    List<Person> flatData = new ArrayList<>();
    flatData.addAll(data);

    People people = new People();
    for (int i = startIndex; i < (startIndex + viewSize); i++) {
        try {
            people.add(flatData.get(i));
        } catch (IndexOutOfBoundsException e) {
            // ignored.
        }
    }
    people.setAbsoluteTotal(flatData.size());
    // Fake a delay for the demo
    new Timer() {
        @Override
        public void run() {
            async.onSuccess(people);
        }
    }.schedule(3000);
}
 
Example #22
Source File: MaterialColoredLineChart.java    From gwt-material-demo with Apache License 2.0 6 votes vote down vote up
private void initialize() {
	ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART);
	chartLoader.loadApi(new Runnable() {

		@Override
		public void run() {
			// Create and attach the chart
			chart = new LineChart();
			cardContent.add(chart);
			draw();
			Timer timer = new Timer() {
			      public void run() {
			        draw2();
			      }
			    };
			timer.schedule(2000);
		}
	});
}
 
Example #23
Source File: MaterialBarChart.java    From gwt-material-demo with Apache License 2.0 6 votes vote down vote up
private void setLoop() {

		Timer timer = new Timer() {

			public void run() {
				if (isLoop) {
					drawChart(values);
					isLoop = false;
				}
				else {
					drawChart(valuesInitial);
					isLoop = true;
				}

			}
		};
		timer.scheduleRepeating(1000);
	}
 
Example #24
Source File: CurriculumProjectionRulesPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
public MyFlexTable() {
	super();
	setCellPadding(2);
	setCellSpacing(0);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONCLICK);
	sinkEvents(Event.ONKEYDOWN);
	setStylePrimaryName("unitime-MainTable");
	iTimer = new Timer() {
		@Override
		public void run() {
			saveOrder();
		}
	};
}
 
Example #25
Source File: HorizontalPanelWithHint.java    From unitime with Apache License 2.0 6 votes vote down vote up
public HorizontalPanelWithHint(Widget hint) {
	super();
	iHint = new PopupPanel();
	iHint.setWidget(hint);
	iHint.setStyleName("unitime-PopupHint");
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONMOUSEMOVE);
	iShowHint = new Timer() {
		@Override
		public void run() {
			iHint.show();
		}
	};
	iHideHint = new Timer() {
		@Override
		public void run() {
			iHint.hide();
		}
	};
}
 
Example #26
Source File: EventAdd.java    From unitime with Apache License 2.0 6 votes vote down vote up
public CourseRelatedObjectsTable(AcademicSessionProvider session) {
	iSession = session;
	setStyleName("unitime-EventOwners");
	
	List<Widget> header = new ArrayList<Widget>();
	header.add(new UniTimeTableHeader(MESSAGES.colSubject()));
	header.add(new UniTimeTableHeader(MESSAGES.colCourseNumber()));
	header.add(new UniTimeTableHeader(MESSAGES.colConfigOrSubpart()));
	header.add(new UniTimeTableHeader(MESSAGES.colClassNumber()));
	header.add(new UniTimeTableHeader("&nbsp;"));
	
	addRow(null, header);
	
	iChangeTimer = new Timer() {
		@Override
		public void run() {
			List<RelatedObjectInterface> value = getValue();
			if (iLastChange != null && iLastChange.equals(value)) return;
			iLastChange = value;
			ValueChangeEvent.fire(CourseRelatedObjectsTable.this, value);
		}
	};
}
 
Example #27
Source File: MobileNotifications.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected void addNotification(final Notification notification) {
	for (Iterator<Notification> i = iNotifications.iterator(); i.hasNext(); ) {
		Notification n = i.next();
		if (n.getText().equals(notification.getText())) {
			i.remove();
		}
	}
	iNotifications.add(notification);
	populate("slideup");
	
	Timer timer = new Timer() {
		@Override
		public void run() {
			iNotifications.remove(notification);
			populate(null);
		}
	};
	timer.schedule(10000);
}
 
Example #28
Source File: FuturamaWalking.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Evaluate
 */
public void evaluate(String name) {
	if (name.equals("futurama")) {
		left = -180;
		top = Window.getClientHeight() - 80 - 21;
		show();
		setPopupPosition(left, top);

		move = new Timer() {
			public void run() {
				left += 2;
				setPopupPosition(left, top);

				if (left < Window.getClientWidth() + 180) {
					move.schedule(40);
				} else {
					move.cancel();
					hide();
				}
			}
		};

		move.schedule(40);
	}
}
 
Example #29
Source File: ShowcaseView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
@UiHandler("btnSplashScreen")
void onSplashscreen(ClickEvent e){
    splash.show();
    Timer t = new Timer() {
        @Override
        public void run() {
          splash.hide();
        }
    };
    t.schedule(3000);
}
 
Example #30
Source File: CircularProgressView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
protected void buildCircularContinuos() {
    Timer timer = new Timer() {
        @Override
        public void run() {
            double total = (i * 100) / 5;
            circContinuos.setValue(total / 100, true);
            if (i >= 5) {
                MaterialToast.fireToast("Finished");
                cancel();
            }
            i++;
        }
    };
    timer.scheduleRepeating(1000);
}