diff options
author | hristoterezov <hristo@jitsi.org> | 2014-02-12 18:06:52 +0200 |
---|---|---|
committer | hristoterezov <hristo@jitsi.org> | 2014-02-12 18:06:52 +0200 |
commit | 5810b3199bcd988f273564714ed174e2ef70b686 (patch) | |
tree | e5ff7972951ab8701f4670dc3421391693007fdc /src/net/java/sip/communicator/plugin/desktoputil | |
parent | 5d36831f2255b97c20baabe72760030df746289d (diff) | |
download | jitsi-5810b3199bcd988f273564714ed174e2ef70b686.zip jitsi-5810b3199bcd988f273564714ed174e2ef70b686.tar.gz jitsi-5810b3199bcd988f273564714ed174e2ef70b686.tar.bz2 |
Implements destroy chat room functionality. Adds destroy chat room button and right hand menu item.
Diffstat (limited to 'src/net/java/sip/communicator/plugin/desktoputil')
-rw-r--r-- | src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java new file mode 100644 index 0000000..d537184 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java @@ -0,0 +1,147 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.desktoputil.chat;
+
+import java.awt.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+
+/**
+ * Dialog with fields for reason and alternate address.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomDestroyReasonDialog extends MessageDialog
+{
+ /**
+ * Serial id.
+ */
+ private static final long serialVersionUID = -916498752420264164L;
+
+ /**
+ * Text field for the alternate address.
+ */
+ private SIPCommTextField alternateAddress
+ = new SIPCommTextField("chatroom@example.com");
+
+ /**
+ * Text field for reason text.
+ */
+ private JTextField reasonField = new JTextField();
+
+ /**
+ * Constructs new chat room destroy dialog.
+ *
+ * @param title the title of the dialog
+ * @param message the message shown in this dialog
+ */
+ public ChatRoomDestroyReasonDialog(String title, String message)
+ {
+ super(null, title, message,
+ DesktopUtilActivator.getResources().getI18NString("service.gui.OK"),
+ false);
+ this.setIcon((ImageIcon)null);
+
+ alternateAddress.setFont(alternateAddress.getFont().deriveFont(12f));
+
+ JLabel altAddressLabel
+ = new JLabel(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.ALTERNATE_ADDRESS") + ":");
+
+ JLabel reasonLabel
+ = new JLabel(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.REASON") + ":");
+
+ JPanel labelsPanel = new JPanel(new GridLayout(2, 1));
+ labelsPanel.add(reasonLabel);
+ labelsPanel.add(altAddressLabel);
+
+ JPanel valuesPanel = new JPanel(new GridLayout(2, 1));
+ valuesPanel.add(reasonField);
+ valuesPanel.add(alternateAddress);
+
+ JPanel fieldsPanel = new JPanel(new BorderLayout());
+ fieldsPanel .add(labelsPanel, BorderLayout.WEST);
+
+ fieldsPanel.add(valuesPanel, BorderLayout.CENTER);
+ fieldsPanel.add(new JLabel(" "), BorderLayout.EAST);
+ fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ fieldsPanel.setOpaque(false);
+
+
+
+ replaceCheckBoxPanel(fieldsPanel);
+ this.pack();
+ }
+
+ /**
+ * Returns the text entered in the alternate address field.
+ *
+ * @return the text from the alternate address field.
+ */
+ public String getAlternateAddress()
+ {
+ return alternateAddress.getText();
+ }
+
+ /**
+ * Returns the text entered in the reason field.
+ *
+ * @return the text from the reason field.
+ */
+ public String getReason()
+ {
+ return reasonField.getText();
+ }
+
+ /**
+ * Opens a dialog with a fields for the reason and alternate address and
+ * returns them.
+ *
+ * @return array with the reason and alternate address values.
+ */
+ public static String[] getDestroyOptions()
+ {
+ ChatRoomDestroyReasonDialog reasonDialog =
+ new ChatRoomDestroyReasonDialog(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.DESTROY_CHATROOM"),
+ DesktopUtilActivator.getResources().getI18NString(
+ "service.gui.DESTROY_MESSAGE"));
+
+ int result = reasonDialog.showDialog();
+
+ String destroyOptions[] = new String[2];
+
+ if (result == MessageDialog.OK_RETURN_CODE)
+ {
+ destroyOptions[0] = proccessFieldValues(reasonDialog.getReason());
+ destroyOptions[1]
+ = proccessFieldValues(reasonDialog.getAlternateAddress());
+ }
+ else
+ {
+ destroyOptions = null;
+ }
+
+
+ return destroyOptions;
+ }
+
+ private static String proccessFieldValues(String value)
+ {
+ if(value != null)
+ {
+ value = value.trim();
+ if(value.equals(""))
+ value = null;
+ }
+ return value;
+ }
+
+}
|