use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class VCardManager method viewProfile.
/**
* Displays <code>VCardViewer</code> for a particular JID.
*
* @param jid the jid of the user to display.
* @param parent the parent component to use for displaying dialog.
*/
public void viewProfile(final String jid, final JComponent parent) {
final SwingWorker vcardThread = new SwingWorker() {
VCard vcard = new VCard();
public Object construct() {
vcard = getVCard(jid);
return vcard;
}
public void finished() {
if (vcard == null) {
// Show vcard not found
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(parent, Res.getString("message.unable.to.load.profile", jid), Res.getString("title.profile.not.found"), JOptionPane.ERROR_MESSAGE);
} else {
editor.displayProfile(jid, vcard, parent);
}
}
};
vcardThread.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class GatewayPlugin method initialize.
@Override
public void initialize() {
ProviderManager.addIQProvider(Gateway.ELEMENT_NAME, Gateway.NAMESPACE, new Gateway.Provider());
LocalPreferences localPref = SettingsManager.getLocalPreferences();
useTab = localPref.getShowTransportTab();
transferTab.setBackground((Color) UIManager.get("ContactItem.background"));
SwingWorker thread = new SwingWorker() {
@Override
public Object construct() {
try {
// Let's try and avoid any timing issues with the gateway presence.
Thread.sleep(5000);
populateTransports();
} catch (Exception e) {
Log.error(e);
return false;
}
return true;
}
@Override
public void finished() {
transferTab.setLayout(new VerticalFlowLayout(0, 0, 0, true, false));
Boolean transportExists = (Boolean) get();
if (!transportExists) {
return;
}
if (TransportUtils.getTransports().size() > 0 && useTab) {
SparkManager.getWorkspace().getWorkspacePane().addTab(Res.getString("title.transports"), SparkRes.getImageIcon(SparkRes.TRANSPORT_ICON), transferTab);
}
for (final Transport transport : TransportUtils.getTransports()) {
addTransport(transport);
}
// Register presences.
registerPresenceListener();
}
};
thread.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class BookmarkItem method addConferenceRoom.
public void addConferenceRoom(final BookmarkedConference bookmark) {
imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.CONFERENCE_IMAGE_16x16));
nameLabel.setText(bookmark.getName());
descriptionLabel.setText(bookmark.getJid().toString());
action = new AbstractAction() {
private static final long serialVersionUID = 4324785627112595384L;
@Override
public void actionPerformed(ActionEvent e) {
SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
try {
Thread.sleep(10);
} catch (InterruptedException e1) {
Log.error(e1);
}
return "ok";
}
@Override
public void finished() {
ConferenceUtils.joinConferenceOnSeperateThread(bookmark.getName(), bookmark.getJid(), bookmark.getPassword());
}
};
worker.start();
}
};
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class VCardManager method viewProfile.
/**
* Displays <code>VCardViewer</code> for a particular JID.
*
* @param jid the jid of the user to display.
* @param parent the parent component to use for displaying dialog.
*/
public void viewProfile(final BareJid jid, final JComponent parent) {
final SwingWorker vcardThread = new SwingWorker() {
VCard vcard = new VCard();
@Override
public Object construct() {
vcard = getVCard(jid);
return vcard;
}
@Override
public void finished() {
if (vcard == null) {
// Show vcard not found
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(parent, Res.getString("message.unable.to.load.profile", jid), Res.getString("title.profile.not.found"), JOptionPane.ERROR_MESSAGE);
} else {
editor.displayProfile(jid, vcard, parent);
}
}
};
vcardThread.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class SoundPreference method load.
@Override
public void load() {
if (soundPanel == null) {
soundPanel = new SoundPanel();
}
SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
loadFromFile();
return preferences;
}
@Override
public void finished() {
// Set default settings
soundPanel.setIncomingMessageSound(preferences.getIncomingSound());
soundPanel.playIncomingSound(preferences.isPlayIncomingSound());
soundPanel.setOutgoingMessageSound(preferences.getOutgoingSound());
soundPanel.playOutgoingSound(preferences.isPlayOutgoingSound());
soundPanel.setOfflineSound(preferences.getOfflineSound());
soundPanel.playOfflineSound(preferences.isPlayOfflineSound());
soundPanel.setInvitationSound(preferences.getIncomingInvitationSoundFile());
soundPanel.setPlayInvitationSound(preferences.playIncomingInvitationSound());
}
};
worker.start();
}
Aggregations