Closed yamtl closed 8 months ago
An example of how it looks like:
Thanks, @arturboronat . This is quite neat.
One thing it does expose, though, is the fact that panel functionality is currently spread out all over the place in the code base rather than having been integrated into the Panel class and its sub-classes. As a result, you had to change code all over the place. This will become unsustainable in the medium term and I propose that we should clean this up -- either in this PR or by separate issue / PR. I also came across this issue in PR #133 (where my solution actually makes the problem worse rather than improving it, so I will propose a better solution in a bit).
Yes, separation of concerns could be improved. At the moment is not a big deal because the codebase is small.
A minimal change that would help is to put all panels in a subfolder panels
.
Moved to PR #151
CompositePanel
The CompositePanel serves as a structural design pattern in the playground UI, employing the concept of composition to enhance modularity. It extends the
Panel
class and acts as a composite object that can encapsulate multiple sub-panels. This allows for the creation of a hierarchical structure of panels, akin to a tree structure in object-oriented design. There are no inherent restrictions on the number of contained panels, and this includes the possibility of nesting other CompositePanels.A typical use case is to use a composite panel to couple an editor with a diagram. See an example in YAMTL's playground, where CompositePanels have been used to implemente MetamodelPanel and ModelPanel.
Configuration
A composite panel def needs to be declared in the tool configuration:
A composite panel is wired in an activity and declares
childrenPanels
, giving some structure to the UI of the playground.CompositePanel
can be regarded as the composition operator of a DSL for defining UIs for the playground.Internal toggle buttons are now built-in and can be used to toggle contained panels. A toggle button is declared within the section
buttons
of a composite panel and is defined withid
,name
,icon
andhint
. In addition, theinternal
action must betoggle
and thetargetPanel
must be the panel to be toggled.Changes that were implemented
createElement
. Hence, a new operatorinitialize
has been added toPanel
and this needs to be overriden byPanel
specializations. Once a panel is instantiated, it needs to be explicitly initialized.OutputPanel
now extendsProgramPanel
.ModelPanel
can be regarded as an instance ofCompositePanel
and is therefore not needed explicitly.Future work