1 14 package zirc.gui ; 15 16 import java.applet.* ; 17 import java.io.* ; 18 import java.net.* ; 19 import java.util.* ; 20 import javax.xml.parsers.* ; 21 import java.awt.* ; 22 import java.awt.event.* ; 23 import javax.swing.* ; 24 import javax.swing.JInternalFrame .* ; 25 import javax.swing.border.* ; 26 import javax.swing.event.* ; 27 import javax.swing.table.* ; 28 import zirc.base.* ; 29 import zirc.gui.smiliesWindow.* ; 30 import zirc.xml.* ; 31 import zirc.dcc2.* ; 32 33 41 42 54 55 public class MainFrame extends JFrame 56 { 57 private Locale currentLocale = new Locale("fr", "FR") ; 58 private Locale oldLocale = new Locale("fr", "FR") ; 59 private int colorFrmPosX ; private int colorFrmPosY ; private int sideFrmPosX ; private int sideFrmPosY ; private int mainFrmSizeX ; 64 private int mainFrmSizeY ; 65 private FontColorFrame colorFrm ; 66 private int selectedColumn ; 67 private int selectedRow ; 68 private OptionDialog dlgServer ; 69 private SmiliesCollection smilies = new SmiliesCollection() ; 70 private AboutDialog aboutDlg = new AboutDialog(this, true, currentLocale) ; 71 private String user_name, user_email, user_nick, server, user_QuitMSG, user_PartMSG ; 72 private String port ; 73 private final File defaultConfig = new File("fichiers/config.xml") ; 74 private final ImageIcon selectedIMG = new ImageIcon("fichiers/images/Selected.png") ; 75 private final ImageIcon showSmiliesIMG = new ImageIcon("fichiers/images/showSmilies.png") ; 76 private final ImageIcon couleursIMG = new ImageIcon("fichiers/images/couleurs.png") ; 77 private final ImageIcon optionIMG2 = new ImageIcon("fichiers/images/options2.png") ; 78 private final ImageIcon connectIMG2 = new ImageIcon("fichiers/images/connect.png") ; 79 private final ImageIcon AproposIMG = new ImageIcon("fichiers/images/Apropos.png") ; 80 private final Image frameIcon = Toolkit.getDefaultToolkit().getImage("fichiers/images/appicon.png") ; 81 private IRCconnexion moduleChatIRC ; private JPanel contentPane ; 83 private JPanel jPanel1 = new JPanel() ; 84 private JDesktopPane mdiPane = new JDesktopPane() ; 85 JPanel jPanel3 = new JPanel() ; 86 JPanel jPanel4 = new JPanel() ; 87 JToolBar jToolBar2 = new JToolBar() ; 88 CardLayout cardLayout2 = new CardLayout() ; 89 TitledBorder titledBorder1 ; 90 TitledBorder titledBorder2 ; 91 JToolBar jToolBar1 = new JToolBar() ; 92 JMenuBar jMenuBar1 = new JMenuBar() ; 93 JMenu jMenu1 = new JMenu() ; 94 JMenuItem jMenuItem1 = new JMenuItem() ; 95 private JButton jButton2 = new JButton() ; 96 private JButton jButton1 = new JButton() ; 97 private BorderLayout borderLayout1 = new BorderLayout() ; 98 CardLayout cardLayout1 = new CardLayout() ; 99 100 JMenu jMenuFavori = new JMenu("Favori") ; 101 JMenuItem jMenuItemGestionFavori = new JMenuItem("Gestion favoris") ; 102 JMenuItem jMenuItemAddChan = new JMenuItem("Ajout Chanel") ; 103 104 JMenu jMenuChanels = new JMenu("Chanels") ; 105 JMenu jMenuServers = new JMenu("Serveurs") ; 106 107 private String [] tagXmlServ = new String [] 108 {"reseau", "nom", "adress", "port"} ; 109 private String [] tagXmlChan = new String [] 110 {"id", "nom", "des"} ; 111 private String servXml = "favoris/servers.xml" ; 112 private String chanXml = "favoris/chanels.xml" ; 113 private JMenuItem[] jmChan ; 114 private JMenuItem[] jmServ ; 115 private GestionFavori gFavori = new GestionFavori(this, "Gestionnaire de favori", true) ; 116 JMenu jMenu3 = new JMenu() ; 117 JMenuItem menuAideJavadoc = new JMenuItem() ; 118 JMenuItem menuAideAide = new JMenuItem() ; 119 JMenuItem menuAideApropos = new JMenuItem() ; 120 Border border1 ; 121 JButton jButton3 = new JButton() ; 122 private JToggleButton jToggleButton1 = new JToggleButton() ; 123 private Border border2 ; 124 private TitledBorder titledBorder3 ; 125 private Border border3 ; 126 private GridLayout gridLayout1 = new GridLayout() ; 127 private JButton jButton4 = new JButton() ; 128 private JDialog sideFrame = new JDialog(this) ; 129 private JTable table ; 130 131 private JButton jButton5 = new JButton() ; 133 private Border border4 ; 134 private JMenu jMenu2 = new JMenu() ; 135 private JCheckBox jCheckBox_Francais = new JCheckBox() ; 136 ButtonGroup buttonGroup1 = new ButtonGroup() ; 137 private JCheckBox jCheckBox_Anglais = new JCheckBox() ; 138 139 public MainFrame() 141 { 142 enableEvents(AWTEvent.WINDOW_EVENT_MASK) ; 143 try 144 { 145 jbInit() ; 146 } 147 catch (Exception e) 148 { 149 e.printStackTrace() ; 150 } 151 } 152 153 private void jbInit() throws Exception 155 { 156 colorFrm = new FontColorFrame(this, moduleChatIRC) ; 157 border4 = BorderFactory.createLineBorder(Color.gray, 2) ; 158 colorFrm.addComponentListener(new java.awt.event.ComponentListener () 159 { 160 public void componentHidden(ComponentEvent e) 161 {} 162 163 public void componentMoved(ComponentEvent e) 164 { 165 colorFrm_componentMoved(e) ; 166 } 167 168 public void componentResized(ComponentEvent e) 169 {} 170 171 public void componentShown(ComponentEvent e) 172 {} 173 }) ; 174 175 sideFrame.addComponentListener(new java.awt.event.ComponentListener () 176 { 177 public void componentHidden(ComponentEvent e) 178 {} 179 180 public void componentMoved(ComponentEvent e) 181 { 182 sideFrm_componentMoved(e) ; 183 } 184 185 public void componentResized(ComponentEvent e) 186 {} 187 188 public void componentShown(ComponentEvent e) 189 {} 190 }) ; 191 192 CustomDataModel customDataModel = new CustomDataModel() ; 193 table = new JTable(customDataModel) ; 194 195 table.getSelectionModel().addListSelectionListener(new ListSelectionListener() 196 { 197 public void valueChanged(ListSelectionEvent e) 198 { 199 table_RowValueChanger(e) ; 200 } 201 202 }) ; 203 204 table.setAutoCreateColumnsFromModel(false) ; 205 CreateColumns() ; 206 table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS) ; 207 table.setRowSelectionAllowed(false) ; 208 table.setCellSelectionEnabled(true) ; 209 table.setShowHorizontalLines(false) ; 210 table.setShowVerticalLines(false) ; 211 table.setRowHeight(30) ; 212 jButton4.setBorder(null) ; 213 jButton4.setToolTipText("Smilies") ; 214 jButton4.setHorizontalTextPosition(SwingConstants.TRAILING) ; 215 jButton4.setIcon(showSmiliesIMG) ; 216 jButton5.setBorder(null) ; 217 jButton5.setToolTipText("Couleurs") ; 218 jButton5.setIcon(couleursIMG) ; 219 jButton5.addActionListener(new java.awt.event.ActionListener () 220 { 221 public void actionPerformed(ActionEvent e) 222 { 223 jButton5_actionPerformed(e) ; 224 } 225 }) ; 226 this.addWindowStateListener(new java.awt.event.WindowStateListener () 227 { 228 public void windowStateChanged(WindowEvent e) 229 { 230 this_windowStateChanged(e) ; 231 } 232 }) ; 233 jMenu2.setText("Langue") ; 234 jCheckBox_Francais.setBorder(null) ; 235 jCheckBox_Francais.setSelected(true) ; 236 jCheckBox_Francais.setText("Francais") ; 237 jCheckBox_Francais.addActionListener(new java.awt.event.ActionListener () 238 { 239 public void actionPerformed(ActionEvent e) 240 { 241 jCheckBox_Francais_actionPerformed(e) ; 242 } 243 }) ; 244 jCheckBox_Anglais.setBorder(null) ; 245 jCheckBox_Anglais.setText("Anglais") ; 246 jCheckBox_Anglais.addActionListener(new java.awt.event.ActionListener () 247 { 248 public void actionPerformed(ActionEvent e) 249 { 250 jCheckBox_Anglais_actionPerformed(e) ; 251 } 252 }) ; 253 254 sideFrame.getContentPane().add(table, BorderLayout.CENTER) ; 255 this.addComponentListener(new java.awt.event.ComponentListener () 256 { 257 public void componentHidden(ComponentEvent e) 258 {} 259 260 public void componentMoved(ComponentEvent e) 261 { 262 this_componentMoved(e) ; 263 } 264 265 public void componentResized(ComponentEvent e) 266 { 267 this_componentResized(e) ; 268 } 269 270 public void componentShown(ComponentEvent e) 271 {} 272 } 273 ) ; 274 275 dlgServer = new OptionDialog(this, moduleChatIRC, this, currentLocale) ; 277 contentPane = (JPanel)this.getContentPane() ; 278 titledBorder1 = new TitledBorder("") ; 279 titledBorder2 = new TitledBorder("") ; 280 border1 = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(SystemColor.control, 0), 281 BorderFactory.createEmptyBorder(1, 0, 0, 0)) ; 282 border2 = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(SystemColor.controlText, 2), 283 BorderFactory.createEmptyBorder(0, 0, 1, 0)) ; 284 titledBorder3 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(165, 163, 151)), "") ; 285 border3 = BorderFactory.createCompoundBorder(titledBorder3, BorderFactory.createEmptyBorder(0, 0, 1, 0)) ; 286 contentPane.setLayout(borderLayout1) ; 287 this.setDefaultCloseOperation(EXIT_ON_CLOSE) ; 288 this.setEnabled(true) ; 289 this.setJMenuBar(jMenuBar1) ; 290 this.setSize(new Dimension(505, 345)) ; 291 this.setTitle("zIrc Alpha 0.5.1") ; 292 this.addWindowListener(new java.awt.event.WindowAdapter () 293 { 294 public void windowClosing(WindowEvent e) 295 { 296 this_windowClosing(e) ; 297 } 298 }) ; 299 jPanel1.setBorder(border1) ; 300 jPanel1.setDebugGraphicsOptions(0) ; 301 jPanel1.setMinimumSize(new Dimension(182, 63)) ; 302 jPanel1.setPreferredSize(new Dimension(10, 63)) ; 303 jPanel1.setLayout(gridLayout1) ; 304 contentPane.setBorder(BorderFactory.createLineBorder(Color.gray)) ; 305 contentPane.setDebugGraphicsOptions(0) ; 306 mdiPane.setBackground(Color.gray) ; 307 mdiPane.addComponentListener(new java.awt.event.ComponentAdapter () 308 { 309 public void componentResized(ComponentEvent e) 310 { 311 mdiPane_componentResized(e) ; 312 } 313 }) ; 314 jPanel3.setLayout(cardLayout1) ; 315 jPanel4.setLayout(cardLayout2) ; 316 jToolBar2.setOrientation(JToolBar.HORIZONTAL) ; 317 jToolBar2.setOpaque(false) ; 318 jToolBar2.setMargin(new Insets(2, 2, 2, 2)) ; 319 jMenu1.setText("Fichier") ; 320 jMenuItem1.setText("Quitter") ; 321 jMenuItem1.addActionListener(new java.awt.event.ActionListener () 322 { 323 public void actionPerformed(ActionEvent e) 324 { 325 jMenuItem1_actionPerformed(e) ; 326 } 327 }) ; 328 jPanel3.setMinimumSize(new Dimension(80, 15)) ; 329 jPanel3.setPreferredSize(new Dimension(80, 32)) ; 330 jToolBar1.setAlignmentX((float)0.5) ; 331 jToolBar1.setOpaque(false) ; 332 jToolBar1.setActionMap(null) ; 333 jToolBar1.setBorderPainted(true) ; 334 jToolBar1.setMargin(new Insets(2, 2, 2, 2)) ; 335 jMenuBar1.setBorder(null) ; 336 jMenuBar1.setBorderPainted(true) ; 337 jButton2.setFont(new java.awt.Font ("Dialog", 0, 9)) ; 338 jButton2.setBorder(null) ; 339 jButton2.setMaximumSize(new Dimension(30, 30)) ; 340 jButton2.setMinimumSize(new Dimension(30, 30)) ; 341 jButton2.setPreferredSize(new Dimension(30, 30)) ; 342 jButton2.setToolTipText("Options") ; 343 jButton2.setBorderPainted(false) ; 344 jButton2.setFocusPainted(false) ; 345 jButton2.setHorizontalTextPosition(SwingConstants.CENTER) ; 346 jButton2.setIcon(optionIMG2) ; 347 jButton2.setMargin(new Insets(20, 20, 20, 20)) ; 348 jButton2.setText("") ; 349 jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM) ; 350 jButton2.addActionListener(new java.awt.event.ActionListener () 351 { 352 public void actionPerformed(ActionEvent e) 353 { 354 jButton2_actionPerformed(e) ; 355 } 356 }) ; 357 jButton1.setFont(new java.awt.Font ("Dialog", 0, 9)) ; 358 jButton1.setBorder(null) ; 359 jButton1.setMaximumSize(new Dimension(30, 30)) ; 360 jButton1.setMinimumSize(new Dimension(30, 30)) ; 361 jButton1.setPreferredSize(new Dimension(30, 30)) ; 362 jButton1.setToolTipText("Connect") ; 363 jButton1.setBorderPainted(false) ; 364 jButton1.setFocusPainted(false) ; 365 jButton1.setHorizontalTextPosition(SwingConstants.CENTER) ; 366 jButton1.setIcon(connectIMG2) ; 367 jButton1.setMargin(new Insets(20, 20, 20, 20)) ; 368 jButton1.setSelectedIcon(null) ; 369 jButton1.setText("") ; 370 jButton1.setVerticalAlignment(javax.swing.SwingConstants.CENTER) ; 371 jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM) ; 372 jButton1.addActionListener(new java.awt.event.ActionListener () 373 { 374 public void actionPerformed(ActionEvent e) 375 { 376 jButton1_actionPerformed(e) ; 377 } 378 }) ; 379 jMenuItemGestionFavori.addActionListener(new java.awt.event.ActionListener () 380 { 381 public void actionPerformed(ActionEvent e) 382 { 383 jMenuItemGestionFavori_actionPerformed(e) ; 384 } 385 }) ; 386 387 jMenuFavori.addMouseListener(new java.awt.event.MouseAdapter () 388 { 389 public void mousePressed(MouseEvent e) 390 { 391 jMenuFavori_mousePressed(e) ; 392 } 393 }) ; 394 jMenuItemAddChan.addActionListener(new java.awt.event.ActionListener () 395 { 396 public void actionPerformed(ActionEvent e) 397 { 398 jMenuItemAddChan_actionPerformed(e) ; 399 } 400 }) ; 401 jMenu3.setText("Aide") ; 402 menuAideJavadoc.setText("Javadoc") ; 403 menuAideJavadoc.addActionListener(new java.awt.event.ActionListener () 404 { 405 public void actionPerformed(ActionEvent e) 406 { 407 menuAideJavadoc_actionPerformed(e) ; 408 } 409 }) ; 410 menuAideAide.setText("Aide") ; 411 menuAideApropos.setText("A propos") ; 412 menuAideApropos.addActionListener(new java.awt.event.ActionListener () 413 { 414 public void actionPerformed(ActionEvent e) 415 { 416 menuAideApropos_actionPerformed(e) ; 417 } 418 }) ; 419 jButton3.setFont(new java.awt.Font ("Dialog", 0, 9)) ; 420 jButton3.setMaximumSize(new Dimension(30, 30)) ; 421 jButton3.setMinimumSize(new Dimension(30, 30)) ; 422 jButton3.setPreferredSize(new Dimension(30, 30)) ; 423 jButton3.setToolTipText("A propos") ; 424 jButton3.setBorderPainted(false) ; 425 jButton3.setFocusPainted(false) ; 426 jButton3.setHorizontalTextPosition(SwingConstants.CENTER) ; 427 jButton3.setIcon(AproposIMG) ; 428 jButton3.setMargin(new Insets(20, 20, 20, 20)) ; 429 jButton3.setVerticalAlignment(javax.swing.SwingConstants.CENTER) ; 430 jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM) ; 431 jPanel4.setPreferredSize(new Dimension(100, 28)) ; 432 jPanel4.setRequestFocusEnabled(true) ; 433 jToggleButton1.setText("jToggleButton1") ; 434 gridLayout1.setRows(2) ; 435 jButton4.addActionListener(new java.awt.event.ActionListener () 436 { 437 public void actionPerformed(ActionEvent e) 438 { 439 jButton4_actionPerformed(e) ; 440 } 441 }) ; 442 443 jPanel1.add(jPanel3, null) ; 444 jPanel3.add(jToolBar2, "jToolBar2") ; 445 jToolBar2.add(jButton2, null) ; 446 jToolBar2.add(jButton1, null) ; 447 jToolBar2.add(jButton4, null) ; 448 jToolBar2.add(jButton5, null) ; 449 jToolBar2.addSeparator() ; 450 jToolBar2.add(jButton3, null) ; 451 jPanel1.add(jPanel4, null) ; 452 jPanel4.add(jToolBar1, "jToolBar1") ; 453 contentPane.add(mdiPane, BorderLayout.CENTER) ; 454 jToolBar1.setPreferredSize(new Dimension(100, 25)) ; 455 jToolBar1.setPreferredSize(new Dimension(100, 35)) ; 456 contentPane.add(jPanel1, BorderLayout.NORTH) ; 457 jMenuBar1.add(jMenu1) ; 458 jMenuBar1.add(jMenu2) ; 459 jMenu1.add(jMenuItem1) ; 460 this.setIconImage(frameIcon) ; 461 jMenuBar1.add(jMenuFavori) ; 462 jMenuBar1.add(jMenu3) ; 463 464 jMenuFavori.add(jMenuItemGestionFavori) ; 466 jMenuFavori.add(jMenuItemAddChan) ; 467 jMenuFavori.addSeparator() ; 468 jMenuServers = chargerMesFavoris(jMenuServers, servXml, tagXmlServ) ; 469 jMenuFavori.add(jMenuServers) ; 470 jMenuChanels = chargerMesFavoris(jMenuChanels, chanXml, tagXmlChan) ; 471 jMenuFavori.add(jMenuChanels) ; 472 jMenu3.add(menuAideJavadoc) ; 473 jMenu3.add(menuAideAide) ; 474 jMenu3.add(menuAideApropos) ; 475 476 for (int i = 0 ; i < jmServ.length ; i++) 478 { 479 jmServ[i].addActionListener(new java.awt.event.ActionListener () 480 { 481 public void actionPerformed(ActionEvent e) 482 { 483 jmServ_actionPerformed(e) ; 484 } 485 }) ; 486 } 487 for (int i = 0 ; i < jmChan.length ; i++) 488 { 489 jmChan[i].addActionListener(new java.awt.event.ActionListener () 490 { 491 public void actionPerformed(ActionEvent e) 492 { 493 jmChan_actionPerformed(e) ; 494 } 495 }) ; 496 } 497 498 mainFrmSizeX = this.getWidth() ; 499 mainFrmSizeY = this.getHeight() ; 500 colorFrm.setBounds((int)this.getBounds().getX() + mainFrmSizeX - colorFrm.getWidth(), 501 (int)this.getBounds().getY() + mainFrmSizeY, colorFrm.getWidth(), 502 colorFrm.getHeight()) ; 503 504 sideFrame.setSize(this.getWidth(), smilies.getRowsCount() * 30 + 30) ; 505 sideFrame.setBounds((int)this.getBounds().getX(), 506 (int)this.getBounds().getY() + this.getHeight(), this.getWidth() - colorFrm.getWidth(), 507 sideFrame.getHeight()) ; 508 509 playSound() ; 511 buttonGroup1.add(jCheckBox_Francais) ; 512 buttonGroup1.add(jCheckBox_Anglais) ; 513 jMenu2.add(jCheckBox_Francais) ; 514 jMenu2.add(jCheckBox_Anglais) ; 515 } 516 517 public void CreateColumns() 519 { 520 521 for (int iCtr = 0 ; iCtr < smilies.getColumnsCount() ; iCtr++) 522 { 523 TableColumn column = new TableColumn(iCtr) ; 524 column.setCellRenderer(new CustomCellRenderer(smilies)) ; 525 table.addColumn(column) ; 526 } 527 } 528 529 private void playSound() 531 { 532 if (dlgServer.isSoundEnabled()) 533 { 534 File file = new File("fichiers/intro.wav") ; 535 AudioClip clip = null ; 536 try 537 { 538 clip = Applet.newAudioClip(file.toURL()) ; 539 } 540 catch (MalformedURLException ex) 541 {} 542 clip.play() ; 543 } 544 } 545 546 protected void processWindowEvent(WindowEvent e) 548 { 549 super.processWindowEvent(e) ; 550 if (e.getID() == WindowEvent.WINDOW_CLOSING) 551 { 552 System.exit(0) ; 553 } 554 } 555 556 void jButton1_actionPerformed(ActionEvent e) 558 { 559 server = dlgServer.getUser_server() ; 560 user_name = dlgServer.getUser_name() ; 561 user_email = dlgServer.getUser_email() ; 562 user_nick = dlgServer.getUser_nick() ; 563 port = dlgServer.getUser_port() ; 564 user_QuitMSG = dlgServer.getUserQuitMSG() ; 565 user_PartMSG = dlgServer.getUserPartMSG() ; 566 567 moduleChatIRC = new IRCconnexion(user_name, user_email, user_nick, server, port, this, smilies, user_QuitMSG, user_PartMSG, 568 this.currentLocale) ; 569 moduleChatIRC.connect() ; 570 colorFrm.setIrcConnexion(moduleChatIRC) ; 571 } 572 573 void jButton2_actionPerformed(ActionEvent e) 575 { 576 dlgServer.setLocation((int)this.getBounds().getX() + 40, (int)this.getBounds().getY() + 40) ; 577 dlgServer.show() ; 578 } 579 580 public JDesktopPane getMdiPanel() 582 { 583 return this.mdiPane ; 584 } 585 586 void jMenuItem1_actionPerformed(ActionEvent e) 587 { 588 System.exit(0) ; 589 } 590 591 public JToolBar getFrameToolBar() 593 { 594 return jToolBar1 ; 595 } 596 597 public JMenu chargerMesFavoris(JMenu _jMenu, String chemin, String [] tagXml) 598 { 599 XmlPars parsServers = new XmlPars(tagXml) ; 601 602 try 604 { 605 SAXParserFactory usine = SAXParserFactory.newInstance() ; 606 SAXParser analyseur = usine.newSAXParser() ; 607 analyseur.parse(new File(chemin), parsServers) ; 608 } 609 catch (Exception e) 610 { 611 e.printStackTrace() ; 612 } 613 ArrayList aArray = parsServers.getAList() ; 615 616 if (chemin.equals(servXml)) 617 { 618 jmServ = new JMenuItem[aArray.size()] ; 619 for (int i = 0 ; i < aArray.size() ; i++) 621 { 622 String [] s = (String [])aArray.get(i) ; 623 jmServ[i] = new JMenuItem(s[1]) ; 624 _jMenu.add(jmServ[i]) ; 625 } 626 } 627 628 if (chemin.equals(chanXml)) 629 { 630 jmChan = new JMenuItem[aArray.size()] ; 631 for (int i = 0 ; i < aArray.size() ; i++) 633 { 634 String [] s = (String [])aArray.get(i) ; 635 jmChan[i] = new JMenuItem(s[1]) ; 636 _jMenu.add(jmChan[i]) ; 637 } 638 } 639 640 return _jMenu ; 641 } 642 643 void jMenuItemGestionFavori_actionPerformed(ActionEvent e) 644 { 645 gFavori.show() ; 646 } 647 648 void jmChan_actionPerformed(ActionEvent e) 649 { 650 652 ArrayList aChan = gFavori.chargeXmlChan() ; 653 String [] s = new String [3] ; 654 655 for (int i = 0 ; i < aChan.size() ; i++) 656 { 657 s = (String [])aChan.get(i) ; 658 if (e.getActionCommand().equals(s[1])) 659 { 660 moduleChatIRC.sendCommand("join " + s[1]) ; 662 } 663 } 664 665 } 666 667 void jmServ_actionPerformed(ActionEvent e) 668 { 669 671 ArrayList aServ = gFavori.chargeXmlServ(servXml) ; 672 String [] s = new String [4] ; 673 674 for (int i = 0 ; i < aServ.size() ; i++) 675 { 676 s = (String [])aServ.get(i) ; 677 if (e.getActionCommand().equals(s[1])) 678 { 679 681 user_name = dlgServer.getUser_name() ; 682 user_email = dlgServer.getUser_email() ; 683 user_nick = dlgServer.getUser_nick() ; 684 685 moduleChatIRC = new IRCconnexion(user_name, user_email, user_nick, s[2], s[3], this, smilies, user_QuitMSG, user_PartMSG, 686 this.currentLocale) ; 687 moduleChatIRC.connect() ; 688 } 689 } 690 } 691 692 void this_windowClosing(WindowEvent e) 693 { 694 for (int i = 0 ; i < moduleChatIRC.getServerArray().size() ; i++) 696 { 697 ((IRCconnexion)(moduleChatIRC.getServerArray().get(i))).disconnect() ; 698 } 699 } 700 701 void jMenuFavori_mousePressed(MouseEvent e) 702 { 703 jMenuFavori.removeAll() ; 704 jMenuServers.removeAll() ; 705 jMenuChanels.removeAll() ; 706 jMenuFavori.add(jMenuItemGestionFavori) ; 708 jMenuFavori.add(jMenuItemAddChan) ; 709 jMenuFavori.addSeparator() ; 710 jMenuServers = chargerMesFavoris(jMenuServers, servXml, tagXmlServ) ; 711 jMenuFavori.add(jMenuServers) ; 712 jMenuChanels = chargerMesFavoris(jMenuChanels, chanXml, tagXmlChan) ; 713 jMenuFavori.add(jMenuChanels) ; 714 for (int i = 0 ; i < jmServ.length ; i++) 716 { 717 jmServ[i].addActionListener(new java.awt.event.ActionListener () 718 { 719 public void actionPerformed(ActionEvent e) 720 { 721 jmServ_actionPerformed(e) ; 722 } 723 }) ; 724 } 725 for (int i = 0 ; i < jmChan.length ; i++) 726 { 727 jmChan[i].addActionListener(new java.awt.event.ActionListener () 728 { 729 public void actionPerformed(ActionEvent e) 730 { 731 jmChan_actionPerformed(e) ; 732 } 733 }) ; 734 } 735 736 } 737 738 void jMenuItemAddChan_actionPerformed(ActionEvent e) 739 { 740 ArrayList aChan = gFavori.chargeXmlChan() ; 743 aChan.add(new String [] 744 {"0", "#nom", "Description", moduleChatIRC.GetMainSockServer(), moduleChatIRC.GetMainSockPort()}) ; 745 gFavori.saveXmlChan(aChan) ; 746 } 747 748 void mdiPane_componentResized(ComponentEvent e) 750 { 751 int nbOfIcons = mdiPane.getComponentCount() ; 752 for (int i = 0 ; i < nbOfIcons ; i++) 753 { 754 try 755 { 756 ((JDesktopIcon)(mdiPane.getComponent(i))).setLocation((int)((JDesktopIcon)(mdiPane.getComponent(i))).getLocation().getX(), 757 mdiPane.getHeight() - (int)((JDesktopIcon)(mdiPane.getComponent(i))).getHeight()) ; 758 } 759 catch (ClassCastException ex) {} 761 } 762 } 763 764 void menuAideJavadoc_actionPerformed(ActionEvent e) 768 { 769 File tmp=new File(""); 770 BrowserLauncher browser = new BrowserLauncher() ; 771 browser.launchBrowserForLocalFiles(tmp.getAbsolutePath()+"/doc/index.html") ; 772 System.err.println(tmp.getAbsolutePath()+"/doc/index.html"); 773 } 774 775 void menuAideApropos_actionPerformed(ActionEvent e) 776 { 777 aboutDlg.setLocation((int)this.getBounds().getX() + 40, (int)this.getBounds().getY() + 40) ; 778 aboutDlg.show() ; 779 } 780 781 void jButton4_actionPerformed(ActionEvent e) 783 { 784 if (sideFrame.isVisible()) 785 { 786 sideFrame.setVisible(false) ; 787 } 788 else 789 { 790 sideFrame.setVisible(true) ; 791 } 792 } 793 794 void this_componentMoved(ComponentEvent e) 795 { 796 invalidate() ; 797 adjust() ; 798 validate() ; 799 } 800 801 void this_componentResized(ComponentEvent e) 802 { 803 invalidate() ; 804 805 sideFrmPosX = (int)this.getBounds().getX() - (int)sideFrame.getBounds().getX() + (mainFrmSizeX - this.getWidth()) ; 806 sideFrmPosY = (int)this.getBounds().getY() - (int)sideFrame.getBounds().getY() + (mainFrmSizeY - this.getHeight()) ; 807 sideFrame.setBounds((int)this.getBounds().getX() - sideFrmPosX, 808 (int)this.getBounds().getY() - sideFrmPosY, sideFrame.getWidth(), 809 sideFrame.getHeight()) ; 810 811 colorFrmPosX = (int)this.getBounds().getX() - (int)colorFrm.getBounds().getX() + (mainFrmSizeX - this.getWidth()) ; 812 colorFrmPosY = (int)this.getBounds().getY() - (int)colorFrm.getBounds().getY() + (mainFrmSizeY - this.getHeight()) ; 813 colorFrm.setBounds((int)this.getBounds().getX() - colorFrmPosX, 814 (int)this.getBounds().getY() - colorFrmPosY, colorFrm.getWidth(), 815 colorFrm.getHeight()) ; 816 817 mainFrmSizeX = this.getWidth() ; 818 mainFrmSizeY = this.getHeight() ; 819 820 validate() ; 821 } 822 823 void colorFrm_componentMoved(ComponentEvent e) 824 { 825 colorFrmPosX = (int)this.getBounds().getX() - (int)colorFrm.getBounds().getX() ; 826 colorFrmPosY = (int)this.getBounds().getY() - (int)colorFrm.getBounds().getY() ; 827 } 828 829 void sideFrm_componentMoved(ComponentEvent e) 830 { 831 sideFrmPosX = (int)this.getBounds().getX() - (int)sideFrame.getBounds().getX() ; 832 sideFrmPosY = (int)this.getBounds().getY() - (int)sideFrame.getBounds().getY() ; 833 } 834 835 void table_RowValueChanger(ListSelectionEvent e) 836 { 837 if (e.getValueIsAdjusting()) 838 { 839 int r = table.getSelectedRow() ; 840 int c = table.getSelectedColumn() ; 841 if (c >= 0 && r >= 0) 842 { 843 try 844 { 845 if (moduleChatIRC.getChatFrameWithFocus() != null) 846 { 847 JTextField tmp = moduleChatIRC.getChatFrameWithFocus().getTextBox() ; 848 tmp.setText(tmp.getText() + smilies.getValueAt(r, c, 1)) ; 849 } 850 } 851 catch (NullPointerException ex) 852 {} } 854 } 855 table.clearSelection() ; } 857 858 void jButton5_actionPerformed(ActionEvent e) 859 { 860 if (!colorFrm.isVisible()) 861 { 862 colorFrm.setVisible(true) ; 863 } 864 else 865 { 866 colorFrm.setVisible(false) ; 867 } 868 } 869 870 void this_windowStateChanged(WindowEvent e) 871 { 872 int state = e.getNewState() ; if (state == 6) 874 { 875 adjust(0, -150) ; 876 } 877 else 878 { 879 adjust() ; 880 } 881 882 } 883 884 void adjust() 885 { 886 invalidate() ; 887 sideFrame.setBounds((int)this.getBounds().getX() - sideFrmPosX, 888 (int)this.getBounds().getY() - sideFrmPosY, sideFrame.getWidth(), 889 sideFrame.getHeight()) ; 890 891 colorFrm.setBounds((int)this.getBounds().getX() - colorFrmPosX, 892 (int)this.getBounds().getY() - colorFrmPosY, colorFrm.getWidth(), 893 colorFrm.getHeight()) ; 894 validate() ; 895 } 896 897 void adjust(int corX, int corY) 898 { 899 invalidate() ; 900 sideFrame.setBounds((int)this.getBounds().getX() - sideFrmPosX + corX, 901 (int)this.getBounds().getY() - sideFrmPosY + corY, sideFrame.getWidth(), 902 sideFrame.getHeight()) ; 903 904 colorFrm.setBounds((int)this.getBounds().getX() - colorFrmPosX + corX, 905 (int)this.getBounds().getY() - colorFrmPosY + corY, colorFrm.getWidth(), 906 colorFrm.getHeight()) ; 907 validate() ; 908 } 909 910 void changeLanguage(String lang) 916 { 917 String language ; 918 String country ; 919 if (lang.equals("Anglais") || lang.equals("English")) 920 { 921 language = new String ("en") ; 922 country = new String ("US") ; 923 } 924 else 925 { 926 language = new String ("fr") ; 927 country = new String ("FR") ; 928 } 929 930 ResourceBundle messages ; 931 currentLocale = new Locale(language, country) ; 932 933 if (!oldLocale.equals(currentLocale)) 935 { 936 messages = ResourceBundle.getBundle("MainFrame", currentLocale) ; 938 939 this.jButton5.setToolTipText(messages.getString("jbcouleurs")) ; 940 this.jButton3.setToolTipText(messages.getString("jbapropos")) ; 941 942 this.jMenu1.setText(messages.getString("menufichier")) ; 943 this.jMenuItem1.setText(messages.getString("smenuquitter")) ; 944 945 this.jMenu2.setText(messages.getString("menulangue")) ; 946 this.jCheckBox_Francais.setText(messages.getString("smenufrancais")) ; 947 this.jCheckBox_Anglais.setText(messages.getString("smenuanglais")) ; 948 949 this.jMenuFavori.setText(messages.getString("menufavori")) ; 950 this.jMenuItemGestionFavori.setText(messages.getString("smenugestion")) ; 951 this.jMenuItemAddChan.setText(messages.getString("smenuajout")) ; 952 this.jMenuServers.setText(messages.getString("smenuserveurs")) ; 953 this.jMenuChanels.setText(messages.getString("smenuchanels")) ; 954 955 this.jMenu3.setText(messages.getString("menuaide")) ; 956 this.menuAideAide.setText(messages.getString("smenuaide")) ; 957 this.menuAideApropos.setText(messages.getString("smenuapropos")) ; 958 959 try 960 { 961 aboutDlg.setLanguage(currentLocale) ; 963 964 dlgServer.setLanguage(currentLocale) ; 966 967 moduleChatIRC.setLanguage(currentLocale) ; 969 } 970 catch (NullPointerException ex) 971 { 972 } finally 974 { oldLocale = currentLocale ; 976 } 977 } 978 } 979 980 void jCheckBox_Francais_actionPerformed(ActionEvent e) 981 { 982 if (jCheckBox_Francais.isSelected()) 983 { 984 changeLanguage(jCheckBox_Francais.getText()) ; 985 } 986 } 987 988 void jCheckBox_Anglais_actionPerformed(ActionEvent e) 989 { 990 if (jCheckBox_Anglais.isSelected()) 991 { 992 changeLanguage(jCheckBox_Anglais.getText()) ; 993 } 994 } 995 } 1000 | Popular Tags |