View Javadoc

1   /*
2    * This file is part of NetPisteur.
3    * 
4    * Copyright 2001-2002 : Olivier CORNEC, David BOUANCHEAU, Loic LOPEZ,
5    *                       Gaetan BOUDARD, Mael LE LANNOU, Julien ROBINEAU
6    * 
7    * Copyright 2002-2003 : Olivier BRIENS, Simon DEZE, Florence FRIGOULT,
8    *                       Olivier JOURNEAULT, Francois MARTINIER, Damien RAUDE-MORVAN
9    * 
10   * Copyright 2004-2007 : Damien RAUDE-MORVAN
11   * 
12   * NetPisteur is free software; you can redistribute it and/or modify
13   * it under the terms of the GNU General Public License as published by
14   * the Free Software Foundation; either version 2 of the License, or
15   * (at your option) any later version.
16   *
17   * NetPisteur is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20   * GNU General Public License for more details.
21   *
22   * You should have received a copy of the GNU General Public License
23   * along with NetPisteur; if not, write to the Free Software
24   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
25   *
26   */
27  package com.drazzib.netpisteur.ui;
28  
29  import java.awt.BorderLayout;
30  import java.awt.Color;
31  import java.awt.Cursor;
32  import java.awt.Dimension;
33  import java.awt.Font;
34  import java.awt.GridLayout;
35  import java.awt.event.ActionEvent;
36  import java.awt.event.ActionListener;
37  import java.awt.event.MouseAdapter;
38  import java.awt.event.MouseEvent;
39  import java.awt.event.WindowAdapter;
40  import java.awt.event.WindowEvent;
41  import java.io.File;
42  import java.io.IOException;
43  import java.net.MalformedURLException;
44  import java.net.URL;
45  import java.util.GregorianCalendar;
46  
47  import javax.swing.ImageIcon;
48  import javax.swing.JButton;
49  import javax.swing.JEditorPane;
50  import javax.swing.JFrame;
51  import javax.swing.JLabel;
52  import javax.swing.JMenu;
53  import javax.swing.JMenuBar;
54  import javax.swing.JMenuItem;
55  import javax.swing.JPanel;
56  import javax.swing.JScrollPane;
57  import javax.swing.JTextField;
58  import javax.swing.SwingUtilities;
59  import javax.swing.WindowConstants;
60  import javax.swing.border.BevelBorder;
61  import javax.swing.border.EtchedBorder;
62  import javax.swing.border.SoftBevelBorder;
63  import javax.swing.event.HyperlinkEvent;
64  import javax.swing.event.HyperlinkListener;
65  import javax.swing.text.html.HTMLDocument;
66  import javax.swing.text.html.HTMLFrameHyperlinkEvent;
67  
68  import org.apache.commons.logging.Log;
69  import org.apache.commons.logging.LogFactory;
70  
71  import com.drazzib.netpisteur.configuration.Configuration;
72  import com.drazzib.netpisteur.loader.Connexion;
73  import com.drazzib.netpisteur.loader.ConnexionFactory;
74  import com.drazzib.netpisteur.monitor.ListClick;
75  import com.drazzib.netpisteur.monitor.ListHL;
76  import com.drazzib.netpisteur.monitor.ListPlacement;
77  import com.drazzib.netpisteur.monitor.Placement;
78  import com.drazzib.netpisteur.ui.listener.ClickListener;
79  import com.drazzib.netpisteur.ui.listener.MoveListener;
80  import com.drazzib.netpisteur.ui.render.HTMLViewer;
81  import com.drazzib.netpisteur.util.Messages;
82  
83  /**
84   * Netpisteur.java
85   * 
86   * Created on 23 janvier 2002, 20:26
87   * 
88   * @author lelannou robineau boudard lopez cornec
89   */
90  
91  public class MainFrame extends JFrame implements HyperlinkListener,
92  		ActionListener {
93  
94  	static Log log = LogFactory.getLog(MainFrame.class);
95  	
96  	/**
97  	 * 
98  	 */
99  	private static final long serialVersionUID = -5717508219567497372L;
100 
101 	// class attributs
102 	private JMenuBar jMenuBar;
103 
104 	private JMenu fichierMenu, optionMenu, aideMenu;
105 
106 	private JMenuItem ouvrirMenuItem, quitterMenuItem, manuelMenu,
107 			sourceMenuItem, aProposMenu, proxyConfMenuItem;
108 
109 	private JButton precedentButton, suivantButton, stopButton,
110 			rechargerButton, acceuilButton, buttonOk;
111 
112 	private JPanel northPanel, navPanel, boutonNavPanel, nomLogoPanel,
113 			espaceNavAddPanel, addressePanel, pagePanel, southPanel,
114 			espaceAdressePagePanel, myProgressPanel;
115 
116 	private JLabel nomLabel, adresseLabel, etatConnexionLabel, userLabel;
117 
118 	private JTextField addresseTextField;
119 
120 	private JEditorPane viewer;
121 
122 	private HTMLViewer parse;
123 
124 	private JScrollPane mainPanel;
125 
126 	private JTextField heureTextField;
127 
128 	private String source;
129 
130 	private ListHL maListeHL = new ListHL();
131 
132 	// table ofmousse position
133 	ListPlacement maListePlace = new ListPlacement();
134 
135 	// tableau des clics de la souristable of click mousse
136 	public ListClick maListeClick = new ListClick();
137 
138 	// timer attibuts
139 	private javax.swing.Timer time;
140 
141 	private int heure;
142 
143 	private int minute;
144 
145 	private int seconde;
146 
147 	int x;
148 
149 	int y;
150 
151 	private LoadBar myLoadBar;
152 
153 	public javax.swing.Timer t;
154 
155 	// timer which measures the downtime of the mouse
156 	javax.swing.Timer timeChrono;
157 
158 	private boolean withoutMonitor;
159 
160 	/**
161 	 * Creates new Netpisteur
162 	 */
163 	public MainFrame(boolean bWithoutMonitor) {
164 		this.withoutMonitor = bWithoutMonitor;
165 		initComponents();
166 	}
167 
168 	private void initComponents() {
169 
170 		// option menu
171 		this.jMenuBar = new JMenuBar();
172 		this.fichierMenu = new JMenu();
173 		this.ouvrirMenuItem = new JMenuItem();
174 		this.quitterMenuItem = new JMenuItem();
175 		this.optionMenu = new JMenu();
176 		this.sourceMenuItem = new JMenuItem();
177 		this.aideMenu = new JMenu();
178 		this.manuelMenu = new JMenuItem();
179 		this.aProposMenu = new JMenuItem();
180 		this.proxyConfMenuItem = new JMenuItem();
181 
182 		// panels installation
183 		this.northPanel = new JPanel();
184 		this.navPanel = new JPanel();
185 		this.boutonNavPanel = new JPanel();
186 		this.nomLogoPanel = new JPanel();
187 		this.espaceNavAddPanel = new JPanel(new BorderLayout());
188 		this.addressePanel = new JPanel();
189 		this.pagePanel = new JPanel();
190 		this.espaceAdressePagePanel = new JPanel();
191 		this.viewer = new JEditorPane();
192 		this.southPanel = new JPanel();
193 
194 		// buttons installation
195 		this.precedentButton = new JButton();
196 		this.suivantButton = new JButton();
197 		this.stopButton = new JButton();
198 		this.rechargerButton = new JButton();
199 		this.acceuilButton = new JButton();
200 		this.buttonOk = new JButton();
201 
202 		// labels installation
203 		this.etatConnexionLabel = new JLabel();
204 		this.nomLabel = new JLabel();
205 		this.adresseLabel = new JLabel();
206 		this.userLabel = new JLabel();
207 
208 		// textfields installation
209 		this.addresseTextField = new JTextField();
210 		this.heureTextField = new JTextField(); // a modif
211 
212 		// under menus and the ear-phones installation
213 		// fichierMenu.setBorder(null);
214 		this.fichierMenu.setText(Messages.getString("mainWindow.FILE")); //$NON-NLS-1$
215 		this.fichierMenu.setFont(new Font("Dialog", 1, 12)); //$NON-NLS-1$
216 
217 		this.ouvrirMenuItem.setText(Messages.getString("mainWindow.OPEN")); //$NON-NLS-1$
218 		this.ouvrirMenuItem.addMouseListener(new MouseAdapter() {
219 			public void mouseReleased(MouseEvent evt) {
220 				ouvrirMenuItemMouseReleased(evt);
221 			}
222 		});
223 
224 		this.fichierMenu.add(this.ouvrirMenuItem);
225 		this.quitterMenuItem.setText(Messages.getString("mainWindow.QUIT")); //$NON-NLS-1$
226 		this.quitterMenuItem.addMouseListener(new MouseAdapter() {
227 			public void mouseReleased(MouseEvent event) {
228 				exitForm();
229 			}
230 		});
231 
232 		this.fichierMenu.add(this.quitterMenuItem);
233 		this.jMenuBar.add(this.fichierMenu);
234 
235 		this.optionMenu.setText(Messages.getString("mainWindow.OPTIONS")); //$NON-NLS-1$
236 		this.optionMenu.setFont(new Font("Dialog", 1, 12)); //$NON-NLS-1$
237 		this.sourceMenuItem.setText(Messages
238 				.getString("mainWindow.SOURCE_PAGE")); //$NON-NLS-1$
239 		this.sourceMenuItem.addMouseListener(new MouseAdapter() {
240 			public void mouseReleased(MouseEvent evt) {
241 				sourceMenuItemMouseReleased(evt);
242 			}
243 		});
244 
245 		this.optionMenu.add(this.sourceMenuItem);
246 
247 		this.jMenuBar.add(this.optionMenu);
248 
249 		this.proxyConfMenuItem.setText(Messages
250 				.getString("mainWindow.CONFIG_PROXY")); //$NON-NLS-1$
251 		this.proxyConfMenuItem.addMouseListener(new MouseAdapter() {
252 			public void mouseReleased(MouseEvent evt) {
253 				proxyConfMenuItemMouseReleased(evt);
254 			}
255 		});
256 		this.optionMenu.add(this.proxyConfMenuItem);
257 
258 		this.jMenuBar.add(this.optionMenu);
259 
260 		this.aideMenu.setText(Messages.getString("mainWindow.HELP")); //$NON-NLS-1$
261 		this.aideMenu.setFont(new Font("Dialog", 1, 12)); //$NON-NLS-1$
262 		this.manuelMenu.setText(Messages.getString("mainWindow.USER_HELP")); //$NON-NLS-1$
263 		this.manuelMenu.addMouseListener(new MouseAdapter() {
264 			public void mouseReleased(MouseEvent evt) {
265 				manuelMenuMouseReleased(evt);
266 			}
267 		});
268 
269 		this.aideMenu.add(this.manuelMenu);
270 		this.aProposMenu.setText(Messages.getString("mainWindow.ABOUT")); //$NON-NLS-1$
271 		this.aProposMenu.addMouseListener(new MouseAdapter() {
272 			public void mouseReleased(MouseEvent evt) {
273 				aProposMenuMouseReleased(evt);
274 			}
275 		});
276 
277 		this.aideMenu.add(this.aProposMenu);
278 		this.jMenuBar.add(this.aideMenu);
279 
280 		// Ajout pour ne pas la cache !
281 		setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
282 		addWindowListener(new WindowAdapter() {
283 			public void windowClosing(WindowEvent event) {
284 				exitForm();
285 			}
286 		});
287 
288 		// posting division as a panel
289 		// part with the top of posting of the page (buttons and logos)
290 		this.northPanel.setLayout(new BorderLayout());
291 		this.northPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
292 		this.northPanel.setBackground(Color.lightGray);
293 		this.northPanel.setPreferredSize(new Dimension(0, 94));
294 		this.northPanel.setMinimumSize(new Dimension(0, 94));
295 
296 		this.pagePanel.setPreferredSize(new Dimension(800, 600));
297 
298 		// navigation part
299 		this.navPanel.setLayout(new GridLayout(1, 2));
300 		this.navPanel.setPreferredSize(new Dimension(938, 50));
301 		this.navPanel.setMinimumSize(new Dimension(0, 50));
302 
303 		// bouton part
304 		this.boutonNavPanel.setLayout(new GridLayout(1, 5));
305 		this.precedentButton.setIcon(new ImageIcon(getClass().getResource(
306 				"/com/drazzib/netpisteur/resources/left.png"))); //$NON-NLS-1$
307 		this.precedentButton.setPreferredSize(new Dimension(34, 34));
308 		this.precedentButton.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
309 		this.precedentButton.addMouseListener(new MouseAdapter() {
310 			public void mouseReleased(MouseEvent evt) {
311 				precedentButtonMouseReleased(evt);
312 			}
313 		});
314 		this.boutonNavPanel.add(this.precedentButton);
315 		this.suivantButton.setIcon(new ImageIcon(getClass().getResource(
316 				"/com/drazzib/netpisteur/resources/right.png"))); //$NON-NLS-1$
317 		this.suivantButton.setPreferredSize(new Dimension(34, 34));
318 		this.suivantButton.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
319 		this.suivantButton.addMouseListener(new MouseAdapter() {
320 			public void mouseReleased(MouseEvent evt) {
321 				suivantButtonMouseReleased(evt);
322 			}
323 		});
324 		this.boutonNavPanel.add(this.suivantButton);
325 		this.stopButton.setIcon(new ImageIcon(getClass().getResource(
326 				"/com/drazzib/netpisteur/resources/stop.png"))); //$NON-NLS-1$
327 		this.stopButton.setPreferredSize(new Dimension(34, 34));
328 		this.stopButton.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
329 		this.stopButton.addMouseListener(new MouseAdapter() {
330 			public void mouseReleased(MouseEvent evt) {
331 				stopButtonMouseReleased(evt);
332 			}
333 		});
334 		this.boutonNavPanel.add(this.stopButton);
335 		this.rechargerButton.setIcon(new ImageIcon(getClass().getResource(
336 				"/com/drazzib/netpisteur/resources/refresh.png"))); //$NON-NLS-1$
337 		this.rechargerButton.setPreferredSize(new Dimension(34, 34));
338 		this.rechargerButton.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
339 		this.rechargerButton.addMouseListener(new MouseAdapter() {
340 			public void mouseReleased(MouseEvent evt) {
341 				rechargerButtonMouseReleased(evt);
342 			}
343 		});
344 		this.boutonNavPanel.add(this.rechargerButton);
345 		this.acceuilButton.setIcon(new ImageIcon(getClass().getResource(
346 				"/com/drazzib/netpisteur/resources/home.png"))); //$NON-NLS-1$
347 		this.acceuilButton.setPreferredSize(new Dimension(34, 34));
348 		this.acceuilButton.setBorder(new SoftBevelBorder(BevelBorder.RAISED));
349 		this.acceuilButton.addMouseListener(new MouseAdapter() {
350 			public void mouseReleased(MouseEvent evt) {
351 				acceuilButtonMouseReleased(evt);
352 			}
353 		});
354 		this.boutonNavPanel.add(this.acceuilButton);
355 		this.navPanel.add(this.boutonNavPanel);
356 
357 		// logo part
358 		this.nomLogoPanel.setBorder(new EtchedBorder());
359 		this.nomLabel.setIcon(new ImageIcon(getClass().getResource(
360 				"/com/drazzib/netpisteur/resources/logo.png"))); //$NON-NLS-1$
361 
362 		this.nomLogoPanel.add(this.nomLabel);
363 		this.navPanel.add(this.nomLogoPanel);
364 
365 		this.northPanel.add(this.navPanel, BorderLayout.NORTH);
366 		Font petit = new Font("Arial", Font.ITALIC, 10); //$NON-NLS-1$
367 
368 		this.userLabel
369 				.setText(Messages.getString("mainWindow.ADMIN") + Configuration.getHandle().getRootPrenom() //$NON-NLS-1$
370 						+ " " + Configuration.getHandle().getRootNom() + " "); //$NON-NLS-1$ //$NON-NLS-2$
371 		this.userLabel.setFont(petit);
372 		this.espaceNavAddPanel.add(this.userLabel, BorderLayout.EAST);
373 		this.espaceNavAddPanel.setPreferredSize(new Dimension(0, 10));
374 		this.espaceNavAddPanel.setMinimumSize(new Dimension(0, 10));
375 		this.northPanel.add(this.espaceNavAddPanel, BorderLayout.CENTER);
376 
377 		this.addressePanel.setLayout(new BorderLayout());
378 
379 		this.addressePanel.setBorder(new EtchedBorder());
380 		this.addressePanel.setPreferredSize(new Dimension(109, 30));
381 		this.addressePanel.setMinimumSize(new Dimension(109, 30));
382 		this.adresseLabel.setFont(new Font("Dialog", 1, 12)); //$NON-NLS-1$
383 		this.adresseLabel.setText(Messages.getString("mainWindow.ADDRESS")); //$NON-NLS-1$
384 		this.addressePanel.add(this.adresseLabel, BorderLayout.WEST);
385 		this.addresseTextField.setText("http://"); //$NON-NLS-1$
386 		this.addressePanel.add(this.addresseTextField, BorderLayout.CENTER);
387 		this.buttonOk.setText(Messages.getString("mainWindow.OK")); //$NON-NLS-1$
388 		this.buttonOk.addMouseListener(new MouseAdapter() {
389 			public void mouseReleased(MouseEvent evt) {
390 				buttonOkMouseReleased(evt);
391 			}
392 		});
393 
394 		this.addressePanel.add(this.buttonOk, BorderLayout.EAST);
395 		this.northPanel.add(this.addressePanel, BorderLayout.SOUTH);
396 		getContentPane().add(this.northPanel, BorderLayout.NORTH);
397 
398 		this.pagePanel.setLayout(new BorderLayout());
399 		this.pagePanel.add(this.espaceAdressePagePanel, BorderLayout.NORTH);
400 
401 		// installation of the panel of the page of posting
402 		this.viewer.addMouseMotionListener(new MoveListener(this));
403 		this.viewer.addMouseListener(new ClickListener(this));
404 
405 		// add of HTML
406 		this.parse = new HTMLViewer();
407 		this.viewer.setEditorKit(this.parse);
408 
409 		// Mode not editable to receive the clics on hypertext link
410 		this.viewer.setEditable(false);
411 
412 		// Addition of the listener of clic on bond
413 		this.viewer.addHyperlinkListener(this);
414 
415 		// Addition of the listener of modification of the seizure
416 		this.addresseTextField.addActionListener(this);
417 
418 		this.mainPanel = new JScrollPane(this.viewer);
419 		getContentPane().add(this.mainPanel, BorderLayout.CENTER);
420 
421 		// put bar of state
422 		this.southPanel.setLayout(new BorderLayout());
423 		this.southPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
424 		this.southPanel.setPreferredSize(new Dimension(0, 30));
425 		this.southPanel.setMinimumSize(new Dimension(64, 30));
426 
427 		this.heureTextField.setFont(new Font("Dialog", 1, 12)); //$NON-NLS-1$
428 		this.heureTextField.setColumns(7);
429 
430 		// timer creation
431 		if (Configuration.getHandle().isTimerActif()) {
432 			this.heure = Configuration.getHandle().getTimerHeure();
433 			this.minute = Configuration.getHandle().getTimerMinute();
434 			this.seconde = Configuration.getHandle().getTimerSeconde();
435 			this.heureTextField.setText(this.heure
436 					+ ":" + this.minute + ":" + this.seconde); //$NON-NLS-1$ //$NON-NLS-2$
437 			this.time = new javax.swing.Timer(1000, new Clock(this.seconde,
438 					this.minute, this.heure, this));
439 			this.time.start();
440 		} else {
441 			this.heureTextField.setText("00:00:00"); //$NON-NLS-1$
442 			this.timeChrono = new javax.swing.Timer(1000, new Clock(this));
443 			this.timeChrono.start();
444 		}
445 		this.southPanel.add(this.heureTextField, BorderLayout.EAST);
446 
447 		this.etatConnexionLabel.setFont(new Font("Dialog", 100, 12)); //$NON-NLS-1$
448 		this.etatConnexionLabel.setForeground(Color.black);
449 		this.etatConnexionLabel.setText(Messages
450 				.getString("mainWindow.STARTED")); //$NON-NLS-1$
451 		this.southPanel.add(this.etatConnexionLabel, BorderLayout.WEST);
452 
453 		// Barre de progression de la connexion
454 		this.myLoadBar = new LoadBar();
455 		this.myProgressPanel = new JPanel();
456 		this.myProgressPanel.setLayout(new GridLayout(3, 3));
457 		this.southPanel.add(this.myProgressPanel, BorderLayout.CENTER);
458 
459 		getContentPane().add(this.southPanel, BorderLayout.SOUTH);
460 		setJMenuBar(this.jMenuBar);
461 
462 		setTitle("NetPisteur v2   ::   $Revision: 1.7 $"); //$NON-NLS-1$
463 
464 		pack();
465 		if (Configuration.getHandle().getRootPage() == null) {
466 			this.maListeHL = new ListHL();
467 		} else {
468 			try {
469 				URL accueil = new URL(Configuration.getHandle().getRootPage());
470 				this.maListeHL = new ListHL(accueil);
471 			} catch (MalformedURLException ex) {
472 				log.error(Messages
473 						.getString("mainWindow.CANNOT_ACCESS"), ex); //$NON-NLS-1$
474 			}
475 		}
476 
477 		// creation of the timer which measures the downtime of the mouse
478 		this.t = timerMouse();
479 		this.t.start();
480 
481 		// post the banner page at the time of the launching of the navigator
482 		loadPage(this.maListeHL.getURLAccueil().toString());
483 	}
484 
485 	/**
486 	 * this method modify the heureTestField
487 	 * 
488 	 */
489 	public void setDuree(String laDuree) {
490 		this.heureTextField.setText(laDuree);
491 	}
492 
493 	/**
494 	 * Exit the Application
495 	 */
496 	void exitForm() {
497 
498 		if (this.withoutMonitor) {
499 			System.exit(0);
500 		} else {
501 			ClosingFrame fermeture = new ClosingFrame(this);
502 			fermeture.setLocationRelativeTo(null);
503 			fermeture.setVisible(true);
504 		}
505 	}
506 
507 	/**
508 	 * Save the datas
509 	 */
510 	public void saveDatas() {
511 
512 		File _rep = new File("data/" + AdvancedOptionsFrame._REP); //$NON-NLS-1$
513 		_rep.mkdir();
514 
515 		if (Configuration.getHandle().isMesurePlacement()) {
516 			this.maListePlace
517 					.writeListePlacementToDisk(
518 							"data/" //$NON-NLS-1$
519 									+ AdvancedOptionsFrame._REP
520 									+ "/" + Configuration.getHandle().getCobayeName() //$NON-NLS-1$
521 									+ "_ListePlacement.dat", Configuration.getHandle().getRootSeparator()); //$NON-NLS-1$
522 		}
523 
524 		if (Configuration.getHandle().isMesureClick()) {
525 			this.maListeClick
526 					.writeListeClickToDisk(
527 							"data/" //$NON-NLS-1$
528 									+ AdvancedOptionsFrame._REP
529 									+ "/" + Configuration.getHandle().getCobayeName() //$NON-NLS-1$
530 									+ "_ListeClick.dat", Configuration.getHandle().getRootSeparator()); //$NON-NLS-1$
531 		}
532 
533 		if (Configuration.getHandle().isMesureURL()) {
534 			this.maListeHL
535 					.writeHLClicToDisk(
536 							"data/"	+ AdvancedOptionsFrame._REP //$NON-NLS-1$
537 									+ "/" + Configuration.getHandle().getCobayeName() + "_ListeHL.dat", Configuration.getHandle().getRootSeparator()); //$NON-NLS-1$ //$NON-NLS-2$
538 		}
539 
540 		if (Configuration.getHandle().isMesureHL()) {
541 			this.maListeHL
542 					.writeListeHLToDisk(
543 							"data/"	+ AdvancedOptionsFrame._REP //$NON-NLS-1$
544 									+ "/" + Configuration.getHandle().getCobayeName() + "_Historique.dat", Configuration.getHandle().getRootSeparator()); //$NON-NLS-1$ //$NON-NLS-2$
545 		}
546 
547 		// FIXME
548 		System.exit(0);
549 	}
550 
551 	void aProposMenuMouseReleased(MouseEvent event) {
552 		AboutDialog ab = new AboutDialog(this, true);
553 		ab.setLocationRelativeTo(null);
554 		ab.setVisible(true);
555 
556 	}// void aProposMenuMouseReleased()
557 
558 	void manuelMenuMouseReleased(MouseEvent event) {
559 		log.info(getClass()
560 				.getResource("/com/drazzib/netpisteur/resources/help-fr.html").toString()); //$NON-NLS-1$
561 		loadPage(getClass().getResource("/com/drazzib/netpisteur/resources/help-fr.html").toString()); //$NON-NLS-1$
562 	} // void manuelMenuMouseReleased()
563 
564 	void sourceMenuItemMouseReleased(MouseEvent event) {
565 		SourceViewFrame fra = new SourceViewFrame(Messages
566 				.getString("mainWindow.SOURCE_PAGE")); //$NON-NLS-1$
567 		fra.setSize(600, 600);
568 
569 		this.source = this.viewer.getText();
570 		if (this.source != null) {
571 			fra.setText(this.source);
572 		} else {
573 			fra.setText(Messages.getString("mainWindow.UNABLE_SOURCE_PAGE")); //$NON-NLS-1$
574 		}
575 		fra.setVisible(true);
576 
577 	}// void sourceMenuItemMouseReleased()
578 
579 	void proxyConfMenuItemMouseReleased(MouseEvent event) {
580 		ConfigProxyFrame configProxyWindow = new ConfigProxyFrame();
581 		configProxyWindow.setLocationRelativeTo(null);
582 		configProxyWindow.setVisible(true);
583 	}// void proxyConfMenuItemMouseReleased()
584 
585 	void ouvrirMenuItemMouseReleased(MouseEvent event) {
586 		ExplorerFrame ouvrirFichierWindow = new ExplorerFrame(this);
587 		ouvrirFichierWindow.setVisible(true);
588 	}// void ouvrirMenuItemMouseReleased()
589 
590 	void buttonOkMouseReleased(MouseEvent event) {
591 		loadPage(this.addresseTextField.getText());
592 		try {
593 			URL url = new URL(this.addresseTextField.getText());
594 			this.maListeHL.add(url);
595 		} catch (MalformedURLException ex) {
596 			log.error(Messages.getString("mainWindow.UNABLE_ACCES")); //$NON-NLS-1$
597 		}
598 
599 	}// void buttonOkMouseReleased()
600 
601 	void acceuilButtonMouseReleased(MouseEvent event) {
602 		loadPage(this.maListeHL.getURLAccueil().toString());
603 		this.maListeHL.add(this.maListeHL.getURLAccueil());
604 	}// void acceuilButtonMouseReleased()
605 
606 	void rechargerButtonMouseReleased(MouseEvent event) {
607 		loadPage(this.maListeHL.getURLCourante().toString());
608 
609 	}// void rechargerButtonMouseReleased()
610 
611 	void stopButtonMouseReleased(MouseEvent event) {
612 		// Do nothing
613 	}// void stopButtonMouseReleased()
614 
615 	void suivantButtonMouseReleased(MouseEvent event) {
616 		loadPage(this.maListeHL.getURLSuivante().toString());
617 		this.maListeHL.addSui();
618 	}// void suivantButtonMouseReleased()
619 
620 	void precedentButtonMouseReleased(MouseEvent event) {
621 		loadPage(this.maListeHL.getURLPrecedente().toString());
622 		this.maListeHL.addPre();
623 	}
624 
625 	/**
626 	 * Method called after a clic on a bond hyper text
627 	 * 
628 	 * @param event
629 	 *            the hyperLinkEvent actived
630 	 */
631 	public void hyperlinkUpdate(HyperlinkEvent event) {
632 		if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
633 			// Modification of the field of seizure
634 			this.addresseTextField.setText(event.getURL().toString());
635 			if (event instanceof HTMLFrameHyperlinkEvent) {
636 				// Special event in the event of use of Frame HTML
637 				HTMLDocument doc = (HTMLDocument) this.viewer.getDocument();
638 				doc
639 						.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) event);
640 			} else {
641 				// Loading of the page
642 				loadPage(this.addresseTextField.getText());
643 			}
644 			this.maListeHL.add(event);
645 			log.info(this.maListeHL.getURLCourante().toString());
646 		}
647 	}
648 
649 	/**
650 	 * Method called after a submition of the address
651 	 * 
652 	 * @param event
653 	 *            the event
654 	 */
655 	public void actionPerformed(ActionEvent event) {
656 		loadPage(this.addresseTextField.getText());
657 		try {
658 			URL url = new URL(this.addresseTextField.getText());
659 			this.maListeHL.add(url);
660 			log.info(this.maListeHL.getURLCourante().toString());
661 		} catch (MalformedURLException ex) {
662 			log.error(Messages.getString("mainWindow.UNABLE_ACCESS")); //$NON-NLS-1$
663 		}
664 
665 	}
666 
667 	/**
668 	 * loading of the page
669 	 * 
670 	 * @param urlText
671 	 *            the page load
672 	 */
673 	public void loadPage(String urlText) {
674 		boolean connecte;
675 		String msgErreur = null;
676 		Cursor c = this.viewer.getCursor();
677 
678 		try {
679 			// Modification of the document visualizes
680 			URL url = new URL(urlText);
681 
682 			// Change of the cursor
683 
684 			Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
685 			setCursor(waitCursor);
686 			setProgressBar(true);
687 
688 			/*-----------------------------
689 			 *connection verification 
690 			 *-----------------------------
691 			 */
692 
693 			// definition of the type of connection with a patern factory
694 			ConnexionFactory cf;
695 			Connexion connexionCourante;
696 
697 			cf = new ConnexionFactory();
698 			connexionCourante = cf.creerConnexion(url);
699 			if (connexionCourante == null) {
700 				// failure of the creation of the connexionCourante object with
701 				// ConnexionFactor
702 				this.viewer.setText(Messages
703 						.getString("mainWindow.CANNOT_CREATE_CONNEXION")); //$NON-NLS-1$
704 
705 			} else {
706 				connecte = connexionCourante.connexion();
707 				// recuperation of the treatment of the errors
708 				msgErreur = connexionCourante.getMessageErreur();
709 				if (!connecte) {
710 					// posting of the result in bottom of the window on the
711 					// error
712 					// panel
713 					this.etatConnexionLabel.setText(msgErreur);
714 					this.viewer
715 							.setText(Messages.getString("mainWindow.ERROR") + msgErreur); //$NON-NLS-1$
716 				} else {
717 					// posting of the result in bottom of the window
718 					this.etatConnexionLabel.setText(msgErreur);
719 					log.info(Messages.getString("mainWindow.SHOW_OK") + msgErreur); //$NON-NLS-1$
720 
721 					// recuperation of the URL if treatment ok error
722 					url = connexionCourante.getTheUrl();
723 					log.info(Messages.getString("mainWindow.URL") + url.toString()); //$NON-NLS-1$
724 
725 				}
726 
727 				// deconnexion
728 				connexionCourante.deconnexion();
729 
730 				// Protocol of posting of the page
731 				if (connecte) {
732 					try {
733 						// viewer.setPage(url);
734 
735 						SwingUtilities.invokeLater(new PageLoader(url, c,
736 								this.viewer, this));
737 
738 						// parse.read(connexionCourante.getSourceByReader(),
739 						// viewer.getDocument(), 0);
740 					} catch (Exception e) {
741 						log.error(e);
742 					}
743 				}
744 				displayUrl(url);
745 				this.parse.setURL(url);
746 
747 			}
748 
749 		} catch (IOException ex) {
750 			log.error(Messages.getString("mainWindow.UNABLE_ACCESS") + urlText, ex); //$NON-NLS-1$
751 		} finally {
752 			setCursor(c);
753 			setProgressBar(false);
754 		}
755 	}
756 
757 	/**
758 	 * display the address of the page has to display @param u the url page of
759 	 * the page post
760 	 */
761 	public void displayUrl(URL u) {
762 		this.addresseTextField.setText(u.toString());
763 	}
764 
765 	/**
766 	 * delete the progress bar
767 	 */
768 	public void unsetProgressBar() {
769 		this.myLoadBar.unloadBar();
770 		this.myProgressPanel.remove(this.myLoadBar);
771 		this.myProgressPanel.validate();
772 
773 	}
774 
775 	/**
776 	 * display the progress bar
777 	 */
778 	public void setProgressBar(boolean pt) {
779 		if (pt) {
780 			this.myLoadBar.loadBar();
781 		} else {
782 			this.myLoadBar.unloadBar();
783 		}
784 		this.myProgressPanel.removeAll();
785 		this.myProgressPanel.add(new JLabel());
786 		this.myProgressPanel.add(new JLabel());
787 		this.myProgressPanel.add(new JLabel());
788 		this.myProgressPanel.add(new JLabel());
789 		this.myProgressPanel.add(this.myLoadBar);
790 		this.myProgressPanel.add(new JLabel());
791 		this.myProgressPanel.add(new JLabel());
792 		this.myProgressPanel.add(new JLabel());
793 		this.myProgressPanel.add(new JLabel());
794 		this.myProgressPanel.validate();
795 
796 	}
797 
798 	/**
799 	 * creation of the timer which measures the downtime of the mouse
800 	 */
801 	public javax.swing.Timer timerMouse() {
802 
803 		// Creation of an object of listener associated the timer
804 		ActionListener listener = new ActionListener() {
805 
806 			// Method called when the timer arrives at zero
807 			public void actionPerformed(ActionEvent event) {
808 				Placement p = new Placement(MainFrame.this.x, MainFrame.this.y,
809 						new GregorianCalendar());
810 				MainFrame.this.maListePlace.addPlacement(p);
811 				log.debug(Messages.getString("mainWindow.PLACEMENT") + MainFrame.this.x + " " + MainFrame.this.y); //$NON-NLS-1$ //$NON-NLS-2$
812 				MainFrame.this.t.stop();
813 			}
814 		};
815 		return new javax.swing.Timer(2000, listener);
816 	}// timerMouse()
817 
818 	public void setX(int x2) {
819 		this.x = x2;
820 	}
821 
822 	public void setY(int y2) {
823 		this.y = y2;
824 	}
825 
826 }