提交 fb4531a3 authored 作者: noelgrandin's avatar noelgrandin

H2 console: add SHIFT+ENTER "run selected" functionality

上级 a97193f8
......@@ -50,6 +50,7 @@ Change Log
</li><li>Issue 528: Add Oracle-compatible TO_CHAR function, patch by Daniel Gredler.
</li><li>Issue 534: CREATE ALIAS NOCACHE, Patch by Nicolas Fortin
</li><li>Fix an issue with storing Unicode surrogate pairs in CLOB columns.
</li><li>H2 console: add SHIFT+ENTER "run selected" functionality
</li></ul>
<h2>Version 1.3.174 (2013-10-19)</h2>
......
......@@ -46,6 +46,7 @@ helpDisconnect=Disconnects from the database
helpDisplayThis=Displays this Help Page
helpDropTable=Delete the table if it exists
helpExecuteCurrent=Executes the current SQL statement
helpExecuteSelected=Executes the SQL statement defined by the text selection
helpIcon=Icon
helpImportantCommands=Important Commands
helpOperations=Operations
......@@ -101,6 +102,7 @@ toolbar.maxRows=Max rows
toolbar.refresh=Refresh
toolbar.rollback=Rollback
toolbar.run=Run (Ctrl+Enter)
toolbar.runSelected=Run Selected (Shift+Enter)
toolbar.sqlStatement=SQL statement
tools.backup=Backup
tools.backup.help=Creates a backup of a database.
......
......@@ -82,10 +82,21 @@ Initial Developer: H2 Group
</select>&nbsp;
</td>
<td class="toolbar">
<a href="javascript:top.frames['h2query'].document.forms['h2query'].submit();"><img src="icon_run.gif"
onmouseover="this.className ='icon_hover'"
onmouseout="this.className ='icon'"
class="icon" alt="${text.toolbar.run}" title="${text.toolbar.run}" border="1">
<a href="javascript:top.frames['h2query'].submitAll();">
<img src="icon_run.gif"
onmouseover="this.className ='icon_hover'"
onmouseout="this.className ='icon'"
class="icon" alt="${text.toolbar.run}"
title="${text.toolbar.run}" border="1">
</a>
</td>
<td class="toolbar">
<a href="javascript:top.frames['h2query'].submitSelected();">
<img src="icon_run_selected.gif"
onmouseover="this.className ='icon_hover'"
onmouseout="this.className ='icon'"
class="icon" alt="${text.toolbar.runSelected}"
title="${text.toolbar.runSelected}" border="1">
</a>
</td>
<td class="toolbar">
......
......@@ -39,11 +39,17 @@ function set(s) {
</td>
</tr>
<tr>
<td style="padding:0px"><img src="icon_run.gif" alt="${text.toolbar.run}"/></td>
<td style="padding:0px"><img src="icon_run_selected.gif" alt="${text.toolbar.run}"/></td>
<td style="vertical-align: middle;">
${text.helpExecuteCurrent}
</td>
</tr>
<tr>
<td style="padding:0px"><img src="icon_run.gif" alt="${text.toolbar.runSelected}"/></td>
<td style="vertical-align: middle;">
${text.helpExecuteSelected}
</td>
</tr>
<tr>
<td style="padding:0px"><img src="icon_disconnect.gif" alt="${text.toolbar.disconnect}"/></td>
<td style="vertical-align: middle;">
......
......@@ -204,7 +204,11 @@ function keyDown(event) {
}
if (key == 13 && (event.ctrlKey || event.metaKey)) {
// ctrl + return, cmd + return
document.h2query.submit();
submitAll();
return false;
} else if(key == 13 && event.shiftKey) {
// shift + return
submitSelected();
return false;
} else if(key == 32 && (event.ctrlKey || event.altKey)) {
// ctrl + space
......@@ -265,13 +269,17 @@ function keyDown(event) {
}
function keyUp(event) {
var key = event == null ? 0 : (event.keyCode ? event.keyCode : event.charCode);
if(autoComplete != 0) {
var key=event == null ? 0 : (event.keyCode? event.keyCode : event.charCode);
if(key != 37 && key != 38 && key != 39 && key != 40) {
// left, right, up, down: don't show autocomplete
showAutoComplete();
}
}
if(key == 13 && event.shiftKey) {
// shift + return
return false;
}
return true;
}
......@@ -448,13 +456,35 @@ function processAsyncResponse() {
}
}
function submitAll() {
document.h2querysubmit.sql.value = document.h2query.sql.value;
document.h2querysubmit.submit();
}
function submitSelected() {
var field = document.h2query.sql;
//alert('contents ' + field.selectionStart + ' ' + field.selectionEnd);
if (field.selectionStart == field.selectionEnd) {
return;
}
var startPos = field.selectionStart;
var endPos = field.selectionEnd;
var selectedText = field.value.substring(startPos, endPos);
document.h2querysubmit.sql.value = selectedText;
document.h2querysubmit.submit();
}
//-->
</script>
</head>
<body onresize="sizeTextArea();" onload="sizeTextArea();" style="margin: 0px; padding: 0px;">
<form name="h2query" method="post" action="query.do?jsessionid=${sessionId}" target="h2result">
<form name="h2querysubmit" method="post" action="query.do?jsessionid=${sessionId}" target="h2result" style="display:none">
<input type="text" id="sql" name="sql">
</form>
<form name="h2query" action="javascript:alert('should not be submitting this form');">
<span style="white-space:nowrap">
<input type="button" class="button" value="${text.toolbar.run}" onclick="javascript:submit();sql.focus();return true;" />
<input type="button" class="button" value="${text.toolbar.run}" onclick="javascript:submitAll();sql.focus();return true;" />
<input type="button" class="button" value="${text.toolbar.runSelected}" onclick="javascript:submitSelected();sql.focus();return true;" />
<input type="button" class="button" value="${text.toolbar.clear}" onclick="javascript:sql.value='';keyUp();sql.focus();return true;" />
${text.toolbar.sqlStatement}:
</span>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论