home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / COMPLETEPAGE.SCRIPT < prev    next >
Encoding:
Text File  |  2002-07-03  |  1.5 KB  |  51 lines

  1. !!Script
  2. // Copyright ⌐ 2002 - Miguel Angel Rojas Gonzßlez.
  3.  
  4. /**
  5. @Tool: completePage~completes a page tag with empty attributes 
  6. @EndTool: 
  7. @Summary: completePage~completes a page tag 
  8. */
  9.  
  10. function DoCommand()
  11. {
  12.   var path = File.getToolsPath() + "\\Smartkeys\\jsp\\completePage.script";
  13.   Application.registerSmartKeyHandler(".jsp", "page\t", path, 
  14.     "Complete: page<tab> with <%@ page language=\"java\" import=\"\" %>");
  15. }
  16.  
  17. function OnEvent(editor,lineBuffer)
  18. {
  19.     var idx = lineBuffer.indexOf( "<%@" );
  20.     
  21.     if ( idx != -1 )
  22.     {
  23.         var selection = editor.getSelection();
  24.         editor.replace(" language=\"java\" import=\"\" %>", selection); 
  25.         
  26.         editor.select( selection.startLineIndex, selection.endCharIndex + 25, 
  27.         selection.startLineIndex, selection.endCharIndex + 25 );
  28.         
  29.         editor.setActive("Complete page");
  30.         return true;
  31.     }
  32.     else
  33.     {
  34.         idx = lineBuffer.indexOf( "page" );
  35.         var selection = editor.getSelection();
  36.         var sCurr     = lineBuffer.substring( 0, idx );
  37.         var vPage     = sCurr + "<%@ page language=\"java\" import=\"\" %>" + lineBuffer.substring( idx+4, lineBuffer.length );
  38.         editor.replace( vPage, selection.startLineIndex );
  39.         
  40.         editor.select( selection.startLineIndex, selection.endCharIndex + 29, 
  41.         selection.startLineIndex, selection.endCharIndex + 29 );
  42.         
  43.         editor.setActive("Complete page");
  44.         return true;
  45.     }
  46. }
  47.  
  48. !!/Script
  49.  
  50.  
  51.