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
| Field | Type | Description |
|---|---|---|
version | string | Read only. The version of Flying Logic. |
apiVersion | string | Read only. The version of Flying Logic scripting API. See the Colophon for the current scripting API version. |
language | string | Read 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. |
vertexOperators | list of VertexOperator | Read only. A list of all available vertex operators. |
defaultOrientation | Orientation Type | The default orientation of new documents preference value. |
defaultBias | Bias Type | The default bias of new documents preference value. |
defaultGraphCompactness | Compactness Type | The default graph compactness of new documents preference value. |
animationSpeed | number | The animation speed preference value, between 0.0 and 1.0. |
adaptiveSpeed | number | The adaptive speed preference value, between 0.0 and 1.0. |
adaptiveAnimation | boolean | The adaptive animation state preference value. |
animationStyle | Animation Style Type | The animation style preference value. |
edgeColors | Edge Colors Type | The edge colors preference value. |
spinnerDisplay | Spinner Display Type | The spinner display preference value. |
undoLevels | integer | The maximum number of undo levels to retain preference value. |
autoBackupOnSave | boolean | The auto-backup on save preference value. |
autoRecoveryValue | boolean | The auto-recovery of files on launch preference. |
checkForUpdates | boolean | The check for updates preference value. |
useProxyServer | boolean | The use proxy server preference value. |
proxyServer | string | The proxy server preference value, either a domain name or an IP address. |
proxyPort | integer | The port of the proxy server preference value. |
maxRecentDocuments | integer | The maximum number of documents in Open Recent menu preference value. |
maxrecentScripts | integer | The maximum number of scripts listed in the Run Script sub-menu. |
maxrecentImports | integer | The maximum number of scripts listed in the Import Via Script sub-menu. |
maxrecentExports | integer | The maximum number of scripts listed in the Run Export Via Script sub-menu. |
autoEditNewEntityTitles | boolean | The auto edit entity titles preference value. |
canDisableControlAltShortcuts | boolean | The can disable ctrl-alt menu shortcuts preference value. Always returns False under MacOS and Linux. |
importPath | string | The directory that should be displayed in a file dialog involved in an import operation for the application. Defaults to the user’s home directory. |
lastAskDirectory | string | Read only. The directory the user chose during the last call to askForFile. |
entityFilter | GraphElemFilter | Read only. An instance of GraphElemFilter that only matches entities. |
junctorFilter | GraphElemFilter | Read only. An instance of GraphElemFilter that only matches junctors. |
groupFilter | GraphElemFilter | Read only. An instance of GraphElemFilter that only matches groups. |
edgeFilter | GraphElemFilter | Read only. An instance of GraphElemFilter that only matches edges. |
startFilter | GraphElemFilter | Read only. An instance of GraphElemFilter that only matches entities with no predecessors. |
endFilter | GraphElemFilter | Read only. An instance of GraphElemFilter that only matches entities with no successors. |
defaultDocumentPath | string | Read only. The default location for storing documents. |
defaultWorkHours | integer | The default work hours for a newly created Workweek instance including the standard calendar when project management is first enabled for a document. |
openDocumentOption | Open Document Option Type | The preferences for whether new documents should be opened in a window, tab, or the user always queried for the choice (when possible). |
Methods
newDocument()
Returns a Document instance representing a newly created Flying logic document.
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( path, params )
Returns a Document instance representing a Flying Logic document created by importing the file with given
path(or by asking the user for a file if path isNone) using an XSLT file to transform the file into a Flying Logic document based on options in theparamsdictionary (see possible options under XSLT Import-Export Type).
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
listof graph elements returns a new list that has been filtered by the given GraphElemFilterfilter.
alert( message )
Displays a simple alert dialog with a string
message.
requestForString( message, defaultValue )
Displays a simple dialog with
messagerequesting the user enter a value, which is returned as a string. The text input control in the dialog is pre-filled with thedefaultValue(the empty string andNoneare equivalent). If the user selects "OK" a string will always be returned, even if it is the empty string. If the user selects Cancel,Nonewill always be returned.
requestForPassword( label, defaultValue )
Displays a simple dialog with requesting the user enter a password, which is returned as a string. The
labelappears to the left of the password input control with the password displayed as bullet characters. The control is pre-filled with thedefaultValue(the empty string andNoneare equivalent). If the user selects "OK" a string will always be returned, even if it is the empty string. If the user selects Cancel,Nonewill always be returned.
requestForInteger( message, defaultValue )
Displays a simple dialog with
messagerequesting the user enter a value, which is returned as an integer. The text input control in the dialog is pre-filled with thedefaultValue, which must be an integer (orNone, which leaves the text input control empty). If the user selects "OK" an integer value is returned. If the user selects Cancel,Nonewill always be returned.
requestForDouble( message, defaultValue )
Displays a simple dialog with
messagerequesting the user enter a value, which is returned as a double. The text input control in the dialog is pre-filled with thedefaultValue, which must be an double (orNone, which leaves the text input control empty). If the user selects "OK" a double value is returned. If the user selects Cancel,Nonewill 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 ifdefaultDirectoryisNone. If the user selects "OK" the path to the selected filename is returned as a string. If the user selects Cancel,Nonewill 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
defaultDirectoryor the default user directory ifdefaultDirectoryisNone. AdefaultFilecan be provided to set the selected file name, otherwise set toNone. If the user selects "OK" the path to the selected filename is returned as a string. If the user selects Cancel,Nonewill always be returned.
askForString( message, defaultValue )
Deprecated. Use
requestForString.
Displays a simple dialog withmessagerequesting the user enter a value, which is returned as a string. If the user selects Cancel, thedefaultValueis returned instead. The valueNoneis an acceptabledefaultValue.
askForPassword( label, defaultValue )
Deprecated. Use
requestForPassword.
Displays a simple dialog requesting the user enter a password, which is returned as a string. Thelabelappears to the left of the password input control with the password displayed as bullet characters. If the user selects Cancel, thedefaultValueis returned instead. The valueNoneis an acceptabledefaultValue.
askForInteger( message, defaultValue )
Deprecated. Use
requestForInteger.
Displays a simple dialog withmessagerequesting the user enter a value, which is returned as an integer. If the user selects Cancel, thedefaultValueis returned instead.
askForDouble( message, defaultValue )
Deprecated. Use
requestForDouble.
Displays a simple dialog withmessagerequesting the user enter a value, which is returned as a float (which is equivalent to a Java double). If the user selects Cancel, thedefaultValueis returned instead.
request( message, labels )
Displays a request dialog titled “Request” to the user to answer a question
messageby making a selection among a set of buttons withlabels(a tuple). Returns an integer matching the index of the label in the tuple. Note: themessagecan 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
titleto the user to answer a questionmessageby making a selection among a set of buttons withlabels(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.
askForFile( defaultDirectory, save )
Deprecated. Use
requestForOpenFileorrequestForSaveFileas appropriate.Displays a file dialog requesting the user select a file. The dialog is a save file dialog if
saveisTrue, else it’s an open file dialog. The dialog initially shows the files indefaultDirectoryor the default user directory ifNone. Returns the path to the selected file as astringorNoneif the user cancelled.
askForFile( save )
Deprecated. Use
requestForOpenFileorrequestForSaveFileas appropriate.Displays a file dialog just like the above method, but always initially shows the files in the default user directory.
appendClassPath( pathList )
Appends the paths in
pathListto 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.
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.
# You should have previously added the path to the MySQL JDBC jar via Application.appendClassPath method
from com.mysql.jdbc import Driver
from java.sql import DriverManager
# Need to create shim Driver
shimDriver = Application.createCompatibleDriver( Driver() )
DriverManager.registerDriver(shimDriver);
conn = DriverManager.getConnection("jdbc:mysql://someserver/somedb", "someuser", "somepassword")
createSQLConnection(url, username, password, driverClassName)
Returns a Python SQL connection object. This method is a replacement for the the connect method in Jython’s zxJDBC package.
# You should have previously added the path to the MySQL JDBC jar via Application.appendClassPath method
url = "jdbc:mysql://someserver/somedb"
username = "someuser"
password = "somepassword"
driver = "com.mysql.jdbc.Driver"
# obtain a connection using the with-statment
#with zxJDBC.connect(jdbc_url, username, password, driver) as conn:
with Application.createSQLConnection(url, username, password, driver) as conn:
with conn:
with conn.cursor() as c:
# execute SQL commands