Java Code Examples for com.google.gwt.user.client.Timer#schedule()

The following examples show how to use com.google.gwt.user.client.Timer#schedule() . 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: 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 2
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 3
Source File: GoogleContactsView.java    From gwt-material-patterns with Apache License 2.0 6 votes vote down vote up
@Inject
GoogleContactsView(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<UserDTO> filteredUser = DataHelper.getAllUsers().stream().filter(dto -> dto.getName().toLowerCase().contains(search.getText().toLowerCase())).collect(Collectors.toList());
        populateUsers(filteredUser);
    });
    populateUsers(DataHelper.getAllUsers());
}
 
Example 4
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 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: 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 7
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 8
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 9
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 10
Source File: ExtendedDefaultValidatorProcessor.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * waitUntilValidatorsFinished
 */
public void waitUntilValidatorsFinished() {
	if (pluginsValidated == plugins && validatorToFire != null) {
		validatorToFire.validationWithPluginsFinished(result);
	} else if (pluginsValidated < plugins) {
		Timer timer = new Timer() {
			@Override
			public void run() {
				waitUntilValidatorsFinished();
			}
		};
		timer.schedule(200);
	}
}
 
Example 11
Source File: LoaderView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
@UiHandler("btnShowNavBarProgress")
void onShowNavBarProgress(ClickEvent e) {
    navBar.showProgress(ProgressType.INDETERMINATE);
    Timer t = new Timer() {
        @Override
        public void run() {
            navBar.hideProgress();
        }
    };
    t.schedule(3000);
}
 
Example 12
Source File: LoaderView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
@UiHandler("btnShowLoader")
void onShowLoader(ClickEvent e) {
    MaterialLoader.loading(true);
    Timer t = new Timer() {
        @Override
        public void run() {
            MaterialLoader.loading(false);
        }
    };
    t.schedule(3000);
}
 
Example 13
Source File: MockComponentsUtil.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
   * Sets the background image for the given widget.
   *
   * @param container the MockContainer to refresh when image is loaded
   * @param widget  widget to change background image for
   * @param image  URL
   */
  static void setWidgetBackgroundImage(final MockContainer container, Widget widget, String image) {
    // Problem: When we change the background image via a Style referencing a "url"
    // the browser doesn't initially know the size of the image. We need to know it
    // when the container layout height and/or width is "Automatic." If we query right
    // away, we will be told the image is 0 x 0 because it isn't loaded yet.
    // I have not been able to figure out how to get the browser to give us a onLoad (or
    // similar event) when the image is loaded. If we could get such an event, we can
    // call refreshForm in the container and win.
    //
    // The code below fudges this by setting up a time to fire after 1 second with the
    // hope that the image will have been loaded by then and its dimensions known.
    // The code commented out immediately below this code is what I would like to use,
    // but it doesn't seem to work!   -JIS
    Timer t = new Timer() {
        @Override
        public void run() {
          container.refreshForm();
        }
      };
//    widget.addHandler(new LoadHandler() {
//        @Override
//        public void onLoad(LoadEvent event) {
//          container.refreshForm();
//        }
//      }, new Type<LoadHandler>());
    setWidgetBackgroundImage(widget, image);
    t.schedule(1000);           // Fire in one second
  }
 
Example 14
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 15
Source File: ObjectPagingProxy.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void load(final PagingLoadConfig config,
		final Callback<PagingLoadResult<M>, Throwable> callback) {
	final ArrayList<M> temp = new ArrayList<M>();

	for (M model : data) {
		temp.add(model);
	}

	final ArrayList<M> sublist = new ArrayList<M>();
	int start = config.getOffset();
	int limit = temp.size();
	if (config.getLimit() > 0) {
		limit = Math.min(start + config.getLimit(), limit);
	}
	for (int i = config.getOffset(); i < limit; i++) {
		sublist.add(temp.get(i));
	}

	Timer t = new Timer() {

		@Override
		public void run() {
			callback.onSuccess(new PagingLoadResultBean<M>(sublist, temp
					.size(), config.getOffset()));
		}
	};
	t.schedule(delay);

}
 
Example 16
Source File: SearchIn.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * switchSearchMode
 */
public void switchSearchMode(int mode) {
	this.searchMode = mode;
	switch (searchMode) {
		case SearchControl.SEARCH_MODE_SIMPLE:
			while (tabPanel.getWidgetCount() > 0) {
				tabPanel.remove(0);
			}

			tabPanel.add(searchSimple, Main.i18n("search.simple"));
			tabPanel.selectTab(0);
			break;

		case SearchControl.SEARCH_MODE_ADVANCED:
			while (tabPanel.getWidgetCount() > 0) {
				tabPanel.remove(0);
			}

			tabPanel.add(searchNormal, Main.i18n("search.normal"));
			tabPanel.add(searchAdvanced, Main.i18n("search.advanced"));
			tabPanel.add(searchMetadata, Main.i18n("search.metadata"));
			tabPanel.selectTab(0);
			break;
	}
	// TODO:Solves minor bug with IE ( now shows contents )
	if (Util.getUserAgent().startsWith("ie")) {
		tabPanel.setWidth("" + (tabWidth - 20) + "px");
		tabPanel.setHeight("" + (height - 20) + "px");
		searchSimple.setPixelSize(tabWidth - 20, height - 42); // Substract tab height
		searchNormal.setPixelSize(tabWidth - 20, height - 42); // Substract tab height
		searchAdvanced.setPixelSize(tabWidth - 20, height - 42); // Substract tab height
		searchMetadata.setPixelSize(tabWidth - 20, height - 42); // Substract tab height
		Timer timer = new Timer() {
			@Override
			public void run() {
				tabPanel.setWidth("" + (tabWidth - 2) + "px");
				tabPanel.setHeight("" + (height - 2) + "px");
				searchSimple.setPixelSize(tabWidth - 2, height - 22); // Substract tab height
				searchNormal.setPixelSize(tabWidth - 2, height - 22); // Substract tab height
				searchAdvanced.setPixelSize(tabWidth - 2, height - 22); // Substract tab height
				searchMetadata.setPixelSize(tabWidth - 2, height - 22); // Substract tab height
			}
		};
		timer.schedule(350);
	}
}
 
Example 17
Source File: FancyFileUpload.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * uploadPendingFile
 */
public void uploadNewPendingFile() {
	// Execute pending workflows
	if (actualFileToUpload != null && actualFileToUpload.getWorkflow() != null
			&& actualFileToUpload.isLastToBeUploaded()) {
		uploadedWorkflowFiles.add(actualFileToUpload.clone());
		executeWorkflow(actualFileToUpload.getWorkflowTaskId());
	}

	if (!filesToUpload.isEmpty()) {
		actualFileToUpload = filesToUpload.remove(0);
		pendingFilePanel.remove(0);

		// Here always with default size
		if (actualFileToUpload.getUploadForm() == null) {
			actualFileToUpload.setUploadForm(new FileUploadForm(actualFileToUpload.getFileUpload(),
					FileToUpload.DEFAULT_SIZE));
		}

		final FileUploadForm uploadForm = actualFileToUpload.getUploadForm();
		uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
		uploadItem.hFileUpload.add(uploadForm);
		uploadForm.setVisible(false);
		actualFileToUpload.getUploadForm().setPath(actualFileToUpload.getPath());
		actualFileToUpload.getUploadForm().setAction(String.valueOf(actualFileToUpload.getAction()));
		actualFileToUpload.getUploadForm().setRename(actualFileToUpload.getDesiredDocumentName());

		setAction(actualFileToUpload.getAction());
		addSubmitCompleteHandler(uploadForm);

		// Case fileupload is workflow notify to users must be disabled ( popup hidden then (modal==false) )
		if (!Main.get().fileUpload.isModal() && actualFileToUpload.getWorkflow() != null) {
			Main.get().fileUpload.showPopup(actualFileToUpload.isEnableAddButton(), actualFileToUpload.isEnableImport(), Main.get().workspaceUserProperties.getWorkspace().isUploadNotifyUsers());
			reset(actualFileToUpload.isEnableImport(), Main.get().workspaceUserProperties.getWorkspace().isUploadNotifyUsers()); // force reset
		}

		fileName = uploadForm.getFileName();
		uploadItem.setPending();
		Main.get().mainPanel.topPanel.setPercentageUploading(0);

		p = new Timer() {
			@Override
			public void run() {
				uploadItem.setLoading();
				uploadForm.submit();

			}
		};

		p.schedule(PENDING_UPDATE_DELAY);
	} else {
		if (actualFileToUpload != null && actualFileToUpload.getWorkflow() != null) {
			Main.get().fileUpload.executeClose();
		}
		actualFileToUpload = null;
	}

	Main.get().mainPanel.topPanel.setPendingFilesToUpload(calculatePendingFilesToUpload());
	diclousureFilesPanel.setVisible(filesToUpload.size() > 0);
}
 
Example 18
Source File: TabDocument.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets document values
 *
 * @param doc The document object
 */
public void setProperties(GWTDocument doc) {
	// We must declare status here due pending downloading ( fired by status )
	if (securityVisible) {
		Main.get().mainPanel.desktop.browser.tabMultiple.status.setUserSecurity();
		Main.get().mainPanel.desktop.browser.tabMultiple.status.setRoleSecurity();
	}

	if (versionVisible) {
		Main.get().mainPanel.desktop.browser.tabMultiple.status.setVersionHistory();
	}

	if (propertyGroupsVisible) {
		Main.get().mainPanel.desktop.browser.tabMultiple.status.setGroupProperties();
	}

	this.doc = doc;
	selectedTab = tabPanel.getSelectedIndex(); // Sets the actual selected tab
	latestSelectedTab = selectedTab; // stores latest selected tab

	document.set(doc); // Used by TabDocumentCommunicator
	notes.set(doc); // Used by TabDocumentCommunicator

	if (versionVisible) {
		version.set(doc);
		version.getVersionHistory();
	}

	if (securityVisible) {
		security.setUuid(doc.getUuid());
		security.GetGrants();

		GWTFolder parentFolder = Main.get().activeFolderTree.getFolder();

		if ((parentFolder.getPermissions() & GWTPermission.SECURITY) == GWTPermission.SECURITY
				&& (doc.getPermissions() & GWTPermission.SECURITY) == GWTPermission.SECURITY && !doc.isCheckedOut()
				&& !doc.isLocked()) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
	}

	if (previewVisible) {
		preview.setPreviewAvailable(doc.isConvertibleToSwf()
				|| doc.getMimeType().equals("application/x-shockwave-flash")
				|| HTMLPreview.isPreviewAvailable(doc.getMimeType())
				|| SyntaxHighlighterPreview.isPreviewAvailable(doc.getMimeType()));
	}

	if (!propertyGroup.isEmpty()) {
		for (Iterator<PropertyGroup> it = propertyGroup.iterator(); it.hasNext(); ) {
			tabPanel.remove(it.next());
		}
		propertyGroup.clear();
	}

	// Only gets groups if really are visible
	if (propertyGroupsVisible) {
		getGroups(doc.getPath()); // Gets all the property group assigned to
		// a document
		// Here evaluates selectedTab
	}

	// Refresh preview if tab is visible
	if (selectedTab == PREVIEW_TAB) {
		previewDocument(false);
	}

	// TODO:Solves minor bug with IE ( now shows contents )
	if (Util.getUserAgent().startsWith("ie") && IEBugCorrections == 1) {
		Timer timer = new Timer() {
			@Override
			public void run() {
				correctIEDefect();
			}
		};

		timer.schedule(500);
	}

	fireEvent(HasDocumentEvent.DOCUMENT_CHANGED);
}
 
Example 19
Source File: TabFolder.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Sets the folder values
 *
 * @param folder The folder object
 */
public void setProperties(GWTFolder folder) {
	this.folder.set(folder); // Used by tabFolderCommunicator
	notes.set(folder);         // Used by TabFolderCommunicator

	selectedTab = tabPanel.getSelectedIndex();    // Sets the actual selected Tab
	latestSelectedTab = selectedTab;            // stores latest selected tab

	if (securityVisible) {
		if (folder.getPath().startsWith("/" + GWTRepository.METADATA)) {
			security.setUuid(folder.getPath());
		} else {
			security.setUuid(folder.getUuid());
		}
		security.GetGrants();

		if ((folder.getPermissions() & GWTPermission.SECURITY) == GWTPermission.SECURITY) {
			security.setChangePermision(true);
		} else {
			security.setChangePermision(false);
		}
	}

	if (propertyGroupsVisible) {
		Main.get().mainPanel.desktop.browser.tabMultiple.status.setGroupProperties();
	}

	if (!propertyGroup.isEmpty()) {
		for (Iterator<PropertyGroup> it = propertyGroup.iterator(); it.hasNext(); ) {
			tabPanel.remove(it.next());
		}

		propertyGroup.clear();
	}

	// Only gets groups if really are visible
	if (propertyGroupsVisible) {
		getGroups(folder.getPath()); // Gets all the property group assigned to a document
		// Here evaluates selectedTab
	}

	// Setting folder object to extensions
	for (Iterator<TabFolderExtension> it = widgetExtensionList.iterator(); it.hasNext(); ) {
		it.next().set(folder);
	}

	// TODO:Solves minor bug with IE ( now shows contents )
	if (Util.getUserAgent().startsWith("ie") && IEBugCorrections == 1) {
		Timer timer = new Timer() {
			@Override
			public void run() {
				correctIEDefect();
			}
		};

		timer.schedule(500);
	}

	fireEvent(HasFolderEvent.FOLDER_CHANGED);
}
 
Example 20
Source File: FinderColumn.java    From core with GNU Lesser General Public License v2.1 2 votes vote down vote up
private void triggerPreviewEvent() {

        if(!hasSelectedItem()) return;

        final T selectedObject = selectionModel.getSelectedObject();

        // different selected object trigger preview
        // preview and place management sometimes compete, hence the deferred event
        // see also DefaultPlacemanager#doRevealPlace() when the callback returns

        Timer t = new Timer() { // used to delay the first invocation
            @Override
            public void run() {


                Scheduler.get().scheduleFixedDelay(() -> {

                    boolean reschedulePreviewEvents = FinderColumn.this.previewLock;

                    if(!reschedulePreviewEvents) {
                        // preview events
                        PlaceManager placeManager = Console.MODULES.getPlaceManager();
                        if (selectedObject != null) {


                            previewFactory.createPreview(selectedObject, new SimpleCallback<SafeHtml>() {
                                @Override
                                public void onSuccess(SafeHtml content) {
                                    PreviewEvent.fire(placeManager, content);
                                }
                            });
                        }
                    }

                    if(reschedulePreviewEvents)
                        System.out.println("Preview event will be re-scheduled: "+FinderColumn.this.title);

                    return reschedulePreviewEvents; // if locked this fn get re-scheduled

                }, 100);

            }
        };

        t.schedule(100);

    }