use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class PhonePlugin method initialize.
public void initialize() {
ProviderManager.addExtensionProvider("phone-event", "http://jivesoftware.com/xmlns/phone", new PhoneEventPacketExtensionProvider());
ProviderManager.addIQProvider("phone-action", "http://jivesoftware.com/xmlns/phone", new PhoneActionIQProvider());
final XMPPConnection con = SparkManager.getConnection();
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
phoneClient = new PhoneClient(con);
// Add BaseListener
phoneClient.addEventListener(new PhoneListener());
} catch (Exception e) {
// Ignore because the user does not have support.
// Log.debug(e);
}
return phoneClient;
}
public void finished() {
if (phoneClient != null) {
setupPhoneSystem();
}
}
};
worker.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class PhoneManager method chatRoomOpened.
public void chatRoomOpened(final ChatRoom room) {
if (!phones.isEmpty() && room instanceof ChatRoomImpl) {
final ChatRoomImpl chatRoomImpl = (ChatRoomImpl) room;
final ChatRoomButton dialButton = new ChatRoomButton(SparkRes.getImageIcon(SparkRes.DIAL_PHONE_IMAGE_24x24));
dialButton.setToolTipText(Res.getString("tooltip.place.voice.call"));
final List<Action> actions = new ArrayList<>();
SwingWorker actionWorker = new SwingWorker() {
public Object construct() {
for (Phone phone : phones) {
final Collection<Action> phoneActions = phone.getPhoneActions(chatRoomImpl.getParticipantJID());
if (phoneActions != null) {
for (Action action : phoneActions) {
actions.add(action);
}
}
}
return actions;
}
public void finished() {
if (!actions.isEmpty()) {
room.addChatRoomButton(dialButton, true);
}
}
};
actionWorker.start();
dialButton.addMouseListener(new MouseAdapter() {
public void mousePressed(final MouseEvent e) {
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(50);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
return true;
}
public void finished() {
// Handle actions.
if (actions.size() > 0) {
// Display PopupMenu
final JPopupMenu menu = new JPopupMenu();
for (Action action : actions) {
menu.add(action);
}
menu.show(dialButton, e.getX(), e.getY());
}
}
};
worker.start();
}
});
}
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class PhoneManager method poppingUp.
public void poppingUp(Object object, final JPopupMenu popup) {
if (!phones.isEmpty()) {
if (object instanceof ContactItem) {
final ContactItem contactItem = (ContactItem) object;
final List<Action> actions = new ArrayList<>();
SwingWorker worker = new SwingWorker() {
public Object construct() {
for (Phone phone : phones) {
final Collection<Action> itemActions = phone.getPhoneActions(contactItem.getJID());
for (Action action : itemActions) {
actions.add(action);
}
}
return null;
}
public void finished() {
if (actions.size() > 0) {
final JMenu dialMenu = new JMenu(Res.getString("title.dial.phone"));
dialMenu.setIcon(SparkRes.getImageIcon(SparkRes.DIAL_PHONE_IMAGE_16x16));
for (Action action : actions) {
dialMenu.add(action);
}
int count = popup.getComponentCount();
if (count > 2) {
popup.insert(dialMenu, 2);
}
popup.invalidate();
popup.validate();
popup.repaint();
}
}
};
worker.start();
}
}
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class SipCodecsPreference method load.
@Override
public void load() {
SwingWorker thread = new SwingWorker() {
LocalPreferences localPreferences;
public Object construct() {
localPreferences = SettingsManager.getLocalPreferences();
return localPreferences;
}
public void finished() {
String sel = localPreferences.getSelectedCodecs();
String avail = localPreferences.getAvailableCodecs();
panel.setAvailable(avail);
panel.setSelected(sel);
}
};
thread.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class SipPreference method load.
public void load() {
SwingWorker worker = new SwingWorker() {
public Object construct() {
loadFromFile();
return preferences;
}
public void finished() {
panel.setUserName(preferences.getUserName() != null ? preferences.getUserName() : "");
panel.setAuthUserName(preferences.getAuthUserName() != null ? preferences.getAuthUserName() : "");
panel.setServer(preferences.getServer() != null ? preferences.getServer() : "");
panel.setPassword(preferences.getPassword() != null ? preferences.getPassword() : "");
panel.setRegister(preferences.isRegisterAtStart());
panel.setStunServer(preferences.getStunServer());
panel.setStunPort(preferences.getStunPort());
panel.setUseStun(preferences.isUseStun());
}
};
worker.start();
}
Aggregations