01: package de.ixdb.squirrel_sql.plugins.cache;
02:
03: import net.sourceforge.squirrel_sql.client.session.ISession;
04: import net.sourceforge.squirrel_sql.client.session.mainpanel.IMainPanelTab;
05:
06: import javax.swing.*;
07: import javax.swing.event.HyperlinkEvent;
08: import javax.swing.event.HyperlinkListener;
09: import javax.swing.text.html.HTMLDocument;
10: import javax.swing.text.html.HTMLFrameHyperlinkEvent;
11: import java.awt.*;
12:
13: public class QueryPlanTab implements IMainPanelTab {
14: private QueryPlanPanel _queryPlanPanel;
15: private QueryPlanTabListener _queryPlanTabListener;
16:
17: QueryPlanTab(String executionPlanHtml,
18: QueryPlanTabListener queryPlanTabListener) {
19: _queryPlanTabListener = queryPlanTabListener;
20:
21: _queryPlanPanel = new QueryPlanPanel();
22: _queryPlanPanel.txtQueryPlan.setContentType("text/html");
23: _queryPlanPanel.txtQueryPlan
24: .addHyperlinkListener(new HyperlinkListener() {
25: public void hyperlinkUpdate(HyperlinkEvent e) {
26: onHyperlinkUpdate(e);
27: }
28: });
29: _queryPlanPanel.txtQueryPlan.setEditable(false);
30: _queryPlanPanel.txtQueryPlan.setText(executionPlanHtml);
31:
32: SwingUtilities.invokeLater(new Runnable() {
33: public void run() {
34: _queryPlanPanel.txtQueryPlan
35: .scrollRectToVisible(new Rectangle(0, 0, 1, 1));
36: }
37: });
38:
39: }
40:
41: private void onHyperlinkUpdate(HyperlinkEvent e) {
42: if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
43: if (ShowQueryPlanAction.HREF_CLOSE_QUERY_PLAN.equals(e
44: .getDescription())) {
45: _queryPlanTabListener.closeRequested();
46:
47: } else {
48: _queryPlanPanel.txtQueryPlan.scrollToReference(e
49: .getDescription());
50: }
51: }
52: }
53:
54: public String getTitle() {
55: return "Query plan";
56: }
57:
58: public String getHint() {
59: return getTitle();
60: }
61:
62: public Component getComponent() {
63: return _queryPlanPanel;
64: }
65:
66: public void setSession(ISession session) {
67: }
68:
69: public void sessionClosing(ISession session) {
70: }
71:
72: public void select() {
73: }
74:
75: }
|