Interface GuiSwingFeature
- All Superinterfaces:
GuiSwingElement.FeatureCollection
- All Known Subinterfaces:
GuiSwingAction.ActionResultHandler, GuiSwingTableColumn.ObjectTableColumnWithContext, GuiSwingView.ValuePane<ValueType>, GuiSwingViewWrapper.ValuePaneWrapper<ValueType>
- All Known Implementing Classes:
GuiSwingActionDefault.ActionResultHandlerEditStarter, GuiSwingActionDefault.ActionResultRootPane, GuiSwingActionDefault.ActionResultTableSelectionConversion, GuiSwingActionDefault.ActionResultWindow, GuiSwingActionDefault.ExecutionAction, GuiSwingRootPane, GuiSwingTableColumn.ValueWrappingPaneForEditor, GuiSwingTableColumnBoolean.ColumnCheckBox, GuiSwingTableColumnCollection.ActionResultHandlerEditStarterForList, GuiSwingTableColumnCollection.ObjectTableColumnCollectionWrapper, GuiSwingTableColumnCollection.TableSelectionListDynamicAction, GuiSwingTableColumnEmbeddedComponent.ColumnEditEmbeddedPane, GuiSwingTableColumnEmbeddedComponent.ColumnEmbeddedPane, GuiSwingTableColumnEnum.ColumnEditEnumComboBox, GuiSwingTableColumnEnum.ColumnEnumPane, GuiSwingTableColumnFilePath.ColumnEditFilePathPane, GuiSwingTableColumnFilePath.ColumnFilePathPane, GuiSwingTableColumnImage.ColumnEditImagePane, GuiSwingTableColumnLabel.PropertyLabelColumn, GuiSwingTableColumnNumber.ColumnEditNumberSpinner, GuiSwingTableColumnNumber.ColumnNumberPane, GuiSwingTableColumnSetDefault.ActionResultTableSelectionListActionSelectionChange, GuiSwingTableColumnSetDefault.TableSelectionAction, GuiSwingTableColumnSetDefault.TableSelectionListAction, GuiSwingTableColumnString.ColumnEditTextPane, GuiSwingTableColumnString.ColumnTextPane, GuiSwingTableColumnString.MultilineColumnStringViewPane, GuiSwingTableColumnString.MultilineColumnTextPane, GuiSwingTableColumnString.MultilineColumnTextPane.MultilineColumnScrollPane, GuiSwingTableColumnString.MultilineColumnTextViewPane, GuiSwingTableColumnString.MultilineColumnWrappingPane, GuiSwingTableModelCollection, GuiSwingViewBooleanCheckBox.PropertyCheckBox, GuiSwingViewCollectionTable.CollectionTable, GuiSwingViewDocumentEditor.PropertyDocumentEditorPane, GuiSwingViewDocumentEditor.PropertyDocumentTextPane, GuiSwingViewEmbeddedComponent.PropertyEmbeddedPane, GuiSwingViewEnumComboBox.PropertyEnumComboBox, GuiSwingViewEnumComboBox.PropertyLabelEnum, GuiSwingViewFilePathField.PropertyFilePathPane, GuiSwingViewImagePane.PropertyImagePane, GuiSwingViewLabel.PropertyLabel, GuiSwingViewNumberSpinner.PropertyLabelNumber, GuiSwingViewNumberSpinner.PropertyNumberSpinner, GuiSwingViewObjectPane.ObjectPane, GuiSwingViewPropertyPane.NamedPropertyPane, GuiSwingViewPropertyPane.PropertyPane, GuiSwingViewPropertyPane.PropertyWrapperPane, GuiSwingViewStringField.PropertyStringPane, GuiSwingViewTabbedPane.ObjectTabbedPane, GuiSwingViewWrapper.ValueScrollPane, GuiSwingViewWrapper.ValueWrappingPane, GuiSwingWindow, LambdaProperty.LambdaBooleanCheckBox, LambdaProperty.LambdaCollectionTable, LambdaProperty.LambdaDocumentPlainEditorPane, LambdaProperty.LambdaDocumentTextPane, LambdaProperty.LambdaEnumComboBox, LambdaProperty.LambdaFilePathPane, LambdaProperty.LambdaImagePane, LambdaProperty.LambdaLabel, LambdaProperty.LambdaNumberSpinner, LambdaProperty.LambdaStringPane, ObjectTableColumnValue
abstraction for GUI element that might not have a displayable area and a specific value.
GUI elements construct a tree.
rootNode
component1
component2
component3
...
Each node might have a GuiMappingContext. it also construct a tree.
rootNode(context0)
component1(context1)
component2(context2)
component3(context2) //share context2 with parent
component4(context3)
...
Each node might be a Component, or a GuiSwingView.ValuePane.
rootNode(context0) : JRootPane
pane1 : JPanel
pane2 : JPanel
component1(context1) : ValuePane
scrollPane(context2) : ValuePane
component2(context2) : ValuePane
component3(context3)
...
Also, each node might be a non-displayable element, like Action.
rootNode(context0) : JRootPane
pane1 : JPanel
pane2 : JPanel
component1(context1) : ValuePane
scrollPane(context2) : ValuePane
component2(context2) : ValuePane
component3(context3)
action1(context4) : Action
...
The interface provides a set of features of GUI applications, and accessors of sub-nodes. Note that the interface methods are basically not recursive operations for the tree, except for the root-node. Static methods in the interface can traverse the sub-nodes.
- Since:
- 1.9
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic interfacestatic classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddSwingEditFinishHandler(Runnable eventHandler) the method is used for table cell-editors, in order to observe the completion of editing.static Stream<?> directChildren(Object obj) static Stream<?> default <RetType> GuiSwingTaskRunner.ContextTaskResult<RetType> executeContextTask(Supplier<RetType> task, Consumer<GuiSwingTaskRunner.ContextTaskResult<RetType>> afterTask) static <TargetType, RetType>
RetTypefindFirstChild(Object obj, Class<TargetType> type, Function<TargetType, RetType> mapper, GuiSwingFeature.TraversalOption... options) static <RetType> RetTypefindFirstChildIf(Object obj, Class<RetType> type, Predicate<RetType> predicate, GuiSwingFeature.TraversalOption... options) static <RetType extends GuiSwingFeature>
RetTypegetChildByName(Object obj, Class<RetType> type, String name) static <RetType extends GuiSwingFeature>
RetTypegetDescendantByContext(Object obj, Class<RetType> type, GuiMappingContext context) default ObjectList<?> It returns a list of sub-nodes of the node.default booleanstatic voidloadChildren(GuiPreferences prefs, Object comp) static voidloadChildren(GuiPreferences prefs, Object comp, GuiSwingPrefsApplyOptions options) traverses descendant components and callGuiSwingView.ValuePane.loadSwingPreferences(GuiPreferences, GuiSwingPrefsApplyOptions)default voidthe convient method for loading preferences withGuiSwingPrefsApplyOptions.APPLY_OPTIONS_DEFAULT.default voidloadSwingPreferences(GuiPreferences prefs, GuiSwingPrefsApplyOptions options) a sub-class which wraps another value-pane should overrides the method in order to omit needless value setting it can useGuiSwingView.loadPreferencesDefault(JComponent, GuiPreferences)default voidfor each component, the method is called before refreshing in order to clear the view-clock.default voidprepare, clear and update via the contextdefault voidstatic voidsaveChildren(GuiPreferences prefs, Object comp) traverse descendant components and callsaveSwingPreferences(GuiPreferences)for each component.default voidonly save the component itself, not including children.default voidsetKeyStrokeString(String keyStrokeString) set the key-stroke info.default voidsetPrefsJsonSupported(Object json) default voidfor each component, at the end of the process, this method will be calledstatic <TargetType>
voidtraverse(Object obj, Class<TargetType> type, Consumer<TargetType> task, GuiSwingFeature.TraversalOption... options) static <TargetType, RetType>
RetTypetraverseFindFirst(Object obj, Class<TargetType> type, Function<TargetType, RetType> mapper, GuiSwingFeature.TraversalOption... options) static <RetType> RetTypetraverseFindFirstIf(Object obj, Class<RetType> type, Predicate<RetType> predicate, GuiSwingFeature.TraversalOption... options) default voidnotifies property update to the component.default voidnotifies property update to the component and enclosing other components.static booleanwalk(Object obj, GuiSwingFeature.Visitor visitor) Methods inherited from interface GuiSwingElement.FeatureCollection
getSwingViewSubNodesSameDisplay
-
Method Details
-
updateSwingViewSource
default void updateSwingViewSource()notifies property update to the component. getter will be called and GUI display will be updated. the method just callsGuiMappingContext.updateSourceSubTree().- Since:
- 1.1
-
updateSwingViewSourceFromRoot
default void updateSwingViewSourceFromRoot()notifies property update to the component and enclosing other components. For single case,updateSwingViewSource()is sufficient. If the component is part of tree of value-panes, the method will be effective. the method just callsGuiMappingContext.updateSourceFromRoot().- Since:
- 1.1
-
getSwingViewContext
GuiMappingContext getSwingViewContext() -
addSwingEditFinishHandler
the method is used for table cell-editors, in order to observe the completion of editing. the default impl. is empty.- Parameters:
eventHandler- the handler called when the editing is finished
-
isSwingEditable
default boolean isSwingEditable() -
saveSwingPreferences
only save the component itself, not including children. it can useGuiSwingView.savePreferencesDefault(JComponent, GuiPreferences)- Parameters:
prefs- target prefs or ancestor of the target; actual target can be obtained byGuiPreferences.getDescendant(GuiMappingContext)
-
loadSwingPreferences
the convient method for loading preferences withGuiSwingPrefsApplyOptions.APPLY_OPTIONS_DEFAULT. In the library, the method should not call be called directly, instead, useloadSwingPreferences(GuiPreferences, GuiSwingPrefsApplyOptions).- Parameters:
prefs- target prefs
-
loadSwingPreferences
a sub-class which wraps another value-pane should overrides the method in order to omit needless value setting it can useGuiSwingView.loadPreferencesDefault(JComponent, GuiPreferences)- Parameters:
prefs- target prefsoptions- options for applying
-
shutdownSwingView
default void shutdownSwingView()for each component, at the end of the process, this method will be called -
getSpecifier
GuiReprValue.ObjectSpecifier getSpecifier()- Returns:
- the specifier for the context value, typically obtained from
GuiSwingView.SpecifierManager
-
requestSwingViewFocus
default void requestSwingViewFocus() -
setKeyStrokeString
set the key-stroke info. to the pane as a guide- Parameters:
keyStrokeString- the key stroke info to be set.
-
prepareForRefresh
default void prepareForRefresh()for each component, the method is called before refreshing in order to clear the view-clock. -
executeContextTask
default <RetType> GuiSwingTaskRunner.ContextTaskResult<RetType> executeContextTask(Supplier<RetType> task, Consumer<GuiSwingTaskRunner.ContextTaskResult<RetType>> afterTask) - Type Parameters:
RetType- the value type- Parameters:
task- the taskafterTask- the task executed for deferred value- Returns:
GuiSwingTaskRunner.executeContextTask(Supplier, Consumer)
-
refreshByContext
default void refreshByContext()prepare, clear and update via the context- Since:
- 1.5
-
getPrefsJsonSupported
- Returns:
- prefs JSON
- Since:
- 1.5
-
setPrefsJsonSupported
- Parameters:
json- prefs JSON- Since:
- 1.5
-
getSwingViewSubNodes
List<?> getSwingViewSubNodes()It returns a list of sub-nodes of the node.A sub-node is a displayable view under the same window, a displayable view under the different window, or a non-displayable element.
If this is a
Container, it typically returnsContainer.getComponents().A sub-node might have a different context or a shared context with
getSwingViewContext()of this.- Specified by:
getSwingViewSubNodesin interfaceGuiSwingElement.FeatureCollection- Returns:
- a list of sub-nodes
-
traverse
static <TargetType> void traverse(Object obj, Class<TargetType> type, Consumer<TargetType> task, GuiSwingFeature.TraversalOption... options) -
directChildren
-
directChildrenSameDisplay
-
traverseFindFirstIf
static <RetType> RetType traverseFindFirstIf(Object obj, Class<RetType> type, Predicate<RetType> predicate, GuiSwingFeature.TraversalOption... options) -
traverseFindFirst
static <TargetType, RetType> RetType traverseFindFirst(Object obj, Class<TargetType> type, Function<TargetType, RetType> mapper, GuiSwingFeature.TraversalOption... options) -
walk
-
findFirstChildIf
static <RetType> RetType findFirstChildIf(Object obj, Class<RetType> type, Predicate<RetType> predicate, GuiSwingFeature.TraversalOption... options) -
findFirstChild
static <TargetType, RetType> RetType findFirstChild(Object obj, Class<TargetType> type, Function<TargetType, RetType> mapper, GuiSwingFeature.TraversalOption... options) -
saveChildren
traverse descendant components and callsaveSwingPreferences(GuiPreferences)for each component. the root pane calls the method.- Parameters:
prefs- the preferences for the compcomp- the top component
-
loadChildren
loadChildren(GuiPreferences, Object, GuiSwingPrefsApplyOptions)withGuiSwingPrefsApplyOptions.APPLY_OPTIONS_DEFAULT- Parameters:
prefs- a top prefscomp- a top component
-
loadChildren
traverses descendant components and callGuiSwingView.ValuePane.loadSwingPreferences(GuiPreferences, GuiSwingPrefsApplyOptions)- Parameters:
prefs- a top prefscomp- a top componentoptions- options for applying- Since:
- 1.4
-
getDescendantByContext
static <RetType extends GuiSwingFeature> RetType getDescendantByContext(Object obj, Class<RetType> type, GuiMappingContext context) - Parameters:
context- the searched context, a descendant child of the context of the pane- Returns:
- a descendant value pane holding the context, or null. wrappers holding the same context are avoided.
-
getChildByName
static <RetType extends GuiSwingFeature> RetType getChildByName(Object obj, Class<RetType> type, String name) - Parameters:
name- the searched context name- Returns:
- a child (or descendant for wrappers) value pane holding the named context, or null. wrappers holding the same context are avoided.
-