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

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