ProjectView.st
author claus
Sat, 11 Dec 1993 02:47:54 +0100
changeset 9 3c0d1690a95a
parent 3 9ff3765f06d0
child 17 58c360f199be
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1993 by Claus Gittinger
              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.
"

StandardSystemView subclass:#ProjectView
         instanceVariableNames:'myProject toggle'
         classVariableNames:'ActiveProjectView'
         poolDictionaries:''
         category:'Interface-Smalltalk'
!

!ProjectView class methodsFor:'instance creation'!

for:aProject
    |newView|

    newView := super new.
    newView setProject:aProject.
    ^ newView

    "ProjectView for:(Project new)"
! !

!ProjectView methodsFor:'private accessing'!

setProject:aProject
    |name e|

    name := aProject name.
    self label:name.
    self iconName:name.
    toggle label:'Project: ' , name.
    toggle resize.
    myProject := aProject.
    e := (toggle width @ toggle height).
    self extent:e.
    self minExtent:e.
    self maxExtent:e
! !

!ProjectView methodsFor:'initialization'!

initialize
    super initialize.
    toggle := Toggle in:self.
    toggle borderWidth:0.
    toggle pressAction:[self showProject].
    toggle releaseAction:[self hideProject].
    toggle middleButtonMenu:(
        PopUpMenu
                labels:#('rename'
                         'properties'
                         'changes'
                         '-'
                         'build'
                         '-'
                         'show'
                         'hide'
                         '-'
                         'destroy'
                        )
             selectors:#(renameProject
                         browseProps
                         browseChanges
                         nil
                         buildProject
                         nil
                         showProject
                         hideProject
                         nil
                         destroy
                        )
              receiver:self
    )
!

addToCurrentProject
    "ignored here"

    ^ self
! !

!ProjectView methodsFor:'menu actions'!

buildProject
    (self confirm:'create files in: ' ,  myProject directory) ifTrue:[
        myProject createProjectFiles.
        (self confirm:'starting make in: ' ,  myProject directory) ifTrue:[
            myProject buildProject.
        ].
    ].
!

browseChanges
    ChangeSetBrowser startOn:(myProject changeSet)
!

browseProps
    "will look better, once property inspector runs ..."

    myProject properties inspect
!

destroyProject
    |box|

    box := YesNoBox new.
    box title:'Destroying a project will discard all changes made
for that project and destroy all views opened for it.

Do you really want to do this ?'.
    box okText:'yes'.
    box yesAction:[
        self doDestroyProject
    ].
    box showAtPointer
!

showProject
    ActiveProjectView notNil ifTrue:[
        ActiveProjectView hideProject
    ].
    ActiveProjectView := self.

    myProject showViews.
    Project current:myProject.
    toggle turnOn
!

hideProject
    myProject hideViews.
    ActiveProjectView := nil.
    toggle turnOff
!

renameProject
    |box|

    box := EnterBox new.
    box title:'new name of project:'.
    box okText:'rename'.
    box initialText:(myProject name).
    box action:[:newName |
        myProject name:newName.
        self setProject:myProject
    ].
    box showAtPointer
!

doDestroy
    self hideProject.

    myProject := nil.
    super destroy
!

destroy
    |box|

    box := YesNoBox new.
    box title:'Destroying a project will discard all changes made
for that project and destroy all views opened for it.

Do you really want to do this ?'.
    box okText:'yes'.
    box yesAction:[
        self doDestroy
    ].
    box showAtPointer
! !