Class BaseController
java.lang.Object
ch.autumo.ui.fx.controller.BaseController
- All Implemented Interfaces:
Initializable
- Direct Known Subclasses:
DefaultInfoController
FX Base Controller.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseController(BaseApp app, Stage stage, BaseModel model, Pane view) Main controller. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether it is safe to leave app:falsewhen the user cancels the platform exit.final voidPrevent macOS menu detach.voidescKeyPressed(KeyEvent key) Override if you want to execute actions on ESC key pressed.getApp()Get the application.Only called on macOS.Get the 'clear all entry' menu entry.Get the language sub-menu.Get the 'recent' sub-menu.getModel()Get model.getStage()Get the stage.Only called on macOS.getView()Get view.Create an image with specified iconf name found in app-resources or base-app-resoruces icons-path; e.g.abstract voidinit(URL location, ResourceBundle resources, double toolBarShift) Delegated initialization.final voidinitialize(URL location, ResourceBundle resources) voidinitializeLanguageMenu(Menu menuLanguage) Initialize the language sub-menu: one radio item per language supported by autumo-ui, each with the language's flag and its name in that language ('English', 'Deutsch').voidinitializeRecentMenu(Menu menuRecent, MenuItem menuItemClearAllRecent) Initialize recent menu structure.protected voidOverwrite to open a file from recent list.booleanisLanguageSelected(String lang) Is the radio item of the given language the selected one?voidkeyPressed(KeyEvent key) Override if you want to execute more actions on specific keyboard shortcuts for the stage/scene associated.protected voidCalled after the language was switched, so an application can re-apply the texts of its own controls; the framework texts, the window title, the language menu and the stored application parameter already follow.voidRebuild recent file list.voidselectLanguageItem(String lang) Marks the radio item of the given language as selected.voidswitchLanguage(String lang) Switch the application language at runtime.toolButton(String iconName, String text, String tip, Runnable action) Create a tool buttonm for the tool bar.Create a tool separator for the tool bar.
-
Field Details
-
app
Application. -
stage
Stage. -
model
Model. -
view
View.
-
-
Constructor Details
-
BaseController
-
-
Method Details
-
getApp
-
getStage
-
getModel
-
getView
-
keyPressed
Override if you want to execute more actions on specific keyboard shortcuts for the stage/scene associated.- Parameters:
key- key pressed
-
escKeyPressed
Override if you want to execute actions on ESC key pressed.- Parameters:
key- key pressed
-
initializeRecentMenu
-
getMenuRecent
-
getMenuItemClearAllRecent
Get the 'clear all entry' menu entry.- Returns:
- 'clear all entry' menu entry
-
getMenuLanguage
Get the language sub-menu.- Returns:
- language sub-menu or null, if
initializeLanguageMenu(Menu)was not called
-
initializeLanguageMenu
Initialize the language sub-menu: one radio item per language supported by autumo-ui, each with the language's flag and its name in that language ('English', 'Deutsch'). The item of the current language is selected, so an application does not have to care about the language it was started with. The sub-menu itself gets the framework's language icon, unless the application has already set its own graphic on it.Selecting an item switches the language of the whole application, see
switchLanguage(String). Call this while the application builds its menu bar.- Parameters:
menuLanguage- language sub-menu, e.g. 'Help > Language'
-
selectLanguageItem
Marks the radio item of the given language as selected.- Parameters:
lang- language code, e.g. 'de'
-
isLanguageSelected
Is the radio item of the given language the selected one?- Parameters:
lang- language code, e.g. 'de'- Returns:
- true, if
initializeLanguageMenu(Menu)added the language and it is selected
-
switchLanguage
Switch the application language at runtime.The framework does its part here: the language of autumo-ui follows (framework bundles, framework dialogs, the window title and the About/license panes), the choice is stored as an application configuration parameter in the user's application configuration ('cfg/app.cfg', see
BaseApp.setConfigurationParameter(String, String)) so the next start comes up in it, and the language menu selection is moved.Afterwards
languageChanged()lets the application re-apply the texts it sets itself.- Parameters:
lang- language code, e.g. 'de'
-
languageChanged
protected void languageChanged()Called after the language was switched, so an application can re-apply the texts of its own controls; the framework texts, the window title, the language menu and the stored application parameter already follow.The default does nothing; an application with own texts overrides it.
-
rebuildRecentList
public void rebuildRecentList()Rebuild recent file list. -
disableMacOSMenuDetach
public final void disableMacOSMenuDetach()Prevent macOS menu detach. -
getMenuBar
Only called on macOS. Get menu bar; implement this, if you want to detach the application menu on macOS system and to add it to macOS its desktop menu. If you implement this, you might want to implement the methodgetToolBar()! Note: This is usually used for main views only! If this method returns null, the menu bar stays attached to the application andgetToolBar()is not called. Overwrite if necessary.- Returns:
- menu bar.
-
getToolBar
Only called on macOS. Returns the tool bar; seegetMenuBar(). It is only called ifgetMenuBar()returns not null! It repositions the tool bar after detaching the menu bar. The tool bar should be inside a pane with a shifted top anchor ('AnchorPane.topAnchor'); it is set to zero!- Returns:
- tool bar pane.
-
confirmDiscardChanges
public boolean confirmDiscardChanges()Whether it is safe to leave app:falsewhen the user cancels the platform exit.- Returns:
truewhen the caller may proceed and discard the state
-
toolButton
-
toolSeparator
Create a tool separator for the tool bar.- Returns:
- styled separator.
-
icon
-
innerOpen
Overwrite to open a file from recent list.- Parameters:
file- file
-
initialize
- Specified by:
initializein interfaceInitializable
-
init
Delegated initialization. SeeInitializable.initialize(URL, ResourceBundle).- Parameters:
location- The location used to resolve relative paths for the root object, ornullif the location is not known.resources- The resources used to localize the root object, ornullif the root object was not localized.toolBarShift- if the tool bar has been shifted, this value is bigger than zero and can be used to adjust the UI layout.
-