Jelajahi Sumber

gh-3235 Add new ECL Source view to ECL Watch

Created a new ECL Source Widget.
Added new source View.
Updated ECL Playground to use new widget.

Fixes gh-3235

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith 13 tahun lalu
induk
melakukan
82e8710dd6

+ 2 - 0
esp/eclwatch/ws_XSLT/wuidcommon.xslt

@@ -608,6 +608,8 @@
           <div class="wugroup">
               <div class="WuGroupHdrLeft">
                 <A href="javascript:void(0)" onclick="toggleElement('querysection');" id="explinkquerysection" class="wusectionexpand">Query: (1)</A>
+                &nbsp;-&nbsp;
+                <a href="/esp/iframe?esp_iframe_title=Query - {$wuid}&amp;inner=/esp/files/WUSource.htm%3fWuid%3d{$wuid}" >Show</a>							
               </div>
           </div>
           <div id="querysection" class="wusectioncontent">

+ 4 - 1
esp/files/CMakeLists.txt

@@ -127,6 +127,7 @@ set ( TEMPLATES_FILES
     templates/SampleSelectWidget.html
     templates/TargetSelectWidget.html
     templates/TimingTreeMapWidget.html
+    templates/ECLSourceWidget.html
 )
 source_group(templates FILES ${TEMPLATES_FILES})
 
@@ -159,7 +160,6 @@ set ( SCRIPTS_FILES
     scripts/ESPBase.js
     scripts/ESPWorkunit.js
     scripts/ESPResult.js
-    scripts/EclEditorControl.js
     scripts/WsWorkunits.js
 
     scripts/ResultsControl.js
@@ -171,6 +171,7 @@ set ( SCRIPTS_FILES
     scripts/SampleSelectWidget.js
     scripts/TargetSelectWidget.js
     scripts/TimingTreeMapWidget.js
+    scripts/ECLSourceWidget.js
 )
 source_group(scripts FILES ${SCRIPTS_FILES})
 
@@ -218,6 +219,8 @@ set ( MAIN_FILES
     WUGraph.js
     WUTimings.htm
     WUTimings.js
+    WUSource.htm
+    WUSource.js
     )
 source_group("Source Files" FILES ${MAIN_FILES})
 

+ 73 - 0
esp/files/WUSource.htm

@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<!--
+/*##############################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+############################################################################## */
+-->
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>HPCC: WU Query</title>
+    <link href="CodeMirror2/lib/codemirror.css" rel="stylesheet">
+    <script src="CodeMirror2/lib/codemirror.js"></script>
+    <script src="CodeMirror2/mode/ecl/ecl.js"></script>
+    <link href="css/ecl.css" rel="stylesheet">
+    <link href="css/hpcc.css" rel="stylesheet">
+    <link href="dijit/themes/claro/claro.css" media="screen" rel="stylesheet">
+    <link href="dojox/grid/resources/Grid.css" rel="stylesheet">
+    <link href="dojox/grid/enhanced/resources/claro/EnhancedGrid.css" rel="stylesheet">
+    <link href="dojox/grid/resources/claroGrid.css" rel="stylesheet">
+    <!-- load dojo and provide config via dojoConfig global -->
+    <script>
+        var dojoConfig = (function () {
+            var base = location.href.split("/");
+            base.pop();
+            base = base.join("/");
+
+            return {
+                async: true,
+                parseOnLoad: true,
+                urlBase: base,
+                packages: [{
+                    name: "main",
+                    location: base + "/"
+                }, {
+                    name: "hpcc",
+                    location: base + "/scripts/"
+                }]
+            };
+        })();
+    </script>
+    <script src="dojo/dojo.js"></script>
+    <script>
+        require([
+		"main/WUSource", "hpcc/ECLSourceWidget",
+        "dojo/domReady!"], function (app) {
+            app.init();
+        });
+    </script>
+</head>
+<body class="claro">
+    <!-- overlay -->
+    <div id="loadingOverlay" class="pageOverlay">
+        <div class="loadingMessage">
+            Loading...
+        </div>
+    </div>
+    <!-- application -->
+    <div id="appLayout" class="hpccApp" data-dojo-props="design: 'headline', readOnly: true" data-dojo-type="ECLSourceWidget">
+    </div>
+</body>
+</html>

+ 70 - 0
esp/files/WUSource.js

@@ -0,0 +1,70 @@
+/*##############################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+############################################################################## */
+define([
+    "dojo/_base/fx",
+    "dojo/_base/window",
+    "dojo/dom",
+    "dojo/dom-style",
+    "dojo/dom-geometry",
+    "dojo/io-query",
+    "dojo/ready",
+
+    "dijit/registry"
+], function (fx, baseWindow, dom, domStyle, domGeometry, ioQuery, ready, registry) {
+    var initUi = function () {
+        var wuid = "";
+
+        var urlWuid = ioQuery.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search.substr(0, 1) == "?" ? 1 : 0)))["Wuid"];
+        if (urlWuid) {
+            wuid = urlWuid;
+        }
+
+        var sourceControl = registry.byId("appLayout");
+        sourceControl.setWuid(wuid);
+    },
+
+    startLoading = function (targetNode) {
+        var overlayNode = dom.byId("loadingOverlay");
+        if ("none" == domStyle.get(overlayNode, "display")) {
+            var coords = domGeometry.getMarginBox(targetNode || baseWindow.body());
+            domGeometry.setMarginBox(overlayNode, coords);
+            domStyle.set(dom.byId("loadingOverlay"), {
+                display: "block",
+                opacity: 1
+            });
+        }
+    },
+
+    endLoading = function () {
+        fx.fadeOut({
+            node: dom.byId("loadingOverlay"),
+            duration: 175,
+            onEnd: function (node) {
+                domStyle.set(node, "display", "none");
+            }
+        }).play();
+    }
+
+    return {
+        init: function () {
+            startLoading();
+            ready(function () {
+                initUi();
+                endLoading();
+            });
+        }
+    };
+});

+ 3 - 5
esp/files/scripts/ECLPlaygroundWidget.js

@@ -26,7 +26,7 @@ require([
 	"dijit/layout/ContentPane",
 	"dijit/registry",
 
-	"hpcc/EclEditorControl",
+	"hpcc/ECLSourceWidget",
 	"hpcc/TargetSelectWidget",
 	"hpcc/SampleSelectWidget",
 	"hpcc/GraphWidget",
@@ -36,7 +36,7 @@ require([
 	"dojo/text!./templates/ECLPlaygroundWidget.html"
 ], function (declare, xhr, dom,
 				_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, registry,
-				EclEditor, TargetSelectWidget, SampleSelectWidget, GraphWidget, ResultsWidget, Workunit,
+				EclSourceWidget, TargetSelectWidget, SampleSelectWidget, GraphWidget, ResultsWidget, Workunit,
 				template) {
     return declare("ECLPlaygroundWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
         templateString: template,
@@ -126,9 +126,7 @@ require([
         },
 
         initEditor: function () {
-            this.editorControl = new EclEditor({
-                domId: this.id + "EclCode"
-            });
+                this.editorControl = registry.byId(this.id + "Source");
         },
 
         initGraph: function () {

+ 142 - 0
esp/files/scripts/ECLSourceWidget.js

@@ -0,0 +1,142 @@
+/*##############################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+############################################################################## */
+require([
+    "dojo/_base/declare",
+    "dojo/aspect",
+    "dojo/has",
+    "dojo/dom",
+    "dojo/dom-construct",
+    "dojo/dom-class",
+
+    "dijit/layout/_LayoutWidget",
+    "dijit/_TemplatedMixin",
+    "dijit/_WidgetsInTemplateMixin",
+    "dijit/layout/BorderContainer",
+    "dijit/layout/ContentPane",
+    "dijit/registry",
+
+    "hpcc/ESPWorkunit",
+
+    "dojo/text!./templates/ECLSourceWidget.html",
+
+    "dijit/Toolbar", "dijit/ToolbarSeparator", "dijit/form/Button"
+],
+    function (declare, aspect, has, dom, domConstruct, domClass,
+            _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, ContentPane, registry,
+            ESPWorkunit,
+            template) {
+        return declare("ECLSourceWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
+            templateString: template,
+            baseClass: "ECLSourceWidget",
+            borderContainer: null,
+            eclSourceContentPane: null,
+            wu: null,
+            editor: null,
+            markers: [],
+            highlightLines: [],
+            readOnly: false,
+
+            buildRendering: function (args) {
+                this.inherited(arguments);
+            },
+
+            postCreate: function (args) {
+                this.inherited(arguments);
+                this.borderContainer = registry.byId(this.id + "BorderContainer");
+            },
+
+            startup: function (args) {
+                this.inherited(arguments);
+                this.initEditor();
+            },
+
+            resize: function (args) {
+                this.inherited(arguments);
+                this.borderContainer.resize();
+            },
+
+            layout: function (args) {
+                this.inherited(arguments);
+            },
+
+            //  Plugin wrapper  ---
+            initEditor: function () {
+                this.editor = CodeMirror.fromTextArea(document.getElementById(this.id + "EclCode"), {
+                    tabMode: "indent",
+                    matchBrackets: true,
+                    gutter: true,
+                    lineNumbers: true,
+                    readOnly: this.readOnly
+                });
+            },
+
+            setWuid: function (wuid) {
+                this.wuid = wuid;
+                var context = this;
+                if (wuid) {
+                    this.wu = new ESPWorkunit({
+                        wuid: wuid
+                    });
+                    this.wu.fetchText(function (text) {
+                        context.editor.setValue(text);
+                    });
+                }
+            },
+
+            clearErrors: function (errWarnings) {
+                for (var i = 0; i < this.markers.length; ++i) {
+                    this.editor.clearMarker(this.markers[i]);
+                }
+                this.markers = [];
+            },
+
+            setErrors: function (errWarnings) {
+                for (var i = 0; i < errWarnings.length; ++i) {
+                    this.markers.push(this.editor.setMarker(parseInt(
+                            errWarnings[i].LineNo, 10) - 1, "",
+                            errWarnings[i].Severity + "Line"));
+                }
+            },
+
+            setCursor: function (line, col) {
+                this.editor.setCursor(line - 1, col - 1);
+                this.editor.focus();
+            },
+
+            clearHighlightLines: function () {
+                for (var i = 0; i < this.highlightLines.length; ++i) {
+                    this.editor.setLineClass(this.highlightLines[i], null, null);
+                }
+            },
+
+            highlightLine: function (line) {
+                this.highlightLines.push(this.editor.setLineClass(line - 1, "highlightline"));
+            },
+
+            setText: function (ecl) {
+                this.editor.setValue(ecl);
+            },
+
+            setReadOnly: function (readonly) {
+                this.editor.readOnly(readonly);
+            },
+
+            getText: function () {
+                return this.editor.getValue();
+            }
+
+        });
+    });

+ 0 - 74
esp/files/scripts/EclEditorControl.js

@@ -1,74 +0,0 @@
-/*##############################################################################
-#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-############################################################################## */
-define([
-	"dojo/_base/declare"
-], function (declare) {
-	return declare(null, {
-		domId: "",
-		editor: null,
-		markers: [],
-		highlightLines: [],
-
-		// The constructor    
-		constructor: function (args) {
-			declare.safeMixin(this, args);
-			this.editor = CodeMirror.fromTextArea(document.getElementById(this.domId), {
-				tabMode: "indent",
-				matchBrackets: true,
-				gutter: true,
-				lineNumbers: true
-			});
-		},
-
-		clearErrors: function (errWarnings) {
-			for (var i = 0; i < this.markers.length; ++i) {
-				this.editor.clearMarker(this.markers[i]);
-			}
-			this.markers = [];
-		},
-
-		setErrors: function (errWarnings) {
-			for (var i = 0; i < errWarnings.length; ++i) {
-				this.markers.push(this.editor.setMarker(parseInt(
-						errWarnings[i].LineNo, 10) - 1, "",
-						errWarnings[i].Severity + "Line"));
-			}
-		},
-
-		setCursor: function (line, col) {
-			this.editor.setCursor(line - 1, col - 1);
-			this.editor.focus();
-		},
-
-		clearHighlightLines: function () {
-			for (var i = 0; i < this.highlightLines.length; ++i) {
-				this.editor.setLineClass(this.highlightLines[i], null, null);
-			}
-		},
-
-		highlightLine: function (line) {
-			this.highlightLines.push(this.editor.setLineClass(line - 1, "highlightline"));
-		},
-
-		setText: function (ecl) {
-			this.editor.setValue(ecl);
-		},
-
-		getText: function () {
-			return this.editor.getValue();
-		}
-	});
-});

+ 1 - 5
esp/files/templates/ECLPlaygroundWidget.html

@@ -9,11 +9,7 @@
                 </div>
             </div>
         </div>
-        <div id="${id}Tabs" class="centerPanel" data-dojo-props="region: 'center'" data-dojo-type="dijit.layout.ContentPane">
-            <div id="${id}EclContent">
-                <textarea id="${id}EclCode">
-				</textarea>
-            </div>
+        <div id="${id}Source" class="centerPanel" data-dojo-props="region: 'center'" data-dojo-type="ECLSourceWidget">
         </div>
         <div id="${id}Graphs" style="width: 240px;" data-dojo-props="minSize:120, region: 'right', splitter:true" data-dojo-type="GraphWidget">
         </div>

+ 7 - 0
esp/files/templates/ECLSourceWidget.html

@@ -0,0 +1,7 @@
+<div class="${baseClass}">
+    <div id="${id}BorderContainer" class="${baseClass}BorderContainer" style="width: 100%; height: 100%; padding: 0px; overflow: hidden" data-dojo-props="splitter: false, gutters:false" data-dojo-type="dijit.layout.BorderContainer">
+        <div id="${id}EclContent" class="centerPanel" data-dojo-props="region: 'center'" data-dojo-type="dijit.layout.ContentPane">
+            <textarea id="${id}EclCode"/>
+        </div>
+    </div>
+</div>