public void chatRoomOpened(final ChatRoom room) { TimerTask task = new SwingTimerTask() { public void doRun() { addBuzzFeatureToChatRoom(room); } }; TaskEngine.getInstance().schedule(task, 100); }
public void windowDeactivated(final WindowEvent windowEvent) { TimerTask task = new SwingTimerTask() { public void doRun() { if (contactField.canClose()) { windowClosing(windowEvent); } } }; TaskEngine.getInstance().schedule(task, 250); } });
@Override public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { searchQuery = searchField.getText(); TaskEngine.getInstance().schedule(transcriptTask, 10); searchField.requestFocus(); focusFlag = true; } }
public TaskNotification() { TimerTask task = new TimerTask() { public void run() { notifyUser(); } }; long twoHours = (60 * 1000) * 120; TaskEngine.getInstance().scheduleAtFixedRate(task, (10 * 1000), twoHours); }
/** * Brings the chat into focus. */ public void focusChat() { TaskEngine.getInstance().schedule(focusTask, 50); }
/** * Checks every room every 30 seconds to see if it's timed out. */ private void handleStaleChats() { int delay = 1000; // delay for 1 second. int period = 60000; // repeat every minute. final TimerTask task = new SwingTimerTask() { public void doRun() { for (ChatRoom chatRoom : getStaleChatRooms()) { // Notify decorators SparkManager.getChatManager().notifySparkTabHandlers(chatRoom); } } }; TaskEngine.getInstance().scheduleAtFixedRate(task, delay, period); }
@Override public void initialize() { TimerTask pManagerInstance = new TimerTask() { @Override public void run() { PrivacyManager.getInstance(); // Initiating PrivacyLists TimerTask thread = new TimerTask() { @Override public void run() { addMenuItemToContactItems(); } }; TaskEngine.getInstance().schedule(thread, 500); } }; TaskEngine.getInstance().schedule(pManagerInstance, 1000); }
protected void createChatStateTimerTask() { typingTimerTask = new TimerTask() { public void run() { final long lastUpdate = System.currentTimeMillis() - lastNotificationSentTime; switch ( lastNotificationSent ) { case paused: case active: if ( lastUpdate > inactiveTimePeriod ) { setChatState( ChatState.inactive ); } break; case composing: if ( lastUpdate > pauseTimePeriod ) { setChatState( ChatState.paused ); } break; } } }; TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, pauseTimePeriod /2, pauseTimePeriod / 2); }
/** * Load all bookmarked data. */ public void loadConferenceBookmarks() { final TimerTask bookmarkLoader = new TimerTask(){ @Override public void run() { Collection<BookmarkedConference> bc = null; try { while (bc == null) { BookmarkManager manager = BookmarkManager.getBookmarkManager(SparkManager.getConnection()); bc = manager.getBookmarkedConferences(); } } catch (XMPPException | SmackException | InterruptedException error) { Log.error(error); } bookmarksUI.loadUI(); addBookmarksUI(); } }; TaskEngine.getInstance().schedule(bookmarkLoader, 500); }
public void mouseEntered(MouseEvent mouseEvent) { canShowPopup = true; timerTask = new DisplayWindowTask(mouseEvent); TaskEngine.getInstance().schedule(timerTask, 500, 1000); }
/** * Check if the period was changed an apply the filter * to the message history * @param change the choosen value for the period */ private synchronized void handlePeriodChange(String change){ try { token.acquire(); if ( !Objects.equals( change, searchPeriod ) && isInitialized.get()){ searchPeriod = change; pref.setSearchPeriod(searchPeriod); isHistoryLoaded.set(false); TaskEngine.getInstance().schedule(transcriptTask, 10); } token.release(); } catch (InterruptedException e) { Log.error(e); e.printStackTrace(); } }
/** * Plays an AudioClip. * * @param clip the audioclip to play. */ public void playClip(final AudioClip clip) { final Runnable playThread = () -> { try { clip.play(); } catch (Exception ex) { System.err.println("Unable to load sound file"); } }; TaskEngine.getInstance().submit(playThread); }
/** * Plays a sound file. * * @param soundFile the File object representing the wav file. */ public void playClip(final File soundFile) { final Runnable playThread = () -> { try { final URL url = soundFile.toURI().toURL(); AudioClip ac = fileMap.get(url); if (ac == null) { ac = Applet.newAudioClip(url); fileMap.put(url, ac); } ac.play(); } catch (MalformedURLException e) { Log.error(e); } }; TaskEngine.getInstance().submit(playThread); }
public void mouseExited(MouseEvent mouseEvent) { if (timerTask != null) { TaskEngine.getInstance().cancelScheduledTask(timerTask); } canShowPopup = false; UIComponentRegistry.getContactInfoWindow().dispose(); } });
@Override public void run() { PrivacyManager.getInstance(); // Initiating PrivacyLists TimerTask thread = new TimerTask() { @Override public void run() { addMenuItemToContactItems(); } }; TaskEngine.getInstance().schedule(thread, 500); } };
public void loadVCard() { final Runnable loadVCard = () -> { VCard vcard = SparkManager.getVCardManager().getVCard(); updateVCardInformation(vcard); }; TaskEngine.getInstance().submit(loadVCard); }
private void refreshRoomList(final DomainBareJid serviceName) { startLoadingImg(); clearTable(); TimerTask refreshTask = new TimerTask() { Collection<HostedRoom> rooms; @Override public void run() { try { rooms = getRoomList(serviceName); try { for (HostedRoom aResult : rooms) { RoomObject room = getRoomsAndInfo(aResult); addRoomToTable(room.getRoomJID(), room.getRoomName(), room.getNumberOfOccupants()); } stopLoadingImg(); } catch (Exception e) { Log.error("Unable to retrieve room list and info.", e); } } catch ( Exception e1 ) { System.err.println(e1); } } }; TaskEngine.getInstance().submit(refreshTask); }
public void initialize() { // Add the preferences NotificationsPreference notifications = new NotificationsPreference(); SparkManager.getPreferenceManager().addPreference(notifications); notifications.load(); final TimerTask registerTask = new SwingTimerTask() { public void doRun() { registerListener(); } }; TaskEngine.getInstance().schedule(registerTask, 5000); }
/** * Action taking when a user clicks on the accept button. */ private void acceptInvitation() { setVisible(false); Localpart name = room.getLocalpart(); ConferenceUtils.enterRoomOnSameThread(name.toString(), room, password); final TimerTask removeUITask = new SwingTimerTask() { public void doRun() { removeUI(); } }; TaskEngine.getInstance().schedule(removeUITask, 2000); }
TaskEngine.getInstance().submit(sharedGroupLoader);