diff --git a/extra/jheidi/helpDialog.ajl b/extra/jheidi/helpDialog.ajl new file mode 100644 index 00000000..4bd44fbb --- /dev/null +++ b/extra/jheidi/helpDialog.ajl @@ -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(); + + + + + + + diff --git a/extra/jheidi/helpDialogEvents.ajl b/extra/jheidi/helpDialogEvents.ajl new file mode 100644 index 00000000..8d7e8754 --- /dev/null +++ b/extra/jheidi/helpDialogEvents.ajl @@ -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(); + } + + + + + + + + + + + + + + + + + + + diff --git a/extra/jheidi/helpMenuEvents.ajl b/extra/jheidi/helpMenuEvents.ajl index 32af58ef..c3afc2dc 100644 --- a/extra/jheidi/helpMenuEvents.ajl +++ b/extra/jheidi/helpMenuEvents.ajl @@ -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 { - + diff --git a/extra/jheidi/images/helpitem.gif b/extra/jheidi/images/helpitem.gif new file mode 100755 index 00000000..9235de52 Binary files /dev/null and b/extra/jheidi/images/helpitem.gif differ diff --git a/extra/jheidi/images/helptopic.gif b/extra/jheidi/images/helptopic.gif new file mode 100755 index 00000000..5edd28c0 Binary files /dev/null and b/extra/jheidi/images/helptopic.gif differ diff --git a/extra/jheidi/initHelpTree.ajl b/extra/jheidi/initHelpTree.ajl new file mode 100644 index 00000000..71f6e946 --- /dev/null +++ b/extra/jheidi/initHelpTree.ajl @@ -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 curItems = db.execute("help contents"); + NodeInfo curNode = root; + + Stack stack = new Stack(); + 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(); + + + + + + + + + + + + + + + + + diff --git a/extra/jheidi/mainToolbarEvents.ajl b/extra/jheidi/mainToolbarEvents.ajl index 51997047..00a2b0bf 100644 --- a/extra/jheidi/mainToolbarEvents.ajl +++ b/extra/jheidi/mainToolbarEvents.ajl @@ -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("/");