input_bar_utils.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* This file is part of AToMPM - A Tool for Multi-Paradigm Modelling
  2. * Copyright 2011 by the AToMPM team and licensed under the LGPL
  3. * See COPYING.lesser and README.md in the root of this project for full details
  4. */
  5. InputBarUtils = function(){
  6. this.processKey = function( event ){
  7. if( event.keyCode == KEY_ENTER ){
  8. var query = $('#mainInput')[0].value.split('(')[0].trim();
  9. var acceptedQueries = ["getCount", "toggleIncUpdate"];
  10. if(query=="help"){
  11. alert("See the text in the developer console (In Chrome, press F12)");
  12. console.log("WARNING :: All commands can be issued after a transformation is loaded!");
  13. console.log("INFO :: You can query the graph before/during/after a transformation using this system.");
  14. console.log("INFO :: Available queries: "+acceptedQueries.toString());
  15. console.log("INFO :: Query usage help");
  16. console.log("getCount :: type 'getCount(\"TypeName\")' to get the number of a specific type in the graph");
  17. console.log("getCount :: You can get the type names in the attribute popup of each element.");
  18. console.log("toggleIncUpdate :: type 'toggleIncUpdate()' to toggle incremental updates (default is on, which will update the model at each step)");
  19. console.log("toggleIncUpdate :: If you turn incremental updates off, the model will be updated at the end.");
  20. }
  21. else if ($.inArray(query, acceptedQueries) > -1) {
  22. console.log("Query '"+query+"' sent! Waiting for reply.");
  23. HttpUtils.httpReq(
  24. 'PUT',
  25. '/__mt/query.transform?wid='+__wid,
  26. {'query':$('#mainInput')[0].value.trim()});
  27. } else {
  28. console.log("ERROR :: Query '"+query+"' is not accepted.\n\tAccepted queries: "+acceptedQueries.toString());
  29. }
  30. }
  31. };
  32. return this;
  33. }();