Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.netcomputing.anyj.scripting
Class AnyJAPI

    java.lang.Object
      |
      +--de.netcomputing.anyj.scripting.AnyJAPI

public class AnyJAPI
extends java.lang.Object

This class is a collection of methods, which can be used from scripts.
This is the first version of the API, so it contains just a view essential methods. The current API is useful to integrate external functionality. It is to weak at this point to create major extensions or enhancements.
The AnyJ API basically follows a functional approach. At least we think this makes it more easy for us to keep the API stable. Exposing the underlying design of AnyJ would make internal redesign of AnyJ more expensive.
What you can do using scripting

- Add menu items to (Tools|Scripting), see AJExternalService
- Access the current selected context of AnyJ
- Access some basic settings ('getEnvironment()')
- Basic manipulation of the Editor Document
- Invoke arbitrary menu items

If you need additional functionality, don't hesitate to mail to 'api@netcomputing.de'. We will quickly provide you with a patch implementing missing functionality.

Constructor Summary
`AnyJAPI()`

Method Summary
`void` | `addMenuStructure(java.lang.String[] newMenu)` define the structure of the main menu.
`java.util.List` | `chooseFromList(java.lang.String dlgTitle, java.lang.String title, java.util.List items, java.util.List initialSel, int width, int height)` Lets the user choose from a List of items.
`void` | `closeEditor(java.lang.String path, boolean askIfModified)` Closes the given file if opened.
`AJSDirDiffResult` | `compareDirs(java.io.File a, java.io.File b, java.io.FilenameFilter filter, boolean ignoreComments, boolean ignoreWhiteSpace)` compare two direcories 'a', 'b'
`java.util.Vector` | `dirContent(java.io.File dir, java.lang.String ending, boolean recursive)` returns a vector of File objects, whose name ends with the gioven ending (use '' to return everything). if ending == "none", only directories are enumerated.
`int` | `executeExternalProcess(java.lang.String outputLabel, java.lang.String workingDirectory, java.lang.String commandline)` Execute an External Process synchrounous (return when process has finished).
`AJSTextDocument` | `getDocumentIfOpen(java.lang.String absPath)` returns an AJSTextDocument if it is currently opened. null otherwise.
`java.util.Hashtable` | `getEnvironment()` returns the current environment of AnyJ.
`java.lang.String` | `getInterpreterClasspath()` return the classpath used by the interpreter this is anyj.jar, your workspaces runtime classpath and all jars found in the [anyjuserhome]/scripts directory
`java.awt.Frame` | `getMainWindow()` returns the main window of AnyJ.
`java.util.Vector` | `getOpenedFiles()` returns a Vector of absolute files (Strings) currently opened in the Editor
`AJSOutput` | `getOrCreateOutputPanel(java.lang.String name)` get (or create if not present) an output panel in AnyJ's output pane
`boolean` | `invokeService(java.lang.String service, java.lang.Object argument0)` invoke a service (a menu item) with the given argument. the name should look like: [category][blank][full name as seen in menu] look in the Preferences,'menus and Shortcuts' to obtain the category of a menu item. e.g.
`void` | `openDirDiff(java.io.File pathA, java.io.File pathB)` Opens a directory diffview on the given files
`void` | `openEditor(java.lang.String path)` Opens the given file in AnyJ.
`void` | `openFileDiff(java.lang.String title, java.lang.String leftTitle, java.lang.String rightTitle, java.io.File pathA, java.io.File pathB)` Opens a diffview on the given files
`void` | `registerMenuHandler(AJExternalService serv)` registers a new userdefined (scripting) menu item (=Service).
`java.lang.String` | `ressolveSymbolicVariables(java.lang.String s)` same as 'ressolveSymbolicVariables( s, getEnvironment() );'
`java.lang.String` | `ressolveSymbolicVariables(java.lang.String s, java.util.Hashtable environment)` replace all occurences of ($varName) by the result of looking up 'varName' in the given 'environment' Hashtable
`void` | `runScript(java.lang.String fileName)` runs a script (by interpreting).
`void` | `setMenuStructure(java.lang.String[] newMenu)` define the structure of the main menu.
`void` | `setPopupMenuStructure(java.lang.String[] newMenu)` Deprecated.
`java.util.List` | `splitSeparatedString(java.lang.String stringToSplit, java.lang.String separator)` Splits a String into a list of strings
`static AnyJAPI` | `This()` The one and only API object.
`void` | `updateFileTree()` synchronizes filebrowser and browser outlines (e.g. files have been added externally).
`void` | `updateMenus()` refresh the menu structure in order to show newly added Services (see registerMenuHandler(..))
`void` | `waitForLongRunningJobEnd()` waits until all currently running jobs have finished (e.g. build all, build changed, cvs commands)

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AnyJAPI

    public AnyJAPI()

Method Detail

### This

    public static AnyJAPI This()

  The one and only API object.

### compareDirs

    public AJSDirDiffResult compareDirs(java.io.File a,
                                        java.io.File b,
                                        java.io.FilenameFilter filter,
                                        boolean ignoreComments,
                                        boolean ignoreWhiteSpace)
                                 throws java.lang.Exception

  compare two direcories 'a', 'b'

### getOrCreateOutputPanel

    public AJSOutput getOrCreateOutputPanel(java.lang.String name)

  get (or create if not present) an output panel in AnyJ's output pane

### invokeService

    public boolean invokeService(java.lang.String service,
                                 java.lang.Object argument0)

  invoke a service (a menu item) with the given argument. the name should look like: [category][blank][full name as seen in menu] look in the Preferences,'menus and Shortcuts' to obtain the category of a menu item. e.g. "Compile Build Changed Files".
  Warning: A lot of operations are processed asynchronously, so control is returned to the script, although the called service has not finished. Currently there it is not documented which Services are processed aynchronously, you 'll have to try out. For most of the compile and build stuff, you can use waitForLongRunningJobEnd(), to wait for the finish of a previously invoked service.
  Warning: The arguments required by a service are still not documented, usually you can guess it (e.g. "Compile Compile File or Dir" requires a File). But sometimes this is not as obvious (e.g. a service might require a AJSTextDocument, though you may guess it requires a String and vice versa).
  Returns:
    false if the service could not process the given argument, true otherwise

### runScript

    public void runScript(java.lang.String fileName)

  runs a script (by interpreting). The 'filename' argument is resolved relative to [anyjuserhome]/scripts/.

      '"#userdata/scripts/"+fileName'

### getMainWindow

    public java.awt.Frame getMainWindow()

  returns the main window of AnyJ.

### ressolveSymbolicVariables

    public java.lang.String ressolveSymbolicVariables(java.lang.String s)

  same as 'ressolveSymbolicVariables( s, getEnvironment() );'

### ressolveSymbolicVariables

    public java.lang.String ressolveSymbolicVariables(java.lang.String s,
                                                      java.util.Hashtable environment)

  replace all occurences of ($varName) by the result of looking up 'varName' in the given 'environment' Hashtable

### getEnvironment

    public java.util.Hashtable getEnvironment()

  returns the current environment of AnyJ. Use the 'Dump Environment' helper script (Tools|Scripting|Dump Environment) to dump the key/values. Be careful, this is a very expensive method.

### registerMenuHandler

    public void registerMenuHandler(AJExternalService serv)

  registers a new userdefined (scripting) menu item (=Service). Note that it is required to call 'updateMenus()' in order to refresh the menu structure after registering one or more services.

### getDocumentIfOpen

    public AJSTextDocument getDocumentIfOpen(java.lang.String absPath)

  returns an AJSTextDocument if it is currently opened. null otherwise.

### executeExternalProcess

    public int executeExternalProcess(java.lang.String outputLabel,
                                      java.lang.String workingDirectory,
                                      java.lang.String commandline)

  Execute an External Process synchrounous (return when process has finished).
  Returns:
    the process result

### waitForLongRunningJobEnd

    public void waitForLongRunningJobEnd()

  waits until all currently running jobs have finished (e.g. build all, build changed, cvs commands)

### getInterpreterClasspath

    public java.lang.String getInterpreterClasspath()

  return the classpath used by the interpreter
  this is anyj.jar, your workspaces runtime classpath and all jars found in the [anyjuserhome]/scripts directory

### dirContent

    public java.util.Vector dirContent(java.io.File dir,
                                       java.lang.String ending,
                                       boolean recursive)

  returns a vector of File objects, whose name ends with the gioven ending (use '' to return everything). if ending == "none", only directories are enumerated.

### openEditor

    public void openEditor(java.lang.String path)

  Opens the given file in AnyJ. If it is already open, it will be brought to front. use getDocumentIfOpen(..) after in order to access the underlying AJSTextDocument.

### openFileDiff

    public void openFileDiff(java.lang.String title,
                             java.lang.String leftTitle,
                             java.lang.String rightTitle,
                             java.io.File pathA,
                             java.io.File pathB)

  Opens a diffview on the given files

### openDirDiff

    public void openDirDiff(java.io.File pathA,
                            java.io.File pathB)

  Opens a directory diffview on the given files

### closeEditor

    public void closeEditor(java.lang.String path,
                            boolean askIfModified)

  Closes the given file if opened.

### getOpenedFiles

    public java.util.Vector getOpenedFiles()

  returns a Vector of absolute files (Strings) currently opened in the Editor

### updateFileTree

    public void updateFileTree()

  synchronizes filebrowser and browser outlines (e.g. files have been added externally).

### setMenuStructure

    public void setMenuStructure(java.lang.String[] newMenu)

  define the structure of the main menu. Warning: can crash IDE if the String[] has an unexpected structure. Has to call updateMenus() to activate the new menu structure

### addMenuStructure

    public void addMenuStructure(java.lang.String[] newMenu)

  define the structure of the main menu. Warning: can crash IDE if the String[] has an unexpected structure. Has to call updateMenus() to activate the new menu structure

### setPopupMenuStructure

    public void setPopupMenuStructure(java.lang.String[] newMenu)

  Deprecated.

  define the structure of a popup menu. Warning: can crash IDE if the String[] has an unexpected structure.

### splitSeparatedString

    public java.util.List splitSeparatedString(java.lang.String stringToSplit,
                                               java.lang.String separator)

  Splits a String into a list of strings

### chooseFromList

    public java.util.List chooseFromList(java.lang.String dlgTitle,
                                         java.lang.String title,
                                         java.util.List items,
                                         java.util.List initialSel,
                                         int width,
                                         int height)

  Lets the user choose from a List of items. Returns a list of selected items or null if the dialog was canceled. Items contained in the initialSel List are initially selected.

### updateMenus

    public void updateMenus()

  refresh the menu structure in order to show newly added Services (see registerMenuHandler(..))

Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD