gui/PPBrowser.st
changeset 327 6f40d57a93c4
equal deleted inserted replaced
326:7695a5ecc5cf 327:6f40d57a93c4
       
     1 "{ Package: 'stx:goodies/petitparser/gui' }"
       
     2 
       
     3 GLMCompositePresentation subclass:#PPBrowser
       
     4 	instanceVariableNames:''
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitGui-Core'
       
     8 !
       
     9 
       
    10 
       
    11 !PPBrowser class methodsFor:'instance creation'!
       
    12 
       
    13 open 
       
    14 	^ self openOn: PPCompositeParser
       
    15 !
       
    16 
       
    17 openOn: aClass
       
    18 	"Less glamorous versions of Glamour do not work with the new browser, fall back to the old one in this case."
       
    19 	
       
    20 	(self superclass canUnderstand: #compose)
       
    21 		ifFalse: [ ^ PPDrabBrowser new openOn: aClass ].
       
    22 	^ self new openOn: aClass
       
    23 ! !
       
    24 
       
    25 !PPBrowser class methodsFor:'accessing'!
       
    26 
       
    27 icon
       
    28 	^ (Form
       
    29 	extent: 16@16
       
    30 	depth: 32
       
    31 	fromArray: #( 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 1069534679 2139069360 2139069360 2139069360 2139069360 1551866800 1199545264 1451203504 2139069360 2139069360 2139069360 2139069360 2139069360 260021168 8362928 16777215 2139069360 14177 67123041 620771169 1224750945 1845507937 3372234593 3087021921 4278204257 4278204257 4278204257 4278204257 4278204257 3405789025 452999009 16777215 2139069360 14177 117454689 704657249 1325414241 1728067425 2197829473 3288348513 4278204257 4278204257 3758110561 3691001697 4278204257 4278204257 654325601 16777215 2139069360 14177 201340769 822097761 1409300321 1543518049 1811953505 3523229537 4278204257 4278204257 2231383905 3019913057 4278204257 4278204257 620771169 16777215 2139069360 14177 318781281 939538273 1509963617 1862285153 2717923169 3573561185 4278204257 4278204257 3238016865 3640670049 4278204257 4060100449 452999009 16777215 2139069360 1593849697 1862285153 2248161121 2281715553 2751477601 3003135841 3825219425 4278204257 4278204257 4278204257 4278204257 4278204257 1476409185 100677473 16777215 2139069360 33568609 536885089 1157642081 1644181345 1946171233 2214606689 4278204257 4278204257 3389011809 2281715553 2130720609 268449633 16791393 14177 16777215 2139069360 83900257 637548385 1258305377 1543518049 1543518049 1543518049 4278204257 4278204257 2466264929 201340769 14177 14177 14177 14177 16777215 2139069360 151009121 754988897 1375745889 1543518049 1543518049 1543518049 4278204257 4278204257 2298492769 125803440 16777215 16777215 16777215 16777215 16777215 2139069360 234895201 872429409 1426077537 1543518049 1543518049 2902472545 4278204257 4278204257 603993953 75471792 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215 16777215)
       
    32 	offset: 0@0)
       
    33 !
       
    34 
       
    35 label
       
    36 	^ 'PetitParser'
       
    37 ! !
       
    38 
       
    39 !PPBrowser class methodsFor:'private'!
       
    40 
       
    41 menuCommandOn: aBuilder
       
    42 	<worldMenu>
       
    43 
       
    44 	(aBuilder item: self label)
       
    45 		parent: #Tools;
       
    46 		icon: self icon;
       
    47 		action: [ self open ]
       
    48 ! !
       
    49 
       
    50 !PPBrowser methodsFor:'building'!
       
    51 
       
    52 compose
       
    53 	"self open"
       
    54 	self title: self defaultTitle.
       
    55 	self tabulator with: [ :tabulator | 
       
    56 		tabulator 
       
    57 			column: #classes;
       
    58 			column: #parser span: 3.
       
    59 		tabulator transmit to: #classes; andShow: [:a | 
       
    60 			self classesIn: a ]. 
       
    61 		tabulator transmit to: #parser; from: #classes; andShow: [:a | 
       
    62 			a custom: PPParserBrowser new noTitle ]
       
    63 	]
       
    64 !
       
    65 
       
    66 defaultTitle
       
    67 	^ 'PetitParser Browser'
       
    68 ! !
       
    69 
       
    70 !PPBrowser methodsFor:'private building'!
       
    71 
       
    72 addNewSubParserOf: class in: list
       
    73 	| refactoring className |
       
    74 	className := UIManager default request: 'Parser class name' initialAnswer: '' title: 'Add new parser'.
       
    75 	^ className
       
    76 		ifNotNil: [ 
       
    77 			refactoring := PPAddParserRefactoring name: className asSymbol category: #ParserExample superclass: class.
       
    78 			PPRefactoringUtils new performRefactoring: refactoring.
       
    79 			list update ]
       
    80 !
       
    81 
       
    82 classesIn: composite
       
    83 	composite tree
       
    84 		title: 'Parsers';
       
    85 		format: [ :class | class name ];
       
    86 		children: [ :class | class subclasses asSortedCollection: [ :a :b | a name < b name ] ];
       
    87 		display: [ :class | class subclasses asSortedCollection: [ :a :b | a name < b name ] ];
       
    88 		selectionAct: [ :list :class | Smalltalk tools browser fullOnClass: list selection ] on: $b entitled: 'Browse (b)';
       
    89 		selectionAct: [ :list :class | self addNewSubParserOf: list selection in: list ]
       
    90 			entitled: 'Add new sub parser';
       
    91 		act: [ :list :class | self addNewSubParserOf: class in: list ]
       
    92 			icon: GLMUIThemeExtraIcons glamorousAdd
       
    93 			on: $+
       
    94 			entitled: 'Add new parser'
       
    95 ! !
       
    96 
       
    97 !PPBrowser class methodsFor:'documentation'!
       
    98 
       
    99 version
       
   100     ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPBrowser.st,v 1.1 2014-03-04 21:14:07 cg Exp $'
       
   101 !
       
   102 
       
   103 version_CVS
       
   104     ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPBrowser.st,v 1.1 2014-03-04 21:14:07 cg Exp $'
       
   105 ! !
       
   106