当前位置:编程学习 > JAVA >>

面向对象的LotusScript

上次提到使用面向对象的LotusScript的好处,这里再给出两个样例。
 
DialogBox是NotesUIWorkspace的一个方法,用于显示一个指定表单的对话框,在开发中很有用。不过对话框繁多的设置都通过方法的参数传递,难记难用。下面就用一个自定义类包装了DialogBox的功能,默认情况下只需要传入一个表单或者文档参数,就可以调用Show()方法显示一个对话框。对话框的显示可以通过设置属性调整。原有的参数按照其意义进行了分类,可以更方便地设置。比如Fit属性可以控制HorizonalFit和VerticalFit设置,AllowUpdate属性可以控制NoFieldUpdate和NoNewFields。如果必要,也可以通过公开的字段更精细地修改原有的参数。
 
[vb]  
%REM  
    Class DialogBox  
    Description: Wraps the ws.Dialogbox() method.  
%END REM  
Public Class DialogBox  
    Public FormName As String   
    Public HorizonalFit As Boolean  
    Public VerticalFit As Boolean  
    Public NoCancel As Boolean  
    Public NoNewFields As Boolean  
    Public NoFieldUpdate As Boolean  
    Public  ReadOnly As Boolean  
    Public Title As String  
    Public Document As NotesDocument  
    Public SizeToTable As Boolean  
    Public NoOKCancel As Boolean  
    Public OKCancelAtBottom As Boolean  
      
    %REM  
        Property Set Fit  
        Description: Wraps the HorizonalFit and VerticalFit fields  
    %END REM  
    Property Set Fit As Boolean  
        me.HorizonalFit=Fit  
        me.VerticalFit=Fit  
    End Property  
      
    %REM  
        Property Set AllowUpdate  
        Description: Wraps the NoFieldUpdate and NoNewFields fields  
    %END REM  
    Property Set AllowUpdate As Boolean  
        me.NoFieldUpdate=Not AllowUpdate  
        me.NoNewFields=Not AllowUpdate  
    End Property  
      
    %REM  
        Property Set DefaultButton  
        Description: Wraps the NoCancel and NoOKCancel fields  
    %END REM  
    Property Set DefaultButton As Boolean  
        me.NoCancel=Not DefaultButton  
        me.NoOKCancel=Not DefaultButton  
    End Property  
      
    %REM  
    Sub New  
    Description: The argument info is either a string of a form name or a document to be shown  
    %END REM  
    Public Sub New(info As Variant)  
        'stop  
        'Default values  
        me.HorizonalFit=False  
        me.VerticalFit=False  
        me.NoCancel=False  
        me.NoFieldUpdate=False  
        me.NoNewFields=False  
        me.NoOKCancel=False  
        me.OKCancelAtBottom=False  
        me.ReadOnly=False  
        me.SizeToTable=False  
        me.Title="Lotus Notes"  
          
        Select Case TypeName(info)  
            Case "NOTESDOCUMENT"  
                Set me.Document=info  
                me.FormName=info.Form(0)  
            Case "STRING"  
                'info is the form name  
                me.FormName=info  
                Set me.Document=CreateDoc(me.FormName)  
        End Select  
  
    End Sub   
      
    %REM  
    Function Show  
    Description: Show the dialogbox.  
    %END REM  
    Public Function Show() As Boolean  
        Dim ws As New NotesUIWorkspace  
        Show = ws.Dialogbox(Me.FormName, Me.HorizonalFit, Me.VerticalFit, Me.NoCancel, Me.NoNewFields, Me.NoFieldUpdate, Me.ReadOnly, Me.Title, Me.Document, Me.SizeToTable, Me.NoOKCancel, Me.OKCancelAtBottom)  
    End Function  
End Class  
下面这个自定义类对Picklistcollection也做了类似的包装。默认情况下打开当前数据库的某个视图,分别通过SelectDocs和SelectDoc进行多选和单选。
 
[vb]  
%REM  
    Class PickBox  
    Description: Wraps the ws.Picklistcollection() method.  
%END REM  
Public Class PickBox  
    Private ws As NotesUIWorkspace  
    Private s As NotesSession  
    Private db As NotesDatabase  
      
    Public MultiSelect As Boolean  
    Public Server As String  
    Public DBPath As String  
    Public Title As String  
    Public Prompt As String  
    Public SingleCategory As String  
      
    %REM  
        Sub New  
        Description: Comments for Sub  
    %END REM  
    Sub New()  
        Set ws=New NotesUIWorkspace  
        Set s=New NotesSession  
        Set db=s.Currentdatabase  
        'Default to open a view in the current db.  
        Server=db.Server  
        DBPath=db.Filepath  
        Title="Lotus Notes"  
        Prompt="Please select the document(s)."  
    End Sub  
      
    %REM  
&nbs
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,