home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 December / INTERNET97.ISO / pc / software / windows / building / xmlspy / setup44.exe / Data1.cab / F1508_DlgExport.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-06-20  |  12.2 KB  |  374 lines

  1. VERSION 5.00
  2. Begin VB.Form DlgExport 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Export settings"
  5.    ClientHeight    =   6000
  6.    ClientLeft      =   2760
  7.    ClientTop       =   3750
  8.    ClientWidth     =   6480
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   6000
  13.    ScaleWidth      =   6480
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame4 
  16.       Caption         =   "Namespace options"
  17.       Height          =   615
  18.       Left            =   120
  19.       TabIndex        =   20
  20.       Top             =   2400
  21.       Width           =   6255
  22.       Begin VB.OptionButton OptReplaceColon 
  23.          Caption         =   "Replace colons with underscores"
  24.          Height          =   255
  25.          Left            =   3240
  26.          TabIndex        =   22
  27.          Top             =   240
  28.          Width           =   2775
  29.       End
  30.       Begin VB.OptionButton OptNoNS 
  31.          Caption         =   "No Namespaces"
  32.          Height          =   255
  33.          Left            =   240
  34.          TabIndex        =   21
  35.          Top             =   240
  36.          Width           =   2655
  37.       End
  38.    End
  39.    Begin VB.CommandButton BtnRemove 
  40.       Caption         =   "Remove element"
  41.       Height          =   255
  42.       Left            =   120
  43.       TabIndex        =   19
  44.       Top             =   5400
  45.       Width           =   1455
  46.    End
  47.    Begin VB.Frame Frame3 
  48.       Caption         =   "Automatic fields"
  49.       Height          =   1095
  50.       Left            =   3240
  51.       TabIndex        =   13
  52.       Top             =   1200
  53.       Width           =   3135
  54.       Begin VB.CheckBox CheckIndep 
  55.          Caption         =   "Independent primary key counter for every element"
  56.          Height          =   375
  57.          Left            =   240
  58.          TabIndex        =   15
  59.          Top             =   600
  60.          Width           =   2655
  61.       End
  62.       Begin VB.CheckBox CheckPrimary 
  63.          Caption         =   "Create primary/foreign keys"
  64.          Height          =   255
  65.          Left            =   240
  66.          TabIndex        =   14
  67.          Top             =   240
  68.          Width           =   2655
  69.       End
  70.    End
  71.    Begin VB.Frame Frame2 
  72.       Caption         =   "Export fields"
  73.       Height          =   2175
  74.       Left            =   120
  75.       TabIndex        =   8
  76.       Top             =   120
  77.       Width           =   3015
  78.       Begin VB.CheckBox CheckEnt2Text 
  79.          Caption         =   "Convert entities to text"
  80.          Height          =   255
  81.          Left            =   240
  82.          TabIndex        =   12
  83.          Top             =   1320
  84.          Width           =   2655
  85.       End
  86.       Begin VB.CheckBox CheckText 
  87.          Caption         =   "Create from text values"
  88.          Height          =   255
  89.          Left            =   240
  90.          TabIndex        =   11
  91.          Top             =   960
  92.          Width           =   2655
  93.       End
  94.       Begin VB.CheckBox CheckSingle 
  95.          Caption         =   "Create from single sub-elements"
  96.          Height          =   255
  97.          Left            =   240
  98.          TabIndex        =   10
  99.          Top             =   600
  100.          Width           =   2535
  101.       End
  102.       Begin VB.CheckBox CheckAttr 
  103.          Caption         =   "Create from attributes"
  104.          Height          =   255
  105.          Left            =   240
  106.          TabIndex        =   9
  107.          Top             =   240
  108.          Width           =   2055
  109.       End
  110.    End
  111.    Begin VB.Frame Frame1 
  112.       Caption         =   "Export depth"
  113.       Height          =   975
  114.       Left            =   3240
  115.       TabIndex        =   3
  116.       Top             =   120
  117.       Width           =   3135
  118.       Begin VB.TextBox EditSubLevels 
  119.          Height          =   285
  120.          Left            =   1320
  121.          TabIndex        =   6
  122.          Text            =   "1"
  123.          Top             =   570
  124.          Width           =   495
  125.       End
  126.       Begin VB.OptionButton CheckNSubs 
  127.          Caption         =   "Limited to"
  128.          Height          =   255
  129.          Left            =   240
  130.          TabIndex        =   5
  131.          Top             =   600
  132.          Width           =   1095
  133.       End
  134.       Begin VB.OptionButton CheckAllSub 
  135.          Caption         =   "Export all sub-levels"
  136.          Height          =   255
  137.          Left            =   240
  138.          TabIndex        =   4
  139.          Top             =   240
  140.          Width           =   1935
  141.       End
  142.       Begin VB.Label Label1 
  143.          Caption         =   "sub-levels"
  144.          Height          =   255
  145.          Left            =   1920
  146.          TabIndex        =   7
  147.          Top             =   600
  148.          Width           =   975
  149.       End
  150.    End
  151.    Begin VB.ListBox ElementList 
  152.       BeginProperty Font 
  153.          Name            =   "Courier"
  154.          Size            =   9.75
  155.          Charset         =   0
  156.          Weight          =   400
  157.          Underline       =   0   'False
  158.          Italic          =   0   'False
  159.          Strikethrough   =   0   'False
  160.       EndProperty
  161.       Height          =   2010
  162.       Left            =   120
  163.       TabIndex        =   2
  164.       Top             =   3360
  165.       Width           =   6255
  166.    End
  167.    Begin VB.CommandButton CancelButton 
  168.       Caption         =   "Cancel"
  169.       Height          =   375
  170.       Left            =   3600
  171.       TabIndex        =   1
  172.       Top             =   5520
  173.       Width           =   1215
  174.    End
  175.    Begin VB.CommandButton OKButton 
  176.       Caption         =   "Continue"
  177.       Height          =   375
  178.       Left            =   5160
  179.       TabIndex        =   0
  180.       Top             =   5520
  181.       Width           =   1215
  182.    End
  183.    Begin VB.Label Label4 
  184.       Caption         =   "Field count"
  185.       Height          =   255
  186.       Left            =   4800
  187.       TabIndex        =   18
  188.       Top             =   3120
  189.       Width           =   1335
  190.    End
  191.    Begin VB.Label Label3 
  192.       Caption         =   "Record count"
  193.       Height          =   255
  194.       Left            =   3360
  195.       TabIndex        =   17
  196.       Top             =   3120
  197.       Width           =   1215
  198.    End
  199.    Begin VB.Label Label2 
  200.       Caption         =   "Element name"
  201.       Height          =   255
  202.       Left            =   120
  203.       TabIndex        =   16
  204.       Top             =   3120
  205.       Width           =   2895
  206.    End
  207. Attribute VB_Name = "DlgExport"
  208. Attribute VB_GlobalNameSpace = False
  209. Attribute VB_Creatable = False
  210. Attribute VB_PredeclaredId = True
  211. Attribute VB_Exposed = False
  212. Public bOK As Boolean
  213. Private bRefresh As Boolean
  214. Private a As Integer
  215. Private objList As ElementList
  216. Public objExpSettings As ExportSettings
  217. Public objDoc As Document
  218. Option Explicit
  219. Private Sub BtnRemove_Click()
  220.     If ElementList.ListIndex >= 0 Then
  221.         objList.RemoveElement ElementList.ListIndex
  222.         ElementList.RemoveItem ElementList.ListIndex
  223.         ElementList.Refresh
  224.     End If
  225. End Sub
  226. Private Sub CancelButton_Click()
  227.     Hide
  228. End Sub
  229. Private Sub CheckAllSub_Click()
  230.     objExpSettings.ExportAllElements = CheckAllSub.Value
  231.     UpdateControls
  232. End Sub
  233. Private Sub CheckAttr_Click()
  234.     objExpSettings.FromAttributes = CheckAttr.Value
  235.     UpdateControls
  236. End Sub
  237. Private Sub CheckEnt2Text_Click()
  238.     objExpSettings.EntitiesToText = CheckEnt2Text.Value
  239.     UpdateControls
  240. End Sub
  241. Private Sub CheckIndep_Click()
  242.     objExpSettings.IndependentPrimaryKey = CheckIndep.Value
  243.     UpdateControls
  244. End Sub
  245. Private Sub CheckNSubs_Click()
  246.     objExpSettings.ExportAllElements = CheckAllSub.Value
  247.     objExpSettings.SubLevelLimit = CInt(Val(EditSubLevels.Text)) + 1
  248.     UpdateControls
  249. End Sub
  250. Private Sub CheckPrimary_Click()
  251.     CheckIndep.Enabled = True
  252.     If CheckPrimary.Value = 0 Then
  253.         CheckIndep.Enabled = False
  254.     End If
  255.     CheckIndep.Refresh
  256.     objExpSettings.CreateKeys = CheckPrimary.Value
  257.     UpdateControls
  258. End Sub
  259. Private Sub CheckSingle_Click()
  260.     objExpSettings.FromSingleSubElements = CheckSingle.Value
  261.     UpdateControls
  262. End Sub
  263. Private Sub CheckText_Click()
  264.     objExpSettings.FromTextValues = CheckText.Value
  265.     UpdateControls
  266. End Sub
  267. Private Sub EditSubLevels_LostFocus()
  268.     objExpSettings.SubLevelLimit = CInt(Val(EditSubLevels.Text)) + 1
  269.     UpdateControls
  270. End Sub
  271. Private Sub Form_Activate()
  272.     bRefresh = False
  273.     CheckAllSub.Value = True
  274.     If objExpSettings.FromAttributes Then
  275.         CheckAttr.Value = 1
  276.     End If
  277.     If objExpSettings.FromSingleSubElements Then
  278.         CheckSingle.Value = 1
  279.     End If
  280.     If objExpSettings.FromTextValues Then
  281.         CheckText.Value = 1
  282.     End If
  283.     If objExpSettings.EntitiesToText Then
  284.         CheckEnt2Text.Value = 1
  285.     End If
  286.     If objExpSettings.CreateKeys Then
  287.         CheckPrimary.Value = 1
  288.     End If
  289.     If objExpSettings.IndependentPrimaryKey Then
  290.         CheckIndep.Value = 1
  291.     End If
  292.     If objExpSettings.ExportAllElements = False Then
  293.         CheckAllSub.Value = False
  294.         CheckNSubs.Value = True
  295.     End If
  296.     bOK = False
  297.     bRefresh = True
  298.     UpdateControls
  299. End Sub
  300. Private Sub OKButton_Click()
  301.     bOK = True
  302.     Hide
  303.     If OptNoNS.Value = True Then
  304.         objExpSettings.Namespace = spyNoNamespace
  305.     Else
  306.         objExpSettings.Namespace = spyReplaceColonWithUnderscore
  307.     End If
  308.     Dim dlgDest As DlgExpDest
  309.     Set dlgDest = New DlgExpDest
  310.     dlgDest.Show vbModal
  311.     If dlgDest.bOK Then
  312.         Dim objDB As DatabaseConnection
  313.         Set objDB = objSpy.GetDatabaseSettings
  314.         
  315.         ClientWnd.MousePointer = vbHourglass
  316.         On Error Resume Next
  317.         objExpSettings.ElementList = objList
  318.         If dlgDest.OptionText Then
  319.             Dim objTextExp As XMLSpyLib.TextImportExportSettings
  320.             Set objTextExp = objSpy.GetTextImportExportSettings
  321.             objTextExp.HeaderRow = dlgDest.CheckHeader
  322.             objTextExp.DestinationFolder = dlgDest.FolderEdit.Text
  323.             objDoc.ExportToText objDoc.RootElement, objExpSettings, objTextExp
  324.             If Err.Number <> 0 Then
  325.                 a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: " & Err.Description)
  326.             End If
  327.         End If
  328.         
  329.         If dlgDest.OptionExistingDB Or dlgDest.OptionNewDB Then
  330.             objDB.CreateMissingTables = dlgDest.CheckTables.Value
  331.             objDB.CreateNew = dlgDest.OptionNewDB.Value
  332.             objDB.File = dlgDest.DBFileEdit
  333.             objDoc.ExportToDatabase objDoc.RootElement, objExpSettings, objDB
  334.             If Err.Number <> 0 Then
  335.                 a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: " & Err.Description)
  336.             End If
  337.         End If
  338.         
  339.         If dlgDest.OptADO Then
  340.             objDB.CreateMissingTables = dlgDest.CheckTables.Value
  341.             objDB.ADOConnection = dlgDest.TxtADO
  342.             objDoc.ExportToDatabase objDoc.RootElement, objExpSettings, objDB
  343.             If Err.Number <> 0 Then
  344.                 a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: " & Err.Description)
  345.             End If
  346.         End If
  347.         
  348.         If dlgDest.OptODBC Then
  349.             objDB.CreateMissingTables = dlgDest.CheckTables.Value
  350.             objDB.ODBCConnection = dlgDest.TxtODBC
  351.             objDoc.ExportToDatabase objDoc.RootElement, objExpSettings, objDB
  352.             If Err.Number <> 0 Then
  353.                 a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: " & Err.Description)
  354.             End If
  355.        End If
  356.         
  357.         ClientWnd.MousePointer = 0
  358.     End If
  359.     Unload dlgDest
  360. End Sub
  361. Private Sub UpdateControls()
  362.     If bRefresh Then
  363.         ElementList.Clear
  364.         Dim objItem As ElementListItem
  365.         Set objList = objDoc.GetExportElementList(objDoc.RootElement, objExpSettings)
  366.         For Each objItem In objList
  367.             Dim strTabs As String
  368.             strTabs = String(32 - Len(objItem.Name), " ")
  369.             ElementList.AddItem objItem.Name & strTabs & objItem.RecordCount & Chr(9) & objItem.FieldCount
  370.         Next
  371.         ElementList.Refresh
  372.     End If
  373. End Sub
  374.