summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary McCain2013-11-08 17:05:42 (EST)
committer Stephan Born2013-12-04 05:11:32 (EST)
commit24cc2aec6880ea55330bb33776d8829857c26425 (patch)
tree372792f3dae992d76554f59eb8ff7df93fb30c32
parentefa1522a4d15db3a46f0897014e023330637dd33 (diff)
downloadorg.eclipse.stardust.ui.web-24cc2aec6880ea55330bb33776d8829857c26425.zip
org.eclipse.stardust.ui.web-24cc2aec6880ea55330bb33776d8829857c26425.tar.gz
org.eclipse.stardust.ui.web-24cc2aec6880ea55330bb33776d8829857c26425.tar.bz2
Jira-ID: CRNT-30922
- In support of Upgrade Ace Code Editor to Version 'package 07.31.2013'. Updated angular directive to add a hook for custom keywords, supporting either a comma delimited string or an array. Needs extensive refactoring as code was ripped fro mthe module solution for m_codeaceeditor. git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ui.web@68700 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Zachary McCain <zachary.mccain@sungard.com>
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js89
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/views/reportDefinitionView.html3
2 files changed, 90 insertions, 2 deletions
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js
index 9449aca..0152a18 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js
@@ -311,6 +311,7 @@ if (!window.bpm.portal.AngularAdapter) {
};
});
+
/*Angular directive to wrap the ace code editor and provide
*a basic set of functionality.
*Supports via attributes:
@@ -323,6 +324,80 @@ if (!window.bpm.portal.AngularAdapter) {
/*Check for our global ace object, if it isn't there then bail.*/
if(!ace){return;}
+ /*Hanging an object off of window.top.ace that we can use
+ *for global state related to our module.*/
+ if(ace.hasOwnProperty("ext_userDefined")===false){
+ ace["ext_userDefined"]={};/*collect here for sameness*/
+ ace.ext_userDefined.completers=[]; /*collection to keep track of completers we add*/
+ }
+
+ /*Our session completer with ace language utils compatible interface.*/
+ var completerFac={
+ /*Completer which allows the user to specify a keyword list attached
+ *to a drlEditor session via session.ext_userDefined.$keywordList*/
+ getSessionCompleter: function(options){
+ var metaName="Data",score=9999;
+ if(options){
+ metaName=options.metaName || metaName;
+ score=options.score || score;
+ }
+ return {
+ getCompletions: function(editor, session, pos, prefix, callback) {
+ var keywords=[];
+ if(session.ext_userDefined && session.ext_userDefined.$keywordList){
+ keywords=session.ext_userDefined.$keywordList;
+ }
+ var t=session.getTextRange({
+ "start":{row: pos.row,column:pos.column-1},
+ "end":{row: pos.row,column:pos.column}
+ });
+ keywords = keywords.filter(function(w) {
+ return w.lastIndexOf(prefix, 0) == 0;
+ });
+ callback(null, keywords.map(function(word) {
+ return {
+ "name": word,
+ "value": word,
+ "score": score,
+ "meta": metaName
+ };
+ }));
+ }
+ };
+ }
+ };
+ var completer=completerFac.getSessionCompleter();
+ var isPresent=false,
+ temp,
+ compString=completer.getCompletions.toString(),
+ langTools,
+ compLength=ace.ext_userDefined.completers.length;
+
+ while(compLength--){
+ temp=ace.ext_userDefined.completers[compLength];
+ if(temp===compString){
+ isPresent=true;
+ console.log("Repeater found, will not be added.");
+ break;
+ }
+ }
+
+ if(isPresent===false){
+ langTools=ace.define.modules["ace/ext/language_tools"];
+ if(langTools){
+ langTools.addCompleter(completer);
+ ace.ext_userDefined.completers.push(completer.getCompletions.toString());
+ }
+ else{
+ ace.config.loadModule("ace/ext/language_tools",function(){
+ langTools=ace.define.modules["ace/ext/language_tools"];
+ langTools.addCompleter(completer);
+ ace.ext_userDefined.completers.push(completer.getCompletions.toString());
+ });
+ }
+ }
+
+
return {
restrict: 'EA', /*Elements and attributes*/
require: '?ngModel',
@@ -330,7 +405,8 @@ if (!window.bpm.portal.AngularAdapter) {
var options,
editor,
session,
- langTools;
+ langTools,
+ keywords;
/*Setting up language tool options for editor*/
options={
@@ -344,6 +420,17 @@ if (!window.bpm.portal.AngularAdapter) {
session.setMode("ace/mode/" + attrs.mode);
editor.setTheme("ace/theme/" + attrs.theme);
+ /*Set our session keywords, we support either an array or comma-delimited string*/
+ keywords=attrs.keywords;
+ if(keywords){
+ if( Object.prototype.toString.call( keywords ) !== '[object Array]' ) {
+ keywords=keywords.split(",");
+ }
+ if(session.hasOwnProperty("ext_userDefined")===false){
+ session["ext_userDefined"]={};
+ }
+ session["ext_userDefined"].$keywordList=keywords;
+ }
/*Get a reference to languageTools module, if it exists*/
langTools=ace.define.modules["ace/ext/language_tools"];
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/views/reportDefinitionView.html b/stardust-web-reporting/src/main/resources/META-INF/webapp/views/reportDefinitionView.html
index fea85c1..720a085 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/views/reportDefinitionView.html
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/views/reportDefinitionView.html
@@ -251,7 +251,8 @@ table.formTable td {
<td>
<div
ipp-Ace
- mode="javascript"
+ mode="javascript"
+ keywords="Hello,World"
theme="chrome"
snippets="true"
autocomplete="true"