View Javadoc

1   package gov.nasa.pds.ltdt.gui;
2   
3   import gov.nasa.pds.ltdt.gui.configuration.LTDTKeys;
4   import gov.nasa.pds.ltdt.gui.util.Utility;
5   
6   import java.awt.event.ActionEvent;
7   import java.io.IOException;
8   import java.net.URL;
9   import java.util.Properties;
10  
11  import javax.swing.AbstractAction;
12  import javax.swing.Icon;
13  import javax.swing.JOptionPane;
14  
15  public class HelpAction extends AbstractAction {
16  	
17  	private Properties props;
18  	private MainWindow window;
19  	
20  	public HelpAction(String name, Icon image, String desc, Integer mnemonic, Properties props, MainWindow window) {
21  		
22  		super (name, image);
23  		putValue (SHORT_DESCRIPTION, desc);
24  		putValue (MNEMONIC_KEY, mnemonic);
25  		
26  		this.props = props;
27  		this.window = window;
28  			
29  	}
30  
31  	public void actionPerformed(ActionEvent ae) {
32  	
33  		URL toolInfoURL = this.getClass().getResource("ltdtool.properties");
34  		
35  		if (toolInfoURL!=null) {
36  			try {
37  				Properties tempProps = Utility.getProperties (toolInfoURL);
38  				
39  				StringBuffer message = new StringBuffer();
40  				message.append(tempProps.get(LTDTKeys.TOOLNAME)+System.getProperty("line.separator"));
41  				message.append(tempProps.get(LTDTKeys.TOOLVERSION)+System.getProperty("line.separator"));
42  				message.append(tempProps.get(LTDTKeys.TOOLRELEASEDATE)+System.getProperty("line.separator"));
43  				message.append(tempProps.get(LTDTKeys.TOOLCOPYRIGHT)+System.getProperty("line.separator")+System.getProperty("line.separator"));
44  				
45  				JOptionPane.showMessageDialog(window, message.toString(), "LTDTool Help", JOptionPane.INFORMATION_MESSAGE, null);
46  			}
47  			catch (IOException ex) {
48  				JOptionPane.showMessageDialog(window, "IO Exception. "+ex.getMessage());
49  			}
50  		}
51  		
52  	}
53  	
54  
55  }