1 package org.opensync.engine.admin.gui;
2
3 import java.awt.CardLayout;
4 import java.io.FileNotFoundException;
5 import java.net.URL;
6
7 import javax.swing.BorderFactory;
8 import javax.swing.JFrame;
9 import javax.swing.JOptionPane;
10 import javax.swing.JPanel;
11 import javax.swing.JScrollPane;
12 import javax.swing.JTextPane;
13 import javax.swing.border.Border;
14 import javax.swing.event.HyperlinkEvent;
15 import javax.swing.event.HyperlinkListener;
16
17 import org.opensync.engine.util.I18n;
18
19 /***
20 *
21 * @version 1.0
22 * @author SOFTMED
23 *
24 */
25
26 public class ViewFileFrm extends JFrame implements HyperlinkListener{
27 JPanel panel = new JPanel();
28 JTextPane textPanel = new JTextPane();
29 JScrollPane scrollPane = new JScrollPane();
30 Border border;
31
32 /***
33 * @param title ?task?
34 * @param url ?log?
35 */
36 public ViewFileFrm(String title,URL url) {
37 super(title);
38 try {
39 border = BorderFactory.createEmptyBorder(10,10,10,10);
40 textPanel.setBorder(border);
41 textPanel.setEditable(false);
42 textPanel.addHyperlinkListener(this);
43 panel.setLayout(new CardLayout());
44 panel.add(scrollPane,"");
45 scrollPane.getViewport().add(textPanel,null);
46 getContentPane().add(scrollPane);
47 setSize(600,600);
48 textPanel.setPage(url);
49 }
50 catch(FileNotFoundException e){
51 JOptionPane.showMessageDialog(this,
52 I18n.getInstance().format(
53 "error.file.not-found",new Object[]{url}
54 )
55 );
56 }
57 catch (Exception ex) {
58 ex.printStackTrace();
59 }
60 }
61 /***
62 * @param e
63 */
64 public void hyperlinkUpdate(HyperlinkEvent e) {
65 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
66 try {
67 textPanel.setPage(e.getURL());
68 }
69 catch (Exception ex) {
70 JOptionPane.showMessageDialog(this,
71 I18n.getInstance().format(
72 "error.file.not-found",new Object[]{e.getURL()}
73 )
74 );
75 }
76 }
77 }
78 }