Skip to content

Commit

Permalink
Merge 8cbfd80 into 8ccdc0b
Browse files Browse the repository at this point in the history
  • Loading branch information
konradh committed Aug 7, 2020
2 parents 8ccdc0b + 8cbfd80 commit 4ab52ae
Show file tree
Hide file tree
Showing 34 changed files with 152 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
comparing
= aRichTextDocument

^ (self textStructures = aRichTextDocument textStructures)
and: [self text = aRichTextDocument text]
and: [self name = aRichTextDocument name]
and: [self timeLastSaved = aRichTextDocument timeLastSaved]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
initialize-release
openInEditor

^ self class editorClass openWith: self
^ self class editorClass open: self
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
accessing
timeLastSaved

self timestampLastSaved ifNil: [^ nil].
^ self timestampLastSaved second
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"fromText:withStructures:" : "ls 6/26/2019 17:31",
"initialTextStructures" : "JEH 7/4/2020 11:19" },
"instance" : {
"=" : "frc 8/6/2020 20:01",
"addAttribute:from:to:" : "kh 6/19/2020 12:35",
"asString" : "frc 7/16/2020 13:46",
"charcount" : "frc 5/25/2020 16:02",
Expand All @@ -21,7 +22,7 @@
"name" : "ls 6/26/2019 17:28",
"name:" : "MB 7/3/2019 19:29",
"openEditor" : "lh 7/24/2019 21:27",
"openInEditor" : "ls 7/24/2019 20:14",
"openInEditor" : "kh 7/27/2020 12:26",
"removeStructure:" : "kh 6/21/2020 10:03",
"removeTextAttribute:from:to:" : "MB 7/24/2019 20:40",
"setNewTemplate:" : "frc 7/15/2020 15:43",
Expand All @@ -38,7 +39,7 @@
"textStructures" : "ls 6/26/2019 17:28",
"textStructures:" : "MB 7/3/2019 19:29",
"textStructuresDo:" : "ls 7/24/2019 21:29",
"timeLastSaved" : "tok 7/20/2020 14:10",
"timeLastSaved" : "frc 8/6/2020 20:07",
"timestampLastSaved" : "tok 7/20/2020 14:10",
"timestampLastSaved:" : "tok 7/20/2020 14:10",
"wordcount" : "frc 7/16/2020 13:47" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
instance creation
open: aRichTextDocument

| instance |
instance := self new.
ToolBuilder default open: instance.
instance setDocument: aRichTextDocument.

^ instance
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import-export
importFileFrom: filePath
importFileFrom: aFilePath

| filestream text document |
filestream := StandardFileStream readOnlyFileNamed: filePath.
text := Text fromString: filestream contents.
| fileStream text document |
fileStream := StandardFileStream readOnlyFileNamed: aFilePath.
text := Text fromString: fileStream contents.
document := self documentClass fromText: text withStructures: (self documentClass initialTextStructures).
self setDocument: document.
filestream close
fileStream close

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import-export
importObjectFileFrom: aFilePath

| stream |
stream := ReferenceStream fileNamed: aFilePath.
self setDocument: stream next.
stream close
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import-export
importObjectFileWithDialog

| filePath |
filePath := self selectFilePath.
filePath ifNotNil: [self importObjectFileFrom: filePath]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ openDocumentMenu
{'Save as' . #saveDocumentInSaverWithNamePrompt}.
{'Load' . #loadDocumentFromSaver}.
{'Import from File' . #importFileWithDialog}.
{'Import from Object File' . #importObjectFileWithDialog}.
{'Export as ...' . #exportFileWithDialog}.
{'Inspect Document' . #inspectDocument}.
{'Document info' . #showInfo}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
initialize-release
openStructureEditor

RichTextStructureEditor openWith: self bufferDocument
RichTextStructureEditor open: self bufferDocument
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
text structure
openTemplateChoser

RichTextStructureEditor openWith: self bufferDocument
RichTextStructureEditor open: self bufferDocument
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
change
update: aParameter

aParameter = #text ifTrue: [^ self textChanged].
aParameter = #textStructures ifTrue: [^ self structuresChanged].
(aParameter literalEqual: #text) ifTrue: [^ self textChanged].
(aParameter literalEqual: #textStructures) ifTrue: [^ self structuresChanged].

self
bufferDocument: self targetDocument copy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"initialLabel" : "ls 6/21/2019 17:54",
"initialize" : "ls 6/21/2019 17:54",
"open" : "ls 7/24/2019 20:00",
"open:" : "kh 7/27/2020 12:26",
"openWith:" : "AG 7/25/2019 13:12",
"saverClass" : "ls 5/8/2019 20:28",
"yellowButtonMenuItems" : "tok 5/31/2020 20:54" },
Expand Down Expand Up @@ -50,8 +51,10 @@
"hasStructure:between:to:" : "6/1/2020 14:03:21",
"hasUnacceptedEdits" : "ls 5/9/2019 10:34",
"help" : "kh 5/25/2020 16:35",
"importFileFrom:" : "tok 7/3/2020 18:50",
"importFileFrom:" : "frc 8/6/2020 20:08",
"importFileWithDialog" : "tok 7/3/2020 18:50",
"importObjectFileFrom:" : "kh 8/3/2020 14:40",
"importObjectFileWithDialog" : "kh 8/3/2020 14:40",
"infoText" : "kh 6/20/2020 21:11",
"initialize" : "ls 7/24/2019 15:10",
"initializeDocuments" : "lh 7/24/2019 22:37",
Expand All @@ -64,12 +67,12 @@
"loadDocumentFromSaver" : "tok 7/8/2020 16:09",
"noUnacceptedEdits" : "ls 7/24/2019 21:08",
"okToChange" : "ls 6/12/2019 22:15",
"openDocumentMenu" : "tok 7/8/2020 16:09",
"openDocumentMenu" : "kh 8/3/2020 14:34",
"openEditMenu" : "frc 7/16/2020 12:35",
"openMenuWith:" : "frc 6/16/2020 19:51",
"openNewEditor" : "JEH 5/31/2020 14:14",
"openStructureEditor" : "ls 7/24/2019 16:53",
"openTemplateChoser" : "JEH 7/6/2020 15:39",
"openStructureEditor" : "kh 7/27/2020 12:26",
"openTemplateChoser" : "kh 7/27/2020 12:26",
"positionInTextAtIndex:" : "JEH 6/15/2020 15:09",
"precedingStructures" : "OS 5/31/2020 23:22",
"precedingStructures:" : "OS 5/31/2020 23:22",
Expand Down Expand Up @@ -119,6 +122,6 @@
"unacceptedEdits" : "ls 7/24/2019 21:06",
"unbufferStructures" : "OS 5/31/2020 13:09",
"undo" : "AG 5/29/2019 18:37",
"update:" : "OS 7/6/2020 13:51",
"update:" : "kh 8/6/2020 14:20",
"updateFooter" : "frc 5/25/2020 15:40",
"wantsAutocompletion" : "kh 5/5/2020 22:18" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I am a RichTextObjectExportStrategy and I export a document to a file by serializing it using a ReferenceStream.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export
export: aRichTextDocument to: aFilePath

(ReferenceStream fileNamed: aFilePath)
nextPut: aRichTextDocument;
close
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export
fileEnding

^ '.obj'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export
label

^ #Object
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export
template

self shouldBeImplemented
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"class" : {
"export:to:" : "kh 7/27/2020 12:38",
"fileEnding" : "kh 7/27/2020 12:15",
"label" : "kh 7/27/2020 12:15",
"template" : "kh 7/27/2020 12:15" },
"instance" : {
} }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "RichTextEditing-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "kh 8/7/2020 09:08",
"instvars" : [
],
"name" : "RichTextObjectExportStrategy",
"pools" : [
],
"super" : "RichTextExportStrategy",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
instance creation
open: aRichTextDocument

| instance |
instance := self basicNew document: aRichTextDocument.
instance initialize.
aRichTextDocument textStructuresDo: [:each | each addDependent: instance].

^ ToolBuilder default open: instance
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"class" : {
"allStructureIdentifiers" : "kh 6/21/2020 16:22",
"open:" : "kh 7/27/2020 12:29",
"openWith:" : "AG 7/25/2019 13:15" },
"instance" : {
"acceptNewTemplate" : "JEH 7/6/2020 15:56",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resources
exampleDocument

| document |
document := RichTextDocument new.
document text: self exampleExportContent asText.
document addAttribute: document textStructures first
from: 1
to: self exampleExportContent size.

^ document
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
utilities
exportVariantExists: aRichTextExportStrategyClass

^ (self answer: aRichTextExportStrategyClass
inDialog: [self editorModel selectExportStrategy]) notNil
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ resources
setUp

super setUp.
self setupFile
self setupPlainTextFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources
setupPlainTextFile

self createTestFileWithContent: self exampleContent at: self exampleImportFilePath.
self fileDirectory: (FileDirectory forFileName: self exampleExportFilePath)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
acceptance-tests
testUS143ExportAsObjectExistsInDialog

self assert: (self exportVariantExists: RichTextObjectExportStrategy)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
acceptance-tests
testUS143ExportImportObjectEqual

self editorModel setDocument: self exampleDocument.
self chooseExportStrategy: RichTextObjectExportStrategy.
self answer: self exampleExportFilePath inDialog: [self editorModel importObjectFileWithDialog].
self assert: self exampleDocument equals: self document
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
acceptance-tests
testUS84importFileFromFilesystem
testUS84ImportFileFromFilesystem

self answer: self exampleImportFilePath inDialog: [self editorModel importFileWithDialog].
self assert: (self exampleContent) equals: (self editorModel bufferDocument text string)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
acceptance-tests
testUS87ExportAsPlainTextExistsInDialog

self assert: (self exportOptionExists: RichTextPlainTextExportStrategy)
self assert: (self exportVariantExists: RichTextPlainTextExportStrategy)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
acceptance-tests
testUS88ExportAsMarkdownExistsInDialog

self assert: (self exportOptionExists: RichTextMarkdownExportStrategy)
self assert: (self exportVariantExists: RichTextMarkdownExportStrategy)
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"assert:equals:withExport:" : "frc 8/4/2020 14:39",
"chooseExportStrategy:" : "tok 7/8/2020 20:45",
"createTestFileWithContent:at:" : "frc 8/4/2020 14:44",
"exampleContent" : "frc 7/29/2020 09:49",
"exampleContent" : "tok 7/9/2020 21:47",
"exampleDocument" : "kh 8/6/2020 10:40",
"exampleExportContent" : "tok 7/9/2020 22:41",
"exampleExportFilePath" : "tok 7/8/2020 20:43",
"exampleImportFilePath" : "tok 7/9/2020 21:16",
"exportOptionExists:" : "frc 8/1/2020 12:44",
"exportOptionExists:" : " 8/6/2020 19:49:02",
"exportVariantExists:" : "kh 8/6/2020 09:50",
"exportedFileContent" : "tok 7/9/2020 22:41",
"exportedFileExists" : "tok 7/9/2020 21:44",
"file" : "frc 6/8/2020 15:00",
Expand All @@ -25,16 +27,19 @@
"htmlParagraphExampleString" : "frc 7/29/2020 09:07",
"paragraphingDocument" : "frc 7/29/2020 09:12",
"plainTextExportLabel" : "tok 7/8/2020 16:44",
"setUp" : "frc 6/12/2020 16:55",
"setUp" : "kh 8/6/2020 10:24",
"setupFile" : "tok 7/9/2020 21:10",
"setupPlainTextFile" : "kh 8/6/2020 10:24",
"tearDown" : "tok 7/8/2020 20:48",
"tearDownFiles" : "tok 7/9/2020 21:44",
"testHTMLExportHandlesLineFeed" : "frc 8/1/2020 13:36",
"testHTMLExportHandlesList" : "frc 8/1/2020 13:36",
"testHTMLExportHandlesParagraph" : "frc 7/29/2020 09:59",
"testUS84importFileFromFilesystem" : "tok 7/9/2020 21:57",
"testUS143ExportAsObjectExistsInDialog" : "kh 8/6/2020 09:51",
"testUS143ExportImportObjectEqual" : "kh 8/6/2020 14:16",
"testUS84ImportFileFromFilesystem" : "kh 8/6/2020 10:48",
"testUS87ExportAsPlainTextExistsInDialog" : "frc 7/30/2020 08:38",
"testUS87ExportDocumentAsPlainText" : "tok 7/9/2020 22:41",
"testUS88ExportAsHTML" : "frc 7/29/2020 10:00",
"testUS88ExportAsHTML" : "frc 7/26/2020 21:15",
"testUS88ExportAsMarkdown" : "frc 8/1/2020 12:44",
"testUS88ExportAsMarkdownExistsInDialog" : "frc 7/30/2020 08:37" } }
"testUS88ExportAsMarkdownExistsInDialog" : "kh 8/6/2020 09:49" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ setUp
super setUp.
self
richTextEditorMorph: self editorView;
wantsToTest: (RichTextStructureEditor openWith: self editorModel bufferDocument);
wantsToTest: (RichTextStructureEditor open: self editorModel bufferDocument);
structureEditor: self structureEditorView model
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"instance" : {
"richTextEditorMorph" : "ls 6/6/2019 00:24",
"richTextEditorMorph:" : "MB 7/25/2019 12:04",
"setUp" : "JEH 5/31/2020 12:35",
"setUp" : "kh 7/27/2020 12:26",
"structureEditor" : "ls 6/6/2019 00:23",
"structureEditor:" : "ls 6/6/2019 00:24",
"structureEditorView" : "ls 6/6/2019 00:24",
Expand Down

0 comments on commit 4ab52ae

Please sign in to comment.