home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 273 cm19990307 - added support for new help engine
- // @Modified build 289 cm19990415 - added keyword extraction when there is no selection
- // @Modified build 291 cm19990430 - added MINDS checks in ShowHelp
- // @Modified build 315 cm19990725 - added var c line
- // @Modified build 326 cm19991005 - fixed GetBeginingOfWord
-
-
- /**
- @Tool: javeContextHelp~lets you get help from Windows Java help files.
- To use it select a keyword in a Java document and then hit F1, the tool bar
- help button or run this script. This script will also be invoked for document
- types based on the Java type. If you want to access
- Java help from another document type then assign this script a hot key.
- @Paragraph: Use the javaHelp script in Tools/Configuration to set the location
- of your Java help file.
- @EndTool:
- @Summary: javaContextHelp~lets you get help from Windows Java help files
- */
-
- var gOutput = getOutput();
-
- function DoCommand()
- {
- var useWin32Help = getMapFileValue("Preferences", "Use win32 help", false);
- if (useWin32Help)
- {
- Win32Help();
- }
- else
- {
- // Use built-in help
- var keyword = "";
- var editor = getActiveEditor();
- if (editor)
- {
- var selection = editor.getSelection();
- if (selection.empty())
- {
- var keyword = GetKeywordAtCaret(editor, selection)
- ShowHelp(keyword);
- }
- else
- {
- var keyword = editor.copy(selection);
- ShowHelp(keyword);
- }
- }
- }
- }
-
- function ShowHelp(keyword)
- {
- if (Application.isMindsInstalled())
- {
- if (Application.isMindsLoaded())
- {
- if (keyword == "" || !Application.showHelp(keyword, "java"))
- {
- alert("No help found for \"" + keyword + "\"");
- }
- }
- else
- {
- alert("The MINDS engine not yet loaded.\r\nTry again when MINDS is loaded.");
- }
- }
- else
- {
- var message = "The MINDS engine is not installed. To use MINDS\r\n";
- message += "restart the IDE without the /nominds option. To use\r\n";
- message += "winHelp turn on the option \"Use win32 help\".\r\n";
- alert(message);
- }
- }
-
- function GetBeginingOfWord(lineData, index)
- {
- while (index >= 0) // cm19991005 changed '=' to '>='
- {
- var c = lineData.charAt(index); //cm19990725
- if (c == ' ' || c == '\t' || c == '.'
- || c == '[' || c == '('
- || c == '"' || c == "'")
- {
- index += 1;
- break;
- }
- index -= 1;
- }
- return index >= 0 ? index : 0;
- }
-
- function GetKeywordAtCaret(editor, selection)
- {
- var lineData = editor.copy(selection.startLineIndex);
- var index = selection.startCharIndex;
- index = GetBeginingOfWord(lineData, index);
- //gOutput.writeLine("Index = " + index);
- var result = searchInString(lineData, "[A-Z|a-z|0-9]*", index, true);
- if (result)
- {
- return result.key;
- }
- return "";
- }
-
-
- function Win32Help()
- {
- var helpers = getMapFile("ApplicationHelpers");
- if (helpers)
- {
- var javaHelp = helpers.lookup("java-help");
- if (javaHelp && javaHelp.exists)
- {
- var editor = getActiveEditor();
- if (editor)
- {
- var selection = editor.getSelection();
- var keyword = editor.copy(selection);
- winHelp("Keyword", javaHelp.path, keyword);
- }
- else
- {
- winHelp("Contents", javaHelp.path);
- }
- }
- else
- {
- var result = confirm("You need to run the Java help setup script\n"
- + "before you can use this command.\n" +
- "Do you want to run the setup script now?");
- if (result)
- {
- run("Configuration\\JavaHelp");
- }
- }
- }
- }
- !!/Script
-