Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swa UI #343

Draft
wants to merge 20 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.filetree
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
world menu
registerInWorldMenu
"self registerInWorldMenu"
(self environment valueOf: #TheWorldMenu) ifNotNil: [:worldMenu |
worldMenu registerOpenCommand: (Array
with: 'Git Browser'
with: 'Squit'
with: (Array
with: self
with: #open))].
2 changes: 1 addition & 1 deletion src/Squit.package/SquitBrowser.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"initialize" : "jr 4/18/2018 21:28",
"initializeSelfUpdate" : "jr 4/18/2018 21:27",
"open" : "fn 4/11/2017 09:09",
"registerInWorldMenu" : "jr 4/15/2017 13:34",
"registerInWorldMenu" : "ek 10/26/2021 20:45",
"selfUpdate" : "jr 3/7/2020 00:09",
"selfUpdateBranch" : "jr 4/21/2018 22:22",
"selfUpdateBranch:" : "jr 4/18/2018 22:37",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I provide an UI to edit all relevant credential fields at once.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
requestCredentials

^ self new getUserResponse
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
as yet unclassified
accept

self
textPanesAccept;
closeDialog: self result.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
initialization
addTextPanesAndDescriptions

| otherMessageMorph |

column := AlignmentMorph newColumn
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
cellGap: 4;
color: Color transparent.
self paneMorph addMorph: column.

self message: 'GitHub username (authentication)'.

column addMorphBack: textPaneUsername.

otherMessageMorph := messageMorph copy.
otherMessageMorph contents: 'GitHub password/token (authentication)'.
column addMorphBack: otherMessageMorph.

column addMorphBack: textPanePassword.

otherMessageMorph := messageMorph copy.
otherMessageMorph contents: 'Name (used for commits, e.g. Maria Muster)'.
column addMorphBack: otherMessageMorph.

column addMorphBack: textPaneDisplayName.

otherMessageMorph := messageMorph copy.
otherMessageMorph contents: 'Email (used for commits)'.
column addMorphBack: otherMessageMorph.

column addMorphBack: textPaneEmail.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization
configurePaneMorph.

self paneMorph
hResizing: #shrinkWrap;
vResizing: #shrinkWrap.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialization
createPasswordTextPaneFor: aSymbol

^ (self createTextPaneFor: aSymbol) font: (StrikeFont passwordFontSize: 12)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
initialization
createTextPaneFor: aSymbol

| textPane |
textPane := PluggableTextMorph
on: self
text: aSymbol
accept: (aSymbol, #:) asSymbol
"readSelection: #selectionInterval
menu: #codePaneMenu:shifted:".
textPane
showScrollBarsOnlyWhenNeeded;
wantsFrameAdornments: false;
hasUnacceptedEdits: true;
askBeforeDiscardingEdits: false;
setProperty: #alwaysAccept toValue: true;
acceptOnCR: true;
setNameTo: aSymbol asString;
layoutFrame: (LayoutFrame fractions: (0@0 corner: 1@1));
hResizing: #spaceFill;
vResizing: #spaceFill;
minimumExtent: 0@2;
updateMinimumExtent;
scrollToTop.
^ textPane
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
initialization
createTextPanes

textPaneUsername := self createTextPaneFor: #username.
textPanePassword := self createPasswordTextPaneFor: #password.
textPaneDisplayName := self createTextPaneFor: #displayName.
textPaneEmail := self createTextPaneFor: #email.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
displayName: aString

displayName := aString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
displayName

^ displayName
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
email: aString

email := aString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
email

^ email
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
initialization
initialize

super initialize.

self title: 'GitHub credentials requested' translated.
self initializeTextPanes.

self createAcceptButton
action: [self accept].
self createCancelButton
action: [self closeDialog: nil].

self preferredPosition: ActiveHand cursorPoint.
self setDefaultParameters.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initialization
initializeTextPanes

self createTextPanes.
self addTextPanesAndDescriptions.
self configurePaneMorph.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
password: aString

password := aString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
password

^ password
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
as yet unclassified
result

^ Dictionary new
at: #username put: self username asString;
at: #password put: self password asString;
at: #displayName put: self displayName asString;
at: #email put: self email asString;
yourself

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
as yet unclassified
textPanesAccept

textPaneUsername accept.
textPanePassword accept.
textPaneDisplayName accept.
textPaneEmail accept.
^ 'meep'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
username: aString

username := aString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
username

^ username
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"class" : {
"requestCredentials" : "ek 9/21/2021 16:53" },
"instance" : {
"accept" : "ek 9/21/2021 18:23",
"addTextPanesAndDescriptions" : "mad 9/9/2022 14:06",
"configurePaneMorph" : "mad 9/9/2022 14:06",
"createPasswordTextPaneFor:" : "ek 9/21/2021 17:27",
"createTextPaneFor:" : "ek 9/21/2021 17:58",
"createTextPanes" : "ek 9/21/2021 17:28",
"displayName" : "ek 9/21/2021 17:31",
"displayName:" : "ek 9/21/2021 17:31",
"email" : "ek 9/21/2021 17:31",
"email:" : "ek 9/21/2021 17:31",
"initialize" : "ek 9/21/2021 18:22",
"initializeTextPanes" : "ek 9/21/2021 17:26",
"password" : "ek 9/21/2021 17:30",
"password:" : "ek 9/21/2021 17:30",
"result" : "ek 9/21/2021 18:26",
"textPanesAccept" : "ek 9/21/2021 18:14",
"username" : "ek 9/21/2021 17:29",
"username:" : "ek 9/21/2021 17:30" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"category" : "Squit-Lecture",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "ek 10/14/2021 13:27",
"instvars" : [
"username",
"password",
"displayName",
"email",
"textPaneUsername",
"textPanePassword",
"textPaneDisplayName",
"textPaneEmail",
"column" ],
"name" : "SquitCredentialsFillInMorph",
"pools" : [
],
"super" : "DialogWindow",
"type" : "normal" }
1 change: 1 addition & 0 deletions src/Squit.package/SwaSquitBrowser.class/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I provide a UI to browse and manipulate exactly one Git repository and its history. I am intended to be a simpler version of the SquitBrowser that can be used in the SWA lecture.
4 changes: 4 additions & 0 deletions src/Squit.package/SwaSquitBrowser.class/class/initialize.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class initialization
initialize

self registerInWorldMenu.
3 changes: 3 additions & 0 deletions src/Squit.package/SwaSquitBrowser.class/class/open.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
open
ToolBuilder open: self new
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
world menu
registerInWorldMenu
"self registerInWorldMenu"
(self environment valueOf: #TheWorldMenu) ifNotNil: [:worldMenu |
worldMenu registerOpenCommand: (Array
with: 'SWA Git Browser'
with: (Array
with: self
with: #open))].
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
world menu
unregisterFromWorldMenu
"self unregisterFromWorldMenu"
(self environment valueOf: #TheWorldMenu) ifNotNil:
[:worldMenu | worldMenu unregisterOpenCommandWithReceiver: self].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions
actionAddOrRemoveTrackedPackages

^ self withUnitOfWork: [SquitPackageChooser chooseFor: self selectedRepository]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
actions
actionCloneAndMerge

| operation |

operation := SwaSquitInteractiveClone new.
[operation clone] on: SquitBadRemote do: [:e | e retry].
self changed: #repositoryList.
self selectRepository: operation repository.
self actionMergeInteractive: false.
Project current addDeferredUIMessage: [self refresh].
self browseRepository.
self refresh.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
actions
actionCommitAndPush

self actionCommitAndThenDo: [self actionPush].
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
actions
actionCommitAndThenDo: aBlock

| workingCopy |
self hasSelectedRepository ifFalse: [^ self].

workingCopy := self selectedRepository.
self withUnitOfWork: [
[SquotGUI waitFor:
((workingCopy newInteractiveSaveOperation
title: 'Select changes and message for the new version';
applyToWorkingCopy)
then: [:result | self refresh. aBlock value]
ifRejected: [:reason | nil])]
on: BrokenPromise do: [:e | e ifNotError: []]].
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
actions
actionCommitDiffWithParent

self withUnitOfWork:
[(SquotDiffExplorer
from: (self selectedCommit parents at: 1 ifAbsent: [SquotSnapshot empty])
to: self selectedCommit)
workingCopy: self selectedRepository;
openLabel: 'Comparing versions'].
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
actions
actionCommitSelectionCheckout

self withUnitOfWork:
[self selectedRepository loadVersionInteractively: self selectedCommit ifCanceled: [^ self]].
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
actions
actionCredentialsEdit

| credentials repository gitRepository remoteUrl displayName email |

repository := self selectedRepository repository.
gitRepository := repository git.
remoteUrl := (repository remoteNames collect:
[:each | (gitRepository remoteUrl: each)]
thenSelect: [:each | each beginsWith: 'http']) first.
credentials := SquitCredentialsFillInMorph requestCredentials.
credentials ifNil: [^ nil].

repository
addCredentialsFor: remoteUrl
user: (credentials at: #username)
password: (credentials at: #password).

displayName := credentials at: #displayName.
email := credentials at: #email.
displayName ifNotNil: [GitStamp defaultName: displayName].
email ifNotNil: [GitStamp defaultEmail: email].
gitRepository configAt: 'user.name' put: displayName.
gitRepository configAt: 'user.email' put: email.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
actions
actionMergeInteractive: aBoolean

self withUnitOfWork: [
self selectedRepository
loadVersion: self selectedCommit
interactive: aBoolean].
Loading