# HG changeset patch # User Claus Gittinger # Date 1309526124 -7200 # Node ID 155ff5be09f236abdedc1e4602aff81823054346 # Parent adb58666157b0da345d3cfe3b268580cf26f379d initial checkin diff -r adb58666157b -r 155ff5be09f2 BookmarkListEditor.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BookmarkListEditor.st Fri Jul 01 15:15:24 2011 +0200 @@ -0,0 +1,494 @@ +" + COPYRIGHT (c) 2006 by eXept Software AG + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" +"{ Package: 'stx:libtool' }" + +ApplicationModel subclass:#BookmarkListEditor + instanceVariableNames:'selectionHolder bookmarkListHolder' + classVariableNames:'' + poolDictionaries:'' + category:'Interface-Bookmarks' +! + +!BookmarkListEditor class methodsFor:'documentation'! + +copyright +" + COPYRIGHT (c) 2006 by eXept Software AG + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" +! ! + +!BookmarkListEditor class methodsFor:'interface specs'! + +windowSpec + "This resource specification was automatically generated + by the UIPainter of ST/X." + + "Do not manually edit this!! If it is corrupted, + the UIPainter may not be able to read the specification." + + " + UIPainter new openOnClass:BookmarkListEditor andSelector:#windowSpec + BookmarkListEditor new openInterface:#windowSpec + BookmarkListEditor open + " + + + + ^ + #(FullSpec + name: windowSpec + window: + (WindowSpec + label: 'Bookmark Editor' + name: 'Bookmark Editor' + min: (Point 10 10) + bounds: (Rectangle 0 0 509 430) + ) + component: + (SpecCollection + collection: ( + (MenuPanelSpec + name: 'ToolBar' + layout: (LayoutFrame 0 0 0 0 0 1 30 0) + menu: toolbarMenu + textDefault: true + ) + (VariableHorizontalPanelSpec + name: 'Panel' + layout: (LayoutFrame 0 0 30 0 0 1 0 1) + component: + (SpecCollection + collection: ( + (HierarchicalListViewSpec + name: 'BookmarkList' + model: selectionHolder + menu: contextMenu + hasHorizontalScrollBar: true + hasVerticalScrollBar: true + listModel: bookmarkListHolder + useIndex: false + highlightMode: line + doubleClickSelector: menuRename + useDefaultIcons: false + ) + ) + + ) + handles: (Any 1.0) + ) + ) + + ) + ) +! ! + +!BookmarkListEditor class methodsFor:'menu specs'! + +contextMenu + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:BookmarkListEditor andSelector:#contextMenu + (Menu new fromLiteralArrayEncoding:(BookmarkListEditor contextMenu)) startUp + " + + + + ^ + #(Menu + ( + (MenuItem + label: 'New...' + itemValue: menuNewFolder + translateLabel: true + submenuChannel: newMenu + labelImage: (ResourceRetriever ToolbarIconLibrary newDirectory22x22Icon 'New...') + ) + (MenuItem + label: 'Rename' + itemValue: menuRename + translateLabel: true + shortcutKey: Rename + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Remove' + itemValue: menuRemove + translateLabel: true + labelImage: (ResourceRetriever ToolbarIconLibrary deleteIcon 'Remove') + ) + (MenuItem + label: '-' + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move Up' + itemValue: menuMoveUp + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetUpIcon 'Move Up') + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move Down' + itemValue: menuMoveDown + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetDownIcon 'Move Down') + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move In' + itemValue: menuMoveIn + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetDownRightIcon 'Move In') + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move Out' + itemValue: menuMoveOut + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetLeftDownIcon 'Move Out') + ) + ) + nil + nil + ) +! + +newMenu + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:BookmarkListEditor andSelector:#newMenu + (Menu new fromLiteralArrayEncoding:(BookmarkListEditor newMenu)) startUp + " + + + + ^ + #(Menu + ( + (MenuItem + label: 'New Folder' + itemValue: menuNew: + translateLabel: true + labelImage: (ResourceRetriever ToolbarIconLibrary newDirectory22x22Icon 'New Folder') + argument: #'Bookmark::Folder' + ) + (MenuItem + label: 'New Separator' + itemValue: menuNew: + translateLabel: true + argument: #'Bookmark::Separator' + ) + ) + nil + nil + ) +! + +toolbarMenu + "This resource specification was automatically generated + by the MenuEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the MenuEditor may not be able to read the specification." + + " + MenuEditor new openOnClass:BookmarkListEditor andSelector:#toolbarMenu + (Menu new fromLiteralArrayEncoding:(BookmarkListEditor toolbarMenu)) startUp + " + + + + ^ + #(Menu + ( + (MenuItem + label: 'New...' + itemValue: menuNewFolder + translateLabel: true + isButton: true + submenuChannel: newMenu + labelImage: (ResourceRetriever ToolbarIconLibrary newDirectory22x22Icon) + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Remove' + itemValue: menuRemove + translateLabel: true + isButton: true + shortcutKey: Delete + labelImage: (ResourceRetriever ToolbarIconLibrary deleteIcon) + ) + (MenuItem + label: '-' + ) + (MenuItem + label: 'Save' + itemValue: menuSave + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary saveToFileIcon) + ) + (MenuItem + label: '-' + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move Up' + itemValue: menuMoveUp + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetUpIcon) + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move Down' + itemValue: menuMoveDown + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetDownIcon) + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move In' + itemValue: menuMoveIn + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetDownRightIcon) + ) + (MenuItem + enabled: hasSelectionHolder + label: 'Move Out' + itemValue: menuMoveOut + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ToolbarIconLibrary moveWidgetLeftDownIcon) + ) + ) + nil + nil + ) +! ! + +!BookmarkListEditor methodsFor:'accessing'! + +bookmarkList + + ^self bookmarkListHolder value + + "Created: / 02-06-2011 / 10:40:25 / Jan Vrany " +! + +bookmarkList: aBookmarkList + + self bookmarkListHolder value: aBookmarkList + + "Created: / 02-06-2011 / 10:40:16 / Jan Vrany " +! + +selection + + ^self selectionHolder value + + "Created: / 02-06-2011 / 10:57:10 / Jan Vrany " +! + +selection: anObject + + ^self selectionHolder value: anObject + + "Created: / 02-06-2011 / 11:46:00 / Jan Vrany " +! ! + +!BookmarkListEditor methodsFor:'aspects'! + +bookmarkListHolder + + + "automatically generated by UIPainter ..." + + "*** the code below creates a default model when invoked." + "*** (which may not be the one you wanted)" + "*** Please change as required and accept it in the browser." + "*** (and replace this comment by something more useful ;-)" + + bookmarkListHolder isNil ifTrue:[ + bookmarkListHolder := ValueHolder new. +"/ if your app needs to be notified of changes, uncomment one of the lines below: +"/ bookmarkListHolder addDependent:self. +"/ bookmarkListHolder onChangeSend:#bookmarkListHolderChanged to:self. + ]. + ^ bookmarkListHolder. + + "Modified: / 02-06-2011 / 10:39:44 / Jan Vrany " +! + +hasSelectionHolder + + ^BlockValue + with:[:selectionHolder|selectionHolder value notNil] + argument: self selectionHolder + + "Created: / 02-06-2011 / 10:55:51 / Jan Vrany " +! + +selectionHolder + + + "automatically generated by UIPainter ..." + + "*** the code below creates a default model when invoked." + "*** (which may not be the one you wanted)" + "*** Please change as required and accept it in the browser." + "*** (and replace this comment by something more useful ;-)" + + selectionHolder isNil ifTrue:[ + selectionHolder := ValueHolder new. +"/ if your app needs to be notified of changes, uncomment one of the lines below: +"/ selectionHolder addDependent:self. +"/ selectionHolder onChangeSend:#selectionHolderChanged to:self. + ]. + ^ selectionHolder. +! ! + +!BookmarkListEditor methodsFor:'hooks'! + +commonPostOpen + + | root | + + self bookmarkList ifNil: + [self bookmarkList: BookmarkList forSystemBrowser]. + root := self bookmarkList root. + root isExpanded ifFalse:[root expand]. + + "Created: / 02-06-2011 / 10:41:45 / Jan Vrany " + "Modified: / 02-06-2011 / 13:33:04 / Jan Vrany " +! ! + +!BookmarkListEditor methodsFor:'menu actions'! + +menuMoveDown + + | sel | + + (sel := self selection) parent moveDown: sel. + self selection: sel. + + "Modified: / 02-06-2011 / 11:45:48 / Jan Vrany " +! + +menuMoveIn + + | sel | + + (sel := self selection) parent moveIn: sel. + self selection: sel. + + "Modified: / 03-06-2011 / 10:27:51 / Jan Vrany " +! + +menuMoveOut + + | sel | + + (sel := self selection) parent moveOut: sel. + self selection: sel. + + "Modified: / 03-06-2011 / 10:28:00 / Jan Vrany " +! + +menuMoveUp + + | sel | + + (sel := self selection) parent moveUp: sel. + self selection: sel. + + "Modified: / 02-06-2011 / 11:46:40 / Jan Vrany " +! + +menuNew: className + + | folder new | + folder := self selection. + folder ifNil:[folder := self bookmarkList root]. + folder isFolderBookmark ifFalse: [folder := folder parent]. + new := (Smalltalk at: className) new. + folder add: new. + + "Created: / 02-06-2011 / 11:49:45 / Jan Vrany " + "Modified: / 02-06-2011 / 13:24:13 / Jan Vrany " +! + +menuNewFolder + + self menuNew: #'Bookmark::Folder' + + "Modified: / 02-06-2011 / 12:00:55 / Jan Vrany " +! + +menuRemove + + self selection parent remove: self selection. + + "Modified: / 02-06-2011 / 13:18:34 / Jan Vrany " +! + +menuRename + + | sel name | + sel := self selection. + name := Dialog request: 'Enter new name' initialAnswer: sel label asString. + name ifNil:[^self]. + sel label: name. + + "Modified: / 03-06-2011 / 10:43:12 / Jan Vrany " +! + +menuSave + + self bookmarkList save. + + "Modified: / 02-06-2011 / 22:53:34 / Jan Vrany " +! ! + +!BookmarkListEditor class methodsFor:'documentation'! + +version_CVS + ^ '$Header: /cvs/stx/stx/libtool/BookmarkListEditor.st,v 1.1 2011-07-01 13:15:24 cg Exp $' +! + +version_SVN + ^ '§Id§' +! !