home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / xmlspy35.exe / Main / DlgExport.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-06-19  |  10.3 KB  |  323 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 ElementList
  192. Public objExpSettings As ExportSettings
  193. Public objDoc As Document
  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.     If objExpSettings.FromAttributes Then
  251.         CheckAttr.Value = 1
  252.     End If
  253.     If objExpSettings.FromSingleSubElements Then
  254.         CheckSingle.Value = 1
  255.     End If
  256.     If objExpSettings.FromTextValues Then
  257.         CheckText.Value = 1
  258.     End If
  259.     If objExpSettings.EntitiesToText Then
  260.         CheckEnt2Text.Value = 1
  261.     End If
  262.     If objExpSettings.CreateKeys Then
  263.         CheckPrimary.Value = 1
  264.     End If
  265.     If objExpSettings.IndependentPrimaryKey Then
  266.         CheckIndep.Value = 1
  267.     End If
  268.     If objExpSettings.ExportAllElements = False Then
  269.         CheckAllSub.Value = False
  270.         CheckNSubs.Value = True
  271.     End If
  272.     bOK = False
  273.     bRefresh = True
  274.     UpdateControls
  275. End Sub
  276. Private Sub OKButton_Click()
  277.     bOK = True
  278.     Hide
  279.     Dim dlgDest As DlgExpDest
  280.     Set dlgDest = New DlgExpDest
  281.     dlgDest.Show vbModal
  282.     If dlgDest.bOK Then
  283.         ClientWnd.MousePointer = vbHourglass
  284.         On Error Resume Next
  285.         objExpSettings.ElementList = objList
  286.         If dlgDest.OptionText Then
  287.             Dim objTextExp As XMLSpyLib.TextImportExportSettings
  288.             Set objTextExp = objSpy.GetTextImportExportSettings
  289.             objTextExp.HeaderRow = dlgDest.CheckHeader
  290.             objTextExp.DestinationFolder = dlgDest.FolderEdit.Text
  291.             objDoc.ExportToText objDoc.RootElement, objExpSettings, objTextExp
  292.             If Err.Number <> 0 Then
  293.                 a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: " & Err.Description)
  294.             End If
  295.         Else
  296.             Dim objDB As DatabaseConnection
  297.             Set objDB = objSpy.GetDatabaseSettings
  298.             objDB.CreateMissingTables = dlgDest.CheckTables.Value
  299.             objDB.CreateNew = dlgDest.OptionNewDB.Value
  300.             objDB.File = dlgDest.DBFileEdit
  301.             objDoc.ExportToDatabase objDoc.RootElement, objExpSettings, objDB
  302.             If Err.Number <> 0 Then
  303.                 a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: " & Err.Description)
  304.             End If
  305.         End If
  306.         ClientWnd.MousePointer = 0
  307.     End If
  308.     Unload dlgDest
  309. End Sub
  310. Private Sub UpdateControls()
  311.     If bRefresh Then
  312.         ElementList.Clear
  313.         Dim objItem As ElementListItem
  314.         Set objList = objDoc.GetExportElementList(objDoc.RootElement, objExpSettings)
  315.         For Each objItem In objList
  316.             Dim strTabs As String
  317.             strTabs = String(32 - Len(objItem.Name), " ")
  318.             ElementList.AddItem objItem.Name & strTabs & objItem.RecordCount & Chr(9) & objItem.FieldCount
  319.         Next
  320.         ElementList.Refresh
  321.     End If
  322. End Sub
  323.