mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
Added reconnection support. SMACK-172
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@5367 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
96e4201f61
commit
3af86fd462
22 changed files with 501 additions and 194 deletions
|
@ -218,6 +218,30 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
});
|
||||
|
||||
}
|
||||
public void reconnectingIn(final int seconds){
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
statusField.setValue("Attempt to reconnect in " + seconds + " seconds");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reconectionSuccessful() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
statusField.setValue("Reconnection stablished");
|
||||
EnhancedDebuggerWindow.connectionEstablished(EnhancedDebugger.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reconnectionFailed(Exception e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
statusField.setValue("Reconnection failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -551,7 +575,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
connPanel.add(
|
||||
label,
|
||||
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
|
||||
field = new JFormattedTextField(new Integer(connection.getPort()));
|
||||
field = new JFormattedTextField(connection.getPort());
|
||||
field.setMinimumSize(new java.awt.Dimension(150, 20));
|
||||
field.setMaximumSize(new java.awt.Dimension(150, 20));
|
||||
field.setEditable(false);
|
||||
|
@ -618,16 +642,9 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
packetsPanel.setBorder(BorderFactory.createTitledBorder("Transmitted Packets"));
|
||||
|
||||
statisticsTable =
|
||||
new DefaultTableModel(new Object[][]{{"IQ", new Integer(0), new Integer(0)}, {
|
||||
"Message", new Integer(0), new Integer(0)
|
||||
}, {
|
||||
"Presence", new Integer(0), new Integer(0)
|
||||
}, {
|
||||
"Other", new Integer(0), new Integer(0)
|
||||
}, {
|
||||
"Total", new Integer(0), new Integer(0)
|
||||
}
|
||||
}, new Object[]{"Type", "Received", "Sent"}) {
|
||||
new DefaultTableModel(new Object[][]{{"IQ", 0, 0}, {"Message", 0, 0},
|
||||
{"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}},
|
||||
new Object[]{"Type", "Received", "Sent"}) {
|
||||
public boolean isCellEditable(int rowIndex, int mColIndex) {
|
||||
return false;
|
||||
}
|
||||
|
@ -719,7 +736,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
String messageType = null;
|
||||
String messageType;
|
||||
String from = packet.getFrom();
|
||||
String type = "";
|
||||
Icon packetTypeIcon;
|
||||
|
@ -780,7 +797,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
String messageType = null;
|
||||
String messageType;
|
||||
String to = packet.getTo();
|
||||
String type = "";
|
||||
Icon packetTypeIcon;
|
||||
|
@ -840,9 +857,10 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
// Surround this setting in a try/catch for compatibility with Java 1.4. This setting is required
|
||||
// for Java 1.5
|
||||
try {
|
||||
tFactory.setAttribute("indent-number", new Integer(2));
|
||||
tFactory.setAttribute("indent-number", 2);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// Ignore
|
||||
}
|
||||
Transformer transformer = tFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.awt.event.*;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
|
@ -90,7 +89,7 @@ public class EnhancedDebuggerWindow {
|
|||
|
||||
private JFrame frame = null;
|
||||
private JTabbedPane tabbedPane = null;
|
||||
private java.util.List debuggers = new ArrayList();
|
||||
private java.util.List<EnhancedDebugger> debuggers = new ArrayList<EnhancedDebugger>();
|
||||
|
||||
private EnhancedDebuggerWindow() {
|
||||
}
|
||||
|
@ -178,6 +177,12 @@ public class EnhancedDebuggerWindow {
|
|||
connectionClosedOnErrorIcon);
|
||||
}
|
||||
|
||||
synchronized static void connectionEstablished(EnhancedDebugger debugger) {
|
||||
getInstance().tabbedPane.setIconAt(
|
||||
getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane),
|
||||
connectionActiveIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the main debug window that provides information about Smack and also shows
|
||||
* a tab panel for each connection that is being debugged.
|
||||
|
@ -264,7 +269,7 @@ public class EnhancedDebuggerWindow {
|
|||
if (tabbedPane.getSelectedIndex() < tabbedPane.getComponentCount() - 1) {
|
||||
int index = tabbedPane.getSelectedIndex();
|
||||
// Notify to the debugger to stop debugging
|
||||
EnhancedDebugger debugger = (EnhancedDebugger) debuggers.get(index);
|
||||
EnhancedDebugger debugger = debuggers.get(index);
|
||||
debugger.cancel();
|
||||
// Remove the debugger from the root window
|
||||
tabbedPane.remove(debugger.tabbedPane);
|
||||
|
@ -281,18 +286,17 @@ public class EnhancedDebuggerWindow {
|
|||
menuItem = new JMenuItem("Close All Not Active");
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ArrayList debuggersToRemove = new ArrayList();
|
||||
ArrayList<EnhancedDebugger> debuggersToRemove = new ArrayList<EnhancedDebugger>();
|
||||
// Remove all the debuggers of which their connections are no longer valid
|
||||
for (int index = 0; index < tabbedPane.getComponentCount() - 1; index++) {
|
||||
EnhancedDebugger debugger = (EnhancedDebugger) debuggers.get(index);
|
||||
EnhancedDebugger debugger = debuggers.get(index);
|
||||
if (!debugger.isConnectionActive()) {
|
||||
// Notify to the debugger to stop debugging
|
||||
debugger.cancel();
|
||||
debuggersToRemove.add(debugger);
|
||||
}
|
||||
}
|
||||
for (Iterator it = debuggersToRemove.iterator(); it.hasNext();) {
|
||||
EnhancedDebugger debugger = (EnhancedDebugger) it.next();
|
||||
for (EnhancedDebugger debugger : debuggersToRemove) {
|
||||
// Remove the debugger from the root window
|
||||
tabbedPane.remove(debugger.tabbedPane);
|
||||
debuggers.remove(debugger);
|
||||
|
@ -324,8 +328,7 @@ public class EnhancedDebuggerWindow {
|
|||
*/
|
||||
public void rootWindowClosing(WindowEvent evt) {
|
||||
// Notify to all the debuggers to stop debugging
|
||||
for (Iterator it = debuggers.iterator(); it.hasNext();) {
|
||||
EnhancedDebugger debugger = (EnhancedDebugger) it.next();
|
||||
for (EnhancedDebugger debugger : debuggers) {
|
||||
debugger.cancel();
|
||||
}
|
||||
// Release any reference to the debuggers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue