List of usage examples for com.google.gwt.user.client Timer scheduleRepeating
public synchronized void scheduleRepeating(final int periodMs)
From source file:org.jboss.errai.widgets.client.effects.effectimpl.MozillaEffectImpl.java
License:Apache License
public Timer doFade(final Element el, double duration, final int start, final int end) { Timer t = start < end ? new Timer() { int step = start; public void run() { step += 5;//from ww w . jav a 2 s. c om if (step < end) { _setOpacity(el, step); } else { _setOpacity(el, end); cancel(); } } } : new Timer() { int step = end; public void run() { step -= 5; if (step > end) { _setOpacity(el, step); } else { _setOpacity(el, end); cancel(); } } }; t.scheduleRepeating(1); return t; }
From source file:org.jboss.errai.workspaces.client.layout.WorkspaceLayout.java
License:Apache License
private Panel createNavigator() { leftPanel.addStyleName("workspace-LeftNavArea"); final HorizontalPanel topNavPanel = new HorizontalPanel(); topNavPanel.setWidth("100%"); topNavPanel.setHeight("20px"); topNavPanel.setStyleName("workspace-NavHeader"); navigationLabel.setStyleName("workspace-NavHeaderText"); topNavPanel.add(navigationLabel);/*from ww w . j a v a 2 s. c o m*/ final ImageResource collapseLeft = erraiImageBundle.collapseLeft(); final ImageResource collapseRight = erraiImageBundle.collapseRight(); final Image collapseButton = new Image(collapseLeft); collapseButton.setStyleName("workspace-NavCollapseButton"); collapseButton.addClickHandler(new ClickHandler() { private boolean collapse = false; public void onClick(ClickEvent event) { if (!collapse) { Timer timer = new Timer() { int i = navigation.getOffsetWidth(); int step = 10; public void run() { i -= step; setSize(); if (i <= 12) { cancel(); i = 12; setSize(); navigation.setWidth(i + "px"); leftPanel.setArmed(true); collapseNavPanel(); } } private void setSize() { leftPanel.setWidth(i + "px"); leftPanel.setHeight("100%"); } }; timer.scheduleRepeating(10); navigation.setVisible(false); navigationLabel.setVisible(false); collapseButton.setUrl(collapseRight.getURL()); } else { leftPanel.setArmed(false); Timer timer = new Timer() { int i = 12; int step = 1; public void run() { i += step++; setSize(); if (i >= 175) { cancel(); i = 175; setSize(); openNavPanel(); } } private void setSize() { leftPanel.setWidth(i + "px"); leftPanel.setHeight("0"); } }; if (navigation.getOffsetWidth() == 0) timer.scheduleRepeating(20); collapseButton.setUrl(collapseLeft.getURL()); } collapse = !collapse; } }); topNavPanel.add(collapseButton); topNavPanel.setCellWidth(collapseButton, "21px"); topNavPanel.setCellVerticalAlignment(collapseButton, HasVerticalAlignment.ALIGN_MIDDLE); topNavPanel.setCellVerticalAlignment(navigationLabel, HasVerticalAlignment.ALIGN_MIDDLE); leftPanel.add(topNavPanel); leftPanel.setCellHeight(topNavPanel, "23px"); leftPanel.add(navigation); leftPanel.setCellHeight(navigation, "100%"); navigation.setWidth("175px"); leftPanel.setArmed(false); return leftPanel; }
From source file:org.kuali.student.common.ui.client.util.Elements.java
License:Educational Community License
public static void fadeIn(final Element e, final int milliseconds, final int maxOpacity, final FadeCallback callback) { final int interval = milliseconds / 50; setOpacity(e, 0);/* w w w . ja v a2s . co m*/ DeferredCommand.addCommand(new Command() { @Override public void execute() { callback.onFadeStart(); final Timer t = new Timer() { int pct = 0; @Override public void run() { pct += 2; pct = Math.min(pct, maxOpacity); setOpacity(e, pct); if (pct == maxOpacity) { this.cancel(); callback.onFadeComplete(); } } }; t.scheduleRepeating(interval); } }); }
From source file:org.kuali.student.common.ui.client.util.Elements.java
License:Educational Community License
public static void fadeOut(final Element e, final int milliseconds, final int minOpacity, final FadeCallback callback) { final int interval = milliseconds / 50; DeferredCommand.addCommand(new Command() { @Override/*w w w.jav a 2 s . com*/ public void execute() { callback.onFadeStart(); final Timer t = new Timer() { int pct = 100; @Override public void run() { pct -= 2; pct = Math.max(pct, minOpacity); setOpacity(e, pct); if (pct == minOpacity) { this.cancel(); callback.onFadeComplete(); } } }; t.scheduleRepeating(interval); } }); }
From source file:org.obiba.opal.web.gwt.app.client.ui.BreadcrumbsTabPanel.java
License:Open Source License
public BreadcrumbsTabPanel() { super(new Breadcrumbs()); // remove all tabs after the one selected addSelectionHandler(new SelectionHandler<Integer>() { @Override// w ww .j a v a 2 s. c o m public void onSelection(SelectionEvent<Integer> event) { final int idx = event.getSelectedItem(); if (isAnimationEnabled()) { // wait for the end of the animation before removing descendants Timer timer = new Timer() { @Override public void run() { if (!isAnimationRunning()) { removeDescendants(idx); cancel(); } } }; timer.scheduleRepeating(10); } else { removeDescendants(idx); } } private void removeDescendants(int idx) { while (getWidgetCount() > idx + 1) { remove(getWidgetCount() - 1); } } }); setAnimationEnabled(true); getMenu().addStyleName("inline-block"); }
From source file:org.opentaps.gwt.common.voip.client.RedirectToCallingParty.java
License:Open Source License
/** * Sets the check in-bound timer.//from w w w. ja v a2s . c om * @param seconds the number of seconds between checking in-bound calls */ private void setCheckInBoundTimer(int seconds) { Timer timer = new Timer() { @Override public void run() { try { //add random number avoid cache page RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(GWT.getHostPageBaseURL() + remoteUrl + "?now=" + new Date().getTime())); builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { // display error message UtilUi.errorMessage(exception.toString()); } public void onResponseReceived(Request request, Response response) { // when get correct response, clear the div insideHeadertext and display call in link. if (response.getStatusCode() == Response.SC_OK) { String returnText = response.getText(); if (!returnText.equals("")) { RootPanel.get(voipkNotificationDiv).clear(); OpentapsConfig config = new OpentapsConfig(); HTML callInTips = new HTML(UtilUi.MSG .callInDisplayMessage(config.getCallInEventIcon(), returnText)); RootPanel.get(voipkNotificationDiv).add(callInTips); } } } }); } catch (RequestException e) { // display error message UtilUi.errorMessage(e.toString()); } } }; // Schedule the timer for every second timer.scheduleRepeating(seconds * 1000); }
From source file:org.pentaho.mantle.client.admin.ContentCleanerPanel.java
License:Open Source License
/** * @param age//from w w w . j a v a 2 s .c o m * in milliseconds */ public void deleteContentNow(long age) { showLoadingIndicator(); String date = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).format(new Date()); String json = "{\"jobName\": \"Content Cleaner\", \"actionClass\": \"org.pentaho.platform.admin.GeneratedContentCleaner\"," + " \"jobParameters\":[ { \"name\": \"age\", \"stringValue\": \"" + age + "\", \"type\": \"string\" }], \"simpleJobTrigger\": { \"endTime\": null, \"repeatCount\": \"0\", " + "\"repeatInterval\": \"0\", \"startTime\": \"" + date + "\", \"uiPassParam\": \"RUN_ONCE\"} }"; RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.POST, GWT.getHostPageBaseURL() + "api/scheduler/job"); scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); scheduleFileRequestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ try { scheduleFileRequestBuilder.sendRequest(json, new RequestCallback() { public void onError(Request request, Throwable exception) { } public void onResponseReceived(Request request, Response response) { String jobId = response.getText(); final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/scheduler/jobinfo?jobId=" + URL.encodeQueryString(jobId)); requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.setHeader("Content-Type", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ requestBuilder.setHeader("accept", "application/json"); //$NON-NLS-1$//$NON-NLS-2$ // create a timer to check if the job has finished Timer t = new Timer() { public void run() { try { requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { // if we're receiving a correct job info, then the job is still executing. // once the job is finished, it is removed from scheduler and we should receive a 404 code. if (response.getStatusCode() != Response.SC_OK) { hideLoadingIndicator(); cancel(); } } @Override public void onError(Request request, Throwable throwable) { hideLoadingIndicator(); cancel(); } }); } catch (RequestException e) { hideLoadingIndicator(); cancel(); } } }; t.scheduleRepeating(1000); } }); } catch (RequestException re) { hideLoadingIndicator(); } }
From source file:org.pentaho.mantle.client.admin.PermissionsPanel.java
License:Open Source License
public void setSelectedPermissions() { Timer t = new Timer() { public void run() { int selectedIndex = rolesListBox.getSelectedIndex(); if (selectedIndex >= 0) { String roleName = rolesListBox.getItemText(selectedIndex); List<String> logicalRoleAssignments = newRoleAssignments.get(roleName); if (logicalRoleAssignments == null) { logicalRoleAssignments = masterRoleMap.get(roleName); }//from ww w . jav a2 s . c o m for (LogicalRoleInfo logicalRoleInfo : logicalRoles.values()) { logicalRoleInfo.checkBox.setValue((logicalRoleAssignments != null) && logicalRoleAssignments.contains(logicalRoleInfo.roleName)); logicalRoleInfo.checkBox.setEnabled(!immutableRoles.contains(roleName)); } } } }; t.scheduleRepeating(100); }
From source file:org.pentaho.mantle.client.admin.UserRolesAdminPanelController.java
License:Open Source License
private void getRolesForUser(String user) { final String url = GWT.getHostPageBaseURL() + "api/userroledao/userRoles?userName=" + encodeUri(user); RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url); executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); executableTypesRequestBuilder.setHeader("accept", "application/xml"); try {/*from www . j a va2 s.c o m*/ executableTypesRequestBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage()); } public void onResponseReceived(Request request, Response response) { selectedRolesListBox.clear(); for (String role : getSortedItems("roles", response)) { selectedRolesListBox.addItem(role); } updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedRolesListBox)); Timer t = new Timer() { public void run() { if (rolesListBox.getItemCount() > 0) { cancel(); // availableRolesListBox = rolesListBox - selectedRolesListBox availableRolesListBox.clear(); for (int i = 0; i < rolesListBox.getItemCount(); i++) { String role = rolesListBox.getValue(i); boolean isSelected = false; for (int j = 0; j < selectedRolesListBox.getItemCount(); j++) { if (selectedRolesListBox.getValue(j).equals(role)) { isSelected = true; } } if (!isSelected) { availableRolesListBox.addItem(role); } } updateHelperDiv( HorizontalScrollWrapper.getListBoxWrapperUIId(availableRolesListBox)); } } }; t.scheduleRepeating(100); } }); } catch (RequestException e) { displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage()); } }
From source file:org.pentaho.mantle.client.admin.UserRolesAdminPanelController.java
License:Open Source License
private void getUsersInRole(String role) { final String url = GWT.getHostPageBaseURL() + "api/userroledao/roleMembers?roleName=" + encodeUri(role); RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url); executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); executableTypesRequestBuilder.setHeader("accept", "application/xml"); try {/*from w w w . j a va 2s . c om*/ executableTypesRequestBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage()); } public void onResponseReceived(Request request, Response response) { selectedMembersListBox.clear(); for (String user : getSortedItems("users", response)) { selectedMembersListBox.addItem(user); } updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedMembersListBox)); Timer t = new Timer() { public void run() { if (usersListBox.getItemCount() > 0) { cancel(); // availableMembersListBox = usersListBox - selectedMembersListBox availableMembersListBox.clear(); for (int i = 0; i < usersListBox.getItemCount(); i++) { String user = usersListBox.getValue(i); boolean isSelected = false; for (int j = 0; j < selectedMembersListBox.getItemCount(); j++) { if (selectedMembersListBox.getValue(j).equals(user)) { isSelected = true; } } if (!isSelected) { availableMembersListBox.addItem(user); } } updateHelperDiv( HorizontalScrollWrapper.getListBoxWrapperUIId(availableMembersListBox)); } } }; t.scheduleRepeating(100); } }); } catch (RequestException e) { displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage()); } }