use of org.jivesoftware.fastpath.workspace.Workpane in project Spark by igniterealtime.
the class FastpathPlugin method joinWorkgroup.
private void joinWorkgroup() {
wasConnected = false;
joinButton.setEnabled(false);
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
Log.error(e);
}
return null;
}
public void finished() {
XMPPConnection con = SparkManager.getConnection();
String workgroupName = org.jivesoftware.spark.util.StringUtils.makeFirstWordCaptial((String) comboBox.getSelectedItem());
workgroupLabel.setText(FpRes.getString("message.workgroup.logged.into", workgroupName));
logoutButton.setVisible(true);
joinButton.setVisible(false);
comboBox.setVisible(false);
String workgroup = comboBox.getSelectedItem() + "@" + getComponentAddress();
if (agentSession != null && agentSession.isOnline()) {
try {
agentSession.setOnline(false);
agentSession.setOnline(true);
} catch (XMPPException | SmackException e) {
Log.error(e);
leaveWorkgroup();
joinButton.setEnabled(true);
return;
}
} else {
agentSession = new AgentSession(workgroup, con);
try {
agentSession.setOnline(true);
} catch (XMPPException | SmackException e1) {
Log.error(e1);
leaveWorkgroup();
joinButton.setEnabled(true);
return;
}
}
// Send actual presence to workgroup.
final Presence actualPresence = SparkManager.getWorkspace().getStatusBar().getPresence();
Presence toWorkgroupPresence = new Presence(actualPresence.getType(), actualPresence.getStatus(), actualPresence.getPriority(), actualPresence.getMode());
toWorkgroupPresence.setTo(workgroup);
try {
con.sendStanza(toWorkgroupPresence);
wgroup = new Workgroup(workgroup, con);
} catch (Exception e) {
e.printStackTrace();
joinButton.setEnabled(true);
return;
}
// Initialize Workspace
litWorkspace = new Workpane();
litWorkspace.listenForOffers();
joinButton.setEnabled(true);
// Register tab handler
SparkManager.getChatManager().addSparkTabHandler(fastpathTabHandler);
}
};
worker.start();
}
Aggregations