gui/PPRefactoringUtils.st
author Claus Gittinger <cg@exept.de>
Tue, 04 Mar 2014 22:14:51 +0100
changeset 333 2ffae473b494
permissions -rw-r--r--
initial checkin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
333
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser/gui' }"
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
Object subclass:#PPRefactoringUtils
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:''
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'PetitGui-Core'
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!PPRefactoringUtils methodsFor:'private refactoring'!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
handleError: anException
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	anException actionBlock isNil
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
		ifTrue: [ UIManager default inform: anException messageText ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
		ifFalse: [ 
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
			(UIManager default confirm: anException messageText) 
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
				ifTrue: [ anException actionBlock value ] ].
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	anException return
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
handleWarning: anException 
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	| message |
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	message := (anException messageText endsWith: '?')
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
		ifTrue: [ anException messageText ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
		ifFalse: [ anException messageText , String cr , 'Do you want to proceed?' ].
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
	(UIManager default confirm: message)
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
		ifTrue: [ anException resume ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
		ifFalse: [ anException return ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
performRefactoring: aRefactoring
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	[ [ aRefactoring execute ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
		on: RBRefactoringWarning
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
		do: [ :exception | self handleWarning: exception ] ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
		on: RBRefactoringError
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
		do: [ :exception | self handleError: exception ]
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
performRenameProduction: oldName from: class
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
	| refactoring newName |
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
	newName := UIManager default request: 'Production name:' initialAnswer: oldName.
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
	refactoring := PPRenameProdcutionRefactoring onClass: class rename: oldName to: newName.
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
	self performRefactoring: refactoring.
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
	^ refactoring
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
! !
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!PPRefactoringUtils class methodsFor:'documentation'!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
version
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPRefactoringUtils.st,v 1.1 2014-03-04 21:14:51 cg Exp $'
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
version_CVS
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/gui/PPRefactoringUtils.st,v 1.1 2014-03-04 21:14:51 cg Exp $'
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
! !
2ffae473b494 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57