mirror of
https://github.com/igniterealtime/Spark.git
synced 2026-08-18 11:10:02 +00:00
Updating conference invites.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@5000 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -21,6 +21,8 @@ import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow;
|
||||
import org.jivesoftware.smackx.packet.DelayInformation;
|
||||
import org.jivesoftware.spark.component.VerticalFlowLayout;
|
||||
import org.jivesoftware.spark.component.panes.CollapsiblePane;
|
||||
import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane;
|
||||
import org.jivesoftware.spark.filetransfer.SparkTransferManager;
|
||||
import org.jivesoftware.spark.search.SearchManager;
|
||||
@ -41,9 +43,11 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
@ -81,12 +85,14 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
private static final Object LOCK = new Object();
|
||||
private List offlineMessages = new ArrayList();
|
||||
|
||||
|
||||
private JPanel cardPanel;
|
||||
private CardLayout cardLayout;
|
||||
|
||||
final public static String WORKSPACE_PANE = "WORKSPACE_PANE";
|
||||
|
||||
private final CollapsiblePane alerts = new CollapsiblePane();
|
||||
private final JPanel alertPanel = new JPanel();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of <CODE>Workspace</CODE>,
|
||||
@ -149,10 +155,18 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
cardPanel.setOpaque(false);
|
||||
cardPanel.add(WORKSPACE_PANE, this);
|
||||
|
||||
// Setup alert Panel
|
||||
alertPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
|
||||
alertPanel.setBackground((Color)UIManager.get("List.background"));
|
||||
|
||||
alerts.setContentPane(alertPanel);
|
||||
alerts.getTitlePane().setVisible(false);
|
||||
|
||||
// Build default workspace
|
||||
this.setLayout(new GridBagLayout());
|
||||
add(workspacePane, new GridBagConstraints(0, 9, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
|
||||
add(statusBox, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
|
||||
add(alerts, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
|
||||
|
||||
|
||||
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F12"), "showDebugger");
|
||||
@ -164,7 +178,6 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
});
|
||||
|
||||
// Set background
|
||||
Color menuBarColor = new Color(235, 233, 237);
|
||||
setBackground(Color.white);
|
||||
}
|
||||
|
||||
@ -397,6 +410,34 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
chatRoom.getChatInputEditor().requestFocusInWindow();
|
||||
}
|
||||
|
||||
public void addAlert(Component comp) {
|
||||
alertPanel.add(comp);
|
||||
|
||||
int comps = alertPanel.getComponentCount();
|
||||
alerts.getTitlePane().setVisible(true);
|
||||
alerts.setTitle("Alerts (" + comps + ")");
|
||||
|
||||
alertPanel.invalidate();
|
||||
alertPanel.validate();
|
||||
alertPanel.repaint();
|
||||
}
|
||||
|
||||
public void removeAlert(Component comp) {
|
||||
alertPanel.remove(comp);
|
||||
|
||||
int comps = alertPanel.getComponentCount();
|
||||
if (comps == 0) {
|
||||
alerts.getTitlePane().setVisible(false);
|
||||
}
|
||||
else {
|
||||
alerts.setTitle("Alerts (" + comps + ")");
|
||||
}
|
||||
|
||||
invalidate();
|
||||
validate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Workspace TabbedPane. If you wish to add your
|
||||
@ -425,4 +466,8 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
public JPanel getCardPanel() {
|
||||
return cardPanel;
|
||||
}
|
||||
|
||||
public JPanel getAlertPanel() {
|
||||
return alertPanel;
|
||||
}
|
||||
}
|
||||
@ -110,6 +110,15 @@ public class CollapsibleTitlePane extends JPanel {
|
||||
|
||||
}
|
||||
|
||||
public void setStartColor(Color color) {
|
||||
// Initialize color
|
||||
startColor = color;
|
||||
}
|
||||
|
||||
public void setEndColor(Color color) {
|
||||
endColor = color;
|
||||
}
|
||||
|
||||
public void setIcon(Icon icon) {
|
||||
titleLabel.setIcon(icon);
|
||||
}
|
||||
|
||||
@ -115,8 +115,11 @@ public class Conferences {
|
||||
}
|
||||
|
||||
// If no listeners handled the invitation, default to generic invite.
|
||||
final InvitationDialog inviteDialog = new InvitationDialog();
|
||||
inviteDialog.invitationReceived(conn, room, inviter, reason, password, message);
|
||||
final InvitationUI inviteDialog = new InvitationUI(conn, room, inviter, reason, password, message);
|
||||
SparkManager.getWorkspace().addAlert(inviteDialog);
|
||||
|
||||
// Alert if necessary
|
||||
SparkManager.getAlertManager().flashWindow(SparkManager.getMainWindow());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
123
src/java/org/jivesoftware/spark/ui/conferences/InvitationUI.java
Normal file
123
src/java/org/jivesoftware/spark/ui/conferences/InvitationUI.java
Normal file
@ -0,0 +1,123 @@
|
||||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
|
||||
* This software is the proprietary information of Jive Software. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.spark.ui.conferences;
|
||||
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChat;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.component.RolloverButton;
|
||||
import org.jivesoftware.spark.component.WrappedLabel;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class InvitationUI extends JPanel implements ActionListener {
|
||||
|
||||
private RolloverButton joinButton;
|
||||
private RolloverButton declineButton;
|
||||
|
||||
private String roomName;
|
||||
private String password;
|
||||
private String inviter;
|
||||
|
||||
private Image backgroundImage;
|
||||
|
||||
|
||||
public InvitationUI(XMPPConnection conn, final String roomName, final String inviter, String reason, final String password, Message message) {
|
||||
this.roomName = roomName;
|
||||
this.password = password;
|
||||
this.inviter = inviter;
|
||||
|
||||
backgroundImage = Default.getImageIcon(Default.TOP_BOTTOM_BACKGROUND_IMAGE).getImage();
|
||||
|
||||
// Set Layout
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
// Build UI
|
||||
final JLabel titleLabel = new JLabel();
|
||||
final WrappedLabel description = new WrappedLabel();
|
||||
|
||||
final JLabel dateLabel = new JLabel();
|
||||
final JLabel dateLabelValue = new JLabel();
|
||||
|
||||
add(description, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 9, 2, 5), 0, 0));
|
||||
add(titleLabel, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
|
||||
add(dateLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
|
||||
add(dateLabelValue, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
|
||||
|
||||
|
||||
titleLabel.setFont(new Font("dialog", Font.BOLD, 11));
|
||||
description.setFont(new Font("dialog", 0, 10));
|
||||
|
||||
titleLabel.setText("Conference Invitation from " + inviter);
|
||||
description.setText(reason);
|
||||
|
||||
// Set Date Label
|
||||
dateLabel.setFont(new Font("dialog", Font.BOLD, 11));
|
||||
dateLabel.setText("Received:");
|
||||
final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
|
||||
final String date = formatter.format(new Date());
|
||||
dateLabelValue.setText(date);
|
||||
|
||||
// Add accept and reject buttons
|
||||
joinButton = new RolloverButton("Join", null);
|
||||
declineButton = new RolloverButton("Decline", null);
|
||||
|
||||
// Add Button Panel
|
||||
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
buttonPanel.setOpaque(false);
|
||||
buttonPanel.add(joinButton);
|
||||
buttonPanel.add(declineButton);
|
||||
add(buttonPanel, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
|
||||
|
||||
|
||||
joinButton.addActionListener(this);
|
||||
declineButton.addActionListener(this);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
final Object obj = actionEvent.getSource();
|
||||
if (obj == joinButton) {
|
||||
String name = StringUtils.parseName(roomName);
|
||||
ConferenceUtils.autoJoinConferenceRoom(name, roomName, password);
|
||||
}
|
||||
else {
|
||||
MultiUserChat.decline(SparkManager.getConnection(), roomName, inviter, "No thank you");
|
||||
}
|
||||
|
||||
SparkManager.getWorkspace().removeAlert(this);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
double scaleX = getWidth() / (double)backgroundImage.getWidth(null);
|
||||
double scaleY = getHeight() / (double)backgroundImage.getHeight(null);
|
||||
AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY);
|
||||
((Graphics2D)g).drawImage(backgroundImage, xform, this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user