public void mouseExited(MouseEvent mouseEvent) { if (timerTask != null) { TaskEngine.getInstance().cancelScheduledTask(timerTask); } canShowPopup = false; UIComponentRegistry.getContactInfoWindow().dispose(); } });
public void chatRoomOpened(final ChatRoom room) { TimerTask task = new SwingTimerTask() { public void doRun() { addBuzzFeatureToChatRoom(room); } }; TaskEngine.getInstance().schedule(task, 100); }
public TaskNotification() { TimerTask task = new TimerTask() { public void run() { notifyUser(); } }; long twoHours = (60 * 1000) * 120; TaskEngine.getInstance().scheduleAtFixedRate(task, (10 * 1000), twoHours); }
/** * 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); }
public void loadVCard() { final Runnable loadVCard = () -> { VCard vcard = SparkManager.getVCardManager().getVCard(); updateVCardInformation(vcard); }; TaskEngine.getInstance().submit(loadVCard); }
public void windowDeactivated(final WindowEvent windowEvent) { TimerTask task = new SwingTimerTask() { public void doRun() { if (contactField.canClose()) { windowClosing(windowEvent); } } }; TaskEngine.getInstance().schedule(task, 250); } });
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); }
/** * 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); }
/** * Close the ChatRoom. */ public void closeChatRoom() { fireClosingListeners(); setChatState(ChatState.gone); if (typingTimerTask != null) { TaskEngine.getInstance().cancelScheduledTask(typingTimerTask); typingTimerTask = null; } getTranscriptWindow().removeContextMenuListener(this); getTranscriptWindow().removeMouseListener(transcriptWindowMouseListener); getChatInputEditor().removeKeyListener(chatEditorKeyListener); this.removeAll(); textScroller.getViewport().remove(transcriptWindow); // Remove Connection Listener SparkManager.getConnection().removeConnectionListener(this); getTranscriptWindow().setTransferHandler(null); getChatInputEditor().setTransferHandler(null); transferHandler = null; packetIDList.clear(); messageListeners.clear(); fileDropListeners.clear(); getChatInputEditor().close(); getChatInputEditor().getActionMap().remove("closeTheRoom"); chatAreaButton.getButton().removeActionListener(this); bottomPanel.remove(chatAreaButton); _chatFrame.removeWindowToFrontListener(this); }
/** * Brings the chat into focus. */ public void focusChat() { TaskEngine.getInstance().schedule(focusTask, 50); }
/** * 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); }
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); }
@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); }
TaskEngine.getInstance().submit(sharedGroupLoader);
/** * 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); }
TaskEngine.getInstance().submit(queueListener);
@Override public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { searchQuery = searchField.getText(); TaskEngine.getInstance().schedule(transcriptTask, 10); searchField.requestFocus(); focusFlag = true; } }
TaskEngine.getInstance().submit(registerThread);
public void mouseEntered(MouseEvent mouseEvent) { canShowPopup = true; timerTask = new DisplayWindowTask(mouseEvent); TaskEngine.getInstance().schedule(timerTask, 500, 1000); }
dlg.toFront(); dlg.requestFocus(); TaskEngine.getInstance().submit(invokeThread);