XMetaL Tips and Tricks

XMetaL Community Forum XMetaL Tips and Tricks Script Example: Collapse and Expand All Elements

  • Derek Read

    Script Example: Collapse and Expand All Elements

    Participants 1
    Replies 0
    Last Activity 12 years, 6 months ago

    XMetaL Author (Enterprise or Essential) 6.0
    Tested in XMetaL Author Enterprise

    Add three macros that provide functionality for collapsing all elements of a particular type (same name) as the currently selected element:

    Shortcut Key:   What it Does:
    Ctrl+Alt+K   Collapse all elements at this nesting level
    Ctrl+Alt+Shift+K   Collapse all elements at any level
    Ctrl+Alt+X   Expand All Elements

    A fourth macro adds these items to the Context Menu to provide easy access (for people that do not like to memorize shortcuts).

    Suggested Usage:
    Your large document consists of a (root element) containing many chapters and you wish to see the content of one chapter only. Place your cursor inside any element (so that “book/chapter” appears in the mini-context menu below the document next to the view mode buttons) then press Ctrl+Alt+K (or select the corresponding context menu item). All elements will be collapsed. You can then expand the single chapter you wish to work on by clicking the '+' symbol on the start tag <+ chapter>.

    * Licensed Materials – Property of JustSystems, Canada, Inc.
    * (c) Copyright JustSystems Canada, Inc. 2010
    * All rights reserved.
    * The sample contained herein is provided to you “AS IS”.
    * It is furnished by JustSystems Corporation as a simple example and has not been
    * thoroughly tested under all conditions. JustSystems Canada, Inc., therefore, cannot
    * guarantee its reliability, serviceability or functionality.
    * This sample may include the names of individuals, companies, brands and products
    * in order to illustrate concepts as completely as possible. All of these names are
    * fictitious and any similarity to the names and addresses used by actual persons or
    * business enterprises is entirely coincidental.

    Script Installation and Usage:
    Important: This script is being made available for use by experienced users, administrators and/or IT departments (people that manage the installation and configuration of an XMetaL deployment). Test this script in a test environment (non-production machine) before distributing to end users. This is unsupported demo code.
       1. Download collapseExpandElements.zip.
       2. Unzip the file to an empty folder of your choice.
       3. Examine the code contained in the MCR file and integrate it into your XMetaL Author customization. The MCR file has been written so that it may simply be dropped into the Startup folder to provide this functionality to all DTDs and Schemas (it is an application-level macro).

    The MCR file adds three items to the standard Context Menu. You may wish to add a toolbar or menu items to allow users to run these macros as well. You may also not like the shortcut keys that I have chosen – you can modify them in the MCR file directly (via any text editor), or import the MCR file into your XMetaL Developer project using Developer's MCR import feature and then reassign keys to each macro before rebuilding your project.

    The concept demonstrated here could be extended to allow for more specific collapsing options. Perhaps for elements with the same attribute or elements with the same attribute and attribute value, etc.


  • You must be logged in to reply to this topic.

Lost Your Password?