4 * License : The MIT License
\r
5 * Copyright(c) 2008 olyutorskii
\r
8 package jp.sourceforge.jindolf;
\r
10 import java.awt.Container;
\r
11 import java.awt.GridBagConstraints;
\r
12 import java.awt.GridBagLayout;
\r
13 import java.awt.Insets;
\r
14 import java.awt.event.ActionEvent;
\r
15 import java.awt.event.ActionListener;
\r
16 import java.awt.event.WindowAdapter;
\r
17 import java.awt.event.WindowEvent;
\r
18 import java.io.IOException;
\r
19 import java.net.URL;
\r
20 import javax.swing.BorderFactory;
\r
21 import javax.swing.JButton;
\r
22 import javax.swing.JEditorPane;
\r
23 import javax.swing.JFrame;
\r
24 import javax.swing.JScrollPane;
\r
25 import javax.swing.JSeparator;
\r
26 import javax.swing.JTabbedPane;
\r
27 import javax.swing.JTextArea;
\r
28 import javax.swing.border.Border;
\r
29 import javax.swing.event.HyperlinkEvent;
\r
30 import javax.swing.event.HyperlinkListener;
\r
35 @SuppressWarnings("serial")
\r
36 public class HelpFrame extends JFrame
\r
37 implements ActionListener, HyperlinkListener{
\r
39 private static final String HELP_HTML = "resources/html/help.html";
\r
41 private final JTabbedPane tabPanel = new JTabbedPane();
\r
42 private final JEditorPane htmlView = new JEditorPane();
\r
43 private final JTextArea vmInfo = new JTextArea();
\r
44 private final JButton closeButton = new JButton("閉じる");
\r
50 super(Jindolf.TITLE + " ヘルプ");
\r
52 GUIUtils.modifyWindowAttributes(this, true, false, true);
\r
54 this.htmlView.setEditable(false);
\r
55 this.htmlView.setContentType("text/html");
\r
56 this.htmlView.putClientProperty(JEditorPane.W3C_LENGTH_UNITS,
\r
58 this.htmlView.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
\r
60 Border border = BorderFactory.createEmptyBorder(0, 0, 0, 0);
\r
61 this.htmlView.setBorder(border);
\r
62 this.htmlView.addHyperlinkListener(this);
\r
63 this.htmlView.setComponentPopupMenu(new TextPopup());
\r
65 this.vmInfo.setEditable(false);
\r
66 this.vmInfo.setLineWrap(true);
\r
67 this.vmInfo.setComponentPopupMenu(new TextPopup());
\r
69 this.closeButton.addActionListener(this);
\r
71 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
\r
72 addWindowListener(new WindowAdapter(){
\r
74 public void windowClosing(WindowEvent event){
\r
79 URL topUrl = Jindolf.getResource(HELP_HTML);
\r
82 StringBuilder info = new StringBuilder();
\r
83 info.append(EnvInfo.getVMInfo());
\r
84 AppSetting setting = Jindolf.getAppSetting();
\r
85 if(setting.useConfigPath()){
\r
86 info.append("設定格納ディレクトリ : "
\r
87 + setting.getConfigPath().getPath() );
\r
89 info.append("※ 設定格納ディレクトリは使っていません。");
\r
91 this.vmInfo.setText(info.toString());
\r
101 private void design(){
\r
102 Container content = this.getContentPane();
\r
103 GridBagLayout layout = new GridBagLayout();
\r
104 GridBagConstraints constraints = new GridBagConstraints();
\r
105 content.setLayout(layout);
\r
107 constraints.gridwidth = GridBagConstraints.REMAINDER;
\r
108 constraints.insets = new Insets(5, 5, 5, 5);
\r
109 constraints.weightx = 1.0;
\r
110 constraints.weighty = 1.0;
\r
111 constraints.fill = GridBagConstraints.BOTH;
\r
113 JScrollPane sc = new JScrollPane(this.htmlView);
\r
114 this.tabPanel.add("ヘルプ", sc);
\r
115 sc = new JScrollPane(this.vmInfo);
\r
116 this.tabPanel.add("実行環境", sc);
\r
117 content.add(this.tabPanel, constraints);
\r
119 constraints.weighty = 0.0;
\r
120 constraints.fill = GridBagConstraints.HORIZONTAL;
\r
121 content.add(new JSeparator(), constraints);
\r
123 constraints.weightx = 0.0;
\r
124 constraints.anchor = GridBagConstraints.EAST;
\r
125 constraints.fill = GridBagConstraints.NONE;
\r
126 content.add(this.closeButton, constraints);
\r
134 private void close(){
\r
140 * URLの示すHTML文書を表示する。
\r
143 private void loadURL(URL url){
\r
144 if(url == null) return;
\r
147 this.htmlView.setPage(url);
\r
148 }catch(IOException e){
\r
149 Jindolf.logger().warn("ヘルプファイルが読み込めません", e);
\r
159 * @param event ボタン押下イベント {@inheritDoc}
\r
162 public void actionPerformed(ActionEvent event){
\r
163 if(event.getSource() != this.closeButton) return;
\r
171 * @param event リンククリックイベント {@inheritDoc}
\r
174 public void hyperlinkUpdate(HyperlinkEvent event){
\r
175 if(event.getEventType() != HyperlinkEvent.EventType.ACTIVATED){
\r
179 URL url = event.getURL();
\r