Skip to content

Commit

Permalink
Merge pull request #52 from hpi-swa-teaching/master
Browse files Browse the repository at this point in the history
Version 0.2
  • Loading branch information
LeonBein authored Jun 13, 2018
2 parents 0eff6c8 + 0012ad1 commit 3e0dd91
Show file tree
Hide file tree
Showing 115 changed files with 634 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ baseline: spec
for: #'common'
do: [
spec

package: 'Presenter-Core';
package: 'Presenter-Tests' with: [spec requires: #('Presenter-Core')];
yourself.
Expand All @@ -14,4 +13,5 @@ baseline: spec
group: 'tests' with: #('Presenter-Tests')];
yourself.
spec
preLoadDoIt: #preLoad
preLoadDoIt: #preLoad;
postLoadDoIt: #postLoad.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
baseline
postLoad

PSPresentationTool initialize.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
baseline
preLoad

(TextStyle named: 'BitstreamVeraSans') fontArray do: [:font |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"class" : {
},
"instance" : {
"baseline:" : "fn 4/17/2018 11:58",
"baseline:" : "LM 6/13/2018 13:41",
"postLoad" : "LM 6/13/2018 13:51",
"preLoad" : "WoC 5/28/2018 17:40" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
presentation mode
enablePresentationMode

self removeResizeHandles
self removeResizeHandles
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"defaultContextMenuContent" : "MK 6/1/2018 18:06",
"disablePresentationMode" : "MK 5/25/2018 16:12",
"dragCorner:event:fromHandle:" : "MK 5/25/2018 17:10",
"enablePresentationMode" : "MK 5/25/2018 15:19",
"enablePresentationMode" : "LM 6/8/2018 20:10",
"extent:" : "MK 5/25/2018 17:11",
"extentBottomLeft:" : "MK 5/25/2018 17:12",
"extentBottomRight:" : "MK 5/25/2018 17:12",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
initialize

super initialize.
self registerInWorldMenu
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instance creation
registerInWorldMenu

TheWorldMenu registerOpenCommand: {'PowerSqueak'. {self. #open}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
presentation loading
abandonMorph: aMorph

aMorph ifNotNil: [aMorph abandon].
^ nil
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
presentation saving
askForPresentationName

^ UIManager default request: 'Please enter a presentation name: ' initialAnswer: 'Presentation' centerAt: World center
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
notifications
buildErrorReportString: aDictionary

| errorString |
errorString := 'I could not load all slides completely.'.
aDictionary keysAndValuesDo: [:key :value |
errorString := errorString, Character cr, key, ' is missing ', value, ' morph(s).'].
^ errorString
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ buttonBarTopData
self selectSlideButtonData.
self textFieldButtonData.
self imageFieldButtonData.
self presentationModeButtonData }
self presentationModeButtonData.
self loadingButtonData.
self saveButtonData }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
presentation saving
createDirectory: aString in: aFileDirectory

aFileDirectory createDirectory: aString.
^ aFileDirectory / aString


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
defaultDirectory

^ (FileDirectory default / self defaultDirectoryName)
assureExistence;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
defaultDirectoryName

^ 'PSPresentations'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
deleteSlideButtonData

^ Dictionary withAll: {
#frame -> (0.4@0.0 corner: 0.55@1.0).
#frame -> (0.35@0.0 corner: 0.50@1.0).
#name -> #DeleteSlideButton.
#label -> 'Delete Slide'.
#action -> #deleteSlide}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
presentation saving
getValidPresentationName: aFileDirectory

| presentationName directory |
presentationName := self askForPresentationName.
presentationName = ''
ifTrue: [^ nil].
directory := (aFileDirectory / presentationName).
^ directory exists
ifTrue: [self validateUsageOf: presentationName inDirectory: aFileDirectory]
ifFalse: [directory assureExistence]

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
presentation loading
isValidPresentationDirectory: aDirectory

| slidesDirectory |
slidesDirectory := aDirectory / self slidesDirectoryName.
^ slidesDirectory exists and: [slidesDirectory directoryNames isEmpty not]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
presentation loading
loadMorphFromFile: aFileDirectory
"This was copied from Morph(class)>>#fromFileName:"
^ self loadMorphFromStream: (MultiByteBinaryOrTextStream with: ((FileStream readOnlyFileNamed: aFileDirectory fullName) binary contentsOfEntireFile)) binary reset
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
presentation loading
loadMorphFromStream: aStream

^ self loadMorphFromStream: aStream testIn: World.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
presentation loading
loadMorphFromStream: aStream testIn: aWorld

| morph |
[morph := aStream fileInObjectAndCode]
on: Error
do: [:error |
morph := self abandonMorph: morph].
(morph isNil not and: [self morph: morph survivesOneCycleIn: aWorld])
ifFalse: [morph := self abandonMorph: morph].
^ morph
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
presentation loading
loadPresentation

| presentations presentationName |
self
warn: self riskyOperationMessage
trueChoice: []
falseChoice: [^ self].
presentations := self defaultDirectory directoryNames.
presentationName := UIManager default
chooseFrom: presentations
values: presentations
title: 'Which presentation do you want me to load?'.
presentationName ifNotNil: [self loadPresentationFromDirectory: self defaultDirectory / presentationName]

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
presentation loading
loadPresentationFromDirectory: aDirectory

(self isValidPresentationDirectory: aDirectory)
ifTrue: [self loadPresentationUnchecked: aDirectory]
ifFalse: [UIManager default inform: 'I could not load the presentation.
It''s directory might be corrupted.']
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
presentation loading
loadPresentationUnchecked: aDirectory

| slidesDirectory errorReport |
errorReport := Dictionary new.
self slides removeAll.
slidesDirectory := aDirectory / self slidesDirectoryName.
slidesDirectory directoryNames do: [:each |
errorReport at: each put: (self loadSlideFromDirectory: slidesDirectory / each)].
self
selectSlide: 1;
showErrorReport: errorReport
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
presentation loading
loadSlideFromDirectory: aDirectory

| slide corruptedMorphs |
corruptedMorphs := 0.
slide := PSSlide new.
aDirectory fileNames do: [:each |
| morph |
morph := self loadMorphFromFile: aDirectory / each.
morph
ifNil: [corruptedMorphs := corruptedMorphs + 1]
ifNotNil: [slide addMorph: morph]].
self slides addLast: slide.
^ corruptedMorphs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
loadingButtonData

^ Dictionary withAll: {
#frame -> (0.6@0.0 corner: 0.7@1.0).
#name -> #loadingButton.
#label -> 'Load'.
#action -> #loadPresentation}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
presentation loading
morph: aMorph survivesOneCycleIn: aWorld
"Some morphs may be loaded successfully but throw errors every world cycle therefore crashing the image."
"World doOneCycle consumes all errors and opens the corresponding debuggers. Therefore we cannot do normal error checking but we can compare the debuggers."
| debuggersBefore newDebuggers |
debuggersBefore := Debugger allInstances.
aMorph openInWorld: aWorld.
World doOneCycle.
newDebuggers := Debugger allInstances reject: [:each |
debuggersBefore includes: each].
newDebuggers do: [:each | each abandon].
newDebuggers size > 0
ifTrue: [^ false].
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
overwriteQuestion

^ 'The name you chose is already used. Do you want to overwrite the Presentation?'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
riskyOperationMessage

^ 'This operation is risky as it might crash your image.', Character cr, 'Do you want me to proceed?'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
saveButtonData

^ Dictionary withAll: {
#frame -> (0.5@0.0 corner: 0.6@1.0).
#name -> #savingButton.
#label -> 'Save'.
#action -> #savingConfirmation}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
presentation saving
savePresentation

| directory |
directory := self defaultDirectory.

directory := self getValidPresentationName: directory.
directory ifNil: [^ self].
directory := self createDirectory: 'slides' in: directory.

self slides doWithIndex: [:each :index |
| directoryName |
directoryName := 'slide', index asString.
directory createDirectory: directoryName.
each saveInDirectory: directory / directoryName ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
presentation saving
savingConfirmation

self warn: self riskyOperationMessage trueChoice: [self savePresentation]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
notifications
showErrorReport: aDictionary

| corruptedSlides |
corruptedSlides := aDictionary select: [:each | each > 0].
corruptedSlides isEmpty
ifTrue: [UIManager inform: 'I successfully loaded the presentation.']
ifFalse: [UIManager inform: (self buildErrorReportString: corruptedSlides)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
slidesDirectoryName

^ 'slides'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
presentation saving
validateUsageOf: aString inDirectory: aFileDirectory

| directory |
directory := aFileDirectory / aString.
self warn: self overwriteQuestion
trueChoice: [directory recursiveDelete.
^ self createDirectory: aString in: aFileDirectory]
falseChoice: [^ self getValidPresentationName: aFileDirectory]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
notifications
warn: aString trueChoice: aBlock

self warn: aString trueChoice: aBlock falseChoice: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
notifications
warn: aString trueChoice: trueBlock falseChoice: falseBlock

(UIManager default confirm: aString)
ifTrue: trueBlock
ifFalse: falseBlock
Loading

0 comments on commit 3e0dd91

Please sign in to comment.