mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
implement help browser
This commit is contained in:
65
extra/jheidi/helpDialog.ajl
Normal file
65
extra/jheidi/helpDialog.ajl
Normal file
@@ -0,0 +1,65 @@
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
|
||||
WindowContext parentContext = argObj("windowContext");
|
||||
Dialog dlg = new Dialog((Frame)parentContext.get("/"),"helpDialog", "SQL Help" );
|
||||
WindowContext context = dlg.getWindowContext();
|
||||
context.put("db", parentContext.get("db"));
|
||||
|
||||
dlg.events("helpDialogEvents");
|
||||
dlg.tabLayout();
|
||||
dlg.insets(10, 10);
|
||||
dlg.tree("helpTree", new Object[] {"A Tree"}, 250, 400);
|
||||
|
||||
//this is the only reliable component in terms of vsize to align on
|
||||
Component tree = dlg.get("helpTreeScrollPane");
|
||||
|
||||
dlg.space(5)
|
||||
.vspace(-6)
|
||||
.text("No Topic Selected", 250)
|
||||
.setTab()
|
||||
.nextRow()
|
||||
.baseline(tree)
|
||||
.tab(1)
|
||||
.vspace(15)
|
||||
.textArea("helpText", 450, 175)
|
||||
.nextRow()
|
||||
.baseline(tree)
|
||||
.vspace(191)
|
||||
.tab(1)
|
||||
.text("Example:")
|
||||
.nextRow()
|
||||
.baseline(tree)
|
||||
.vspace(215)
|
||||
.tab(1)
|
||||
.textArea("exampleText", 450, 180)
|
||||
.nextRow()
|
||||
.baseline(tree)
|
||||
.vspace(405)
|
||||
.line(712)
|
||||
.nextRow()
|
||||
.vspace(5)
|
||||
.space(481)
|
||||
.button("Search MySQL", 110)
|
||||
.space(5)
|
||||
.button("Close", 110)
|
||||
.setDefaultButton("Close");
|
||||
|
||||
((TextArea)context.get("/helpText")).setEditable(false);
|
||||
((TextArea)context.get("/exampleText")).setEditable(false);
|
||||
((Tree)context.get("/helpTree")).setRootVisible(false);
|
||||
((Tree)context.get("/helpTree")).setShowsRootHandles(true);
|
||||
((Text)context.get("/No Topic Selected")).style(Font.BOLD);
|
||||
|
||||
|
||||
args().put("windowContext", context);
|
||||
script("initHelpTree", args());
|
||||
|
||||
dlg.visible();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
63
extra/jheidi/helpDialogEvents.ajl
Normal file
63
extra/jheidi/helpDialogEvents.ajl
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
String who = arg("source");
|
||||
NodeInfo node = argObj("node");
|
||||
WindowContext context = argObj("windowContext");
|
||||
|
||||
log.debug("event received: " + who);
|
||||
|
||||
if ( node != null )
|
||||
{
|
||||
String nodeType = node.getType();
|
||||
log.debug("node type = " + nodeType);
|
||||
if ( "helpitem".equals(nodeType) )
|
||||
{
|
||||
String itemName = node.getText();
|
||||
log.debug("itemName: " + itemName + " clicked");
|
||||
|
||||
DB db = context.get("db");
|
||||
db.begin();
|
||||
DB.Result items = db.execute("help '" + itemName + "'");
|
||||
if ( !items.isEmpty() )
|
||||
{
|
||||
HashObject item = items.first();
|
||||
((Text)context.get("/No Topic Selected")).setText(itemName);
|
||||
TextArea helpText = context.get("/helpText");
|
||||
TextArea exampleText = context.get("/exampleText");
|
||||
helpText.setText(item.get("description"));
|
||||
helpText.setCaretPosition(0);
|
||||
exampleText.setText(item.get("example"));
|
||||
exampleText.setCaretPosition(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( "Search MySQL".equals(who) )
|
||||
{
|
||||
String query = ((Text)context.get("/No Topic Selected")).getText();
|
||||
query = "No Topic Selected".equals(query) ? "" : query.replace(" ", "+");
|
||||
|
||||
BareBonesBrowserLaunch.openURL("http://dev.mysql.com/doc/mysql/search.php?version=5.1&q=" + query + "&lang=en");
|
||||
}
|
||||
else if ( "Close".equals(who) )
|
||||
{
|
||||
Dialog d = context.get("/");
|
||||
d.dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
|
||||
String who = arg("source");
|
||||
|
||||
String who = arg("source");
|
||||
|
||||
WindowContext context = argObj("windowContext");
|
||||
|
||||
log.debug("Event received: " + who);
|
||||
log.debug("Event received: " + who);
|
||||
|
||||
if ("Heidi SQL Website".equals(who))
|
||||
if ("SQL Help".equals(who))
|
||||
{
|
||||
script("helpDialog", args());
|
||||
}
|
||||
else if ("Heidi SQL Website".equals(who))
|
||||
{
|
||||
BareBonesBrowserLaunch.openURL("http://www.heidisql.com");
|
||||
}
|
||||
@@ -41,5 +45,5 @@ else {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
extra/jheidi/images/helpitem.gif
Executable file
BIN
extra/jheidi/images/helpitem.gif
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 351 B |
BIN
extra/jheidi/images/helptopic.gif
Executable file
BIN
extra/jheidi/images/helptopic.gif
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 580 B |
76
extra/jheidi/initHelpTree.ajl
Normal file
76
extra/jheidi/initHelpTree.ajl
Normal file
@@ -0,0 +1,76 @@
|
||||
import java.util.*;
|
||||
|
||||
WindowContext context = argObj("windowContext");
|
||||
HashObject profile = context.get("profile");
|
||||
Tree tree = context.get("/helpTree");
|
||||
NodeInfo root = (NodeInfo)tree.getModel().getRoot();
|
||||
|
||||
tree.setCellRenderer(new IconicCellRenderer("images/helptopic.gif", "images/helpitem.gif"));
|
||||
|
||||
DB db = context.get("db");
|
||||
db.begin();
|
||||
|
||||
List<HashObject> curItems = db.execute("help contents");
|
||||
NodeInfo curNode = root;
|
||||
|
||||
Stack<HashObject> stack = new Stack<HashObject>();
|
||||
HashObject pointer = new HashObject();
|
||||
pointer.put("node", curNode);
|
||||
pointer.put("items", curItems);
|
||||
stack.push(pointer);
|
||||
|
||||
while (!stack.empty())
|
||||
{
|
||||
pointer = stack.pop();
|
||||
curItems = pointer.getObject("items");
|
||||
curNode = pointer.getObject("node");
|
||||
|
||||
for ( HashObject item: curItems)
|
||||
{
|
||||
if ( "Y".equals(item.get("is_it_category")))
|
||||
{
|
||||
NodeInfo branch = new NodeInfo(item.get("name"));
|
||||
//this if statement is needed because of bugs in some mysql help tables
|
||||
//causing infinite recursion. lazier loading in jheidi would also work.
|
||||
if ( !branch.getText().equals(curNode.getText()))
|
||||
{
|
||||
branch.setType("helptopic");
|
||||
branch.setIcon("helptopic");
|
||||
HashObject newPointer = new HashObject();
|
||||
newPointer.put("items", db.execute("help '" + item.get("name") + "'"));
|
||||
newPointer.put("node", branch);
|
||||
curNode.add(branch);
|
||||
stack.push(newPointer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeInfo leaf = new NodeInfo(item.get("name"));
|
||||
leaf.setType("helpitem");
|
||||
leaf.setIcon("helpitem");
|
||||
curNode.add(leaf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
db.end();
|
||||
|
||||
tree.updateUI();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -99,10 +99,6 @@ else if ("Drop Database".equals(who))
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("Help".equals(who))
|
||||
{
|
||||
BareBonesBrowserLaunch.openURL("http://www.heidisql.com");
|
||||
}
|
||||
else if ("Close".equals(who) )
|
||||
{
|
||||
Frame window = context.get("/");
|
||||
|
||||
Reference in New Issue
Block a user