PowerShell yUML Workbench

August 20, 2009

in PowerBoots,PowerShell,REBOL,yUML

Tobin Harris, creator of yUML, tweeted Automate YUml Diagrams with Rebol. It’s been years since I played with Carl Sassenrath’s REBOL.

After looking at the REBOL sample I fired up PowerShell and PowerBoots.

You can choose examples from the left and the diagram updates from yUML.me. You can also type in your own yUML and click Draw.

This PowerShell sample only supports UseCase diagrams. That is easy to change. In the Global:yUMLUrl change usecase to class. A future update will let you switch between usecase and class diagrams in the WPF GUI.

image

The Code

Most of the code is setting up the WPF layout and the sample yUML DSL (domain specific language). If you strip that away, integrating PowerShell, WPF and a Web Service is just a handful of code.

Filter Global:yUMLUrl {            
    "http://yuml.me/diagram/usecase/$($_)"            
}            
            
Function Global:ShowImage {            
    $dsl = (Select-BootsElement $BootsWindow txtBox).Text            
    (Select-BootsElement $BootsWindow image).Source = ( $dsl | Global:yUMLUrl)            
}                
            
Function Global:Set-Sample ($dsl) {            
    (Select-BootsElement $BootsWindow txtBox).Text = $dsl            
    Global:ShowImage            
}            
            
Boots -Title 'PowerShell yUML Workbench' -WindowStartupLocation CenterScreen -Width 850 -Height 600 -On_Loaded {            
    Global:ShowImage            
} {            
    GridPanel -ColumnDefinitions @(            
        ColumnDefinition -Width 100            
        ColumnDefinition -Width 300*            
    ) -RowDefinitions @(            
        RowDefinition -Height Auto            
        RowDefinition -Height Auto            
        RowDefinition -Height Auto            
        RowDefinition -Height Auto            
    ) {            
        StackPanel {            
            RadioButton '_Actor' -On_Click { Set-Sample '[Customer]' } -IsChecked $true            
            RadioButton 'Actor+_UseCase' -On_Click { Set-Sample '[Customer]-(Login)' }            
            RadioButton '_Notes' -On_Click { Set-Sample '[Customer]-(Login), [Customer]-(note: Cust can be registered or not{bg:beige})' }            
            RadioButton '_Many' -On_Click { Set-Sample '[Customer]-(Login), [Customer]-(Logout)' }            
            RadioButton '_Inheritance' -On_Click { Set-Sample '[Cms Admin]^[User]' }            
            RadioButton 'Mu_ltiple Actors And Inheritance' -On_Click { Set-Sample '[Cms Admin]^[User], [Customer]^[User], [Agent]^[User]' }            
            RadioButton '_Extends' -On_Click { Set-Sample '(Login)<(Register), (Login)<(Request Password Reminder)' }            
            RadioButton 'In_cludes' -On_Click { Set-Sample '(Register)>(Confirm Registration)' }            
                        
            RadioButton 'Meaty E_xample' -On_Click {             
                Set-Sample @'
(note: figure 1.2{bg:beige}), 
[User]-(Login),
[Site Maintainer]-(Add User),
(Add User)<(Add Company),
[Site Maintainer]-(Upload Docs),
(Upload Docs)<(Manage Folders),
[User]-(Upload Docs),
[User]-(Full Text Search Docs), 
(Full Text Search Docs)>(Preview Doc),
(Full Text Search Docs)>(Download Docs), 
[User]-(Browse Docs),
(Browse Docs)>(Preview Doc),
(Download Docs),
[Site Maintainer]-(Post New Event To The Web Site),
[User]-(View Events)
'@                            
            }            
        } -"Grid.Row" 0 -"Grid.Column" 0             
                    
            Image -Name image -MinHeight 400 -MaxHeight 400 -HorizontalAlignment left `
                -"Grid.Column" 1 -"Grid.Row" 0 -"Grid.RowSpan" 2 `
                -Source $null                        
            TextBox -Name txtBox `
                -Text '[Customer]' `
                -AcceptsReturn -Margin 5 `
                -TextWrapping Wrap -VerticalScrollBarVisibility Visible `
                -HorizontalAlignment left `
                -"Grid.Row" 2 -"Grid.Column" 1 `
                -MinHeight 150 -MaxHeight 150  -MinWidth 700            
            Button -Margin 5 -Content '_Draw' `
                -MaxWidth 75 -MinWidth 75 `
                -MaxHeight 32 -VerticalAlignment Top `
                -HorizontalAlignment Left -On_Click { Global:ShowImage } `
                -"Grid.Row" 2 -"Grid.Column" 0}                    
}

Grab the Code

{ 1 trackback }

Rebol Tutorial - Why Carl Sassenrath is One of the 30 Most Influential People In Programming
08.30.09 at 2:30 pm

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Contrat Creative Commons

© 2007-2013, Doug Finke