{"hidden":false,"children":[{"configs":{"itemId":"sys.util.sqlBuilder"},"expanded":true,"children":[{"configs":{"layout":"border","itemId":"win","dialog":"true","createInstance":"false","resizable":"true","width":"800","autoShow":"true","title":"SQL生成器","iconCls":"sql_icon","modal":"true","maximizable":"true","height":"450"},"expanded":true,"children":[{"configs":{"itemId":"toolbar1","weight":"80","region":"north"},"expanded":true,"children":[{"configs":{"itemId":"selectBtn","pressed":"true","toggleGroup":"sql","tooltip":"显示select语句","text":"select"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"insertBtn","toggleGroup":"sql","tooltip":"显示insert语句","text":"insert"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"updateBtn","toggleGroup":"sql","tooltip":"显示update语句","text":"update"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"deleteBtn","toggleGroup":"sql","tooltip":"显示delete语句","text":"delete"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"sp","toggleGroup":"sql","text":"-"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"nativeBtn","toggleGroup":"type","tooltip":"显示原生语句","text":"原生"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"paramsBtn","pressed":"true","toggleGroup":"type","tooltip":"显示参数宏语句","text":"参数"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"replaceBtn","toggleGroup":"type","tooltip":"显示替换宏语句","text":"替换"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"sp1","toggleGroup":"sql","text":"-"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"prefixText","emptyText":"select 表名前缀","width":"150"},"expanded":false,"children":[],"type":"text","events":{"change":"createSQL();"}}],"type":"toolbar"},{"configs":{"itemId":"tableTree","split":"true","plugins":"{ptype:'bufferedrenderer'}","width":"200","region":"west","title":"数据库列表","iconCls":"db_icon","collapsible":"true","rootVisible":"false"},"expanded":true,"children":[{"configs":{"itemId":"store","fields":"['text', 'jndi', 'type', 'schema', 'table']","url":"m?xwl=dev/ide/sql-builder/get-tree"},"expanded":false,"children":[],"type":"treestore","events":{"beforeload":"operation.params = operation.node.data;"}},{"configs":{"itemId":"tools"},"expanded":true,"children":[{"configs":{"itemId":"refreshBtn","tooltip":"刷新","tooltype":"refresh"},"expanded":false,"children":[],"type":"item","events":{"click":"Wb.reload(app.tableTree);"}}],"type":"array"}],"type":"tree","events":{"selectionchange":"createSQL();"}},{"configs":{"itemId":"sqlPanel","html":"<textarea><\/textarea>","region":"center"},"expanded":false,"children":[],"type":"panel","events":{"afterrender":"panel.editor = CodeMirror.fromTextArea(panel.el.down('textarea', true), {\n  mode: 'text/x-sql',\n  lineWrapping: true,\n  matchBrackets: true\n});\napp.editor = panel.editor;","resize":"if (panel.editor && !panel.destroying) {\n  Ext.fly(panel.editor.getScrollerElement()).setHeight(height);\n  panel.editor.refresh();\n}"}}],"type":"window","events":{"afterrender":"app.toolbar1.items.each(function(btn) {\n  if (btn.itemId != 'sp') {\n    btn.allowDepress = false;\n    btn.mon(btn, 'toggle', createSQL);\n  }\n});","ok":"app.callback(app.editor.getValue());\nwin.close();"}}],"type":"module","events":{"initialize":"//私有方法\nfunction createSQL() {\n  var node = app.tableTree.getSelection()[0];\n  if (!node || !node.isLeaf())\n    return;\n  var params = [];\n  app.toolbar1.items.each(function(btn) {\n    if (btn.pressed)\n      params.push(btn.itemId.slice(0, -3));\n  });\n  Wb.request({\n    url: 'm?xwl=dev/ide/sql-builder/create-clause',\n    mask: app.sqlPanel,\n    params: {\n      sql: params[0],\n      type: params[1],\n      jndi: node.data.jndi,\n      table: Wb.addPrefix(node.data.schema, node.data.table),\n      prefix: app.prefixText.getValue()\n    },\n    success: function(resp) {\n      app.editor.setValue(resp.responseText);\n    }\n  });\n}\n\nfunction showWin() {\n  function doShow() {\n    var sqlWin;\n\n    //单例模式\n    if (Wb.hasNS('sys.util.sqlBuilder.winInstance'))\n      sqlWin = sys.util.sqlBuilder.winInstance;\n    else {\n      sqlWin = new Ext.window.Window(app.win);\n      app.winInstance = sqlWin;\n    }\n    sqlWin.show();\n  }\n  if (window.CodeMirror)\n    doShow();\n  else {\n    Wb.addLink(['wb/libs/cm/cmirror.css', 'wb/libs/cm/cmirror.js'],\n      doShow\n    );\n  }\n}\n\n//公有方法，可通过app.method来访问\nWb.apply(app, {\n  /**\n   * @param {Function} [callback] 点击确定按钮后执行的方法，传递参数为编辑器SQL。\n   */\n  getSQL: function(callback) {\n    app.callback = callback;\n    showWin();\n  }\n});"}}],"roles":{},"title":"SQL 生成器","iconCls":"","inframe":false,"pageLink":""}