Class { #name : #GrafoscopioNewCodeModel, #superclass : #GrafoscopioNewTextModel, #instVars : [ 'preview', 'previewButton' ], #category : #'Grafoscopio-New-UI' } { #category : #specs } GrafoscopioNewCodeModel class >> defaultSpec [ ^ SpBoxLayout newVertical add: #body; yourself ] { #category : #initialization } GrafoscopioNewCodeModel >> content: aGrafoscopioNodeContent [ self layout: (self createLayoutFor: aGrafoscopioNodeContent). body text: (aGrafoscopioNodeContent ifNil: [ '' ]) ] { #category : #initialization } GrafoscopioNewCodeModel >> createLayoutFor: aGrafoscopioNodeContent [ ^ SpBoxLayout newVertical add: (SpBoxLayout newHorizontal add: (SpBoxLayout newVertical add: #up; add: #down; add: #delete; yourself) width: 30; add: (SpBoxLayout newHorizontal add: #body; add: #previewButton width: 30; add: #preview; yourself); yourself) height: (self heightFor: aGrafoscopioNodeContent) ] { #category : #initialization } GrafoscopioNewCodeModel >> editionLayoutFor: aGrafoscopioNodeContent [ ^ SpBoxLayout newVertical add: (SpBoxLayout newHorizontal add: (SpBoxLayout newVertical add: #up; add: #down; add: #delete; yourself) width: 30; add: (SpBoxLayout newHorizontal add: #body; add: #previewButton width: 30; add: #preview; yourself); yourself) height: (self heightFor: aGrafoscopioNodeContent) ] { #category : #initialization } GrafoscopioNewCodeModel >> initializeWidgets [ super initializeWidgets. previewButton := self newButton. previewButton icon: (self iconNamed: #smallFind). previewButton action: [ self previewCode ]. preview := self newLabel ] { #category : #initialization } GrafoscopioNewCodeModel >> newTextComponent [ ^ self newCode whenTextChangedDo: [ model text: body text ]; autoAccept: true; yourself ] { #category : #initialization } GrafoscopioNewCodeModel >> normalLayoutFor: aGrafoscopioNodeContent [ ^ SpBoxLayout newVertical add: (SpBoxLayout newHorizontal add: (SpBoxLayout newHorizontal add: #body; add: #previewButton width: 30; add: #preview; yourself); yourself) height: (self heightFor: aGrafoscopioNodeContent) ] { #category : #initialization } GrafoscopioNewCodeModel >> previewCode [ [ preview label: (self class compiler evaluate: body text) asString ] on: Error do: [ :e | preview label: e asString] ]