From b9448781adaf47475483d3f0b651a1ec99fd4aca Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 18 Aug 2016 17:31:14 +0000 Subject: [PATCH] Basic adding of nodes working, but have the problem reported today in the Pharo mailing list. I will try the approached I talked in the message today. --- .../Grafoscopio/GrafoscopioGUI.class.st | 9 ++- .../Grafoscopio/GrafoscopioNode.class.st | 15 +++- .../Grafoscopio/GrafoscopioNotebook.class.st | 71 ++++++++++--------- 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioGUI.class.st b/repository/Grafoscopio/GrafoscopioGUI.class.st index 0a7a667..3c13737 100644 --- a/repository/Grafoscopio/GrafoscopioGUI.class.st +++ b/repository/Grafoscopio/GrafoscopioGUI.class.st @@ -506,9 +506,8 @@ GrafoscopioGUI class >> showSettings [ { #category : #'graphical interface' } GrafoscopioGUI class >> startDockingBar [ - "Creates a custom docking bar for grafoscopio on top, with shorcuts for most used actions, and a fixed place for asking for help. - Some of the functionalities implemented now in the grafoscopio interface for document trees should be moved here, like the ones - related with help, external tools and grafoscopio updates and about" + "Creates a custom docking bar for grafoscopio on top, with shorcuts for most used actions, + and a fixed place for asking for help, external tools and grafoscopio updates and about" | launchMenu helpMenu updateMenu | @@ -740,8 +739,8 @@ GrafoscopioGUI class >> updateSystem [ GrafoscopioGUI class >> updateUI [ "I update the User Interface (UI) with new versions of the docking bar or logos where available. I'm helpful while testing new functionality that should be expossed to the user via the UI" - GrafoscopioGUI startDockingBar. - (World submorphs select: [ :each | each class = DockingBarMorph ]) allButLastDo: [ :bar | bar delete ]. + self startDockingBar. + (World submorphs select: [ :each | each class = DockingBarMorph ]) allButFirstDo: [ :bar | bar delete ]. ] diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index 820b229..0403f5c 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -158,6 +158,11 @@ GrafoscopioNode >> asSton [ ] +{ #category : #accessing } +GrafoscopioNode >> asText [ + ^ self body +] + { #category : #initialization } GrafoscopioNode >> becomeDefaultTestTree [ | node1 node2 node3 node4 | @@ -176,9 +181,8 @@ GrafoscopioNode >> becomeDefaultTestTree [ body: 'Just testing'. node1 addNode: node3. node4 := self class new - header: 'Button'; - body: 'Click me!'->[42 inspect]; - tagAs: 'johan'. + header: 'Something'; + body: 'else'. node1 addNode: node4. self addNode: node1; @@ -368,6 +372,11 @@ GrafoscopioNode >> initialize [ self key: '' ] +{ #category : #accessing } +GrafoscopioNode >> isEmpty [ + body ifNil: [ ^ true ] ifNotNil: [ ^ false ] +] + { #category : #accessing } GrafoscopioNode >> key [ "Returns a unique key identifying the receiver in the help system" diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index 7f6f916..b8a55ef 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -47,15 +47,13 @@ GrafoscopioNotebook class >> defaultSpec [ ] { #category : #operation } -GrafoscopioNotebook >> addNode [ - +GrafoscopioNotebook >> addNode [ tree needRebuild: true. - tree selectedItem content addNodeAfterMe. - self selectNextItem. + tree highlightedItem content addNodeAfterMe. + self notebookContent: notebook. tree roots: tree roots. + self highlightNextItem. self buildWithSpecLayout: self class defaultSpec. - - ] { #category : #accessing } @@ -73,10 +71,10 @@ GrafoscopioNotebook >> changeBody: aNode [ self needRebuild: false. tree needRebuild: false. body needRebuild: true. - body := self instantiate: aNode specModelClass new. + body := self instantiate: aNode content specModelClass new. body content: aNode content. body body class = TextModel - ifTrue: [body body whenTextChanged: [ :arg | aNode body: arg ]]. + ifTrue: [body body whenTextChanged: [ :arg | aNode content body: arg ]]. body body class = GlamourPresentationModel ifTrue: [ | playground | playground := body body glmPres. @@ -84,10 +82,10 @@ GrafoscopioNotebook >> changeBody: aNode [ do: [ :ann | ann property = #text ifTrue: [ | playgroundText | playgroundText := (playground pane ports at: 2) value. - aNode body: playgroundText] + aNode content body: playgroundText] ] ]. - header text: aNode header. + header text: aNode content header. self buildWithSpecLayout: self class defaultSpec. ] @@ -130,15 +128,38 @@ GrafoscopioNotebook >> header: anObject [ header := anObject ] +{ #category : #operation } +GrafoscopioNotebook >> highlightNextItem [ + | currentItem | + currentItem := tree highlightedItem. + currentItem + ifNotNil: [ | allItems index childrenSize parentNode | + currentItem parentNode + ifNil: [ + parentNode := currentItem container. + allItems := parentNode roots ] + ifNotNil: [ + parentNode := currentItem parentNode. + allItems := parentNode children value. ]. + childrenSize := currentItem content parent children size. + index := allItems indexOf: currentItem. + (index < childrenSize) ifTrue: [ + "{allItems . currentItem . index } inspect." + currentItem selected: false. + parentNode + highlightedItem: ((allItems at:(index+1)) selected:true; + takeHighlight;yourself). + ] + ] +] + { #category : #initialization } GrafoscopioNotebook >> initializePresenter [ - tree whenSelectedItemChanged: [ :item | - self updateBodyFor: item. - header whenTextChanged: [ :arg | - (tree selectedItem content header) = arg - ifFalse: [ - (tree highlightedItem) content header: arg. - tree roots: tree roots]]] + tree whenHighlightedItemChanged: [ :item | self updateBodyFor: item]. + header whenTextChanged: [ :arg | + (tree highlightedItem content header) = arg + ifFalse: [ (tree highlightedItem) content header: arg. + tree roots: tree roots]]. ] @@ -153,7 +174,6 @@ GrafoscopioNotebook >> initializeWidgets [ tree childrenBlock: [:node | node children]; displayBlock: [:node | node title ]. - tree whenBuiltDo: [ tree selectedItem: (tree roots first selected: true; takeHighlight; yourself)]. self focusOrder add: tree; add: header; @@ -514,21 +534,6 @@ GrafoscopioNotebook >> saveWorkingNotebook [ ] -{ #category : #operation } -GrafoscopioNotebook >> selectNextItem [ - | currentItem | - currentItem := self tree selectedItem. - currentItem ifNotNil: [ | allItems index| - allItems := currentItem container roots. - index := allItems indexOf: currentItem. - (index < allItems size) ifTrue: [ - currentItem selected: false. - currentItem container selectedItem: ((allItems at:(index+1)) selected:true;takeHighlight;yourself). - tree selectedItem inspect. - ] - ] -] - { #category : #accessing } GrafoscopioNotebook >> tree [ ^ tree