mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Fix right-click in Tabs.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@4884 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -21,7 +21,6 @@ import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.Form;
|
||||
import org.jivesoftware.smackx.MessageEventNotificationListener;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChat;
|
||||
import org.jivesoftware.spark.component.tabbedPane.SparkTab;
|
||||
import org.jivesoftware.spark.ui.ChatContainer;
|
||||
import org.jivesoftware.spark.ui.ChatRoom;
|
||||
import org.jivesoftware.spark.ui.ChatRoomListener;
|
||||
@ -37,20 +36,15 @@ import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.preference.chat.ChatPreference;
|
||||
import org.jivesoftware.sparkimpl.preference.chat.ChatPreferences;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* Handles the Chat Management of each individual <code>Workspace</code>. The ChatManager is responsible
|
||||
@ -109,9 +103,6 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
}
|
||||
}
|
||||
}, new PacketTypeFilter(Message.class));
|
||||
|
||||
// Start timeout
|
||||
checkRoomsForTimeout();
|
||||
}
|
||||
|
||||
|
||||
@ -414,29 +405,4 @@ public class ChatManager implements MessageEventNotificationListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks every room every 30 seconds to see if it's timed out.
|
||||
*/
|
||||
private void checkRoomsForTimeout() {
|
||||
int delay = 60000; // delay for 1 minute
|
||||
int period = 30000; // repeat every 30 seconds.
|
||||
Timer timer = new Timer();
|
||||
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
public void run() {
|
||||
for (ChatRoom chatRoom : getChatContainer().getStaleChatRooms()) {
|
||||
// Turn tab gray
|
||||
int index = getChatContainer().indexOfComponent(chatRoom);
|
||||
SparkTab tab = getChatContainer().getTabAt(index);
|
||||
|
||||
final JLabel titleLabel = tab.getTitleLabel();
|
||||
titleLabel.setForeground(Color.gray);
|
||||
titleLabel.validate();
|
||||
titleLabel.repaint();
|
||||
}
|
||||
}
|
||||
}, delay, period);
|
||||
}
|
||||
|
||||
}
|
||||
@ -83,10 +83,7 @@ public class SparkTab extends TabPanel {
|
||||
if (boldWhenActive && selected) {
|
||||
textLabel.setFont(textLabel.getFont().deriveFont(Font.BOLD));
|
||||
}
|
||||
else if (!selected && boldWhenActive) {
|
||||
textLabel.setFont(defaultFont);
|
||||
}
|
||||
else if(selected){
|
||||
else if(boldWhenActive && !selected){
|
||||
textLabel.setFont(defaultFont);
|
||||
}
|
||||
|
||||
@ -94,6 +91,10 @@ public class SparkTab extends TabPanel {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public Font getDefaultFont(){
|
||||
return defaultFont;
|
||||
}
|
||||
|
||||
public JLabel getTitleLabel() {
|
||||
return textLabel;
|
||||
}
|
||||
|
||||
@ -14,6 +14,13 @@ import org.jivesoftware.resource.SparkRes;
|
||||
import org.jivesoftware.spark.component.RolloverButton;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Component;
|
||||
@ -34,13 +41,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -82,7 +82,7 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
tabs = new JPanel(new
|
||||
FlowLayout(FlowLayout.LEFT, 0, 0)) {
|
||||
FlowLayout(FlowLayout.LEFT, 0, 0)) {
|
||||
public Dimension getPreferredSize() {
|
||||
if (getParent() == null)
|
||||
return getPreferredSize();
|
||||
@ -399,7 +399,10 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
if (e.getSource() instanceof SparkTab) {
|
||||
SparkTab tab = (SparkTab)e.getSource();
|
||||
setSelectedTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedTab(SparkTab tab) {
|
||||
@ -413,14 +416,7 @@ public class SparkTabbedPane extends JPanel implements MouseListener {
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if(e.isPopupTrigger()){
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getSource() instanceof SparkTab) {
|
||||
SparkTab tab = (SparkTab)e.getSource();
|
||||
setSelectedTab(tab);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
@ -34,6 +34,20 @@ import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
@ -52,20 +66,8 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* Contains all <code>ChatRoom</code> objects within Spark.
|
||||
@ -616,6 +618,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
}
|
||||
|
||||
public void messageSent(ChatRoom room, Message message) {
|
||||
useTabDefault(room);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -702,7 +705,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
}
|
||||
|
||||
final int ok = JOptionPane.showConfirmDialog(SparkManager.getMainWindow(), message,
|
||||
"Confirmation", JOptionPane.YES_NO_OPTION);
|
||||
"Confirmation", JOptionPane.YES_NO_OPTION);
|
||||
if (ok == JOptionPane.OK_OPTION) {
|
||||
room.closeChatRoom();
|
||||
return;
|
||||
@ -908,19 +911,21 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
}
|
||||
|
||||
public void useTabDefault(final ChatRoom room) {
|
||||
// Check if room is stale
|
||||
boolean containsRoom = getStaleChatRooms().contains(room);
|
||||
if (containsRoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int index = indexOfComponent(room);
|
||||
if (index != -1) {
|
||||
SparkTab tab = getTabAt(index);
|
||||
Font defaultFont = tab.getDefaultFont();
|
||||
|
||||
final JLabel titleLabel = tab.getTitleLabel();
|
||||
|
||||
Font font = titleLabel.getFont();
|
||||
titleLabel.setForeground(Color.black);
|
||||
|
||||
Font newFont = font.deriveFont(Font.PLAIN);
|
||||
titleLabel.setFont(newFont);
|
||||
titleLabel.validate();
|
||||
titleLabel.repaint();
|
||||
titleLabel.setFont(defaultFont);
|
||||
}
|
||||
}
|
||||
|
||||
@ -990,6 +995,9 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Start timer
|
||||
checkRoomsForTimeout();
|
||||
}
|
||||
|
||||
|
||||
@ -1072,15 +1080,6 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
LocalPreferences pref = SettingsManager.getLocalPreferences();
|
||||
int timeoutMinutes = pref.getChatLengthDefaultTimeout();
|
||||
|
||||
try {
|
||||
ChatRoom activeChatRoom = getActiveChatRoom();
|
||||
if (activeChatRoom == chatRoom) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (ChatRoomNotFoundException e) {
|
||||
}
|
||||
|
||||
if (timeoutMinutes <= minutes) {
|
||||
staleRooms.add(chatRoom);
|
||||
}
|
||||
@ -1130,7 +1129,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
|
||||
Action closeOldAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
for(ChatRoom rooms : getStaleChatRooms()){
|
||||
for (ChatRoom rooms : getStaleChatRooms()) {
|
||||
closeTab(rooms);
|
||||
}
|
||||
}
|
||||
@ -1145,4 +1144,29 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks every room every 30 seconds to see if it's timed out.
|
||||
*/
|
||||
private void checkRoomsForTimeout() {
|
||||
int delay = 1000; // delay for 1 minute
|
||||
int period = 60000; // repeat every 30 seconds.
|
||||
Timer timer = new Timer();
|
||||
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
public void run() {
|
||||
for (ChatRoom chatRoom : getStaleChatRooms()) {
|
||||
// Turn tab gray
|
||||
int index = indexOfComponent(chatRoom);
|
||||
SparkTab tab = getTabAt(index);
|
||||
|
||||
final JLabel titleLabel = tab.getTitleLabel();
|
||||
titleLabel.setForeground(Color.gray);
|
||||
titleLabel.setFont(tab.getDefaultFont());
|
||||
titleLabel.validate();
|
||||
titleLabel.repaint();
|
||||
}
|
||||
}
|
||||
}, delay, period);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -301,6 +301,8 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
* @param message the message to send.
|
||||
*/
|
||||
public void sendMessage(Message message) {
|
||||
lastActivity = System.currentTimeMillis();
|
||||
|
||||
// Check to see if the user is online to recieve this message.
|
||||
RosterEntry entry = roster.getEntry(participantJID);
|
||||
if (presence == null && !offlineSent && entry != null) {
|
||||
@ -345,8 +347,6 @@ public class ChatRoomImpl extends ChatRoom {
|
||||
catch (Exception ex) {
|
||||
Log.error("Error sending message", ex);
|
||||
}
|
||||
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getRoomname() {
|
||||
|
||||
Reference in New Issue
Block a user