mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Fix NPE in ChatRoom
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@4946 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -118,6 +118,7 @@ public final class InputDialog implements PropertyChangeListener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
textArea.requestFocus();
|
textArea.requestFocus();
|
||||||
|
textArea.setWrapStyleWord(true);
|
||||||
|
|
||||||
|
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|||||||
@ -25,6 +25,7 @@ public class PublicPlugin {
|
|||||||
private boolean readMeAvailable;
|
private boolean readMeAvailable;
|
||||||
private boolean smallIconAvailable;
|
private boolean smallIconAvailable;
|
||||||
private boolean largeIconAvailable;
|
private boolean largeIconAvailable;
|
||||||
|
private String minVersion;
|
||||||
|
|
||||||
private File pluginDir;
|
private File pluginDir;
|
||||||
|
|
||||||
@ -131,4 +132,12 @@ public class PublicPlugin {
|
|||||||
public void setLargeIconAvailable(boolean largeIconAvailable) {
|
public void setLargeIconAvailable(boolean largeIconAvailable) {
|
||||||
this.largeIconAvailable = largeIconAvailable;
|
this.largeIconAvailable = largeIconAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMinVersion() {
|
||||||
|
return minVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinVersion(String minVersion) {
|
||||||
|
this.minVersion = minVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,7 @@ import java.awt.Component;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
@ -179,6 +180,19 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
KeyStroke appleStroke = KeyStroke.getKeyStroke(Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), 0);
|
||||||
|
String appleString = org.jivesoftware.spark.util.StringUtils.keyStroke2String(appleStroke);
|
||||||
|
|
||||||
|
// Handle Apple Key W
|
||||||
|
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(appleString + "w"), "appleStroke");
|
||||||
|
this.getActionMap().put("appleStroke", new AbstractAction("appleStroke") {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
closeActiveRoom();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1213,6 +1227,10 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
|||||||
for (ChatRoom chatRoom : getStaleChatRooms()) {
|
for (ChatRoom chatRoom : getStaleChatRooms()) {
|
||||||
// Turn tab gray
|
// Turn tab gray
|
||||||
int index = indexOfComponent(chatRoom);
|
int index = indexOfComponent(chatRoom);
|
||||||
|
if (index == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SparkTab tab = getTabAt(index);
|
SparkTab tab = getTabAt(index);
|
||||||
|
|
||||||
final JLabel titleLabel = tab.getTitleLabel();
|
final JLabel titleLabel = tab.getTitleLabel();
|
||||||
|
|||||||
@ -25,25 +25,6 @@ import org.jivesoftware.spark.util.log.Log;
|
|||||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@ -64,6 +45,25 @@ import javax.swing.event.DocumentListener;
|
|||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
import javax.swing.text.Document;
|
import javax.swing.text.Document;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of all ChatRoom conversations. You would implement this class to have most types of Chat.
|
* The base implementation of all ChatRoom conversations. You would implement this class to have most types of Chat.
|
||||||
*/
|
*/
|
||||||
@ -244,7 +244,7 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener
|
|||||||
getChatInputEditor().getActionMap().put("closeTheRoom", new AbstractAction("closeTheRoom") {
|
getChatInputEditor().getActionMap().put("closeTheRoom", new AbstractAction("closeTheRoom") {
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
final int ok = JOptionPane.showConfirmDialog(SparkManager.getMainWindow(), "Would you like to close this chat?",
|
final int ok = JOptionPane.showConfirmDialog(SparkManager.getMainWindow(), "Would you like to close this chat?",
|
||||||
"Confirmation", JOptionPane.YES_NO_OPTION);
|
"Confirmation", JOptionPane.YES_NO_OPTION);
|
||||||
if (ok == JOptionPane.OK_OPTION) {
|
if (ok == JOptionPane.OK_OPTION) {
|
||||||
// Leave this chat.
|
// Leave this chat.
|
||||||
closeChatRoom();
|
closeChatRoom();
|
||||||
@ -353,8 +353,13 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener
|
|||||||
int chatLength = transcriptWindow.getDocument().getLength();
|
int chatLength = transcriptWindow.getDocument().getLength();
|
||||||
transcriptWindow.setCaretPosition(chatLength);
|
transcriptWindow.setCaretPosition(chatLength);
|
||||||
|
|
||||||
JScrollBar sb = textScroller.getVerticalScrollBar();
|
try {
|
||||||
sb.setValue(sb.getMaximum());
|
JScrollBar sb = textScroller.getVerticalScrollBar();
|
||||||
|
sb.setValue(sb.getMaximum());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Log.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -421,7 +426,7 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener
|
|||||||
private void checkForEnter(KeyEvent e) {
|
private void checkForEnter(KeyEvent e) {
|
||||||
final KeyStroke keyStroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
|
final KeyStroke keyStroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
|
||||||
if (!keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)) &&
|
if (!keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)) &&
|
||||||
e.getKeyChar() == KeyEvent.VK_ENTER) {
|
e.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||||
e.consume();
|
e.consume();
|
||||||
sendMessage();
|
sendMessage();
|
||||||
getChatInputEditor().setText("");
|
getChatInputEditor().setText("");
|
||||||
|
|||||||
Reference in New Issue
Block a user