Source code: org/mitre/cvw/CVWGroupCommDialog.java
1 /*
2 * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3 * All rights reserved.
4 * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5 */
6
7 package org.mitre.cvw;
8
9 import javax.swing.*;
10 import java.awt.*;
11 import java.awt.event.*;
12 import java.util.Vector;
13
14 /**
15 * Opens a dialog to allow communciaton to a group
16 * @version 1.0 10/98
17 * @author Rich Taylor
18 * @author Deb Ercolini
19 */
20 public class CVWGroupCommDialog extends CVWCommFrame {
21
22 protected GridBagLayout gbl = new GridBagLayout();
23 JCheckBox listenersOnlyCkBox;
24
25 /**
26 * Constructor
27 *
28 * @param appletFrame The frame to display the dialog in.
29 * @param obj The group object
30 * @param <code>true</code> if the default command is private say
31 * <p><code>false</code> if the default command is popup
32 */
33 CVWGroupCommDialog(Container par, CVWObject obj, int cmd) {
34 super(par, obj, cmd);
35 }
36
37 /**
38 * Initializes the dialog
39 */
40 public void init() {
41 super.init();
42 this.setTitle("Communication to Group");
43
44 listenersOnlyCkBox = new JCheckBox("Only send to available users", true);
45
46 constrain(this, listenersOnlyCkBox, 1, 1, 2, 1,
47 GridBagConstraints.NONE, GridBagConstraints.WEST,
48 0.5, 0.0, 2, 5, 10, 5, 0, 0);
49 cmdEntry.personFieldSetEnabled(false);
50
51 }
52
53 private void addWindowToMgr() {
54 WindowMgr.getWindowMgr().addObjectWindow(WindowMgr.OBJECT, this, cvwObj.getObjNum());
55 }
56
57 /**
58 * Returns the vector of CVWCommands that are allowed for this CmdEntryPanel container.
59 *
60 * @return the vector of CVWCommands to be displayed.
61 *
62 * @see CVWCommmand
63 */
64 public Vector getCmdChoiceMenuItems() {
65 Vector v = new Vector(2);
66 v.addElement(new Integer(CVWCommand.SAY_PRIVATE));
67 v.addElement(new Integer(CVWCommand.PAGE));
68 return v;
69 }
70
71 /**
72 * Creates the appriprate MCP to send to the CVWServer as entered in the CmdEntryPanel.
73 * Invoked when the user hits the send button or the return key.
74 *
75 * @param cvwCmd the intetger of the current CVWCommand
76 * @see org.mitre.cvw.CVWCommand
77 */
78 public void sendCommand(int cvwCmd) {
79 String msg = cmdEntry.mudEntryGetText();
80 String cmd = "to: " + cvwObj.objNum.strValue();
81 cmd += " type: \"group page\" level: " ;
82 if (cvwCmd == CVWCommand.PAGE)
83 cmd += "h";
84 else
85 cmd += "m";
86
87 cmd += " store_msg: ";
88 if (listenersOnlyCkBox.isSelected())
89 cmd += "0";
90 else
91 cmd += "1"; //all listeners
92
93 cmd += " text: " + "\"" + msg + "\"";
94 CVWServerComm.sendMCPCmdToServer("#$#cvw-text", cmd);
95
96 if (!retainWindowCkBox.isSelected()) {
97 WindowMgr.getWindowMgr().removeObjectWindow((Window)this, cvwObj.getObjNum());
98 dispose();
99 } else {
100 cmdEntry.mudEntrySetText("");
101 }
102 return;
103 }
104
105 }
106