Commits

Ryan Macnak committed e1f309c

Improve MemoryHole UI: can remove repositories; can add/remove repositories without having to refresh them all; somewhat clearer refresh behavior.

Comments (0)

Files changed (1)

 refreshSCAfter: block = (
 
 	sendUp refreshSCAfter: block 
+)'as yet unclassified'
+deferred: block initially: fragment = (
+	^(deferred: block) initialContent: fragment
+)
+removeButtonWithAction: aBlock = (
+	^imageButton: {
+		HopscotchImages default cancel16px.
+		HopscotchImages default cancel16pxOver.
+		HopscotchImages default cancel16pxDown}
+	action: aBlock
 )'combinators'
 h1: body = (
 
 		halfColumnSeparator.
 		ifConflict: [
 			headingForSide: #commonAncestorSource labeled: 'common ancestor'].
-		link: '?' action: [self inspect].
+		"link: '?' action: [self inspect]."
 		halfColumnSeparator.
 		headingForSide: #ourSource labeled: 'ours'}
 )
 		actionDeleteHistorian.}
 ))
 class LocalRepositoryPresenter onSubject: subject = BasePresenter onSubject: subject (|
+deferredContent = holder: nothing.
 changesNotification
 messagesContainer
 inspectionHolder
 statusOrLogLinkHolder
 |)
 ('as yet unclassified'
-definition = (
+actualDefinition = (
 
 	messagesContainer:: OrderedCollection new.
 	statusOrLogLinkHolder:: holder: (linkForLog: true).
 	statusOrLogHolder:: holder: repositoryStatusPresenter.
+	
 	^column: {
 		h1:: row: {
 			presentTitle.
 		statusOrLogHolder
 	}
 )
+definition = (
+	^deferredContent
+)
 linkForLog: showLog = (
 
 	^ showLog
 					statusOrLogHolder content: repositoryStatusPresenter.
 					statusOrLogLinkHolder content: (linkForLog: showLog not)]]
 )
+noticeImminentExposure = (
+	refreshSCAfter: []
+)
 presentAge = (
 	"subject isRecent ifTrue: [
 		^(link: '[active]' action: [confirm: 'New version published to server within the last week.' ifConfirmed:[]]) tinyFont color: Color gray
 		label: repositoryName asText allBold
 	}
 )
+refreshSCAfter: block = (
+
+	deferredContent content: (label: 'performing action...') tinyFont.
+	[showWaitCursorWhile: [
+		block value.
+		shell desktop scheduleUIAction: [deferredContent content: actualDefinition].
+	]
+	]forkAt: 30 named: 'Refreshing: ', subject title
+)
 repositoryEnterSubject: newSubject = (
 
 	statusOrLogHolder content: newSubject presenter.
 	^ subject historianSubjects collect: [:each | each presenter]
 ))
 class SourceControlPresenter onSubject: subject = BasePresenter onSubject: subject (|
-helpHolder
+"helpHolder
 status
 deferredContent
 inspectionHolder
 modifiedList
-updatedList
+updatedList"
+addHolder
+reposHolder
 |)
 ('as yet unclassified'
 createLocalHgRepoAt: relPath <String> = (
 
 	| path hg uiusername repository |
 
+	#BOGUS. "This logic belongs somewhere else!"
+
 	path:: ((FileDirectory on: SmalltalkImage current imagePath) / relPath) pathName.
 
 	hg:: ExternalLauncher for: 'hg'.
 	repository:: vcs hg Backend new LocalRepository onRepositoryId: path.
 
 	subject model add: repository.
-	refreshSCAfter: [].
+	self refresh.
 )
 definition = (
 
-	helpHolder:: list.
-	status:: holder: [(label: 'refreshing...') tinyFont].
-	deferredContent:: holder: [(label: '') tinyFont].
-	refreshSCAfter: [].
 	^column: {
-		helpHolder.
-		list: [presentLoadImageIfOld].
-		presentAddRepositories.
-		"heading: [label: 'Documentation'] details: [presentDocumentation]."
-		blank: 10.
-		deferredContent.
+		majorHeadingBlock: (row: {
+			label: 'MemoryHole Repositories' asText allBold.
+			filler.
+			addButtonWithAction: [addHolder content: presentAddRepositories].
+		}).
+		mediumBlank.
+		addHolder:: holder: nothing.
+		reposHolder:: holder: [presentRepositories].
 	}
 )
-noticeAbandonment = (
-
-	"There is probably a better way to determine when to shut down source control"
-	subject shutdown
-)
 openLocalHgRepoAt: path = (
 
-	refreshSCAfter: [
-
 	| repository |
 
 	repository:: vcs hg Backend new LocalRepository onRepositoryId:
 		((FileDirectory on: SmalltalkImage current imagePath) / path) pathName.
 
 	subject model add: repository.
-
-	].
+	self refresh.
 )
 openRemoteHgRepoAt: url <String> = (
 
 	repository:: vcs hg Backend new LocalRepository onRepositoryId: path.
 
 	subject model add: repository.
-	refreshSCAfter: [].
+	self refresh.
 )
 presentAddRepositories = (
 	^column: {
 				text: 'https://bitbucket.org/username/repository';
 				acceptResponse: [:editor | 
 					editor defaultAcceptResponse.
-					openRemoteHgRepoAt: editor text asString].
+					openRemoteHgRepoAt: editor text asString.
+					addHolder content: nothing].
 		}.
 		row: {
 			label: 'Open local Mercurial repository at '.
 				text: 'path/relativeTo/imageDirectory';
 				acceptResponse: [:editor | 
 					editor defaultAcceptResponse.
-					openLocalHgRepoAt: editor text asString].
+					openLocalHgRepoAt: editor text asString.
+					addHolder content: nothing].
 		}.
 		row: {
 			label: 'Create new local Mercurial repository at '.
 				text: 'path/relativeTo/imageDirectory';
 				acceptResponse: [:editor | 
 					editor defaultAcceptResponse.
-					createLocalHgRepoAt: editor text asString].
+					createLocalHgRepoAt: editor text asString.
+					addHolder content: nothing].
 		}.
 		"row: {
 			label: 'Open Git Repository at '.
 presentHelp = (
 	^(link: '[?]' action: [respondToHelp]) tinyFont
 )
-presentLoadImageIfOld = (
-	| ageInDays |
-	inspectionHolder:: holder: [nothing].
-	^true
-		ifTrue: [{row: {status. filler. inspectionHolder. smallBlank. presentHelp}}]
-	"	ifFalse:
-			[ageInDays:: NsBoot ageInDays.
-			ageInDays < 90 ifTrue:
-				[ | link |
-				link:: link: 'get latest nightly boot image' action: [respondToDownloadNewImage].
-				link tinyFont.
-				ageInDays < 1 ifTrue: [link color: Color gray].
-				ageInDays > 2 ifTrue: [link color: Color red].
-				^{row: {status. filler. link. smallBlank. inspectionHolder. smallBlank. presentHelp. smallBlank. advanced}}].
-			{
-				row: {status. filler. inspectionHolder. smallBlank. presentHelp. smallBlank. advanced}.
-				(column: {
-					blank: 50.
-					centered: (label: 'This image is more than ' asText, (ageInDays printString, ' days old.') asText allBold).
-					largeBlank.
-					centered: (button: 'Download New Image' action: [respondToDownloadNewImage]).
-					blank: 50
-					}
-				) color: (Color h:0 s: 0.6 v: 0.9).
-				mediumBlank
-			}]"
-)
 presentRepositories = (
-	| localRepositorySubjects |
-	localRepositorySubjects:: subject modifiedLocalRepositorySubjects collect:
-		[ :ea  | ea presenter].
-	^ list: localRepositorySubjects
-)
-refreshSCAfter: block = (
-
-	[
-		showWaitCursorWhile: [
-			shell desktop scheduleUIAction: [
-				status content: (label: 'performing action...') tinyFont.
-				deferredContent content: nothing.
-			].
-			block value.
-			shell desktop scheduleUIAction: [
-				deferredContent content: presentRepositories.
-				status content: (label: '') tinyFont
-			].
-		].
-	]
-	forkAt: 30 named: 'Refreshing: ', subject title
+	^list: (subject modifiedLocalRepositorySubjects collect: [:ea <LocalRepositorySubject> |		
+		row: {
+			smallBlank.
+			link: ea title action: [enterSubject: ea].
+			filler.
+			removeButtonWithAction: [confirm: 'Remove Repository' ifConfirmed: [subject removeRepository: ea model. self refresh]].
+			smallBlank.
+		}
+	])
 )
 respondToCloseHelp = (
 	helpHolder setPresenters: {}
 	diffsFromPrevious:: model diffsFromFirstParent collect: [:each | diffSubjectOn: each].
 	^ diffsFromPrevious reject: [:each | each isEquals]
 ))'as yet unclassified'
+= other = (
+	^class = other class and: [model = other model]
+)
 createPresenter = (
 
 	^ LocalRepositoryPresenter onSubject: self
 )
+hash = (
+	^model hash
+)
 imageHistorian = (
 
 	^ model imageHistorian
 repositoryType = (
 
 	^ model repositoryType
+)
+title = (
+	^'[',repositoryType,'] ',repositoryName
 ))'as yet unclassified'
 = other = (
 	^self class = other class and: [self model = other model]
 
 	^ model collect: [:each | LocalRepositorySubject onModel: each]
 )
+removeRepository: r = (
+	model remove: r.
+)
 shutdown = (
 
 	"If our model is simply some repositories we don't really own VCS and thus shouldn't be allowed to shut it down, should we?"