/3.2 (Extension.1 Name: "Filter Themes" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 12 Roots: 13 Roots: 14 Version: 32 About: "Sets definition query filters on multiple, active, vector-based themes using values from an attribute field shared by these themes." InstallScript: 15 UninstallScript: 16 ExtVersion: 1 ) (List.2 ) (List.3 Child: 4 ) (List.4 Child: 5 Child: 9 Child: 11 ) (List.5 Child: 6 Child: 7 Child: 8 ) (AVStr.6 S: "View" ) (AVStr.7 S: "ButtonBar" ) (AVStr.8 S: "flt_thms.Main" ) (Butn.9 Help: "Filter Themes//Filter active themes by shared field values. Ctrl = Use same field as last time. Shift = Provide definition options such as add to set or subtract from set.." Tag: "Sname" Icon: 10 Click: "flt_thms.Main" ) (AVIcon.10 Name: "flt_thms.bmp" Data: 4e442049 6d616765 00010012 00110000 Data: 03b8ffff ffffffff ffffffff ffffffff Data: ffffffff ffffffff ffffffff ffffffff Data: ffffffff ffffffff ffffffff ffffffff Data: ffffffff ffffffff 5affffff ff34465a Data: 34465a34 465a3446 5a34465a 34465a00 Data: 00000000 00000000 00000000 00003446 Data: 5a34465a 34465a34 465a3446 5affffff Data: ffffffff ff34465a ffffff34 465affff Data: ff34465a a5e2ffa5 e2ffa5e2 ffa5e2ff Data: a5e2ff34 465affff ff34465a ffffff34 Data: 465a3446 5affffff 5affffff ff34465a Data: 34465a34 465a3446 5a34465a a5e2ffa5 Data: e2ffa5e2 ffa5e2ff 34465a34 465a3446 Data: 5a34465a 34465a34 465a3446 5affffff Data: 5affffff ff34465a 34465aff ffff3446 Data: 5aa5e2ff a5e2ffa5 e2ffa5e2 ffa5e2ff Data: 34465aff ffff3446 5affffff 34465aff Data: ffff3446 5affffff 5affffff ff34465a Data: 34465a34 465a3446 5aa5e2ff a5e2ffa5 Data: e2ffa5e2 ff34465a 34465a34 465a3446 Data: 5a34465a 34465a34 465a3446 5affffff Data: ffffffff ff34465a a5e2ff72 83957283 Data: 95a5e2ff a5e2ffa5 e2ff0000 00000000 Data: 00000072 83957283 95728395 72839534 Data: 465a3446 5affffff ffffffff ff34465a Data: a5e2ffa5 e2ffa5e2 ffa5e2ff a5e2ffa5 Data: e2ffa5e2 ffa5e2ff a5e2ffa5 e2ffa5e2 Data: ffa5e2ff 34465a34 465a3446 5affffff Data: 5affffff ff34465a a5e2ffa5 e2ffa5e2 Data: ffa5e2ff a5e2ffa5 e2ffa5e2 ffa5e2ff Data: a5e2ffa5 e2ffa5e2 ffa5e2ff 34465aff Data: ffff3446 5affffff ffffffff ff34465a Data: 34465a34 465aa5e2 ffa5e2ff a5e2ff34 Data: 465a3446 5a34465a 34465a34 465a3446 Data: 5a34465a 34465a34 465a3446 5affffff Data: 5affffff ff34465a ffffff34 465aa5e2 Data: ffa5e2ff a5e2ff34 465affff ff34465a Data: ffffff34 465affff ff34465a ffffff34 Data: 465a3446 5affffff 00ffffff ff34465a Data: 728395a5 e2ffa5e2 ffa5e2ff a5e2ff00 Data: 00000000 00000000 00000000 00000000 Data: 00000000 00000000 00003446 5affffff Data: ffffffff ff34465a a5e2ffa5 e2ffa5e2 Data: ffa5e2ff a5e2ffa5 e2ffa5e2 ffa5e2ff Data: a5e2ffa5 e2ffa5e2 ffa5e2ff a5e2ffa5 Data: e2ff3446 5affffff 5affffff ff34465a Data: a5e2ffa5 e2ffa5e2 ffa5e2ff a5e2ffa5 Data: e2ffa5e2 ffa5e2ff a5e2ffa5 e2ffa5e2 Data: ffa5e2ff a5e2ff34 465a3446 5affffff Data: 5affffff ff34465a 34465a34 465a3446 Data: 5a34465a 34465a34 465a3446 5a34465a Data: 34465a34 465a3446 5a34465a 34465a34 Data: 465a3446 5affffff 5affffff ff34465a Data: 34465a34 465a3446 5a34465a 34465a34 Data: 465a3446 5a34465a 34465a34 465a3446 Data: 5a34465a 34465a34 465a3446 5affffff Data: 5affffff ffffffff ffffffff ffffffff Data: ffffffff ffffffff ffffffff ffffffff Data: ffffffff ffffffff ffffffff ffffffff Data: ffffffff ffffffff ffff0000 00000001 Data: 00180007 00200001 00020000 00000000 Data: 0000 ) (Numb.11 N: 33.00000000000000 ) (List.12 ) (List.13 ) (Script.14 Name: "flt_thms.Main" SourceCode: "'----------------------------------------------------------------\n' ArcView Extension: Filter Themes\n'\n' Purpose: Sets definition query filters on multiple, active, \n' vector-based themes using values from an attribute field \n' shared by these themes.\n'\n' Author: Greg Krakow \n'\n'----------------------------------------------------------------\n' Copyright (c) 2008 Georgia Department of Natural Resources\n'\n' Permission is hereby granted, free of charge, to any pe rson obtaining \n' a copy of this software and associated documentation files (the \n' \"Software\"), to deal in the Software without restriction, including \n' without limitation the rights to use, copy, modify, merge, publish, \n' distribute, sublicense, and/or sell copies of the Software, and to \n' permit persons to whom the Software is furnished to do so, subject \n' to the following conditions:\n'\n' The above copyright notice and this permission notice shall be \n' included in all copies or substantial portions of the Software.\n'\n' THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, \n' EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF \n' MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. \n' IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY \n' CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, \n' TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE \n' SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n'\n'-------- --------------------------------------------------------\n'\n' Version 1.4 January 12, 2009\n' Text showing theme is filtered now added only once upon \n' sucessive filters.\n'\n' Version 1.3 December 29, 2008\n' Added function showing user if theme is filtered.\n'\n' Version 1.2 September 08, 2008\n' Filter fields to only work with visible fields.\n'\n' Version 1.1 July 11, 2008\n' Fixed bug with quering numeric attributes\n'\n' Version 1.0 May 7, 2008\n'\n'----------------------------------------------------------------\n\n ' Text to show user that theme is filtered.\nfilteredText = \" (Filtered)\"\n\n\n' Provide definition options if Shift key is pressed\nif (System.IsShiftKeyDown) then\n doDefOptions = True\nelse\n doDefOptions = False\nend\n\n' Skip field selection dialog if Control key is pressed\nif (System.IsControlKeyDown) then\n skipFieldDialog = True\nelse\n skipFieldDialog = False\nend\n\n' Get Themes and give error if none are active\ntheView = av.GetActiveDoc\nactiveThemes = theView.GetActiveThemes\nif (activeThemes.Count = 0) then\n theMsg = \"No active themes. Make one or more themes active and \" +\n \"try again.\"\n theTitle = \"Filter Themes Error!\"\n msgbox.error(theMsg, theTitle)\n return nil\nend\n\n' Provide user with various query options such as add to set and\n' subtract from set.\ndefOption = \"\"\nif (doDefOptions) then\n defOptions = {\"Add to Definition\", \n \"Select from Definition\",\n \"Manually Edit Definition\",\n }\n theMsg = \"Select a definition option below.\"\n theTitle = \"Availab le Definition Options\"\n defOption = msgbox.listasstring(defOptions, theMsg, theTitle)\nend\n\n\n' Allow manual edit of query string for all themes\n' Collect all active theme query stirngs and make sure they are \n' all the same before proceeding.\nif (defOption = \"Manually Edit Definition\") then\n queryStrings = {}\n for each activeTheme in activeThemes\n theVTab = activeTheme.GetFTab\n queryStrings.Add(theVTab.GetDefinition)\n end\n queryStrings.RemoveDuplicates\n if (queryStrings.Count = 1) then\n queryS tring = queryStrings.Get(0)\n theMsg = \"Manually edit query for all active themes\"\n theTitle = \"Manual Query Edit\"\n queryString = msgbox.input(theMsg, theTitle, queryString)\n if (queryString = nil) then\n return nil\n end\n for each activeTheme in activeThemes\n theVTab = activeTheme.GetFTab\n theVtab.SetDefinition(queryString)\n theVTab.UpdateDefBitmap \n end\n theView.Invalidate\n elseif (queryStrings.Count > 1) then\n errMsg = \"Definition query strings are not the same in all active \" +\n \"themes. Please use query builder (Hammer Question Mark \" +\n \"Icon) in theme properties to edit definition \" +\n \"query strings individually in each active theme.\"\n errTitle = \"Active Theme Definitions Differ!!!\"\n msgbox.error(errMsg, errTitle)\n end\n return nil\nend\n\n\n' Skip asking for field to query on if control key is pressed.\n' If the query field is not in self tag then run anyway.\ntheQueryField = Self.GetTag\nif ((skipFieldDialog.NOT) or (theQueryField = \"\")) then\n ' Derive a list of attribute fields shared by all themes\n sharedFields = {}\n firstTime = True\n for each t in activeThemes\n theVTab = t.GetFTab\n ' Put current themes's field names into a list\n theFields = theVTab.GetFields\n currentFieldNames = {}\n for each fld in theFields\n ' Only add visible fields to fields list\n if (fld.IsVisible) then \n currentFieldNames.Add(fld.getAlias.AsString)\n end\n end\n currentFieldNames.Remove(0) ' Get rid o f Shape\n if (firstTime = True) then\n sharedFields = currentFieldNames\n firstTime = False\n else\n for each fld in sharedFields.Clone\n if (currentFieldNames.FindByValue(fld) = -1) then\n sharedFields.RemoveObj(fld)\n end\n end\n end\n end\n\n ' Bail out of script if active themes do not share any field names. \n if (SharedFields.Count = 0) then\n theMsg = \"The active themes do not share any field names. \" + \n \"You may need to add a field allias name in the attribute \" +\n \"table under field properties. The field name spelling should \" +\n \"be the same in all active themes. Quitting extension...\" \n theTitle = \"No Shared Field Names!\"\n msgbox.error(theMsg, theTitle)\n return nil\n end\n\n ' Ask user to select field to work with and \n ' allow clearing of definition filter\n sharedFields.Sort(True)\n theClearString = \"* Clear Definition Filter *\"\n theMsg = \"Choose a field for value selection or \" + nl +\n \"allow clearing of definition filter.\"\n theTitle = \"Field Selection\"\n sharedFields.insert(theClearString)\n theQueryField = msgbox.ChoiceAsString(sharedFields, theMsg, theTitle)\n if (theQueryField = nil) then\n return nil\n elseif (theQueryField = theClearString) then\n for each t in activeThemes\n theVTab = t.GetFTab\n theVTab.SetDefinition(\"\")\n\n ' Clear filtered designation from theme name in table of contents.\n themeName = t.GetName.substitute(filteredText, \"\")\n t.SetName(themeName)\n end \n theView.Invalidate\n return nil\n end\nend\n\n' Clear the themes definition to allow for\n' Put current vtab definitions into dictionary \n' value selection from all records\nvtabDefDict = dictionary.Make(10)\nfor each t in activeThemes\n theVTab = t.GetFTab\n vtabDefDict.Add(theVTab, theVTab.GetDefinition)\n theVTab.SetDefinition(\"\")\nend\ntheView.Invalidate\n\n' Derive a list of values for user to select from.\ntheValues = {}\nfor each t in activeThemes\n theVTab = t.GetFTab\n theField = theVTab.FindField(theQu eryField)\n for each rec in theVTab\n theValue = theVTab.ReturnValue(theField, rec)\n if (theValue <> \"\") then\n theValues.Add(theValue.AsString)\n end\n end\nend\n\n' Ask user for values to use in query. Allow multiple wildcard\n' values if user wants.\nbailOut = False\ntheValues.RemoveDuplicates\ntheValues.Sort(True)\ntheValues.RemoveObj(\"\")\nuseWildcards = \"* Partial Field Values Using Wildcards *\"\ntheValues.Insert(useWildcards)\ntheMsg = \"Select one or more below. If needed, select wildcard values \" +\n \"in addition to whole field values.\"\ntheTitle = \"Value Selection for [\" + theQueryField + \"]\"\ntheValues = msgbox.multilistasstring(theValues, theMsg, theTitle)\nif (theValues = nil) then\n bailOut = True\nelseif (theValues.Count = 0) then\n bailOut = True\nelseif (theValues.Get(0) = useWildCards) then\n theValues.Remove(0)\n continueAddingValues = True\n while (continueAddingValues)\n theMsg = \"Manually enter query value using wildcard. \" + \n \"For example, AB* lists all field \" + \n \"values that start with AB; ?atherine would select \" +\n \"both Katherine and Catherine.\"\n theTitle = \"Enter Value Using Wildcard for [\" + \n theQueryField + \"] Field\"\n aValue = msgbox.input(theMsg, theTitle, \"\")\n if (aValue = \"\") then\n bailOut = True\n end\n theValues.Add(aValue)\n theTitle = \"Add Another Wildcard Value for [\" + \n theQueryField + \"] Field?\"\n theMsg = \"Select YES if you want to add another wildcard value.\" + \n nl + \"Select NO to execute definition query now.\"\n continueAddingValues = msgbox.yesno(theMsg, theTitle, FALSE)\n end\n if (theValues.Get(0) = nil) then\n bailOut = True\n end\nend\nif (theValues = Nil) then\n bailOut = True\nelseif (theValues.Count = 0) then\n bailOut = True\nend\n\n' Restore original definition if user bails out early\nif (bailOut = True) then\n for each t in activeThemes\n theVTab = t.GetFTab\n theVTab.SetDefinition(vtabDefDict.Get(theVTab))\n end\n theView.Invalidate\n return nil\nend\n\n' Assemble query string\nqueryString = \"\"\ntheCount = 0\nfor each theValue in theValues\n if (theValue.IsNumber.Not) then\n theValue = theValue.Quote\n end\n currentQuery = \"([\" + theQueryField + \"] = \" + theValue + \")\"\n if (theCount = 0) then\n queryString = currentQuery\n else\n queryString = \"(\" + queryString ++ \n \"or\" ++ currentQuery + \")\"\n end\n theCount = theCount + 1\nend\n\n' Set Definition\nfor each activeTheme in activeThemes\n theVTab = activeTheme.GetFTab\n currentQuery = querySt ring\n theDefString = vtabDefDict.Get(theVTab)\n \n ' If user wants, add to or select from current definition \n if (defOption = \"Add to Definition\") then\n currentQuery = \"(\" + queryString ++ \"or\" ++ theDefString + \")\"\n elseif (defOption = \"Select from Definition\") then\n currentQuery = \"(\" + queryString ++ \"and\" ++ theDefString + \")\"\n end\n \n theVTab.SetDefinition(currentQuery)\n theVTab.UpdateDefBitmap\n \n ' Set current theme to show user that it is filtered if it \n ' isn't already showing that it is filtered.\n themeName = activeTheme.GetName\n if (themeName.Contains(filteredText).NOT) then\n activeTheme.SetName(themeName + filteredText)\n end\nend\n\nself.SetTag(theQueryField)\ntheView.Invalidate\n" ) (Script.15 Name: "My Extension Install" SourceCode: "'DO NOT EDIT!!!\n\nif (av.getproject=nil) then return(nil) end\n\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheMenuList = SELF.get(2)\ntheToolMenuList=SELF.Get(3)\ntheProject=Av.getproject\n\n\n'Add the Docs\n'\nfor each adoc in theDocs\n theProject.addDoc(adoc)\nend\n\n'Add the Controls\n'\nfor each totalControl in theControlList\n 'The Control list\n acontrol=totalControl.get(0)\n \n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This finds the control set \n thecommand=\"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=thescript1.doit(\"\")\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex )\nend\n\n\n'Add the menus\nfor each totalcontrol in theMenuList\n \n 'The Control list\n acontrol=totalControl.get(0)\n mDoc=acontrol.get(0)\n mMenu=acontrol.get(1)\n mMenuItem=acontrol.get(2)\n\n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the c urrent project.\",\"Script Eror\")\n return(nil)\n end\n \n theMbar=av.getproject.findGUI(mDoc).GetMenuBar\n themenu=theMbar.findbylabel(mMenu)\n if (themenu=NiL) then\n themenu=menu.make\n themenu.setlabel(mMenu)\n theMbar.add(themenu,999)\n end\n \n themenu.add(thecontrol, theCindex)\nend\n \n \n'Add the Tool Menus\n\nfor each totalControl in theToolMenuList\n 'The Control list\n acontrol=totalControl.get(0)\n \n 'The physical control\n theControl = totalControl.get(1)\n \n 'The con trol Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This finds the control set \n thecommand=\"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=av.getproject.findGUI(aControl.get(0)).GetToolBa r\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex)\nend\n\n\nav.getproject.setmodified(true)\n\n\n'And the scripts add themselves\n" ) (Script.16 Name: "My Extension Uninstall" SourceCode: "'DO NOT EDIT!!!\n\n'The SELF is the Extension\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheMenuList = SELF.get(2)\ntheToolMenuList=SELF.get(3)\ntheProject=Av.getproject\n\n\n'Add the Docs\n'\nfor each adoc in theDocs\n If (theProject.finddoc(adoc.getname)<>NIL) then \n theAnswer=msgbox.yesno(\"Remove the Document \"+adoc.getname+\"?\",\"Remove Document?\",TRUE)\n if (theAnswer=TRUE) then theProject.RemoveDoc(adoc) end\n end\nend\n\n'Removethe Controls\n'\nfor each totalControl in theControlList\n 'Get the control list from the Ext\n acontrol=totalControl.get(0)\n \n 'Get the physical Control\n theControl = totalControl.get(1)\n \n 'Get the Controls Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI for the Control\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This sequence finds the appropiate control set\n thecommand= \"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=thescript1.doit(\"\")\n\n 'See if the control is in the set , if so remove it\n if (theControlSet.GetControls.find(theControl)<>NIL) then\n theControlSet.remove(theControl)\n if (thecontrol = \"ToolBar\") then\n theControlSet.selectdefault\n end\n end\nend\n\n\n'Remove the Menus\n'\nfor each totalcontrol in theMenuList\n \n 'The Control list\n acontrol=totalControl.get(0 )\n mDoc=acontrol.get(0)\n mMenu=acontrol.get(1)\n mMenuItem=acontrol.get(2)\n\n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n theMbar=av.getproject.findGUI(mDoc).GetMenuBar\n themenu=theMbar.findbylabel(mMenu)\n if (themenu=NiL) then\n MsgBox.Warning(\"The menu named \"+mMenu+\" is not here.\",\"Script Eror\")\n 'return(nil)\n else\n \n thething=themenu.getcontrols.find(thecontrol)\n if (thething<>NIL) then \n themenu.remove(thecontrol) \n end\n 'msgbox.info(themenu.GetControls.count.asstring,\"\")\n if (themenu.GetControls.count<1) then\n theMbar.remove(themenu)\n end\n end\nend\n \nfor each totalControl in theToolMenuList\n 'Get the control list from the Ext\n acontrol=totalControl.get(0)\n \n 'Get the physical Control\n theControl = totalControl.get(1)\n \n 'Get the Controls Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI for the Control\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This sequence finds the appropiate control set\n thecontrolset=av.getp roject.findGUI(aControl.get(0)).GetToolBar\n\n \n 'See if the control is in the set , if so remove it\n if (theControlSet.GetControls.find(theControl)<>NIL) then\n \n theControlSet.remove(theControl)\n theControlSet.selectdefault\n end\n\nend\n \n\n'And the scripts delete themselves\n\n\nav.getproject.setmodified(true)\n" )