Skip to content

Commit

Permalink
add app menu with self-updating, feedback reporting, and modern about…
Browse files Browse the repository at this point in the history
… dialog
  • Loading branch information
LinqLover committed Dec 19, 2024
1 parent d85ac62 commit ef9e79d
Show file tree
Hide file tree
Showing 35 changed files with 219 additions and 27 deletions.
1 change: 1 addition & 0 deletions packages/BaselineOfSwaLint.package/.squot-contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ '754834ba8adc4221ac3980e7f59502f9' ],
#objectsReplacedByNames : true,
#serializer : #SquotCypressCodeSerializer
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
projectClass

^ (self environment classNamed: #MetacelloCypressBaselineProject) ifNil: [super projectClass]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
},
"instance" : {
"baseline:" : "fn 5/18/2018 12:54",
"postLoad" : "BD 6/16/2018 18:09" } }
"postLoad" : "BD 6/16/2018 18:09",
"projectClass" : "ct 5/26/2021 15:29" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
building
addModelItemsToWindowMenu: menu

menu addLine.
SwaLint appMenu: menu.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"saveTestsSelected:" : "BD 6/29/2018 14:37",
"windowColorSpecification" : "NA 6/30/2015 13:23" },
"instance" : {
"addModelItemsToWindowMenu:" : "ct 12/19/2024 23:21",
"autoLint" : "BD 7/6/2018 10:57",
"browsable" : "NA 7/1/2015 17:05",
"buildButtonsWith:" : "fm 6/29/2018 03:17",
Expand Down
11 changes: 11 additions & 0 deletions packages/SwaLint-Core.package/SwaLint.class/class/appMenu..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
app - menu
appMenu: menu

menu
"add: 'about' target: self action: #showAbout;"
add: 'options' target: SLPreferenceBrowser action: #open;
add: 'self-update...' target: self action: #doSelfUpdate;
balloonTextForLastItem: ('download and install the latest updates for {1}' format: {self appName});
add: 'send feedback...' target: self action: #sendFeedback.

^ menu
4 changes: 4 additions & 0 deletions packages/SwaLint-Core.package/SwaLint.class/class/appName.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app - accessing
appName

^ self swaLint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app - self-updating
basicSelfUpdateBranch: aString

SelfUpdateBranch := aString.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app - feedback
defaultFeedbackText

^ '<br><br><i>Reported from {1} (VM: {2}), for version of {3} last updated at {4}.</i>' asTextFromHtml format:
{SystemVersion current.
([Smalltalk vm openSmalltalkVMBuildNumber] ifError: [nil]) ifNil: [Smalltalk platformSourceVersion].
self appName.
self latestTimeStamp}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
app - self-updating
defaultSelfUpdateBranch

(self environment classNamed: #MCRepositoryGroup) ifNotNil: [:mcRepositoryGroupClass |
| repoPrefix |
repoPrefix := 'github://{1}/{2}' format: {self githubRepositoryParams first. self githubRepositoryParams second}.
mcRepositoryGroupClass default repositories
detect: [:repo | repo description beginsWith: repoPrefix]
ifFound: [:repo | ^ repo projectVersion]].

^ 'main'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app - self-updating
doSelfUpdate

(Project uiManager confirm: ('Are you sure you would like to install the latest updates for {1}?' withCRs format: {self appName})) ifFalse: [^ false].

self selfUpdate.
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app - feedback
githubNewIssueUrl

^ self githubNewIssueUrlWithBody: '<!-- Your feedback goes here -->\' withCRs, (String streamContents: [:stream |
(HtmlReadWriter on: stream)
breakLines: false;
nextPutText: self defaultFeedbackText])
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app - feedback
githubNewIssueUrlWithBody: htmlString

^ 'https://github.com/{1}/{2}/issues/new?{3}' format: {
self githubRepositoryParams first.
self githubRepositoryParams second.
WebUtils encodeUrlEncodedForm: {
'body' -> htmlString}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app - accessing
githubRepositoryParams
"{owner. name. directory}"

^ {'hpi-swa-teaching'. 'SwaLint'. 'packages'}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app - accessing
githubUrl

^ 'https://github.com/{1}/{2}' format: {
self githubRepositoryParams first.
self githubRepositoryParams second}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
app - accessing
latestTimeStamp

| packages |
packages := PackageInfo allPackages select: [:ea | '*SwaLint*' match: ea name].
^ CurrentReadOnlySourceFiles cacheDuring:
[((packages gather: #methods) collect:
[:method | [TimeStamp fromMethodTimeStamp: method timeStamp] ifError: [TimeStamp new]])
max]
12 changes: 12 additions & 0 deletions packages/SwaLint-Core.package/SwaLint.class/class/openUrl..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
app - feedback
openUrl: urlString

self flag: #moveUpstream.
"Something similar but less convenient is also in TextURL >> #actOnClickFor:."
WebBrowser defaultOrNil ifNotNil: [:browser |
(Project uiManager
confirm: ('Do you want to open this URL in a web browser?\\{1}' withCRs format: {urlString})
title: 'Open Web Page' translated) ifTrue: [browser openOnUrl: urlString].
^ self].

(urlString tdbAsTextWithAttribute: (TextURL new url: urlString)) editWithLabel: 'Requested URL'.
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
accessing
app - accessing
projectDescription
"Answer... read below..."

^ '
', self swaLint, ' (v', self versionString, ') written by
Christoph Neijenhuis,
Johannes Dyck,
Tobias Pape,
Nico Rehwaldt and
Arian Treffer,
Jan-Tobias Matysik,
Siegfried Horschig,
Nico Aechtner,
Toni Stachewicz,
Niklas Hoffmann and
Björn Daase.
See http://swalint.netshed.de for more information.'
^ ('{1} (v{2}) written by
Christoph Neijenhuis,
Johannes Dyck,
Tobias Pape,
Nico Rehwaldt,
Arian Treffer,
Jan-Tobias Matysik,
Siegfried Horschig,
Nico Aechtner,
Toni Stachewicz,
Niklas Hoffmann,
Björn Daase, and
Christoph Thiede.
See <a href="{3}">{3}</a> for more information.'
format:
{self swaLint.
self versionString.
self githubUrl})
asTextFromHtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
app - accessing
projectLogo
"the SwaLint logo"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
app - accessing
projectLogoContents
"This is a base64 png"

Expand Down
15 changes: 15 additions & 0 deletions packages/SwaLint-Core.package/SwaLint.class/class/selfUpdate.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
app - self-updating
selfUpdate
"SwaLint selfUpdate"

| squeakVersion |
squeakVersion := SystemVersion current version.
((Project uiManager
confirm: ('It is recommended to install the latest updates for {1} first.' format: {squeakVersion})
title: ('Updating {1}' format: {self appName})
trueChoice: ('Yes, install latest {1} updates now' format: {'Squeak'})
falseChoice: ('Skip latest {1} updates (not recommended)' format: {'Squeak'}))
ifNil: [^ self])
ifTrue: [MCMcmUpdater default doUpdate: true].

^ self selfUpdateFromMetacello
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app - self-updating
selfUpdateBranch: aString

self basicSelfUpdateBranch: aString.

(Project uiManager confirm: 'Would you like to install updates now?' title: ('{1} self-update' format: {self appName}))
ifTrue: [self selfUpdate].
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
app - self-updating
selfUpdateBranch
<slpreference: 'SwaLint self-update branch'
type: #String
categories: #(SwaLint)
defaultValue: ''
helpText: 'The branch used for installing updates for SwaLint from the GitHub repository.'
projectLocal: false
changeInformee: #SwaLint
changeSelector: #refresh>

^ SelfUpdateBranch ifNil: [self defaultSelfUpdateBranch]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app - self-updating
selfUpdateFromMetacello

Metacello new
baseline: self appName;
repository: self selfUpdateGitHubPath;
get;
load.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app - self-updating
selfUpdateGitHubPath

^ ('github://{1}/{2}:\{1\}/{3}' format: {
self githubRepositoryParams first.
self githubRepositoryParams second.
self githubRepositoryParams third}) format: {self selfUpdateBranch}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app - feedback
sendFeedback

^ self sendFeedbackGitHub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app - feedback
sendFeedbackGitHub

self openUrl: self githubNewIssueUrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app - accessing
showAbout

| text |
text := (Text string: Character startOfHeader asString attribute: self projectLogo asTextAnchor)
, String cr , self projectDescription.
^ text editWithLabel: ('About {1}' format: {self swaLint})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
app - accessing
swaLint

^ 'SwaLint Code Critics'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
app - accessing
versionString

^ '4.2.0'
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"UseOBRefactoryIfAvailable:" : "MT 7/23/2014 21:40",
"WorldMenuEntry" : "MT 7/23/2014 21:41",
"WorldMenuEntry:" : "MT 7/23/2014 21:41",
"appMenu:" : "ct 12/19/2024 23:26",
"appName" : "ct 12/19/2024 23:08",
"basicSelfUpdateBranch:" : "ct 8/27/2023 20:17",
"class:ignoreRule:" : "LG 7/24/2018 20:48",
"class:ignoresRule:" : "LG 7/24/2018 20:47",
"class:unignoreRule:" : "LG 7/24/2018 20:34",
Expand All @@ -24,19 +27,36 @@
"debugMode" : "NH 7/15/2015 22:10",
"debugMode:" : "NH 7/15/2015 22:11",
"debugOut:" : "NH 7/15/2015 22:11",
"defaultFeedbackText" : "ct 8/27/2023 22:35",
"defaultSelfUpdateBranch" : "ct 8/27/2023 20:17",
"doSelfUpdate" : "ct 8/27/2023 23:11",
"githubNewIssueUrl" : "ct 8/27/2023 20:16",
"githubNewIssueUrlWithBody:" : "ct 8/27/2023 20:16",
"githubRepositoryParams" : "ct 12/19/2024 23:05",
"githubUrl" : "ct 12/19/2024 23:17",
"hiddenCategory" : "NH 7/15/2015 22:40",
"ifColorizeResult:" : "AT 5/9/2008 21:20",
"initializePreferences" : "NH 7/15/2015 21:46",
"install" : "NA 7/30/2015 16:31",
"latestTimeStamp" : "ct 12/19/2024 23:16",
"menuCommandOn:" : "BD 7/13/2018 11:37",
"open" : "NA 7/28/2015 13:19",
"projectDescription" : "BD 6/22/2018 13:01",
"openUrl:" : "ct 8/27/2023 20:17",
"projectDescription" : "ct 12/19/2024 23:18",
"projectLogo" : "AT 5/8/2008 10:35",
"projectLogoContents" : "NR 5/28/2008 14:29",
"refresh" : "BD 7/9/2018 18:16",
"refreshAllEnvironments" : "BD 7/13/2018 11:56",
"registerInWorldMenu" : "topa 4/21/2010 16:54",
"registerPlugIn:" : "LS 6/15/2018 16:07",
"selfUpdate" : "ct 12/19/2024 23:08",
"selfUpdateBranch" : "ct 12/19/2024 23:29",
"selfUpdateBranch:" : "ct 8/27/2023 20:18",
"selfUpdateFromMetacello" : "ct 8/27/2023 20:18",
"selfUpdateGitHubPath" : "ct 8/27/2023 20:18",
"sendFeedback" : "ct 8/27/2023 20:17",
"sendFeedbackGitHub" : "ct 11/12/2023 18:55",
"showAbout" : "ct 12/19/2024 23:19",
"swaLint" : "topa 4/21/2010 16:53",
"try:catch:" : "topa 4/23/2010 15:39",
"unload" : "BD 7/13/2018 11:48",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"DebugMode",
"MarkLongRuntimeTests",
"OrderByTests",
"SelfUpdateBranch",
"UseOBRefactoryIfAvailable",
"WorldMenuEntry" ],
"commentStamp" : "LG 7/24/2018 20:38",
Expand Down
1 change: 1 addition & 0 deletions packages/SwaLint-Preferences.package/.squot-contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ '3838eeacfc88474badc38b5e34dd6e39' ],
#objectsReplacedByNames : true,
#serializer : #SquotCypressCodeSerializer
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
initialization
aboutSelected

^ (PopUpMenu labels: ' OK ' translated)
startUpWithCaption: (SwaLint projectDescription withNoLineLongerThan: 35)
icon: (Smalltalk at: #SwaLint) projectLogo
^ SwaLint showAbout
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"instanceRemoved" : "NR 5/10/2008 10:29",
"open" : "NR 5/10/2008 10:23" },
"instance" : {
"aboutSelected" : "topa 4/15/2014 17:58",
"aboutSelected" : "ct 12/19/2024 23:19",
"defaultSelected" : "NR 5/7/2008 12:19",
"initialize" : "NR 1/17/2008 13:19",
"initializeWithModel:" : "NR 12/18/2007 14:40",
Expand Down

0 comments on commit ef9e79d

Please sign in to comment.