View Javadoc

1   /*
2    *                Doelan development code
3    *
4    * This code may be freely distributed and modified under the
5    * terms of the GNU General Public Licence.  This should
6    * be distributed with the code. If you do not have a copy,
7    * see:
8    *
9    *      http://www.gnu.org/copyleft/gpl.txt
10   *
11   * Copyright (c) 2004-2005 ENS Microarray Platform
12   * Copyright for this code is held jointly by the individual
13   * authors.  These should be listed in @author doc comments.
14   *
15   * For more information on the Doelan project and its aims,
16   * or to join the Doelan mailing list, visit the home page
17   * at:
18   *
19   *      http://www.transcriptome.ens.fr/doelan
20   */
21  
22  package fr.ens.transcriptome.doelan.gui;
23  
24  import java.awt.Font;
25  import java.awt.event.MouseEvent;
26  import java.awt.event.MouseListener;
27  import java.io.IOException;
28  import java.net.URL;
29  
30  import javax.swing.ImageIcon;
31  import javax.swing.JLabel;
32  import javax.swing.JOptionPane;
33  import javax.swing.JPanel;
34  import javax.swing.JTextPane;
35  
36  import fr.ens.transcriptome.doelan.DoelanRegistery;
37  import fr.ens.transcriptome.nividic.util.WebBrowser;
38  
39  /***
40   * About widget
41   * @author Laurent Jourdren
42   */
43  public class AboutWidget extends JPanel {
44  
45    private class WebSiteMouseListener implements MouseListener {
46  
47      private String browserPath = DoelanRegistery.getBrowserPath();
48      private String url;
49  
50      private void setURL(final String url) {
51        this.url = url;
52      }
53  
54      public void mouseClicked(final MouseEvent e) {
55  
56        try {
57  
58          WebBrowser.launch(browserPath, this.url);
59        } catch (IOException exception) {
60          showMessage("Error while launching navigator : "
61              + exception.getMessage(), true);
62        }
63  
64      }
65  
66      public void mouseEntered(final MouseEvent e) {
67      }
68  
69      public void mouseExited(final MouseEvent e) {
70      }
71  
72      public void mousePressed(final MouseEvent e) {
73      }
74  
75      public void mouseReleased(final MouseEvent e) {
76      }
77  
78      public WebSiteMouseListener(final String url) {
79        setURL(url);
80      }
81  
82    }
83  
84    /***
85     * Show a message to the user.
86     * @param message Message to show
87     * @param error true if message is an error
88     */
89    private void showMessage(final String message, final boolean error) {
90  
91      JOptionPane.showMessageDialog(this, message, error ? "Error" : "Message",
92          error ? JOptionPane.ERROR_MESSAGE : JOptionPane.WARNING_MESSAGE);
93    }
94  
95    private void init() {
96  
97      setLayout(new java.awt.GridLayout(1, 2));
98  
99      URL url = CommonWindow.class.getResource("/files/doelan-300.png");
100     ImageIcon ii = new ImageIcon(url);
101 
102     JLabel logoLabel = new JLabel(ii);
103     logoLabel.setToolTipText("Click to view " + DoelanRegistery.getAppName()
104         + " website");
105 
106     add(logoLabel);
107     // add(new JLabel(" "));
108 
109     JTextPane copyrightLabel = new javax.swing.JTextPane();
110     // copyrightLabel.setLineWrap(true);
111     // jLabel4.setFocusable(false);
112     copyrightLabel.setEditable(false);
113 
114     copyrightLabel.setBackground(logoLabel.getBackground());
115     // copyrightLabel.setWrapStyleWord(true);
116     // copyrightLabel.setForeground(Color.MAGENTA);
117     copyrightLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
118 
119     copyrightLabel.setText(DoelanRegistery.about());
120     // copyrightLabel.setDragEnabled(false);
121     // copyrightLabel.setFocusable(false);
122     copyrightLabel.setToolTipText("Click to view "
123         + DoelanRegistery.getOrganizationName() + " website");
124 
125     add(copyrightLabel);
126 
127     // add link to the webs site of the project
128     if (!DoelanRegistery.isAppletMode()) {
129 
130       WebSiteMouseListener goProjectWebsiteListener = new WebSiteMouseListener(
131           DoelanRegistery.getAppURL());
132       WebSiteMouseListener goOrganizationWebsiteListener = new WebSiteMouseListener(
133           DoelanRegistery.getOrganizationURL());
134 
135       logoLabel.addMouseListener(goProjectWebsiteListener);
136       copyrightLabel.addMouseListener(goOrganizationWebsiteListener);
137     }
138 
139   }
140 
141   //
142   // Constructor
143   //
144 
145   /***
146    * Public constructor.
147    */
148   public AboutWidget() {
149     init();
150   }
151 
152 }