'From Squeak3.2alpha of 3 October 2001 [latest update: #4625] on 18 December 2001 at 11:48:02 am'! "Change Set: insertCardsEtc-sw Date: 18 December 2001 Author: Scott Wallace Adds an item to the stack menu for loading cards from a file. Makes the facilities for adding cards from the clipboard and from a file share the same code."! !StackMorph methodsFor: 'menu' stamp: 'sw 12/18/2001 11:32'! invokeBookMenu "Invoke the book's control panel menu." | aMenu | aMenu _ MenuMorph new defaultTarget: self. aMenu addTitle: 'Stack'. aMenu addStayUpItem. aMenu addList: #( ('find...' textSearch) ('find via this template' findViaTemplate) ('show designations' showDesignationsOfObjects) ('explain designations' explainDesignations) - ('previous card' goToPreviousCardInStack) ('next card' goToNextCardInStack) ('first card' goToFirstCardOfStack) ('last card' goToLastCardOfStack) ('go to card...' goToCard) - ('add a card of this background' insertCard) ('add a card of background...' insertCardOfBackground) ('make a new background...' makeNewBackground) - ('insert cards from clipboard data' addCardsFromClipboardData 'Create new cards from a formatted string on the clipboard') ('insert cards from a file...' addCardsFromAFile 'Create new cards from data in a file') - ('instance variable order...' changeInstVarOrder 'Caution -- DANGER. Change the order of the variables on the cards') ('be defaults for new cards' beDefaultsForNewCards 'Make these current field values be the defaults for their respective fields on new cards') ('sort cards by...' sortCards 'Sort all the cards of the current background using some field as the sort key') - ('delete this card' deleteCard) ('delete all cards *except* this one' deleteAllCardsExceptThisOne) - ('move card to front of stack' makeCurrentCardFirstInStack) ('move card to back of stack' makeCurrentCardLastInStack) ('move card one position earlier' moveCardOnePositionEarlier) ('move card one position later' moveCardOnePositionLater) - ('scripts for this background' browseCardClass) - ('debug...' offerStackDebugMenu) ('bookish items...' offerBookishMenu)). aMenu addUpdating: #showingPageControlsString action: #toggleShowingOfPageControls. aMenu addUpdating: #showingFullScreenString action: #toggleFullScreen. aMenu popUpEvent: self world activeHand lastEvent in: self world ! ! !StackMorph methodsFor: 'background' stamp: 'sw 12/18/2001 11:44'! addCardsFromAFile "Using the current background, create new cards by reading in data from a fileThe data are in each record are expected to be tab-delimited, and to occur in the same order as the instance variables of the current-background's cards " | aFileStream | (aFileStream _ FileList2 modalFileSelector) ifNil: [^ self beep]. self addCardsFromString: aFileStream contentsOfEntireFile. aFileStream close! ! !StackMorph methodsFor: 'background' stamp: 'sw 12/18/2001 11:35'! addCardsFromClipboardData "Using the current background, paste data from the (textual) clipboard to create new records. The data are in each record are expected to be tab-delimited, and to occur in the same order as the instance variables of the current-background's cards " | clip | (clip _ Clipboard clipboardText) isEmptyOrNil ifTrue: [^ self beep]. self addCardsFromString: clip! ! !StackMorph methodsFor: 'background' stamp: 'sw 12/18/2001 11:20'! addCardsFromClipboardDataForInstanceVariables: slotNames "Using the current background, paste data from the (textual) clipboard to create new records. No senders, but can be usefully called manually for selectively bringing in data in oddball format." | clip | (clip _ Clipboard clipboardText) isEmptyOrNil ifTrue: [^ self beep]. self addCardsFromString: clip slotNames: slotNames! ! !StackMorph methodsFor: 'background' stamp: 'sw 12/18/2001 11:13'! addCardsFromFile: fileStream "Using the current background, take tab delimited data from the file to create new records." | aString | (aString _ fileStream contentsOfEntireFile) isEmptyOrNil ifTrue: [^ self beep]. self addCardsFromString: aString! ! !StackMorph methodsFor: 'background' stamp: 'sw 12/18/2001 11:35'! addCardsFromString: aString "Using the current background, add cards from a string, which is expected be tab- and return-delimited. The data are in each record are expected to be tab-delimited, and to occur in the same order as the instance variables of the current-background's cards " self addCardsFromString: aString slotNames: self currentCard slotNames ! ! !StackMorph methodsFor: 'background' stamp: 'sw 12/18/2001 11:19'! addCardsFromString: aString slotNames: slotNames "Using the current background, add cards from a string, which is expected be tab- and return-delimited" | count | count _ 0. aString asString linesDo: [:aLine | aLine size > 0 ifTrue: [count _ count + 1. self insertCardOfBackground: self currentPage withDataFrom: aLine forInstanceVariables: slotNames]]. self inform: count asString, ' card(s) added' ! !