Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Application

The Application class represents those features of Flying Logic that are independent of any particular document. Such features include application preferences, document loading and importing, version information, etc. In addition the Application class contains constants used in method calls in the Application class and others.

There is only one instance (singleton) of the Application class. This instance can be accessed by the global variable Application.

There are a number of enumerated types (orientation type, bias type, etc.) accessible from the Application instance. These are listed in their own section.

Fields

FieldTypeDescription
versionstringRead only. The version of Flying Logic.
apiVersionstringRead only. The version of Flying Logic scripting API. See the Colophon for the current scripting API version.
languagestringRead only. The user interface language of Flying Logic as a two-letter ISO 639 code possibly with a hyphen and country code appended to the end.
vertexOperatorslist of VertexOperatorRead only. A list of all available vertex operators.
defaultOrientationOrientation TypeThe default orientation of new documents preference value.
defaultBiasBias TypeThe default bias of new documents preference value.
defaultGraphCompactnessCompactness TypeThe default graph compactness of new documents preference value.
animationSpeednumberThe animation speed preference value, between 0.0 and 1.0.
adaptiveSpeednumberThe adaptive speed preference value, between 0.0 and 1.0.
adaptiveAnimationbooleanThe adaptive animation state preference value.
animationStyleAnimation Style TypeThe animation style preference value.
edgeColorsEdge Colors TypeThe edge colors preference value.
spinnerDisplaySpinner Display TypeThe spinner display preference value.
undoLevelsintegerThe maximum number of undo levels to retain preference value.
autoBackupOnSavebooleanThe auto-backup on save preference value.
autoRecoveryValuebooleanThe auto-recovery of files on launch preference.
checkForUpdatesbooleanThe check for updates preference value.
useProxyServerbooleanThe use proxy server preference value.
darkModebooleanAPI 1.18
The application dark mode setting.
proxyServerstringThe proxy server preference value, either a domain name or an IP address.
proxyPortintegerThe port of the proxy server preference value.
maxRecentDocumentsintegerThe maximum number of documents in Open Recent menu preference value.
maxrecentScriptsintegerThe maximum number of scripts listed in the Run Script sub-menu.
maxrecentImportsintegerThe maximum number of scripts listed in the Import Via Script sub-menu.
maxrecentExportsintegerThe maximum number of scripts listed in the Run Export Via Script sub-menu.
autoEditNewEntityTitlesbooleanThe auto edit entity titles preference value.
canDisableControlAltShortcutsbooleanThe can disable ctrl-alt menu shortcuts preference value. Always returns False under MacOS and Linux.
importPathstringThe directory that should be displayed in a file dialog involved in an import operation for the application. Defaults to the user’s home directory.
lastAskDirectorystringRead only. The directory the user chose during the last call to askForFile.
entityFilterGraphElemFilterRead only. An instance of GraphElemFilter that only matches entities.
junctorFilterGraphElemFilterRead only. An instance of GraphElemFilter that only matches junctors.
groupFilterGraphElemFilterRead only. An instance of GraphElemFilter that only matches groups.
edgeFilterGraphElemFilterRead only. An instance of GraphElemFilter that only matches edges.
startFilterGraphElemFilterRead only. An instance of GraphElemFilter that only matches entities with no predecessors.
endFilterGraphElemFilterRead only. An instance of GraphElemFilter that only matches entities with no successors.
defaultDocumentPathstringRead only. The default location for storing documents.
defaultWorkHoursintegerThe default work hours for a newly created Workweek instance including the standard calendar when project management is first enabled for a document.
openDocumentOptionOpen Document Option TypeThe preferences for whether new documents should be opened in a window, tab, or the user always queried for the choice (when possible).

Methods

compareVersion( version )

API 1.18
Compares the running Flying Logic version to the given version string. Returns a negative integer if the running version is older, zero if equal, a positive integer if newer.

compareApiVersion( version )

API 1.18
Compares the running scripting API version to the given version string. Returns a negative integer if the running version is older, zero if equal, a positive integer if newer.

getDocuments( )

API 1.18
Returns a list of all currently open Document instances.

getSymbols( )

API 1.18
Returns a list of all built-in Symbol instances. These correspond to the Application.FLOWCHART_*, Application.WRITING_*, and Application.DINGBAT_* constants. Use document.getSymbolByName to look up a specific symbol by name, or iterate this list to enumerate all available symbols.

newDocument()

Returns a Document instance representing a newly created Flying logic document.

getExamples( )

API 1.18
Returns a list of ExampleCategory objects representing the bundled example documents included with Flying Logic. Each category has a name and a documents list of ExampleEntry objects. Use the path field of an ExampleEntry to open a specific example via openDocument. Do not hard-code paths to example files; use this method to discover them at runtime.

openDocument( path )

Returns a Document instance representing the Flying Logic document opened from the given path. If the document is already opened, this method just returns the existing Document instance.

findDocument( path )

Returns a Document instance representing the open Flying Logic document opened from the given path, otherwise None is the document is not open.

importDocument( kind, path, params )

Imports a file at path and returns a new Document instance. Unlike document.importDocument, this method always creates a new document. The kind is one of the Import Types (IMPORT_DIAGRAM_CSV, IMPORT_DIAGRAM_PROJECT, or IMPORT_DIAGRAM_XSLT). If path is None, the user is asked to select a file. The keys and values in params are import-kind dependent (see CSV Import Type and XSLT Import-Export Type).

Returns None if the import fails. CSV and MS Project imports raise a ScriptingException on failure; XSLT import returns None silently — always check the return value.

showQuickCapture()

Displays the Quick Capture dialog.

exporterLabel( exportType )

Returns the label for the export menu item matching the given exportType.

vertexOperatorByName( name )

Returns the VertexOperator with the given user interface name; i.e., “Fuzzy And”.

filterGraphElemList(list, filter)

Given a list of graph elements returns a new list that has been filtered by the given GraphElemFilter filter.

showConsole()

API 1.18
Will show and bring the scripting console window to front once the script has completed.

alert( message )

Displays a simple alert dialog with a string message.

requestForString( message, defaultValue )

Displays a simple dialog with message requesting the user enter a value, which is returned as a string. The text input control in the dialog is pre-filled with the defaultValue (the empty string and None are equivalent). If the user selects "OK" a string will always be returned, even if it is the empty string. If the user selects Cancel, None will always be returned.

requestForPassword( label, defaultValue )

Displays a simple dialog with requesting the user enter a password, which is returned as a string. The label appears to the left of the password input control with the password displayed as bullet characters. The control is pre-filled with the defaultValue (the empty string and None are equivalent). If the user selects "OK" a string will always be returned, even if it is the empty string. If the user selects Cancel, None will always be returned.

requestForInteger( message, defaultValue )

Displays a simple dialog with message requesting the user enter a value, which is returned as an integer. The text input control in the dialog is pre-filled with the defaultValue, which must be an integer (or None, which leaves the text input control empty). If the user selects "OK" an integer value is returned. If the user selects Cancel, None will always be returned.

requestForDouble( message, defaultValue )

Displays a simple dialog with message requesting the user enter a value, which is returned as a double. The text input control in the dialog is pre-filled with the defaultValue, which must be an double (or None, which leaves the text input control empty). If the user selects "OK" a double value is returned. If the user selects Cancel, None will always be returned.

requestForOpenFile( defaultDirectory )

Displays a open file dialog requesting the user select a file. The dialog initially shows the files in defaultDirectory, or the default user directory if defaultDirectory is None. If the user selects "OK" the path to the selected filename is returned as a string. If the user selects Cancel, None will always be returned.

requestForSaveFile( defaultDirectory, defaultFile )

Displays a save file dialog requesting the user enter or select a file. The dialog initially shows the files in defaultDirectory or the default user directory if defaultDirectory is None. A defaultFile can be provided to set the selected file name, otherwise set to None. If the user selects "OK" the path to the selected filename is returned as a string. If the user selects Cancel, None will always be returned.

request( message, labels )

Displays a request dialog titled “Request” to the user to answer a question message by making a selection among a set of buttons with labels (a tuple). Returns an integer matching the index of the label in the tuple. Note: the message can be a string or a Java Component object, allowing for the creation of a more complicated dialog.

request( title, message, labels )

Displays a request dialog with title to the user to answer a question message by making a selection among a set of buttons with labels (a tuple). Returns an integer matching the index of the label in the tuple. Note: the message can be a string or a Java Component object, allowing for the creation of a more complicated dialog.

appendClassPath( pathList )

Appends the paths in pathList to the Java classpath for the script. The values in the list should be either directories containing Java class files or paths to jar files, as strings. pathList must be a Python list even when adding a single path — passing a bare string will fail.

After calling appendClassPath, load classes from the added JAR using a Jython import statement. Do not use Class.forName(): it uses the JVM application class loader and will not find JARs added dynamically by this method.

Appended paths are available only for the duration of the current script run. Each script that needs an external JAR must call appendClassPath at the top.

Application.appendClassPath([“/absolute/path/to/driver.jar”])
from org.sqlite import JDBC  # use Jython import, not Class.forName()

createCompatibleDriver( driver )

Returns a “compatible” instance of java.sql.Driver that acts as a shim class to another instance of java.sql.Driver created from a JDBC library. This is a workaround for a “feature” of Java where Driver instances can only be used if created by the application ClassLoader, which is not true of scripts running in Flying Logic. Use this method for drivers that register with java.sql.DriverManager (such as MySQL). For drivers that allow direct instantiation (such as SQLite), you can connect without a shim — see the SQLite example below.

Application.appendClassPath([“/path/to/mysql-connector.jar”])
from com.mysql.jdbc import Driver
from java.sql import DriverManager

shimDriver = Application.createCompatibleDriver(Driver())
DriverManager.registerDriver(shimDriver)
conn = DriverManager.getConnection(“jdbc:mysql://someserver/somedb”, “someuser”, “somepassword”)

SQLite example (direct instantiation — no shim required):

from java.util import Properties

Application.appendClassPath([“/path/to/sqlite-jdbc.jar”])
from org.sqlite import JDBC

connection = None
statement = None
resultSet = None
try:
    connection = JDBC().connect(“jdbc:sqlite:/path/to/database.db”, Properties())
    statement = connection.createStatement()
    resultSet = statement.executeQuery(“SELECT COUNT(*) FROM my_table”)
    resultSet.next()
    count = resultSet.getInt(1)
finally:
    if resultSet is not None:
        resultSet.close()
    if statement is not None:
        statement.close()
    if connection is not None:
        connection.close()

createSQLConnection(url, username, password, driverClassName)

Returns a Python SQL connection object. This method is a replacement for the connect method in Jython’s zxJDBC package. Call appendClassPath to load the driver JAR before calling this method.

Application.appendClassPath([“/path/to/mysql-connector.jar”])
url = “jdbc:mysql://someserver/somedb”
username = “someuser”
password = “somepassword”
driver = “com.mysql.jdbc.Driver”

with Application.createSQLConnection(url, username, password, driver) as conn:
  with conn:
    with conn.cursor() as c:
      # execute SQL commands