Class Helper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int[]Icon sizes of an application icon, ascending: 16, 32, 48, 64, 128 and 256 pixels. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddLanguageListener(Runnable listener) Register a listener that is called after the language changed.static CursorReturn an Atari-busy-cursor!static StringChoose a file.static StringchooseFolder(String defaultDir, Stage parent, String title, String desc) Choose a folder.static WebViewcreateWebView(BaseApp app) Create a web view with a proper local storage for the underlying web engine.static voidEdit a file on the desktop.static intextensionDotIndex(Path file) Get extension dot index.Get the application icons of an application: the application's own icons if it ships any, otherwise the default autumo-ui logo.Get the style sheets of an application scene: the autumo-ui base style first and, if the application ships one, its own application stylesheet (style/application.css) on top.static StringgetAppResource(BaseApp app, String resourcePath) Get a resource path in external form.static StringgetAppResourceOrBase(BaseApp app, String resourcePath) Get a resource path in external form: the application's resource if it has one, otherwise the autumo-ui base resource of the same path.static InputStreamgetAppResourceStream(BaseApp app, String resourcePath) Get a resource stream from the application.static URLgetAppResourceURL(BaseApp app, String resourcePath) Get a resource URL.static StringGet style resource from the autumo-ui base.static URLGet style resource from the autumo-ui base.static StringgetBaseResource(String relativeResourcePath) Get a resource from the autumo-ui base.static InputStreamgetBaseResourceStream(String relativeResourcePath) Get a resource stream from the autumo-ui base.static URLgetBaseResourceURL(String relativeResourcePath) Get a resource from the autumo-ui base.static StringGet style resource from the autumo-ui base.static URLGet style resource from the autumo-ui base.static CountryDataGet loaded country data.static StringGet the language the UI is currently displayed in.static ResourceBundlegetMessageBundle(String baseResourcePath) Get the message bundle of the active language.static StringgetPropertiesPath(BaseApp app) Get base configuration/settings path for the application.static String[]Get all languages supported by autumo-ui.static StringGet a text translation with fallback.static StringgetTranslatedText(BaseApp app, String translationId) Get a text translation.static StringgetTranslatedText(BaseApp app, String translationId, Object... variables) Get a text translation.static ch.autumo.commons.versioning.VersionsgetWebVersions(BaseApp app) Get web versions for current application.static booleanhasExtension(Path file) File has an extension.static booleanisSupportedLang(String lang) Is the language supported by the app?static PropertiesLoad configuration properties / app settings.static PropertiesLoad template base configuration properties 'base.ifc' if any.static PropertiesLoad template configuration properties 'app.cfg'static StringnameFromPath(Path path) File name without extension from path.static voidOpen a file on the desktop.static booleanopenFolder(String folder) Open a folder on the desktop.static voidOpen an URL on the desktop.static voidremoveLanguageListener(Runnable listener) Remove a language listener again.static StringChoose a file for saving.static voidsetLanguage(String lang) Switch the UI language at runtime.static voidStart timer.static voidStop timer.static voidstoreAppConfiguration(BaseApp app, Properties settings, String comment) Store application configuration 'app.cfg'.static voidstoreBaseConfiguration(BaseApp app, Properties baseSettings) Store BASE configuration properties 'base.ifc'.
-
Field Details
-
APPLICATION_ICON_SIZES
public static final int[] APPLICATION_ICON_SIZESIcon sizes of an application icon, ascending: 16, 32, 48, 64, 128 and 256 pixels.
-
-
Method Details
-
loadAppConfiguration
Load configuration properties / app settings.- Parameters:
app- the application- Returns:
- configuration properties
-
storeBaseConfiguration
Store BASE configuration properties 'base.ifc'.- Parameters:
app- the applicationbaseSettings- the settings
-
storeAppConfiguration
Store application configuration 'app.cfg'.- Parameters:
app- the applicationsettings- the settingscomment- the settings
-
getPropertiesPath
-
loadTemplateBaseConfiguration
Load template base configuration properties 'base.ifc' if any.- Parameters:
app- the application- Returns:
- configuration properties
-
loadTemplateConfiguration
Load template configuration properties 'app.cfg'- Parameters:
app- the application- Returns:
- configuration properties
-
getBaseStyle
-
getBaseHTMLStyleURL
Get style resource from the autumo-ui base.- Returns:
- resource
-
getBaseHTMLStyle
Get style resource from the autumo-ui base.- Returns:
- resource
-
getBaseStyleURL
-
getBaseResource
-
getBaseResourceURL
-
getBaseResourceStream
Get a resource stream from the autumo-ui base.- Parameters:
relativeResourcePath- relative resource path- Returns:
- resource stream
-
getAppResource
Get a resource path in external form.The resource must be an application resource; if it may be missing because the autumo-ui base ships a default, use
getAppResourceOrBase(BaseApp, String)instead. A missing resource is reported here with a readable exception instead of aNullPointerExceptiondeep inside the call chain.- Parameters:
app- the applicationresourcePath- relative or absolute resource path- Returns:
- resource path in external form
-
getAppResourceOrBase
Get a resource path in external form: the application's resource if it has one, otherwise the autumo-ui base resource of the same path.This is the lookup for framework panes whose content an application may, but does not have to, provide: the default
html/remove_<lang>.htmlof the 'Remove App Data' pane lives in the autumo-ui base, and an application ships its own file only if it wants different wording. Without this fallback such a pane would fail with aNullPointerExceptionfor every application that ships nothing.A resource that neither the application nor the autumo-ui base ships is reported with a readable
MissingResourceExceptioninstead.- Parameters:
app- the applicationresourcePath- relative or absolute resource path- Returns:
- resource path in external form
-
getApplicationStyleSheets
Get the style sheets of an application scene: the autumo-ui base style first and, if the application ships one, its own application stylesheet (style/application.css) on top.This is the combination the main window has — a base look, extended by the application — and dialogs must use the same combination to match it: an application stylesheet that only carries overrides (navigation tree, fonts, colours of its own) still gets the framework's palette, and an application without any sheet gets the framework look instead of an unstyled dialog.
- Parameters:
app- the application- Returns:
- style sheet URLs, base style first, application style second or none
-
getApplicationIcons
Get the application icons of an application: the application's own icons if it ships any, otherwise the default autumo-ui logo.An application defines its own icon by shipping any of:
icons/app-16.png...icons/app-256.png— any subset ofAPPLICATION_ICON_SIZES, the sharp icon for each window-manager size,icons/app.png— a single icon (at least 256×256 pixels) that is used for every size.
Both are application resources, resolved relative to the application class. If the application ships neither, the framework's default logo (
icons/autumo-ui-logo-16.png...icons/autumo-ui-logo-256.png) is used, so every autumo-ui application has an application icon on all operating systems without any further effort. The images are returned in ascending size order — the last one is the largest and is what the macOS dock icon of a packaged application is built from (jpackage--icon).- Parameters:
app- the application- Returns:
- application icon resource URLs in ascending size order, possibly empty
-
getAppResourceURL
-
getAppResourceStream
Get a resource stream from the application.- Parameters:
app- the applicationresourcePath- relative or absolute resource path- Returns:
- resource stream
-
getTranslatedText
-
getTranslatedText
-
getMessageBundle
Get the message bundle of the active language.Two gettext catalogues are merged, the application's one wins: its own
lang/messages.<lang>.poand the autumo-ui framework's/ch/autumo/ui/lang/messages.<lang>.po. An application therefore only has to translate its own texts; the framework's keys (its panes, dialogs and the installer) always resolve, and the application may still override any framework text by defining the key in its own catalogue. There are no.propertiescatalogues anymore.The merged bundle is cached per base resource path and language; a language change (
setLanguage(String)) clears the cache.- Parameters:
baseResourcePath- base resource path, e.g. '/ch/autumo/.../', no backslashes! Ifnullor empty, the autumo-ui base resource path is used- Returns:
- resource bundle
-
getLanguage
Get the language the UI is currently displayed in. It is derived from the 'user.language' system property on first use and can be changed at runtime withsetLanguage(String).- Returns:
- language code, e.g. 'en'; always one of
getSupportedLanguages()
-
getSupportedLanguages
Get all languages supported by autumo-ui.- Returns:
- language codes, e.g. 'de', 'en'
-
setLanguage
Switch the UI language at runtime. This sets the JVM default locale and the 'user.language' system property, drops the cached resource bundles and notifies all registeredlanguage listeners. A region is ignored (de_CHselectsde); unsupported ornullvalues fall back to English.This covers the framework resources only (window titles, About/HTML panes, dialogs). An application that translates its own texts has to re-apply them in a language listener.
- Parameters:
lang- language code, e.g. 'de'
-
addLanguageListener
Register a listener that is called after the language changed.- Parameters:
listener- listener, e.g. one that re-applies the application texts
-
removeLanguageListener
Remove a language listener again.- Parameters:
listener- listener to remove
-
isSupportedLang
Is the language supported by the app?A region is ignored, i.e. 'de_CH' is supported because 'de' is (autumo-ui's own
Constants.LOCALE_DEis 'de_CH').- Parameters:
lang- lang code, e.g. 'en'- Returns:
- true if so
-
hasExtension
File has an extension.- Parameters:
file- file- Returns:
- true if there's an extension
-
extensionDotIndex
Get extension dot index.- Parameters:
file- file- Returns:
- extension dot index
-
getWebVersions
Get web versions for current application.- Parameters:
app- application- Returns:
- timeout read and connection timeout in seconds
-
createWebView
-
getCountryData
-
nameFromPath
-
openURL
-
openFolder
Open a folder on the desktop.- Parameters:
folder- folder- Returns:
- true, if folder could be opened
-
editFile
-
openFile
-
chooseFolder
-
chooseFile
-
saveFile
-
atariBusy
-
startTime
public static void startTime()Start timer. -
stopTime
-
getText
-