/
ClyMetaLinkInstallationPresenter.class.st
123 lines (110 loc) · 3.3 KB
/
ClyMetaLinkInstallationPresenter.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Class {
#name : #ClyMetaLinkInstallationPresenter,
#superclass : #SpPresenter,
#instVars : [
'sourceNode',
'list',
'toolBar',
'isForMetaLinkInstallation'
],
#category : #'Calypso-SystemPlugins-Reflectivity-Browser-Metalinks'
}
{ #category : #specs }
ClyMetaLinkInstallationPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #toolBar
expand: false
fill: false
padding: 0;
add: #list;
yourself
]
{ #category : #'instance creation' }
ClyMetaLinkInstallationPresenter class >> onNode: aSourceNode forInstallation: forInstallation [
^ self basicNew
sourceNode: aSourceNode;
isForMetaLinkInstallation: forInstallation;
initialize
]
{ #category : #opening }
ClyMetaLinkInstallationPresenter class >> openInstallerOnNode: aSourceNode [
(self onNode: aSourceNode forInstallation: true) openWithSpec
]
{ #category : #opening }
ClyMetaLinkInstallationPresenter class >> openUninstallerOnNode: aSourceNode [
(self onNode: aSourceNode forInstallation: false) openWithSpec
]
{ #category : #accessing }
ClyMetaLinkInstallationPresenter >> allRelevantMetaLinks [
| baseLinks |
baseLinks := self isForMetaLinkInstallation
ifTrue: [ MetaLink allInstances ]
ifFalse: [ sourceNode links ].
^ baseLinks reject: [ :link |
link metaObject == Break or: [
{
Watchpoint.
ExecutionCounter } includes: link metaObject class ] ]
]
{ #category : #initialization }
ClyMetaLinkInstallationPresenter >> close [
self withWindowDo: #close
]
{ #category : #initialization }
ClyMetaLinkInstallationPresenter >> initializePresenter [
list := self newList.
list items: MetaLink allInstances.
toolBar := self newToolBar.
self toolbarButtons do: [ :button | toolBar addItem: button ]
]
{ #category : #installation }
ClyMetaLinkInstallationPresenter >> installSelectedMetalink [
list selection selectedItem ifNotNil: [ :metalink |
sourceNode link: metalink ].
self close
]
{ #category : #testing }
ClyMetaLinkInstallationPresenter >> isForMetaLinkInstallation [
^isForMetaLinkInstallation ifNil:[isForMetaLinkInstallation := true]
]
{ #category : #accessing }
ClyMetaLinkInstallationPresenter >> isForMetaLinkInstallation: anObject [
isForMetaLinkInstallation := anObject
]
{ #category : #accessing }
ClyMetaLinkInstallationPresenter >> sourceNode: anObject [
sourceNode := anObject
]
{ #category : #accessing }
ClyMetaLinkInstallationPresenter >> toolbarButtons [
| buttons |
buttons := OrderedCollection new.
buttons add: (self isForMetaLinkInstallation
ifTrue: [
SpToolBarButton new
label: 'Install';
icon: (self iconNamed: #smallOk);
help: 'Install the selected metalink';
action: [ self installSelectedMetalink ];
yourself ]
ifFalse: [
SpToolBarButton new
label: 'Uninstall';
icon: (self iconNamed: #smallOk);
help: 'Uninstall the selected metalink';
action: [ self uninstallSelectedMetalink ];
yourself ]).
buttons add: (SpToolBarButton new
label: 'Cancel';
icon: (self iconNamed: #smallCancel);
help: 'Cancel';
action: [ self close ];
yourself).
^ buttons
]
{ #category : #installation }
ClyMetaLinkInstallationPresenter >> uninstallSelectedMetalink [
list selection selectedItem ifNotNil: [ :metalink |
sourceNode removeLink: metalink ].
self close
]