Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

776 lines
19 KiB

  1. VERSION 5.00
  2. Begin VB.Form frmSynonymSets
  3. BorderStyle = 1 'Fixed Single
  4. Caption = "Edit Synonym Sets"
  5. ClientHeight = 9375
  6. ClientLeft = 45
  7. ClientTop = 330
  8. ClientWidth = 9495
  9. LinkTopic = "Form1"
  10. MaxButton = 0 'False
  11. MinButton = 0 'False
  12. ScaleHeight = 9375
  13. ScaleWidth = 9495
  14. Begin VB.CommandButton cmdClose
  15. Caption = "Close"
  16. Height = 375
  17. Left = 8160
  18. TabIndex = 18
  19. Top = 8880
  20. Width = 1215
  21. End
  22. Begin VB.ListBox lstAllSynonymSets
  23. Height = 2985
  24. Left = 120
  25. TabIndex = 1
  26. Top = 360
  27. Width = 9255
  28. End
  29. Begin VB.Frame fraSelectedSynonymSet
  30. Caption = "Selected Synonym Set"
  31. Height = 4695
  32. Left = 120
  33. TabIndex = 4
  34. Top = 4080
  35. Width = 9255
  36. Begin VB.TextBox txtName
  37. Height = 285
  38. Left = 1680
  39. TabIndex = 6
  40. Top = 360
  41. Width = 7455
  42. End
  43. Begin VB.ListBox lstAllKeywords
  44. Height = 2790
  45. Left = 120
  46. MultiSelect = 2 'Extended
  47. TabIndex = 8
  48. Top = 1200
  49. Width = 3735
  50. End
  51. Begin VB.ListBox lstKeywordsInSynonymSet
  52. Height = 2790
  53. Left = 5400
  54. MultiSelect = 2 'Extended
  55. TabIndex = 15
  56. Top = 1320
  57. Width = 3735
  58. End
  59. Begin VB.CommandButton cmdCancel
  60. Caption = "Cancel"
  61. Height = 375
  62. Left = 7920
  63. TabIndex = 17
  64. Top = 4200
  65. Width = 1215
  66. End
  67. Begin VB.CommandButton cmdUpdateCreate
  68. Caption = "Update/Create"
  69. Height = 375
  70. Left = 6480
  71. TabIndex = 16
  72. Top = 4200
  73. Width = 1335
  74. End
  75. Begin VB.CommandButton cmdRemoveAll
  76. Caption = "<< Remove All"
  77. Height = 375
  78. Left = 3960
  79. TabIndex = 11
  80. Top = 2880
  81. Width = 1335
  82. End
  83. Begin VB.CommandButton cmdRemove
  84. Caption = "<< Remove"
  85. Height = 375
  86. Left = 3960
  87. TabIndex = 10
  88. Top = 2400
  89. Width = 1335
  90. End
  91. Begin VB.CommandButton cmdAdd
  92. Caption = "Add >>"
  93. Height = 375
  94. Left = 3960
  95. TabIndex = 9
  96. Top = 1920
  97. Width = 1335
  98. End
  99. Begin VB.Label lblAllKeywords
  100. Caption = "All Keywords:"
  101. Height = 255
  102. Left = 120
  103. TabIndex = 7
  104. Top = 960
  105. Width = 3735
  106. End
  107. Begin VB.Label lblName
  108. Caption = "Synonym Set Name:"
  109. Height = 255
  110. Left = 120
  111. TabIndex = 5
  112. Top = 360
  113. Width = 1455
  114. End
  115. Begin VB.Label lblKeywordsInSynonymSet3
  116. Caption = "contains the following Keywords:"
  117. Height = 255
  118. Left = 5400
  119. TabIndex = 14
  120. Top = 1080
  121. Width = 3735
  122. End
  123. Begin VB.Label lblKeywordsInSynonymSet2
  124. Caption = "<Synonym Set>"
  125. BeginProperty Font
  126. Name = "MS Sans Serif"
  127. Size = 8.25
  128. Charset = 0
  129. Weight = 700
  130. Underline = 0 'False
  131. Italic = 0 'False
  132. Strikethrough = 0 'False
  133. EndProperty
  134. Height = 255
  135. Left = 6720
  136. TabIndex = 13
  137. Top = 840
  138. Width = 2295
  139. End
  140. Begin VB.Label lblKeywordsInSynonymSet1
  141. Caption = "The Synonym Set"
  142. Height = 255
  143. Left = 5400
  144. TabIndex = 12
  145. Top = 840
  146. Width = 1335
  147. End
  148. End
  149. Begin VB.CommandButton cmdDelete
  150. Caption = "Delete"
  151. Height = 375
  152. Left = 8160
  153. TabIndex = 3
  154. Top = 3480
  155. Width = 1215
  156. End
  157. Begin VB.CommandButton cmdCreate
  158. Caption = "Create"
  159. Height = 375
  160. Left = 6840
  161. TabIndex = 2
  162. Top = 3480
  163. Width = 1215
  164. End
  165. Begin VB.Label lblAllSynonymSets
  166. Caption = "All Synonym Sets:"
  167. Height = 255
  168. Left = 120
  169. TabIndex = 0
  170. Top = 120
  171. Width = 1695
  172. End
  173. End
  174. Attribute VB_Name = "frmSynonymSets"
  175. Attribute VB_GlobalNameSpace = False
  176. Attribute VB_Creatable = False
  177. Attribute VB_PredeclaredId = True
  178. Attribute VB_Exposed = False
  179. Option Explicit
  180. Private p_clsSynonymSets As AuthDatabase.SynonymSets
  181. Private p_clsKeywords As AuthDatabase.Keywords
  182. Private p_rsAllSynonymSets As ADODB.Recordset
  183. Private p_rsAllKeywords As ADODB.Recordset
  184. Private p_rsKeywordsInSynonymSetCopy As ADODB.Recordset
  185. Private p_blnUpdating As Boolean
  186. Private p_blnCreating As Boolean
  187. Private Const STR_DEFAULT_SYNONYM_SET_NAME_C As String = "<Synonym Set>"
  188. Private Sub Form_Load()
  189. On Error GoTo LErrorHandler
  190. Set p_clsSynonymSets = g_AuthDatabase.SynonymSets
  191. Set p_clsKeywords = g_AuthDatabase.Keywords
  192. Set p_rsAllSynonymSets = New ADODB.Recordset
  193. Set p_rsAllKeywords = New ADODB.Recordset
  194. Set p_rsKeywordsInSynonymSetCopy = New ADODB.Recordset
  195. cmdClose.Cancel = True
  196. p_UpdateAllSynonymSets
  197. p_UpdateAllKeywords
  198. p_DisableDelete
  199. p_DisableSelectedSynonymSet
  200. p_SetModeCreating False
  201. p_SetToolTips
  202. LEnd:
  203. Exit Sub
  204. LErrorHandler:
  205. p_DisplayErrorMessage "Form_Load"
  206. GoTo LEnd
  207. End Sub
  208. Private Sub Form_Unload(Cancel As Integer)
  209. Set p_clsSynonymSets = Nothing
  210. Set p_clsKeywords = Nothing
  211. Set p_rsAllSynonymSets = Nothing
  212. Set p_rsKeywordsInSynonymSetCopy = Nothing
  213. Set p_rsAllKeywords = Nothing
  214. End Sub
  215. Private Sub lstAllSynonymSets_Click()
  216. On Error GoTo LErrorHandler
  217. If (p_blnCreating Or p_blnUpdating) Then
  218. Exit Sub
  219. End If
  220. If (lstAllSynonymSets.ListIndex <> -1) Then
  221. p_rsAllSynonymSets.Move lstAllSynonymSets.ListIndex, adBookmarkFirst
  222. p_EnableDelete
  223. p_EnableSelectedSynonymSetExceptUpdateCreateCancel
  224. p_GetAndUpdateKeywordsInSynonymSet p_rsAllSynonymSets("EID")
  225. txtName = p_rsAllSynonymSets("Name") & ""
  226. Else
  227. p_DisableSelectedSynonymSet
  228. p_GetAndUpdateKeywordsInSynonymSet INVALID_ID_C
  229. txtName = ""
  230. End If
  231. lblKeywordsInSynonymSet2.Caption = txtName
  232. LEnd:
  233. Exit Sub
  234. LErrorHandler:
  235. p_DisplayErrorMessage "lstAllSynonymSets_Click"
  236. GoTo LEnd
  237. End Sub
  238. Private Sub cmdCreate_Click()
  239. On Error GoTo LErrorHandler
  240. p_SetModeCreating True
  241. LEnd:
  242. Exit Sub
  243. LErrorHandler:
  244. p_DisplayErrorMessage "cmdCreate_Click"
  245. GoTo LEnd
  246. End Sub
  247. Private Sub cmdDelete_Click()
  248. On Error GoTo LErrorHandler
  249. Dim intEID As Long
  250. intEID = p_rsAllSynonymSets("EID")
  251. p_clsSynonymSets.Delete intEID
  252. p_UpdateAllSynonymSets
  253. LEnd:
  254. Exit Sub
  255. LErrorHandler:
  256. p_DisplayErrorMessage "cmdDelete_Click"
  257. GoTo LEnd
  258. End Sub
  259. Private Sub cmdAdd_Click()
  260. On Error GoTo LErrorHandler
  261. Dim intIndex As Long
  262. Dim intKID As Long
  263. If (p_rsAllKeywords.RecordCount > 0) Then
  264. p_rsAllKeywords.MoveFirst
  265. End If
  266. For intIndex = 0 To lstAllKeywords.ListCount - 1
  267. If (lstAllKeywords.Selected(intIndex)) Then
  268. lstAllKeywords.Selected(intIndex) = False
  269. intKID = p_rsAllKeywords("KID")
  270. If (Not p_KIDAlreadyInSynonymSet(intKID)) Then
  271. p_rsKeywordsInSynonymSetCopy.AddNew
  272. p_rsKeywordsInSynonymSetCopy("KID") = intKID
  273. p_rsKeywordsInSynonymSetCopy("Keyword") = p_rsAllKeywords("Keyword")
  274. End If
  275. End If
  276. p_rsAllKeywords.MoveNext
  277. Next
  278. p_UpdateKeywordsInSynonymSet
  279. If (Not p_blnCreating) Then
  280. p_SetModeUpdating True
  281. End If
  282. LEnd:
  283. Exit Sub
  284. LErrorHandler:
  285. p_DisplayErrorMessage "cmdAdd_Click"
  286. GoTo LEnd
  287. End Sub
  288. Private Sub cmdRemove_Click()
  289. On Error GoTo LErrorHandler
  290. Dim intIndex As Long
  291. If (p_rsKeywordsInSynonymSetCopy.RecordCount > 0) Then
  292. p_rsKeywordsInSynonymSetCopy.MoveFirst
  293. End If
  294. For intIndex = 0 To lstKeywordsInSynonymSet.ListCount - 1
  295. If (lstKeywordsInSynonymSet.Selected(intIndex)) Then
  296. p_rsKeywordsInSynonymSetCopy.Delete
  297. End If
  298. p_rsKeywordsInSynonymSetCopy.MoveNext
  299. Next
  300. p_UpdateKeywordsInSynonymSet
  301. If (Not p_blnCreating) Then
  302. p_SetModeUpdating True
  303. End If
  304. LEnd:
  305. Exit Sub
  306. LErrorHandler:
  307. p_DisplayErrorMessage "cmdRemove_Click"
  308. GoTo LEnd
  309. End Sub
  310. Private Sub cmdRemoveAll_Click()
  311. On Error GoTo LErrorHandler
  312. Dim intIndex As Long
  313. For intIndex = 0 To lstKeywordsInSynonymSet.ListCount - 1
  314. lstKeywordsInSynonymSet.Selected(intIndex) = True
  315. Next
  316. cmdRemove_Click
  317. LEnd:
  318. Exit Sub
  319. LErrorHandler:
  320. p_DisplayErrorMessage "cmdRemoveAll_Click"
  321. GoTo LEnd
  322. End Sub
  323. Private Sub cmdUpdateCreate_Click()
  324. On Error GoTo LErrorHandler
  325. Dim strName As String
  326. strName = RemoveExtraSpaces(txtName.Text)
  327. If (strName = "") Then
  328. MsgBox "Synonym Set Name cannot be an empty string", vbExclamation + vbOKOnly
  329. txtName.SetFocus
  330. Exit Sub
  331. End If
  332. If (p_blnCreating) Then
  333. p_CreateSynonymSet strName
  334. Else
  335. p_UpdateSynonymSet p_rsAllSynonymSets("EID"), strName
  336. End If
  337. LEnd:
  338. Exit Sub
  339. LErrorHandler:
  340. p_DisplayErrorMessage "cmdUpdateCreate_Click"
  341. GoTo LEnd
  342. End Sub
  343. Private Sub cmdCancel_Click()
  344. On Error GoTo LErrorHandler
  345. If (p_blnCreating) Then
  346. p_SetModeCreating False
  347. ElseIf (p_blnUpdating) Then
  348. p_SetModeUpdating False
  349. End If
  350. p_DisableUpdateCreateCancel
  351. LEnd:
  352. Exit Sub
  353. LErrorHandler:
  354. p_DisplayErrorMessage "cmdCancel_Click"
  355. GoTo LEnd
  356. End Sub
  357. Private Sub cmdClose_Click()
  358. Unload Me
  359. End Sub
  360. Private Sub txtName_KeyPress(KeyAscii As Integer)
  361. On Error GoTo LErrorHandler
  362. p_EnableUpdateCreateCancel
  363. If (Not p_blnCreating) Then
  364. p_SetModeUpdating True
  365. End If
  366. LEnd:
  367. Exit Sub
  368. LErrorHandler:
  369. p_DisplayErrorMessage "txtName_KeyPress"
  370. GoTo LEnd
  371. End Sub
  372. Private Sub p_UpdateAllSynonymSets()
  373. p_clsSynonymSets.GetAllSynonymSetsRs p_rsAllSynonymSets
  374. lstAllSynonymSets.Clear
  375. Do While (Not p_rsAllSynonymSets.EOF)
  376. lstAllSynonymSets.AddItem p_rsAllSynonymSets("Name") & ""
  377. p_rsAllSynonymSets.MoveNext
  378. Loop
  379. End Sub
  380. Private Sub p_UpdateKeywordsInSynonymSet()
  381. lstKeywordsInSynonymSet.Clear
  382. If (p_rsKeywordsInSynonymSetCopy.RecordCount <> 0) Then
  383. p_rsKeywordsInSynonymSetCopy.MoveFirst
  384. End If
  385. Do While (Not p_rsKeywordsInSynonymSetCopy.EOF)
  386. lstKeywordsInSynonymSet.AddItem p_rsKeywordsInSynonymSetCopy("Keyword") & ""
  387. p_rsKeywordsInSynonymSetCopy.MoveNext
  388. Loop
  389. End Sub
  390. Private Sub p_GetAndUpdateKeywordsInSynonymSet(i_intEID As Long)
  391. Dim rs As ADODB.Recordset
  392. Set rs = New ADODB.Recordset
  393. p_clsKeywords.GetKeywordsInSynonymSet i_intEID, rs
  394. CopyRecordSet rs, p_rsKeywordsInSynonymSetCopy
  395. p_UpdateKeywordsInSynonymSet
  396. End Sub
  397. Private Sub p_UpdateAllKeywords()
  398. p_clsKeywords.GetAllKeywordsRs p_rsAllKeywords
  399. lstAllKeywords.Clear
  400. Do While (Not p_rsAllKeywords.EOF)
  401. lstAllKeywords.AddItem p_rsAllKeywords("Keyword") & ""
  402. p_rsAllKeywords.MoveNext
  403. Loop
  404. End Sub
  405. Private Sub p_EnableCreate()
  406. cmdCreate.Enabled = True
  407. End Sub
  408. Private Sub p_DisableCreate()
  409. cmdCreate.Enabled = False
  410. End Sub
  411. Private Sub p_EnableDelete()
  412. cmdDelete.Enabled = True
  413. End Sub
  414. Private Sub p_DisableDelete()
  415. cmdDelete.Enabled = False
  416. End Sub
  417. Private Sub p_DisableSelectedSynonymSet()
  418. fraSelectedSynonymSet.Enabled = False
  419. lblName.Enabled = False
  420. txtName.Enabled = False
  421. lblAllKeywords.Enabled = False
  422. lstAllKeywords.Enabled = False
  423. cmdAdd.Enabled = False
  424. cmdRemove.Enabled = False
  425. cmdRemoveAll.Enabled = False
  426. lblKeywordsInSynonymSet1.Enabled = False
  427. lblKeywordsInSynonymSet2.Enabled = False
  428. lblKeywordsInSynonymSet3.Enabled = False
  429. lstKeywordsInSynonymSet.Enabled = False
  430. p_DisableUpdateCreateCancel
  431. End Sub
  432. Private Sub p_EnableSelectedSynonymSetExceptUpdateCreateCancel()
  433. fraSelectedSynonymSet.Enabled = True
  434. lblName.Enabled = True
  435. txtName.Enabled = True
  436. lblAllKeywords.Enabled = True
  437. lstAllKeywords.Enabled = True
  438. cmdAdd.Enabled = True
  439. cmdRemove.Enabled = True
  440. cmdRemoveAll.Enabled = True
  441. lblKeywordsInSynonymSet1.Enabled = True
  442. lblKeywordsInSynonymSet2.Enabled = True
  443. lblKeywordsInSynonymSet3.Enabled = True
  444. lstKeywordsInSynonymSet.Enabled = True
  445. End Sub
  446. Private Sub p_EnableUpdateCreateCancel()
  447. cmdUpdateCreate.Enabled = True
  448. cmdCancel.Enabled = True
  449. End Sub
  450. Private Sub p_DisableUpdateCreateCancel()
  451. cmdUpdateCreate.Enabled = False
  452. cmdCancel.Enabled = False
  453. End Sub
  454. Private Sub p_NameUpdate()
  455. cmdUpdateCreate.Caption = "Update"
  456. End Sub
  457. Private Sub p_NameCreate()
  458. cmdUpdateCreate.Caption = "Create"
  459. End Sub
  460. Private Sub p_SetModeCreating(i_bln)
  461. If (i_bln) Then
  462. p_blnCreating = True
  463. p_DisableCreate
  464. p_DisableDelete
  465. fraSelectedSynonymSet.Caption = "Creating new Synonym Set"
  466. lblKeywordsInSynonymSet2.Caption = STR_DEFAULT_SYNONYM_SET_NAME_C
  467. p_EnableSelectedSynonymSetExceptUpdateCreateCancel
  468. txtName = ""
  469. txtName.SetFocus
  470. p_GetAndUpdateKeywordsInSynonymSet INVALID_ID_C
  471. p_EnableUpdateCreateCancel
  472. p_NameCreate
  473. Else
  474. p_blnCreating = False
  475. p_EnableCreate
  476. fraSelectedSynonymSet.Caption = "Selected Synonym Set"
  477. lstAllSynonymSets_Click
  478. p_DisableUpdateCreateCancel
  479. p_NameUpdate
  480. End If
  481. End Sub
  482. Private Sub p_SetModeUpdating(i_bln)
  483. If (i_bln) Then
  484. p_blnUpdating = True
  485. p_DisableCreate
  486. p_DisableDelete
  487. p_EnableUpdateCreateCancel
  488. Else
  489. p_blnUpdating = False
  490. p_EnableCreate
  491. lstAllSynonymSets_Click
  492. p_DisableUpdateCreateCancel
  493. End If
  494. End Sub
  495. ' Output in o_arrKeywords(1..Number of keywords)
  496. Private Sub p_GetKeywordsInSynonymSet(o_arrKeywords() As Long)
  497. Dim intIndex As Long
  498. Dim intCount As Long
  499. intCount = lstKeywordsInSynonymSet.ListCount
  500. If (intCount = 0) Then
  501. ReDim o_arrKeywords(0)
  502. Exit Sub
  503. End If
  504. ReDim o_arrKeywords(intCount)
  505. p_rsKeywordsInSynonymSetCopy.MoveFirst
  506. intIndex = 1
  507. Do While (Not p_rsKeywordsInSynonymSetCopy.EOF)
  508. o_arrKeywords(intIndex) = p_rsKeywordsInSynonymSetCopy("KID")
  509. p_rsKeywordsInSynonymSetCopy.MoveNext
  510. intIndex = intIndex + 1
  511. Loop
  512. End Sub
  513. Private Function p_KIDAlreadyInSynonymSet(i_intKID As Long) As Boolean
  514. p_KIDAlreadyInSynonymSet = False
  515. If (p_rsKeywordsInSynonymSetCopy.RecordCount = 0) Then
  516. Exit Function
  517. End If
  518. p_rsKeywordsInSynonymSetCopy.MoveFirst
  519. p_rsKeywordsInSynonymSetCopy.Find "KID = " & i_intKID, , adSearchForward
  520. If (Not p_rsKeywordsInSynonymSetCopy.EOF) Then
  521. p_KIDAlreadyInSynonymSet = True
  522. End If
  523. End Function
  524. Private Sub p_CreateSynonymSet(i_strName As String)
  525. Dim arrKeywords() As Long
  526. p_GetKeywordsInSynonymSet arrKeywords
  527. p_clsSynonymSets.Create i_strName, arrKeywords
  528. p_UpdateAllSynonymSets
  529. p_SetModeCreating False
  530. End Sub
  531. Private Sub p_UpdateSynonymSet(i_intEID As Long, i_strName As String)
  532. Dim arrKeywords() As Long
  533. p_GetKeywordsInSynonymSet arrKeywords
  534. p_clsSynonymSets.Update i_intEID, i_strName, arrKeywords
  535. p_UpdateAllSynonymSets
  536. p_SetModeUpdating False
  537. End Sub
  538. Private Sub p_DisplayErrorMessage( _
  539. ByVal i_strFunction As String _
  540. )
  541. Select Case Err.Number
  542. Case errContainsGarbageChar
  543. MsgBox "The Name " & txtName & " contains garbage characters", _
  544. vbExclamation + vbOKOnly
  545. Case errAlreadyExists
  546. MsgBox "The Name " & txtName & " already exists", _
  547. vbExclamation + vbOKOnly
  548. Case E_FAIL
  549. DisplayDatabaseLockedError
  550. Case errDatabaseVersionIncompatible
  551. DisplayDatabaseVersionError
  552. Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, _
  553. errAuthoringGroupNotPresent
  554. DisplayAuthoringGroupError
  555. Case Else
  556. g_ErrorInfo.SetInfoAndDump i_strFunction
  557. End Select
  558. End Sub
  559. Private Sub p_SetToolTips()
  560. lblAllSynonymSets.ToolTipText = "This is a list of all Synonym Sets that have " & _
  561. "been created for this database."
  562. lstAllSynonymSets.ToolTipText = lblAllSynonymSets.ToolTipText
  563. lblName.ToolTipText = "If you have selected a Synonym Set, its name will appear here. " & _
  564. "If you are creating a new Synonym Set, type in the new name here."
  565. txtName.ToolTipText = lblName.ToolTipText
  566. lblAllKeywords.ToolTipText = "This is a list of all keywords that have been created " & _
  567. "for this database."
  568. lstAllKeywords.ToolTipText = lblAllKeywords.ToolTipText
  569. lblKeywordsInSynonymSet1.ToolTipText = "This is a list of all the keywords that " & _
  570. "the selected synonym set contains."
  571. lblKeywordsInSynonymSet2.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
  572. lblKeywordsInSynonymSet3.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
  573. lstKeywordsInSynonymSet.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
  574. End Sub