Skip to content

Commit

Permalink
Merge pull request #1332 from tesonep/improve-repair-actions
Browse files Browse the repository at this point in the history
Improve Repair Actions
  • Loading branch information
tesonep authored Jan 2, 2020
2 parents 701e37d + f17a717 commit 466c123
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 126 deletions.
29 changes: 13 additions & 16 deletions Iceberg-TipUI/IceTipDiffPanel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ IceTipDiffPanel class >> title [
{ #category : #accessing }
IceTipDiffPanel >> basicRefresh [
self resetDiffContents.
changeList widget
in: [ :this |
this selectRowIndexes: #().
changeList widget
in: [ :this |
this selectIndexes: #().
self resetDataSource: this dataSource ];
refresh.

refresh
]

{ #category : #'accessing ui' }
Expand All @@ -63,9 +62,10 @@ IceTipDiffPanel >> changeList: anObject [
{ #category : #private }
IceTipDiffPanel >> changeSelected [
| index |
self flag: #todo. "This should -maybe- be modeled better on a SpecTablePresenter ;)"
index := changeList widget selectedRowIndex.
index = 0 ifTrue: [ ^ nil ].
self flag: #todo. "This should -maybe- be modeled better on a SpecTablePresenter ;)"
index := changeList widget selectedIndex.
index = 0
ifTrue: [ ^ nil ].
^ changeList widget dataSource realElementAt: index
]

Expand Down Expand Up @@ -205,16 +205,13 @@ IceTipDiffPanel >> rightLabel: aString [
{ #category : #'event handling' }
IceTipDiffPanel >> selectionChanged: ann [
| element |
(ann newSelectedRowIndexes reject: [ :each | each = 0 ])
(ann newSelectedIndexes reject: [ :each | each = 0 ])
ifNotEmpty: [ :indexes |
element := changeList widget dataSource realElementAt: indexes first.
self
diffContentsLeft: element value rightContents
right: element value leftContents ]
ifEmpty: [
self resetDiffContents ].


self
diffContentsLeft: element value rightContents
right: element value leftContents ]
ifEmpty: [ self resetDiffContents ]
]

{ #category : #initialization }
Expand Down
115 changes: 101 additions & 14 deletions Iceberg-TipUI/IceTipEditProjectDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Class {
'formatLabel',
'formats',
'defaultFormat',
'messagePanel'
'messagePanel',
'addDirectoryButton',
'removeDirectoryButton'
],
#category : #'Iceberg-TipUI-View-Project'
}
Expand All @@ -27,7 +29,9 @@ IceTipEditProjectDialog class >> defaultSpec [
newRow: [ :row |
row
newColumn: #nameLabel width: self iceLabelWidth;
newColumn: #nameInput ]
newColumn: #nameInput ;
newColumn: #addDirectoryButton width: (self iconNamed: #add) width + 10;
newColumn: #removeDirectoryButton width: (self iconNamed: #remove) width + 10]
height: self inputTextHeight;
newRow: [ :row |
row
Expand Down Expand Up @@ -78,6 +82,32 @@ IceTipEditProjectDialog >> acceptCallback [
^ acceptCallback
]

{ #category : #actions }
IceTipEditProjectDialog >> addDirectory [

| newDirectoryName newDirectory |

newDirectoryName := UIManager default
textEntry: 'Enter the new Directory name'
title: 'Create a directory'.

newDirectory := (selectedDirectoryPath / newDirectoryName) asResolvedBy: self model fileSystem.

newDirectory exists
ifFalse: [ newDirectory createDirectory ].

"The FTTable lost the selection when the expansion is done"
sourceDirectoryTree widget dataSource updateData.
sourceDirectoryTree widget dataSource expandAll.
sourceDirectoryTree widget selectIndex: (sourceDirectoryTree widget dataSource indexOfElement: (selectedDirectoryPath asResolvedBy: self model fileSystem)).

]

{ #category : #accessing }
IceTipEditProjectDialog >> addDirectoryButton [
^ addDirectoryButton
]

{ #category : #initialization }
IceTipEditProjectDialog >> defaultFormat [

Expand Down Expand Up @@ -164,14 +194,17 @@ IceTipEditProjectDialog >> initialize [

{ #category : #initialization }
IceTipEditProjectDialog >> initializeDirectoryTree [

| dataSource |
dataSource := self newDirectoryDataSource.
sourceDirectoryTree widget
addColumn: (IceTipTableColumn newAction: #name icon: [ :each | self iconNamed: #package ]);
addColumn:
(IceTipTableColumn
newAction: #name
icon: [ :each | self iconNamed: #package ]);
dataSource: dataSource;
onAnnouncement: FTSelectionChanged do: [ :announcement |
self sourceDirectorySelectionChanged: announcement newSelectedRowIndexes ]
onAnnouncement: FTSelectionChanged
do:
[ :announcement | self sourceDirectorySelectionChanged: announcement newSelectedIndexes ]
]

{ #category : #initialization }
Expand All @@ -192,14 +225,14 @@ IceTipEditProjectDialog >> initializeMessagePanel [
IceTipEditProjectDialog >> initializePresenter [
| path currentNode |
super initializePresenter.

self formatList
items: self formats;
displayBlock: [ :each | each description ];
setSelectedItem: model repositoryProperties fileFormat.

path := (RelativePath with: model sourceDirectory) segments asOrderedCollection.
currentNode := self sourceDirectoryTree widget dataSource rootItem children first.
path := (RelativePath with: model sourceDirectory) segments
asOrderedCollection.
currentNode := self sourceDirectoryTree widget dataSource rootItem
children first.
currentNode expand.
[ path isEmpty ]
whileFalse: [ | currentSegment |
Expand All @@ -210,11 +243,11 @@ IceTipEditProjectDialog >> initializePresenter [
node expand.
node ]
ifNone: [ nil ] ].

currentNode
ifNotNil: [ | index |
index := self sourceDirectoryTree widget dataSource indexOfElementMatching: [ :elem | elem = currentNode data ].
self sourceDirectoryTree widget selectRowIndex: index ].
index := self sourceDirectoryTree widget dataSource
indexOfElementMatching: [ :elem | elem = currentNode data ].
self sourceDirectoryTree widget selectIndex: index ]
]

{ #category : #initialization }
Expand All @@ -229,6 +262,22 @@ IceTipEditProjectDialog >> initializeWidgets [

formatLabel := self newLabel label: 'Format'.
formatList := self newDropList.

addDirectoryButton := self newButton
label: '';
help: 'Create a new directory under the selected one';
iconName: #add;
enabled: false;
action: [ self addDirectory ];
yourself.

removeDirectoryButton := self newButton
label: '';
help: 'Removes the selected directory';
iconName: #remove;
enabled: false;
action: [ self removeDirectory ];
yourself.

self initializeMessagePanel.

Expand Down Expand Up @@ -285,6 +334,34 @@ IceTipEditProjectDialog >> onAccept: aBlockClosure [
acceptCallback := aBlockClosure
]

{ #category : #actions }
IceTipEditProjectDialog >> removeDirectory [

| toRemove |

toRemove := selectedDirectoryPath asResolvedBy: self model fileSystem.

toRemove exists
ifTrue: [
(UIManager default
questionWithoutCancel: ('Are you sure to delete ''{1}''?' format: {toRemove basename})
title: 'Remove directory')
ifFalse: [ ^ self].
toRemove ensureDelete ].

"The FTTable lost the selection when the expansion is done"
sourceDirectoryTree widget dataSource updateData.
sourceDirectoryTree widget dataSource expandAll.
sourceDirectoryTree widget selectIndex: (sourceDirectoryTree widget dataSource indexOfElement: toRemove parent).

]

{ #category : #accessing }
IceTipEditProjectDialog >> removeDirectoryButton [

^ removeDirectoryButton
]

{ #category : #initialization }
IceTipEditProjectDialog >> selectedDirectoryPath [

Expand Down Expand Up @@ -324,12 +401,15 @@ IceTipEditProjectDialog >> sourceDirectorySelectionChanged: selectedIndexes [
selection := self sourceDirectoryTree widget dataSource rootItem children first.
selectedDirectory := self sourceDirectoryTree widget dataSource rootItem children first data.
] ifNotEmpty: [
selection := self sourceDirectoryTree widget dataSource elementAt: selectedIndexes first.
[selection := self sourceDirectoryTree widget dataSource elementAt: selectedIndexes first]
on:SubscriptOutOfBounds do:[ ^ self ].
].

selectedDirectory := selection data.
selectedDirectoryPath := selectedDirectory relativeTo: self model fileSystem.
formatList setSelectedItem: (self guessFormatFromDirectory: selectedDirectory).

self updateRemoveAndAddButton.
]

{ #category : #accessing }
Expand All @@ -342,6 +422,13 @@ IceTipEditProjectDialog >> sourceDirectoryTree: anObject [
sourceDirectoryTree := anObject
]

{ #category : #events }
IceTipEditProjectDialog >> updateRemoveAndAddButton [

addDirectoryButton enabled: selectedDirectoryPath isNotNil.
removeDirectoryButton enabled: selectedDirectoryPath isWorkingDirectory not
]

{ #category : #accessing }
IceTipEditProjectDialog >> username [
^ self nameInput text trimBoth
Expand Down
46 changes: 25 additions & 21 deletions Iceberg-TipUI/IceTipHistoryBrowser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,33 @@ IceTipHistoryBrowser >> initialExtent [

{ #category : #initialization }
IceTipHistoryBrowser >> initializeCommitList [
commitList widget
commitList widget
beResizable;
addColumn: (IceTipTableColumn new
id: 'Timestamp';
action: [ :each | each timeStamp asLocalStringYMDHM ];
width: 110 * World displayScaleFactor;
yourself);
addColumn: (IceTipTableColumn new
id: 'Commit';
action: #shortId;
width: 60 * World displayScaleFactor;
yourself);
addColumn: (IceTipTableColumn new
id: 'Author';
action: #author;
width: 150 * World displayScaleFactor;
yourself);
addColumn: (IceTipTableColumn new
id: 'Description';
action: #descriptionWithDecoration;
yourself);
addColumn:
(IceTipTableColumn new
id: 'Timestamp';
action: [ :each | each timeStamp asLocalStringYMDHM ];
width: 110 * World displayScaleFactor;
yourself);
addColumn:
(IceTipTableColumn new
id: 'Commit';
action: #shortId;
width: 60 * World displayScaleFactor;
yourself);
addColumn:
(IceTipTableColumn new
id: 'Author';
action: #author;
width: 150 * World displayScaleFactor;
yourself);
addColumn:
(IceTipTableColumn new
id: 'Description';
action: #descriptionWithDecoration;
yourself);
dataSource: self newCommitsDataSource;
selectRowIndex: 1
selectIndex: 1
]

{ #category : #initialization }
Expand Down
13 changes: 8 additions & 5 deletions Iceberg-TipUI/IceTipOptionDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ IceTipOptionDialog >> replacePanelWith: aType [

{ #category : #private }
IceTipOptionDialog >> selectFirst [
typeList widget selectRowIndex: 1.
self basicSelectionChanged: self allTypes first
typeList widget selectIndex: 1.
self basicSelectionChanged: self allTypes first
]

{ #category : #accessing }
Expand All @@ -190,9 +190,12 @@ IceTipOptionDialog >> selectedType [

{ #category : #private }
IceTipOptionDialog >> selectionChanged: ann [
self basicSelectionChanged: (ann newSelectedRowIndexes
ifNotEmpty: [ :indexes | self typeList widget dataSource realElementAt: indexes first ]
ifEmpty: [ nil ])
self
basicSelectionChanged:
(ann newSelectedIndexes
ifNotEmpty:
[ :indexes | self typeList widget dataSource realElementAt: indexes first ]
ifEmpty: [ nil ])
]

{ #category : #'accessing ui' }
Expand Down
8 changes: 4 additions & 4 deletions Iceberg-TipUI/IceTipRepairCheckoutBranch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Class {
{ #category : #accessing }
IceTipRepairCheckoutBranch class >> help [
^ 'Discard all changes in your image and checkout an existing branch.
This action will checkout the branch in the repository and align your image with your repository.
This action will checkout the branch in the repository and synchronize your image with your repository.
This situation happens because the code loaded in your image does not correspond with the status of your repository.
Opens a preview window before doing any change.
This action opens a preview window before doing any change.
This operation will modify the state of your working copy in disk. All non-commited changes in your disk working copy that are not in the image will be lost. If you want to keep them, perform a commit from outside before.'
This operation will modify the state of your working copy on disk. All non-commited changes in your disk working copy that are not in the image will be lost (this can happen if you edited the repository from outside). If you want to keep them, perform a commit from outside before.'
]

{ #category : #accessing }
Expand All @@ -45,7 +45,7 @@ IceTipRepairCheckoutBranch class >> order [

{ #category : #accessing }
IceTipRepairCheckoutBranch class >> title [
^ 'Discard local changes and checkout an existing branch'
^ 'Checkout an existing branch discarding image changes'
]

{ #category : #executing }
Expand Down
6 changes: 3 additions & 3 deletions Iceberg-TipUI/IceTipRepairCheckoutNewBranch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Class {

{ #category : #accessing }
IceTipRepairCheckoutNewBranch class >> help [
^ 'You can create a new branch from the commit your image is pointing to.
^ 'It creates a new branch from the commit your image is pointing to.
This will not lose any change in the image.
This situation happens because the code loaded in your image does not correspond with the status of your repository.
This operation will modify the state of your working copy in disk. All non-commited changes in your disk working copy that are not in the image will be lost. If you want to keep them, perform a commit from outside before.'
This operation will modify the state of your working copy on disk. All non-commited changes in your disk working copy that are not in the image will be lost (this can happen if you edited the repository from outside). If you want to keep them, perform a commit from outside before.'
]

{ #category : #accessing }
Expand Down Expand Up @@ -47,7 +47,7 @@ IceTipRepairCheckoutNewBranch class >> order [

{ #category : #accessing }
IceTipRepairCheckoutNewBranch class >> title [
^ 'Create a new branch from your image commit'
^ 'Create a new branch pointing to your image commit'
]

{ #category : #executing }
Expand Down
Loading

0 comments on commit 466c123

Please sign in to comment.