use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class BookmarksUI method addRegisteredServices.
private void addRegisteredServices() {
SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
try {
if (SparkManager.getConnection().isConnected()) {
mucServices = MultiUserChatManager.getInstanceFor(SparkManager.getConnection()).getMucServiceDomains();
}
} catch (XMPPException | SmackException | InterruptedException e) {
Log.error("Unable to load MUC Service Names.", e);
}
return mucServices;
}
@Override
public void finished() {
if (mucServices == null) {
return;
}
for (DomainBareJid service : mucServices) {
if (!hasService(service)) {
addServiceToList(service);
}
}
}
};
worker.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class ContactList method clientReconnected.
public void clientReconnected() {
switch(localPreferences.getReconnectPanelType()) {
case 0:
workspace.changeCardLayout(Workspace.WORKSPACE_PANE);
break;
case 1:
mainPanel.remove(_reconnectpanelsmall);
break;
case 2:
SwingWorker sw = new SwingWorker() {
@Override
public Object construct() {
_reconnectpanelicon.remove();
_reconnectpanelicon.getPanel().revalidate();
return 42;
}
};
sw.start();
break;
}
offlineGroup.fireContactGroupUpdated();
try {
updateContactList(null);
} catch (Exception e) {
Log.error(e);
}
final Presence myPresence = SparkManager.getWorkspace().getStatusBar().getPresence();
SparkManager.getSessionManager().changePresence(myPresence);
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class ContactGroup method displayWindow.
/**
* Displays the <code>ContactInfoWindow</code>.
*
* @param e the mouseEvent that triggered this event.
*/
private void displayWindow(MouseEvent e) {
if (preferences.areVCardsVisible()) {
final ContactGroup parent = this;
final SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
UIComponentRegistry.getContactInfoWindow().display(parent, e);
return null;
}
};
worker.start();
}
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class UserHistory method loadHistory.
public void loadHistory() {
SwingWorker transcriptThread = new SwingWorker() {
final List<TranscriptSummary> transcriptList = new ArrayList<>();
public Object construct() {
try {
Transcripts transcripts = FastpathPlugin.getAgentSession().getTranscripts(userID);
transcriptList.addAll(transcripts.getSummaries());
} catch (XMPPException | SmackException | InterruptedException e) {
Log.error("Error getting transcripts.", e);
}
transcriptList.sort(timeComparator);
return transcriptList;
}
public void finished() {
init(transcriptList);
}
};
transcriptThread.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class AgentConversations method stateChanged.
public void stateChanged(ChangeEvent e) {
if (FastpathPlugin.getUI().getMainPanel().getSelectedComponent() == this && list == null) {
init();
SwingWorker agentWorker = new SwingWorker() {
AgentRoster agentRoster;
Collection<EntityBareJid> agentSet;
public Object construct() {
try {
agentRoster = FastpathPlugin.getAgentSession().getAgentRoster();
} catch (SmackException.NotConnectedException | InterruptedException e1) {
Log.warning("Unable to get agent roster.", e1);
}
agentSet = agentRoster.getAgents();
return agentSet;
}
public void finished() {
agentRoster.addListener(new AgentRosterListener() {
@Override
public void agentAdded(EntityBareJid jid) {
}
@Override
public void agentRemoved(EntityBareJid jid) {
}
@Override
public void presenceChanged(Presence presence) {
EntityBareJid agentJID = presence.getFrom().asEntityBareJidOrThrow();
AgentStatus agentStatus = presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
if (agentStatus != null) {
List<AgentStatus.ChatInfo> list = agentStatus.getCurrentChats();
removeOldChats(agentJID, list);
// Add new ones.
for (Object o : list) {
AgentStatus.ChatInfo chatInfo = (AgentStatus.ChatInfo) o;
Date startDate = chatInfo.getDate();
String username = chatInfo.getUserID();
String nickname = chatInfo.getUsername();
if (!ModelUtil.hasLength(nickname)) {
nickname = "Not specified";
}
String question = chatInfo.getQuestion();
if (!ModelUtil.hasLength(question)) {
question = "No question asked";
}
String email = chatInfo.getEmail();
if (!ModelUtil.hasLength(email)) {
email = "Not specified";
}
addAgentChat(agentJID, nickname, email, question, startDate, chatInfo.getSessionID());
}
}
calculateNumberOfChats(agentRoster);
}
});
}
};
agentWorker.start();
}
}
Aggregations