|
From: <tob...@us...> - 2014-05-14 17:09:04
|
Revision: 8319
http://sourceforge.net/p/bigdata/code/8319
Author: tobycraig
Date: 2014-05-14 17:09:02 +0000 (Wed, 14 May 2014)
Log Message:
-----------
Highlight errors in queries/updates
Modified Paths:
--------------
branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css
branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js
Modified: branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css
===================================================================
--- branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css 2014-05-14 17:01:37 UTC (rev 8318)
+++ branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css 2014-05-14 17:09:02 UTC (rev 8319)
@@ -280,6 +280,19 @@
font-family: monospace;
}
+/* make cursor visible in error highlighting */
+div.CodeMirror-cursors {
+ z-index: 3;
+}
+
+.error-line {
+ background: red;
+}
+
+.error-character {
+ background: green;
+}
+
#page-selector {
float: right;
}
Modified: branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js
===================================================================
--- branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js 2014-05-14 17:01:37 UTC (rev 8318)
+++ branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js 2014-05-14 17:09:02 UTC (rev 8319)
@@ -2,9 +2,15 @@
// global variables
var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACE_URL, NAMESPACES_READY, NAMESPACE_SHORTCUTS, FILE_CONTENTS, QUERY_RESULTS;
-var QUERY_EDITOR, UPDATE_EDITOR;
+var CODEMIRROR_DEFAULTS, EDITORS = {}, ERROR_LINE_MARKERS = {}, ERROR_CHARACTER_MARKERS = {};
var PAGE_SIZE = 50, TOTAL_PAGES, CURRENT_PAGE;
+CODEMIRROR_DEFAULTS = {
+ lineNumbers: true,
+ mode: 'sparql',
+ extraKeys: {'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight}
+};
+
// debug to access closure variables
$('html, textarea, select').bind('keydown', 'ctrl+d', function() { debugger; });
@@ -49,10 +55,8 @@
if(!nohash && window.location.hash.substring(1).indexOf(tab) != 0) {
window.location.hash = tab;
}
- if(tab == 'query') {
- QUERY_EDITOR.refresh();
- } else if(tab == 'update') {
- UPDATE_EDITOR.refresh();
+ if(EDITORS[tab]) {
+ EDITORS[tab].refresh();
}
}
@@ -379,7 +383,7 @@
mode = rdf_modes[type];
}
}
- UPDATE_EDITOR.setOption('mode', mode);
+ EDITORS.update.setOption('mode', mode);
}
// .xml is used for both RDF and TriX, assume it's RDF
@@ -420,9 +424,14 @@
$('#update-update').click(submitUpdate);
-UPDATE_EDITOR = CodeMirror.fromTextArea($('#update-box')[0], {lineNumbers: true, mode: 'sparql',
- extraKeys: {'Ctrl-Enter': submitUpdate, 'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight}
+EDITORS.update = CodeMirror.fromTextArea($('#update-box')[0], CODEMIRROR_DEFAULTS);
+EDITORS.update.on('change', function() {
+ if(ERROR_LINE_MARKERS.update) {
+ ERROR_LINE_MARKERS.update.clear();
+ ERROR_CHARACTER_MARKERS.update.clear();
+ }
});
+EDITORS.update.addKeyMap({'Ctrl-Enter': submitUpdate});
function submitUpdate(e) {
// Updates are submitted as a regular form for SPARQL updates in monitor mode, and via AJAX for non-monitor SPARQL, RDF & file path updates.
@@ -437,7 +446,7 @@
var settings = {
type: 'POST',
- data: FILE_CONTENTS == null ? UPDATE_EDITOR.getValue() : FILE_CONTENTS,
+ data: FILE_CONTENTS == null ? EDITORS.update.getValue() : FILE_CONTENTS,
success: updateResponseXML,
error: updateResponseError
}
@@ -538,9 +547,14 @@
}
});
-QUERY_EDITOR = CodeMirror.fromTextArea($('#query-box')[0], {lineNumbers: true, mode: 'sparql',
- extraKeys: {'Ctrl-Enter': submitQuery, 'Ctrl-,': moveTabLeft, 'Ctrl-.': moveTabRight}
+EDITORS.query = CodeMirror.fromTextArea($('#query-box')[0], CODEMIRROR_DEFAULTS);
+EDITORS.query.on('change', function() {
+ if(ERROR_LINE_MARKERS.query) {
+ ERROR_LINE_MARKERS.query.clear();
+ ERROR_CHARACTER_MARKERS.query.clear();
+ }
});
+EDITORS.query.addKeyMap({'Ctrl-Enter': submitQuery});
function submitQuery(e) {
try {
@@ -548,8 +562,13 @@
} catch(e) {}
// transfer CodeMirror content to textarea
- QUERY_EDITOR.save();
+ EDITORS.query.save();
+ // do nothing if query is empty
+ if($('#query-box').val().trim() == '') {
+ return;
+ }
+
var settings = {
type: 'POST',
data: $('#query-form').serialize(),
@@ -811,21 +830,9 @@
if(match) {
// highlight character at error position
var line = match[1] - 1;
- var column = match[2] - 1;
- var input = $('#' + pane + '-box').val();
- var lines = input.split('\n');
- var container = '#' + pane + '-errors';
- $(container).html('');
- for(var i=0; i<line; i++) {
- var p = $('<p>').text(lines[i]);
- $(container).append(p);
- }
- $(container).append('<p class="error-line">');
- $(container + ' .error-line').append(document.createTextNode(lines[line].substr(0, column)));
- $(container + ' .error-line').append($('<span class="error-character">').text(lines[line].charAt(column) || ' '));
- $(container + ' .error-line').append(document.createTextNode(lines[line].substr(column + 1)));
- $(container).show();
- $('#' + pane + '-box').scrollTop(0);
+ var character = match[2] - 1;
+ ERROR_LINE_MARKERS[pane] = EDITORS.query.doc.markText({line: line, ch: 0}, {line: line}, {className: 'error-line'});
+ ERROR_CHARACTER_MARKERS[pane] = EDITORS.query.doc.markText({line: line, ch: character}, {line: line, ch: character + 1}, {className: 'error-character'});
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tob...@us...> - 2014-05-26 16:13:58
|
Revision: 8420
http://sourceforge.net/p/bigdata/code/8420
Author: tobycraig
Date: 2014-05-26 16:13:54 +0000 (Mon, 26 May 2014)
Log Message:
-----------
#891 - Added dropdown groups for namespaces
Modified Paths:
--------------
branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css
branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js
Modified: branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css
===================================================================
--- branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css 2014-05-26 14:40:47 UTC (rev 8419)
+++ branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/css/style.css 2014-05-26 16:13:54 UTC (rev 8420)
@@ -188,27 +188,6 @@
overflow: hidden;
}
-.namespace-shortcuts {
- float: right;
- margin-bottom: 20px;
-}
-
-.namespace-shortcuts li {
- display: inline-block;
- border: 1px solid #e4e4e4;
- padding: 5px;
- margin-left: 5px;
- cursor: pointer;
- width: 40px;
- text-align: center;
-}
-
-.namespace-shortcuts li:hover {
- border-color: #b7b7b7;
- background-color: #b7b7b7;
- color: #ededed;
-}
-
#query-form, #update-box-container {
clear: both;
}
Modified: branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js
===================================================================
--- branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js 2014-05-26 14:40:47 UTC (rev 8419)
+++ branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js 2014-05-26 16:13:54 UTC (rev 8420)
@@ -214,34 +214,51 @@
/* Namespace shortcuts */
NAMESPACE_SHORTCUTS = {
- 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
- 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
- 'owl': 'http://www.w3.org/2002/07/owl#',
- 'bd': 'http://www.bigdata.com/rdf#',
- 'bds': 'http://www.bigdata.com/rdf/search#',
- 'gas': 'http://www.bigdata.com/rdf/gas#',
- 'foaf': 'http://xmlns.com/foaf/0.1/',
- 'hint': 'http://www.bigdata.com/queryHints#',
- 'dc': 'http://purl.org/dc/elements/1.1/',
- 'xsd': 'http://www.w3.org/2001/XMLSchema#'
+ 'Bigdata': {
+ 'bd': 'http://www.bigdata.com/rdf#',
+ 'bds': 'http://www.bigdata.com/rdf/search#',
+ 'gas': 'http://www.bigdata.com/rdf/gas#',
+ 'hint': 'http://www.bigdata.com/queryHints#'
+ },
+ 'W3C': {
+ 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+ 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
+ 'owl': 'http://www.w3.org/2002/07/owl#',
+ 'skos': 'http://www.w3.org/2004/02/skos/core#',
+ 'xsd': 'http://www.w3.org/2001/XMLSchema#'
+ },
+ 'Dublic Core': {
+ 'dc': 'http://purl.org/dc/elements/1.1/',
+ 'dcterm': 'http://purl.org/dc/terms/',
+ 'void': 'http://rdfs.org/ns/void#'
+ },
+ 'Social/Other': {
+ 'foaf': 'http://xmlns.com/foaf/0.1/',
+ 'schema': 'http://schema.org/',
+ 'sioc': 'http://rdfs.org/sioc/ns#'
+ }
};
-$('.namespace-shortcuts').html('<ul>');
-for(var ns in NAMESPACE_SHORTCUTS) {
- // cannot use data-ns attribute on li, as jQuery mangles namespaces that don't end with #, adding </li> to them
- var li = $('<li>' + ns.toUpperCase() + '</li>');
- li.data('ns', 'prefix ' + ns + ': <' + NAMESPACE_SHORTCUTS[ns] + '>');
- li.appendTo('.namespace-shortcuts ul');
+$('.namespace-shortcuts').html('');
+for(var category in NAMESPACE_SHORTCUTS) {
+ var select = $('<select><option>' + category + '</option></select>').appendTo($('.namespace-shortcuts'));
+ for(var ns in NAMESPACE_SHORTCUTS[category]) {
+ select.append('<option value="' + NAMESPACE_SHORTCUTS[category][ns] + '">' + ns + '</option>');
+ }
}
-$('.namespace-shortcuts li').click(function() {
+$('.namespace-shortcuts select').change(function() {
+ var uri = this.value;
var tab = $(this).parents('.tab').attr('id').split('-')[0];
var current = EDITORS[tab].getValue();
- var ns = $(this).data('ns');
- if(current.indexOf(ns) == -1) {
- EDITORS[tab].setValue(ns + '\n' + current);
+ if(current.indexOf(uri) == -1) {
+ var ns = $(this).find(':selected').text();
+ EDITORS[tab].setValue('prefix ' + ns + ': <' + uri + '>\n' + current);
}
+
+ // reselect group label
+ this.selectedIndex = 0;
});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tob...@us...> - 2014-06-02 17:09:13
|
Revision: 8437
http://sourceforge.net/p/bigdata/code/8437
Author: tobycraig
Date: 2014-06-02 17:09:07 +0000 (Mon, 02 Jun 2014)
Log Message:
-----------
#960 & #961 - Added namespace properties export and namespace clone functionality
Modified Paths:
--------------
branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/index.html
branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js
Modified: branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/index.html
===================================================================
--- branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/index.html 2014-06-02 16:43:56 UTC (rev 8436)
+++ branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/index.html 2014-06-02 17:09:07 UTC (rev 8437)
@@ -204,7 +204,14 @@
</div>
<div class="box">
- <form id="namespace-create"><input type="text"> <input type="submit" value="Create namespace"></form>
+ <h1>Create namespace</h1>
+ <form id="namespace-create">
+ <label for="new-namespace-name">Name:</label> <input type="text" id="new-namespace-name"><br>
+ <label for="new-namespace-index">Index:</label> <input type="checkbox" id="new-namespace-index"><br>
+ <label for="new-namespace-truth-maintenance">Truth maintenance:</label> <input type="checkbox" id="new-namespace-truth-maintenance"><br>
+ <label for="new-namespace-quads">Quads:</label> <input type="checkbox" id="new-namespace-quads"><br>
+ <input type="submit" value="Create namespace">
+ </form>
</div>
</div>
Modified: branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js
===================================================================
--- branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js 2014-06-02 16:43:56 UTC (rev 8436)
+++ branches/NEW_WORKBENCH_1_3_2_BRANCH/bigdata-war/src/html/js/workbench.js 2014-06-02 17:09:07 UTC (rev 8437)
@@ -4,7 +4,14 @@
var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACE_URL, NAMESPACES_READY, NAMESPACE_SHORTCUTS, FILE_CONTENTS, QUERY_RESULTS;
var CODEMIRROR_DEFAULTS, EDITORS = {}, ERROR_LINE_MARKERS = {}, ERROR_CHARACTER_MARKERS = {};
var PAGE_SIZE = 50, TOTAL_PAGES, CURRENT_PAGE;
+var NAMESPACE_PARAMS = {
+ 'name': 'com.bigdata.rdf.sail.namespace',
+ 'index': 'com.bigdata.search.FullTextIndex.fieldsEnabled',
+ 'truth-maintenance': 'com.bigdata.rdf.sail.truthMaintenance',
+ 'quads': 'com.bigdata.rdf.store.AbstractTripleStore.quads'
+};
+
CODEMIRROR_DEFAULTS = {
lineNumbers: true,
mode: 'sparql',
@@ -195,22 +202,50 @@
});
}
+function cloneNamespace(namespace) {
+ var url = '/bigdata/namespace/' + namespace + '/properties';
+ $.get(url, function(data) {
+ var reversed_params = {};
+ for(var key in NAMESPACE_PARAMS) {
+ reversed_params[NAMESPACE_PARAMS[key]] = key;
+ }
+ $.each(data.getElementsByTagName('entry'), function(i, entry) {
+ var key = entry.getAttribute('key');
+ if(reversed_params[key] == 'name') {
+ return;
+ }
+ if(key in reversed_params) {
+ $('#new-namespace-' + reversed_params[key]).prop('checked', entry.textContent.trim() == 'true');
+ }
+ });
+ $('#new-namespace-name').focus();
+ });
+}
+
function createNamespace(e) {
e.preventDefault();
- var input = $(this).find('input[type=text]');
- var namespace = input.val();
- if(!namespace) {
+ // get new namespace name and config options
+ var params = {};
+ params.name = $('#new-namespace-name').val().trim();
+ if(!params.name) {
return;
}
+ params.index = $('#new-namespace-index').is(':checked');
+ params.truthMaintenance = $('#new-namespace-truth-maintenance').is(':checked');
+ params.quads = $('#new-namespace-quads').is(':checked');
// TODO: validate namespace
// TODO: allow for other options to be specified
- var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n<entry key="com.bigdata.rdf.sail.namespace">' + namespace + '</entry>\n</properties>';
+ var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n';
+ for(key in NAMESPACE_PARAMS) {
+ data += '<entry key="' + keys[key] + '">' + params[key] + '</entry>\n';
+ }
+ data += '</properties>';
var settings = {
type: 'POST',
data: data,
contentType: 'application/xml',
- success: function() { input.val(''); getNamespaces(); },
- error: function(jqXHR, textStatus, errorThrown) { alert(jqXHR.statusText); }
+ success: function() { $('#new-namespace-name').val(''); getNamespaces(); },
+ error: function(jqXHR, textStatus, errorThrown) { debugger;alert(jqXHR.responseText); }
};
$.ajax('/bigdata/namespace', settings);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|