forked from pharo-project/pharo
/
RBPushUpPreviewPresenter.class.st
104 lines (86 loc) · 2.65 KB
/
RBPushUpPreviewPresenter.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"
I am a preview of Pull up refactoring, I can select the superClass of pull up methos and select the methods of class to pull up.
EXAMPLES
-------------------------------------------------
RBPushUpPreview on: RBPushDownPreview withSelectors: Array new.
Instance Variables
-------------------------------------------------
label: <LabelPresenter> A label of droplist
label2: <LabelPresenter> A label of table
classDropList: <DropListPresenter> A drop list to select the superclass to push up the selected methods
"
Class {
#name : #RBPushUpPreviewPresenter,
#superclass : #RBPushDownPreviewPresenter,
#instVars : [
'label2',
'classDropList'
],
#category : #'SystemCommands-RefactoringSupport'
}
{ #category : #specs }
RBPushUpPreviewPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #label2 withConstraints: [ :c | c height: self labelHeight ];
add:
(SpBoxLayout newHorizontal
add: #classDropList ;
yourself) withConstraints: [ :c | c height: self toolbarHeight ];
add: #label withConstraints: [ :c | c height: self buttonHeight ];
add:
(SpBoxLayout newHorizontal
add: #table;
yourself);
yourself
]
{ #category : #examples }
RBPushUpPreviewPresenter class >> example [
<script>
^ (self on: RBPushUpPreviewPresenter withSelectors: Array new)
]
{ #category : #specs }
RBPushUpPreviewPresenter class >> title [
^ 'Pull methods up to'
]
{ #category : #'instance creation' }
RBPushUpPreviewPresenter >> accept [
refactoring superClass: self activeClass .
refactoring selectors: (selectedMethods collect: #selector).
]
{ #category : #updating }
RBPushUpPreviewPresenter >> activeClass [
^classDropList selectedItem
]
{ #category : #initialization }
RBPushUpPreviewPresenter >> classes [
^ class allSuperclasses removeAllSuchThat: [ :each | each == Object or: [ each == ProtoObject ] ].
]
{ #category : #initialization }
RBPushUpPreviewPresenter >> initializeDropList [
classDropList := self newDropList.
classDropList
display: [ :scope | scope name ];
iconBlock: [ :e | e systemIcon ]
]
{ #category : #initialization }
RBPushUpPreviewPresenter >> initializeWidgets [
super initializeWidgets .
label2 := self newLabel.
self initializeDropList.
]
{ #category : #initialization }
RBPushUpPreviewPresenter >> on: aClass withSelectors: selectors [
|classes|
super on: aClass withSelectors: selectors.
classes := self classes.
classDropList items: classes.
label2 label: self textLabel2
]
{ #category : #'acessing text' }
RBPushUpPreviewPresenter >> textLabel [
^ 'Methods to be pulled up'
]
{ #category : #'acessing text' }
RBPushUpPreviewPresenter >> textLabel2 [
^ 'Pull up methods of ', class name,' to:' .
]