root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / help / HelpPanel.java @ 29593
History | View | Annotate | Download (2.04 KB)
1 |
package org.gvsig.andami.help; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Frame; |
5 |
import java.awt.event.ComponentEvent; |
6 |
import java.awt.event.ComponentListener; |
7 |
|
8 |
import javax.help.BadIDException; |
9 |
import javax.help.HelpSet; |
10 |
import javax.help.JHelp; |
11 |
import javax.swing.JPanel; |
12 |
|
13 |
import org.slf4j.Logger; |
14 |
import org.slf4j.LoggerFactory; |
15 |
|
16 |
public class HelpPanel extends JPanel { |
17 |
|
18 |
private static final long serialVersionUID = 4164482247505362337L; |
19 |
|
20 |
public static int WIDTH = 645; |
21 |
public static int HEIGHT = 495; |
22 |
private String title = null; |
23 |
private JHelp jh;
|
24 |
|
25 |
private Logger log() { |
26 |
return LoggerFactory.getLogger("org.gvsig"); |
27 |
} |
28 |
|
29 |
public HelpPanel(HelpSet hs){
|
30 |
log().info("HelpPanel(hs)");
|
31 |
init(hs,null);
|
32 |
} |
33 |
|
34 |
public HelpPanel(HelpSet hs, String id){ |
35 |
log().info("HelpPanel(hs,id) id="+id);
|
36 |
init(hs,id); |
37 |
} |
38 |
|
39 |
private void init(HelpSet hs, String id){ |
40 |
jh = new JHelp(hs);
|
41 |
log().info("init() ID "+ id);
|
42 |
if (id != null) { |
43 |
try {
|
44 |
log().info("init() setCurrentID "+ id);
|
45 |
jh.setCurrentID(id); |
46 |
} catch (BadIDException ex) {
|
47 |
log().error(ex.toString()); |
48 |
|
49 |
} catch (NullPointerException ex) { |
50 |
log().error(ex.toString()); |
51 |
} |
52 |
} |
53 |
String hsTitle = hs.getTitle();
|
54 |
if (hsTitle == null || hsTitle.equals("")) { |
55 |
hsTitle = "gvSIG Help";
|
56 |
} |
57 |
title = hsTitle; |
58 |
setLayout(new BorderLayout()); |
59 |
add(jh,BorderLayout.CENTER);
|
60 |
} |
61 |
|
62 |
public void showWindow() { |
63 |
|
64 |
log().info("showWindow()");
|
65 |
Frame frame = new Frame(); |
66 |
frame.add(this);
|
67 |
frame.setSize(WIDTH, HEIGHT + 30);
|
68 |
frame.setTitle(getTitle()); |
69 |
frame.setResizable(true);
|
70 |
this.setVisible(true); |
71 |
frame.show(); |
72 |
} |
73 |
|
74 |
public void showWindow(String id) { |
75 |
if (id != null) { |
76 |
try {
|
77 |
log().info("showWindow(id) -> setCurrentID "+ id);
|
78 |
jh.setCurrentID(id); |
79 |
} catch (BadIDException ex) {
|
80 |
log().error(ex.toString()); |
81 |
} |
82 |
} |
83 |
String hsTitle = jh.getHelpSetPresentation().getTitle();
|
84 |
if (hsTitle == null || hsTitle.equals("")) { |
85 |
hsTitle = "gvSIG Help";
|
86 |
} |
87 |
title = hsTitle; |
88 |
showWindow(); |
89 |
} |
90 |
|
91 |
public String getTitle() { |
92 |
return this.title; |
93 |
} |
94 |
|
95 |
} |