1 package zirc.gui ; 2 3 import java.awt.* ; 4 import java.awt.event.* ; 5 import javax.swing.* ; 6 import javax.swing.event.* ; 7 8 import zirc.base.* ; 9 import java.util.* ; 10 11 24 31 32 public class ActionDialog extends JDialog 33 { 34 private JList JlistAction = new JList() ; 35 private ChatFrame chatFrm; 36 private DefaultListModel lm = new DefaultListModel() ; 37 private IRCconnexion IRCchan ; 38 private String chan ; 39 private JDialog jDialog1 = new JDialog(this) ; 40 private JPanel jPanel1 = new JPanel() ; 41 private JButton jButton_OK = new JButton() ; 42 private JTextField jt_Message = new JTextField() ; 43 private String kickMSG = "" ; 44 private String nick ; 45 private String action ; 46 private JPanel jPanel2 = new JPanel() ; 47 private BorderLayout borderLayout1 = new BorderLayout() ; 48 private BorderLayout borderLayout2 = new BorderLayout() ; 49 50 public ActionDialog(IRCconnexion _IRCchan, String _chan, ChatFrame _chatFrm) 51 { 52 IRCchan = _IRCchan ; 53 chan = _chan ; 54 chatFrm=_chatFrm; 55 try 56 { 57 jbInit() ; 58 } 59 catch (Exception e) 60 { 61 e.printStackTrace() ; 62 } 63 } 64 65 private void jbInit() throws Exception 66 { 67 jDialog1.setSize(new Dimension(150, 107)) ; 68 this.setSize(120, 220) ; 69 JlistAction.setModel(lm) ; 70 JlistAction.addListSelectionListener(new javax.swing.event.ListSelectionListener () 71 { 72 public void valueChanged(ListSelectionEvent e) 73 { 74 JlistAction_valueChanged(e) ; 75 } 76 }) ; 77 this.setResizable(false) ; 78 this.setUndecorated(true) ; 79 this.getContentPane().setLayout(borderLayout2) ; 80 jDialog1.setModal(true) ; 81 jPanel1.setLayout(null) ; 82 jButton_OK.setBounds(new Rectangle(46, 53, 55, 21)) ; 83 jButton_OK.setText("OK") ; 84 jButton_OK.addActionListener(new java.awt.event.ActionListener () 85 { 86 public void actionPerformed(ActionEvent e) 87 { 88 jButton_OK_actionPerformed(e) ; 89 } 90 }) ; 91 jt_Message.setText("") ; 92 jt_Message.setBounds(new Rectangle(4, 21, 141, 25)) ; 93 jPanel2.setLayout(borderLayout1) ; 94 jPanel2.setBorder(BorderFactory.createLineBorder(Color.gray)) ; 95 this.getContentPane().add(jPanel2, BorderLayout.CENTER) ; 96 jPanel2.add(JlistAction, BorderLayout.CENTER) ; 97 jDialog1.getContentPane().add(jPanel1, BorderLayout.CENTER) ; 98 jPanel1.add(jt_Message, null) ; 99 jPanel1.add(jButton_OK, null) ; 100 lm.addElement("\t X") ; 101 lm.addElement("userestremplaceapres") ; 102 lm.addElement("PrivMsg") ; 103 lm.addElement("Op") ; 104 lm.addElement("DeOp") ; 105 lm.addElement("HalfOp") ; 106 lm.addElement("DeHalfOp") ; 107 lm.addElement("Voice") ; 108 lm.addElement("DeVoice") ; 109 lm.addElement("Kick") ; 110 lm.addElement("Ban pour bientot") ; 111 lm.addElement("Whois") ; 112 113 JlistAction.setFont(new Font(IRCchan.FIXEDSYS.getName(), 0, 14)) ; 114 115 } 116 117 public void setUserForAction(String user) 118 { 119 lm.remove(1) ; 120 lm.insertElementAt("\t" + user, 1) ; 121 } 122 123 void JlistAction_valueChanged(ListSelectionEvent e) 124 { 125 if (!e.getValueIsAdjusting()) 126 { 127 if (JlistAction.getSelectedIndex() == 0) { 129 this.setVisible(false) ; 130 } 131 else 132 { 133 if (JlistAction.getSelectedIndex() > 1) { 135 ChanUser user = new ChanUser(lm.get(1).toString().trim()) ; 136 nick = user.getNameSansRank() ; 137 action = JlistAction.getSelectedValue().toString() ; 138 139 if (action.equals("PrivMsg")) 140 { 141 if (user != null) 143 { 144 PrivateFrame frm = IRCchan.GetFenetreDuPrive(nick) ; 146 if (frm == null) 147 { 148 frm = IRCchan.createPrivateFrame(nick) ; 149 } 150 151 chatFrm.setVisible(true); 152 } 153 } 154 else 155 { 156 if (action.equals("Op")) 157 { 158 IRCchan.sendCommand("MODE" + " " + chan + " " + "+o " + nick) ; 159 } 160 else 161 { 162 if (action.equals("DeOp")) 163 { 164 IRCchan.sendCommand("MODE" + " " + chan + " " + "-o " + nick) ; 165 } 166 else 167 { 168 if (action.equals("HalfOp")) 169 { 170 IRCchan.sendCommand("MODE" + " " + chan + " " + "+h " + nick) ; 171 } 172 else 173 { 174 if (action.equals("DeHalfOp")) 175 { 176 IRCchan.sendCommand("MODE" + " " + chan + " " + "-h " + nick) ; 177 } 178 else 179 { 180 if (action.equals("Voice")) 181 { 182 IRCchan.sendCommand("MODE" + " " + chan + " " + "+v " + nick) ; 183 } 184 else 185 { 186 if (action.equals("DeVoice")) 187 { 188 IRCchan.sendCommand("MODE" + " " + chan + " " + "-v " + nick) ; 189 } 190 else 191 { 192 if (action.equals("Kick")) 193 { 194 jDialog1.setLocationRelativeTo(this) ; 195 jDialog1.setVisible(true) ; 196 } 197 else 198 { 199 if (action.equals("Ban")) 200 { 201 } 203 else 204 { 205 if (action.equals("Whois")) 206 { 207 IRCchan.sendCommand("WHOIS" + " " + nick) ; 208 } 209 } 210 } 211 } 212 } 213 } 214 } 215 } 216 } 217 } 218 } 219 } 220 JlistAction.clearSelection() ; 221 this.setVisible(false); 222 } 223 } 224 225 void traiteKick() 226 { 227 IRCchan.sendCommand("KICK" + " " + chan + " " + nick + " " + kickMSG) ; 228 } 229 230 void jButton_OK_actionPerformed(ActionEvent e) 231 { 232 kickMSG = jt_Message.getText().replaceAll(" ", "_") ; 233 jDialog1.setVisible(false) ; 234 traiteKick() ; 235 } 236 } 237 | Popular Tags |