SPARK-600 Broadcast button in wrong place

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@7593 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-03-19 05:11:09 +00:00
committed by derek
parent 229248f150
commit 532c8f0b50
2 changed files with 33 additions and 12 deletions

View File

@ -177,6 +177,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
// Handle Left Arrow
this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("alt " + leftStrokeString + ""), "navigateLeft");
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("alt " + leftStrokeString + ""), "navigateLeft");
this.getActionMap().put("navigateLeft", new AbstractAction("navigateLeft") {
public void actionPerformed(ActionEvent evt) {
navigateLeft();
@ -188,6 +189,8 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
// Handle Right Arrow
this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("alt " + rightStrokeString + ""), "navigateRight");
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("alt " + rightStrokeString + ""), "navigateRight");
this.getActionMap().put("navigateRight", new AbstractAction("navigateRight") {
public void actionPerformed(ActionEvent evt) {
navigateRight();
@ -195,7 +198,6 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
});
this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("ESCAPE"), "escape");
this.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ESCAPE"), "escape");
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "escape");
this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("Ctrl W"), "escape");

View File

@ -43,16 +43,6 @@ import org.jivesoftware.spark.util.ResourceUtils;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -64,6 +54,17 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
/**
* Handles broadcasts from server and allows for roster wide broadcasts.
*/
@ -158,7 +159,25 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, PacketLi
RolloverButton broadcastToRosterButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
broadcastToRosterButton.setToolTipText(Res.getString("message.send.a.broadcast"));
commandPanel.add(broadcastToRosterButton);
// Regardless of loading time, the broadcast button should be to the left of the seperator.
final Component[] comps = commandPanel.getComponents();
final int no = comps != null ? comps.length : 0;
int indexOfSeperator = -1;
for (int i = 0; i < no; i++) {
Component comp = comps[i];
if (comp instanceof JSeparator) {
indexOfSeperator = i;
break;
}
}
if (indexOfSeperator == -1) {
commandPanel.add(broadcastToRosterButton);
}
else {
commandPanel.add(broadcastToRosterButton, indexOfSeperator - 1);
}
statusBar.invalidate();
statusBar.validate();
statusBar.repaint();