// Copyright (C) 1997-2004 Alias Systems Corp. // // The information in this file is provided for the exclusive use of the // licensees of Alias. Such users have the right to use, modify, // and incorporate this code into other products for purposes authorized // by the Alias license agreement, without fee. // // ALIAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO // EVENT SHALL ALIAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. // // Alias Script File // MODIFY THIS AT YOUR OWN RISK // // Creation Date: 28 June 1996 // // // Procedure Name: // createNewLayer // // Description: // This procedure creates a new set, based on the // name that the user types in, and adds a menu item // the the optionPopup called "layerPopup" that // corresponds to the newly created set/layer. // // Input Arguments: // None. // // Return Value: // None. // proc int isValidName( string $name ) // Description: // This procedure checks if the given string is a valid object // name. It returns true if it is, false otherwise. // { int $isValid = true; // check if name contains invalid characters string $regex = "[^0-9a-zA-Z_]"; string $match = match( $regex, $name ); if ($match != "") { $isValid = false; confirmDialog -title "Alert" -button "OK" -defaultButton "OK" -message " Name contains illegal characters. Please select another. "; } else { // check if name begins with an alphabetic character $regex = "[a-zA-Z_][0-9a-zA-Z_]*"; $match = match( $regex, $name ); if ($match != $name) { $isValid = false; confirmDialog -title "Alert" -button "OK" -defaultButton "OK" -message " Name is not valid. Please select another. "; } } return $isValid; } global proc editLayerName () { // Query the current name of the active layer string $currentLayerName = `optionMenu -query -value layerPopup`; // If it's not the default universe layer then place dialogue if ($currentLayerName != "Universe") { // // Prompt the user for a new layer name // string $result = `promptDialog -title "Rename Layer" -message "Enter New Layer Name:" -text $currentLayerName -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; // // If the result was "OK", then proceed // if ( $result == "OK" ) { // // Query the promptDialog for the name the // user typed in - note: there is no checking // being done for illegal characters, spaces, // etc. This should be added. // // The set is created in the layer partition // first, then the elements are forced into // the set, so that exclusivity can be maintained, // and the set creation won't fail before it's // even created. // string $newLayerName = `promptDialog -q`; if ( isValidName($newLayerName) ) { if (catch($newLayerName = `rename $currentLayerName $newLayerName`)) { // // error due to non - unique name for context // confirmDialog -title "Alert" -button "OK" -defaultButton "OK" -message " Error in trying to rename Layer. Please select another "; } else { string $layerEntryName = ( $newLayerName + "LayerItem" ); string $oldLayerEntryName = ( $currentLayerName + "LayerItem" ); // change the label of the menu item and rename // the menu item menuItem -e -l $newLayerName $oldLayerEntryName; renameUI $oldLayerEntryName $layerEntryName; } } } } else { warning( "Universe layer cannot be renamed" ); } }