use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class NonRosterPanel method setupDefaults.
public void setupDefaults() {
holdButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
toggleHold();
}
});
muteButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
toggleMute();
}
});
transferButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
TransferManager ui = new TransferManager();
final String number = ui.getNumber(SparkManager.getChatManager().getChatContainer().getChatFrame());
if (ModelUtil.hasLength(number)) {
setStatus(PhoneRes.getIString("phone.transferring") + "...", blueColor);
historyPanel.transferring();
SwingWorker transferringThread = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}
public void finished() {
setStatus(PhoneRes.getIString("phone.transfered"), blueColor);
historyPanel.transfer(number);
callWasTransferred = true;
softPhone.handleTransfer(getActiveCall().getID(), number);
callEnded();
}
};
transferringThread.start();
}
}
});
final SoftPhoneManager manager = SoftPhoneManager.getInstance();
hangUpButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
manager.getDefaultGuiManager().hangup(activeCall);
hangUpButton.setEnabled(false);
muteButton.setButtonSelected(false);
holdButton.setButtonSelected(false);
}
});
redialButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
manager.getDefaultGuiManager().dial(activeCall.getCall().getNumber());
redialButton.setVisible(false);
hangUpButton.setVisible(true);
}
});
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class RosterMemberPanel method setupDefaults.
public void setupDefaults() {
holdButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
toggleHold();
}
});
muteButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
toggleMute();
}
});
transferButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
TransferManager ui = new TransferManager();
final String number = ui.getNumber(SparkManager.getChatManager().getChatContainer().getChatFrame());
if (ModelUtil.hasLength(number)) {
setStatus("Transferring...", blueColor);
historyPanel.transferring();
SwingWorker transferringThread = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}
public void finished() {
setStatus("Transferred", blueColor);
historyPanel.transfer(number);
callWasTransferred = true;
softPhone.handleTransfer(getActiveCall().getID(), number);
callEnded();
}
};
transferringThread.start();
}
}
});
final SoftPhoneManager manager = SoftPhoneManager.getInstance();
hangUpButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
manager.getDefaultGuiManager().hangup(activeCall);
hangUpButton.setEnabled(false);
}
});
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class CallManager method interlocutorRemoved.
public void interlocutorRemoved(final InterlocutorUI interlocutorUI) {
if (softPhone.getInterlocutors().size() == 0) {
if (offPhonePresence == null) {
// Set user to available when all phone calls are hung up.
Presence availablePresence = new Presence(Presence.Type.available, "Online", 1, Presence.Mode.available);
SparkManager.getSessionManager().changePresence(availablePresence);
} else {
// Set user presence to last one choosed
SparkManager.getSessionManager().changePresence(offPhonePresence);
}
offPhonePresence = null;
}
final SwingWorker delay = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}
public void finished() {
String phoneNumber = interlocutorUI.getCall().getNumber();
phoneNumber = SoftPhoneManager.getNumbersFromPhone(phoneNumber);
final PhonePanel phonePanel = calls.get(phoneNumber);
if (phonePanel == null) {
return;
}
for (ChatRoom room : SparkManager.getChatManager().getChatContainer().getChatRooms()) {
Component comp = room.getSplitPane().getRightComponent();
if (comp != null && comp instanceof PhonePanel) {
final PhonePanel cp = (PhonePanel) comp;
if (cp == phonePanel) {
room.getSplitPane().setRightComponent(null);
removePhonePanel(cp);
// Remove state mapping
softPhone.removeCallSession(room);
SparkManager.getChatManager().notifySparkTabHandlers(room);
}
return;
}
}
}
};
delay.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class SoftPhonePlugin method initialize.
/**
* Called after Spark is loaded to initialize the new plugin. Load
* Configuration from VCard and Instantiate a SoftPhoneManager
*/
public void initialize() {
final SwingWorker initializeThread = new SwingWorker() {
public Object construct() {
PhoneManager.getInstance();
softPhone = SoftPhoneManager.getInstance();
return true;
}
public void finished() {
if (softPhone.isPhoneEnabled()) {
// Add TabHandler
SparkManager.getChatManager().addSparkTabHandler(new SoftPhoneTabHandler());
initializeUI();
}
SipCodecsPreference preference = new SipCodecsPreference();
SparkManager.getPreferenceManager().addPreference(preference);
preference.load();
}
};
initializeThread.start();
}
use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.
the class JoinConferenceRoomDialog method joinRoom.
public void joinRoom(final String roomJID, final String roomName) {
final LocalPreferences pref = SettingsManager.getLocalPreferences();
// Set default nickname
nicknameField.setText(pref.getNickname());
// Enable password field if a password is required
passwordField.setVisible(false);
passwordLabel.setVisible(false);
roomNameDescription.setText(roomName);
final JOptionPane pane;
TitlePanel titlePanel;
// Create the title panel for this dialog
titlePanel = new TitlePanel(Res.getString("title.join.conference.room"), Res.getString("message.specify.information.for.conference"), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), true);
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
Object[] options = { Res.getString("join"), Res.getString("cancel") };
pane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(pane, BorderLayout.CENTER);
final JOptionPane p = new JOptionPane();
final JDialog dlg = p.createDialog(SparkManager.getMainWindow(), Res.getString("title.conference.rooms"));
dlg.setModal(false);
dlg.pack();
dlg.setSize(350, 250);
dlg.setResizable(true);
dlg.setContentPane(mainPanel);
dlg.setLocationRelativeTo(SparkManager.getMainWindow());
PropertyChangeListener changeListener = e -> {
String value = (String) pane.getValue();
if (Res.getString("cancel").equals(value)) {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
dlg.dispose();
} else if (Res.getString("join").equals(value)) {
pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
dlg.dispose();
ConferenceUtils.joinConferenceOnSeperateThread(roomName, roomJID, null);
}
};
pane.addPropertyChangeListener(changeListener);
dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
SwingWorker worker = new SwingWorker() {
boolean requiresPassword;
public Object construct() {
requiresPassword = ConferenceUtils.isPasswordRequired(roomJID);
return requiresPassword;
}
public void finished() {
passwordField.setVisible(requiresPassword);
passwordLabel.setVisible(requiresPassword);
}
};
worker.start();
}
Aggregations