Pages: 1
Print
Author Topic: Script Example: Collapse and Expand All Elements  (Read 3119 times)
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2618



WWW
« on: July 29, 2010, 05:53:35 PM »

Product(s):
XMetaL Author (Enterprise or Essential) 6.0
Tested in XMetaL Author Enterprise 6.0.1.030

Description:
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 <elementname> elements at this nesting level
Ctrl+Alt+Shift+K  Collapse all <elementname> 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 <book> (root element) containing many chapters and you wish to see the content of one chapter only. Place your cursor inside any <chapter> 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 <chapter> 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>.

Legal:
* 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 <XMetaL Author Install Path>\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.

* demo_collapseExpandElements.zip (1.64 KB - downloaded 404 times.)

* collapseExpandElementsContextMenu.jpg (206.33 KB, 1003x695 - viewed 783 times.)
« Last Edit: July 30, 2010, 01:17:49 AM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us