gui/PPParserBrowser.st
author Claus Gittinger <cg@exept.de>
Sun, 22 Jul 2018 22:41:13 +0200
changeset 633 4be0b0537d80
parent 330 d807737e23f8
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
330
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser/gui' }"
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
GLMCompositePresentation subclass:#PPParserBrowser
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:''
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'PetitGui-Core'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!PPParserBrowser class methodsFor:'as yet unclassified'!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
openOn: aParserClass 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	^ self new openOn: aParserClass
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
! !
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
!PPParserBrowser methodsFor:'building'!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
buildBrowser
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	"self openOn: PPArithmeticParser"
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	| browser |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	browser := GLMTabulator new.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	browser title: [:each | each name].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	browser 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
		row: [:r | r column: #productions ; column: #workspace span: 2];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
		row: #inspector.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
	browser transmit to: #productions; andShow: [:a | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
	 	self productionsIn: a ]. 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
	browser transmit to: #workspace; fromOutsidePort: #entity; from: #productions; andShow: [:a | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
		self workspaceIn: a ]. 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	browser transmit to: #inspector; fromOutsidePort: #entity; from: #productions; passivelyFrom: #outer port: #sampleText; andShow: [:a |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
		self inspectorIn: a ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	browser transmit from: #inspector port: #sampleText; toOutsidePort: #sampleText; when: [:arg | arg notNil ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
	browser transmit from: #workspace; toOutsidePort: #productionToSelect; 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
		transformed: [:parser | parser name ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
		when: [:parser | parser name notNil ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
	browser transmit fromOutsidePort: #productionToSelect; to: #productions port: #selection.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
	^ browser
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
compose
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
	"self openOn: PPArithmeticParser"
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
	self title: [:each | each name].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
	self tabulator with: [ :tabulator |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
		tabulator 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
			row: [:r | r column: #productions ; column: #workspace span: 2];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
			row: #inspector.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
		tabulator transmit to: #productions; andShow: [:a | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
		 	self productionsIn: a ]. 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
		tabulator transmit to: #workspace; fromOutsidePort: #entity; from: #productions; andShow: [:a | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
			self workspaceIn: a ]. 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
		tabulator transmit to: #inspector; fromOutsidePort: #entity; from: #productions; passivelyFrom: #outer port: #sampleText; andShow: [:a |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
			self inspectorIn: a ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
		tabulator transmit from: #inspector port: #sampleText; toOutsidePort: #sampleText; when: [:arg | arg notNil ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
		tabulator transmit from: #workspace; toOutsidePort: #productionToSelect; 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
			transformed: [:parser | parser name ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
			when: [:parser | parser name notNil ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
		tabulator transmit fromOutsidePort: #productionToSelect; to: #productions port: #selection ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
! !
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
!PPParserBrowser methodsFor:'private building'!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
exampleIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
	composite text
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
		title: 'Example';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
		useExplicitNotNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
		display: [ :class :productionSelector | (self production: productionSelector from: class) example ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
		act: [:text | text update] icon: GLMUIThemeExtraIcons glamorousRefresh entitled: 'Generate another one'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
firstIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
	composite list
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
		title: 'First';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
		useExplicitNotNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
		display: [ :class :productionSelector | (self production: productionSelector from: class) firstSet ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
		format: [ :parser | parser displayName ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
followIn: aBrowser
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
	aBrowser list
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
		title: 'Follow';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
		useExplicitNotNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
		format: [ :parser | parser displayName ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
		display: [ :class :productionSelector | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
			| parser |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
			parser := class new.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
			parser followSets
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
				at: (parser productionAt: productionSelector)
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
				ifAbsent: [ Array with: nil asParser ] ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
graphIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
	composite morph
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
		title: 'Graph';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
		useExplicitNotNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
		display: [ :class :selector |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
			| morph |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
			morph := ScrollPane new.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
			morph color: Color white.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
			morph scroller addMorph: (self production: selector from: class) morphicProduction.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
			morph ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
inspectorIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
	composite dynamic
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
		allowNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
		display: [ :class :productionSelector :sampleText | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
					| wrapperBrowser |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
					wrapperBrowser := GLMTabulator new.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
					wrapperBrowser allowNil.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
					wrapperBrowser column: #wrapped.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
					wrapperBrowser transmit
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
						to: #wrapped;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
						andShow: [ :a | a custom: (PPParserInspector new noTitle) ].
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
					wrapperBrowser transmit
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
						from: #wrapped port: #sampleText;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
						toOutsidePort: #sampleText.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
						
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
					wrapperBrowser transmit
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
						fromOutsidePort: #sampleText;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
						to: #wrapped port: #sampleText.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
					wrapperBrowser startOn: ([(self production: productionSelector from: class) end] on: Error do: [:e | nil]) .
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
					(wrapperBrowser pane port: #sampleText) value: (sampleText ifNil: [ '' ] ifNotNil: [ sampleText ]).
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
					wrapperBrowser
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
					]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
				
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
mapIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
	self class environment at: #GLMRoassalPresentation ifPresent: [ :cls |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
		composite roassal
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
			title: 'Map';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
			useExplicitNotNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
			painting: [ :view :class :selector |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
				(self production: #start from: class)
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
					viewAllNamedParsersWithSelection: (Array with: selector)  
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
					previewing: [:eachParser | self sourceCodeFrom: class selector: eachParser name ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
					on:  view ] ]	
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
productionsIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
	"Doru: These menus should be built dynamically: title and enabled status should adapt" 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
	"enabled: RBRefactoryChangeManager instance hasRedoableOperations"	" , RBRefactoryChangeManager instance redoChange"	"enabled: RBRefactoryChangeManager instance hasUndoableOperations"	" , RBRefactoryChangeManager instance undoChange "
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
	composite list
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
		title: [ :class | class name ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
		format: [ :class | class asString ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
		display: [ :class | self productionSelectorsFrom: class ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
		shouldValidate: true;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
		act: [ :list :class | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
					RBRefactoryChangeManager instance redoOperation.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
					list pane browser update ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
			icon: GLMUIThemeExtraIcons glamorousRedo
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
			entitled: 'Redo';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
		act: [ :list :class | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
					RBRefactoryChangeManager instance undoOperation.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
					list pane browser update ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
			icon: GLMUIThemeExtraIcons glamorousUndo
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
			entitled: 'Undo';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
		selectionAct: [ :list  :class | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
					| oldName refactoring |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
					oldName := list selection.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
					refactoring := PPRefactoringUtils new performRenameProduction: oldName from: class.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
					refactoring changes changes notEmpty ifTrue: [
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
						list update.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
						list selection: refactoring changes changes first newName asSymbol ] ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
			on: $r
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
			entitled: 'Rename (r)';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
		selectionAct: [ :list :class | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
					PPRefactoringUtils new performRefactoring: (PPRemoveProdcutionRefactoring onClass: class production: list selection).
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
					list pane browser update ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
			on: $x
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
			entitled: 'Remove (x)';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
		selectionAct: [ :list :class | Smalltalk tools browser fullOnClass: class selector: list selection ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
			on: $b
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
			entitled: 'Browse (b)';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
		selectionAct: [ :list :class | (self production: list selection from: class) explore ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
			on: $I
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
			entitled: 'Explore (I)'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
sourceIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
	composite smalltalkCode
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
		title: 'Source';
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
		useExplicitNotNil;
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
		display: [ :class :production | self sourceCodeFrom: class selector: production ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
		smalltalkClass: [ :class | class ];
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
		selectionAct: [ :text :class :production | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
				| selector refactoring |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
				selector := UIManager default
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
					request: 'Production name to extract to:'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
					initialAnswer: ''
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
					title: 'Extract production'.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
				selector isEmptyOrNil ifFalse: [
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
					selector := selector asSymbol.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
					refactoring := PPExtractProdcutionRefactoring
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
						onClass: class
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
						production: production
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
						interval: text selectionInterval
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
						to: selector.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
					PPRefactoringUtils new performRefactoring: refactoring.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
					text pane browser update.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
					(text pane port: #productionToSelect) value: selector ] ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
			on: $e
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
			entitled: 'Extract production';		
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
		act: [ :text :class :production | 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
				| selector refactoring |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
				refactoring := PPDefineProdcutionRefactoring 	
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
						onClass: class 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
						source: text text asString 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
						protocols: #(grammar).
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
				PPRefactoringUtils new performRefactoring: refactoring.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
				selector := refactoring changes changes last selector.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
				selector = production 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
					ifTrue: [text update]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
					ifFalse: [
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
						text pane browser update.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
						(text pane port: #productionToSelect) value: selector ] ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
			icon: GLMUIThemeExtraIcons glamorousAccept
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
			on: $s
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
			entitled: 'Accept'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
workspaceIn: composite
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
	self sourceIn: composite.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
	self graphIn: composite.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
	self mapIn: composite.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
	self exampleIn: composite.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
	self firstIn: composite.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
	self followIn: composite.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
! !
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
!PPParserBrowser methodsFor:'private utilities'!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
production: selector from: class
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
	| parser |
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
	parser := class new.
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
	^ selector isNil 
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
		ifTrue: [ parser ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
		ifFalse: [ parser productionAt: selector ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
productionSelectorsFrom: class
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
	^ (((class allInstVarNames copyWithoutAll: class ignoredNames)
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
		collect: [ :each | each asSymbol ])
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
			select: [ :each | class includesSelector: each ]) asSortedCollection add: #start; yourself
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
sourceCodeFrom: class selector: production
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
	^ class ultimateSourceCodeAt: (production ifNil: [ #start ]) ifAbsent: [ String new ]
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
! !
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
!PPParserBrowser class methodsFor:'documentation'!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
version
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserBrowser.st,v 1.1 2014-03-04 21:14:30 cg Exp $'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
!
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
version_CVS
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPParserBrowser.st,v 1.1 2014-03-04 21:14:30 cg Exp $'
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
! !
d807737e23f8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268