home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 January / PCWorld_2001-01_cd.bin / Software / Topware / xmlspy / xmlspy35.exe / Main / DlgExport.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-11-20  |  10.2 KB  |  311 lines

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