; Generation of whole Dojo classes for cdes (defun dojo-cdes-jsgen-get-css-file-path () (concat dojo-workspace-path "cdes-web/src/main/resources/OSGI-INF/webapp/cdes/cdes.css") ) (defun dojo-cdes-jsgen-generate-instance-class (directory name) (interactive "DDirectory: \nsClass name: ") (let* ((project-and-path (dojo-jsgen-open-file directory name)) (project (nth 0 project-and-path)) (path (nth 1 project-and-path)) ) (dojo-cdes-jsgen-insert-header) (dojo-jsgen-insert-imports (list (list "clazzes/TinyLog" "TinyLog") (list "dojo/_base/declare" "declare"))) (dojo-jsgen-insert-declare-section (dojo-cdes-jsgen-get-package-name directory) name) (dojo-insert-js "});") (newline) (dojo-insert-js (concat "return " name ";")) (dojo-insert-js "});") ) ) (defun dojo-cdes-jsgen-generate-static-class (directory name) (interactive "DDirectory: \nsClass name: ") (let* ((project-and-path (dojo-jsgen-open-file directory name)) (project (nth 0 project-and-path)) (path (nth 1 project-and-path)) ) (dojo-cdes-jsgen-insert-header) (dojo-jsgen-insert-imports (list (list "clazzes/TinyLog" "TinyLog"))) (dojo-jsgen-classes-insert-classname-log-section package-name name) (dojo-insert-js (concat "var " name " = {") nil "};" nil (concat "return " name ";") "});") ) ) (defun dojo-cdes-jsgen-generate-page (directory name) (interactive "DDirectory: \nsClass name: ") (let* ((project-and-path (dojo-jsgen-open-file directory name)) (css-file-path (dojo-cdes-jsgen-get-css-file-path)) (project (nth 0 project-and-path)) (path (nth 1 project-and-path)) ) (dojo-cdes-jsgen-insert-header) (dojo-jsgen-insert-imports (list (list "cdes/widget/ContextBar" "ContextBar") (list "clazzes/TinyLog" "TinyLog") (list "clazzes/util/DOMHelper" "DOMHelper") (list "clazzes/util/ErrorHelper" "ErrorHelper") (list "clazzes/widgets/layout/ContentWidget" "ContentWidget") (list "dojo/dom-class" "domClass") (list "dojo/dom-construct" "domConstruct") (list "dojo/dom-style" "domStyle") (list "dojo/_base/declare" "declare") (list "dojo/_base/lang" "lang") (list "dojo/i18n!/cdes/nls/cdes-web-i18n.js" "i18n"))) (dojo-jsgen-insert-declare-section (dojo-cdes-jsgen-get-package-name directory) name) (dojo-jsgen-insert-default-content-widget-functions name) ; constructTopDiv (dojo-insert-fct-start "constructTopDiv" "") (dojo-insert-js "var topDiv = domConstruct.create(\"div\", null, null);") (newline) (dojo-insert-js "// Context Bar") (dojo-insert-js "this.contextBar = new ContextBar({") (dojo-insert-js "applicationContext : this.applicationContext") (dojo-insert-js "});") (dojo-insert-js "this.contextBar.setData(0); // TODO depth; values 0 nothing, 1 network, 2 network+project, 3 network+project+subproject") (dojo-insert-js (list "this.contextBarDiv = this.contextBar.getContainer();" "domConstruct.place(this.contextBarDiv, topDiv);")) (newline) (dojo-insert-js (list "// Caption Bar" "this.captionBarDiv = this.constructCaptionBar();" (concat "domClass.add(this.captionBarDiv, \"cdesGeneralPageCaptionBar\");") "domConstruct.place(this.captionBarDiv, topDiv);" nil "// Content" "this.contentDiv = this.constructContentDiv();" "domConstruct.place(this.contentDiv, topDiv);" nil "return topDiv;")) (dojo-insert-fct-end) ; constructCaptionBar (dojo-insert-fct-start "constructCaptionBar" "") (dojo-js-i18n-insert-i18n-at-point-by-symbol project path "cdes/nls/cdes-web-i18n" (concat (dojo-strings-get-with-lower-first-char name) "Caption")) (dojo-insert-js (list "var captionBarDiv = domConstruct.create(\"div\", null, null);" nil "// Caption" (concat "this.captionDiv = DOMHelper.createTextNode(\"h1\", i18n." (dojo-strings-get-with-lower-first-char name) "Caption, captionBarDiv, \"cdesGeneralPageCaption\");") nil "return captionBarDiv;")) (dojo-insert-fct-end) ; constructTopDiv (dojo-insert-fct-start "constructContentDiv" "") (dojo-insert-js (list "var contentDiv = domConstruct.create(\"div\", null, null);" (concat "domClass.add(contentDiv, \"refNodeOfPositionAbsolute\", \"" (dojo-strings-get-with-lower-first-char name) "ContentDiv\");") nil "return contentDiv;")) (dojo-insert-fct-end) (dojo-css-gen-insert-rule-into-file css-file-path path (concat "." (dojo-strings-get-with-lower-first-char name) "ContentDiv") (list "top" "65px" "left" "0px" "right" "0px" "bottom" "0px")) ; resize (dojo-insert-fct-start "resize" "newSize") (dojo-insert-js (list "var totalHeight = newSize.h;" nil "var width = this.contextBarDiv.offsetWidth - 15;" "var contentHeight = totalHeight" "- this.contextBarDiv.offsetHeight - domStyle.get(this.contextBarDiv, \"margin-top\") - domStyle.get(this.contextBarDiv, \"margin-bottom\")" "- this.captionBarDiv.offsetHeight" "- 16;" nil "domStyle.set(this.contentDiv, \"height\", contentHeight + \"px\");")) (dojo-insert-fct-end) ; setData (dojo-insert-fct "setData" "" nil) ; reload (dojo-insert-fct "reload" "" "this.contextBar.reload();") ; updateWidgetState (dojo-insert-fct "updateWidgetState" "" nil) ; destroy (dojo-insert-fct "destroy" "" "this.inherited(arguments);" t) (dojo-insert-js "});") (newline) (dojo-insert-js (list (concat name ".AsyncOperation = {") nil "};")) (newline) (dojo-insert-js (concat "return " name ";")) (dojo-insert-js "});") ) ) (defun dojo-cdes-jsgen-generate-list-widget-with-actions (directory name) (interactive "DDirectory: \nsClass name: ") (let* ((project-and-path (dojo-jsgen-open-file directory name)) (css-file-path (dojo-cdes-jsgen-get-css-file-path)) (project (nth 0 project-and-path)) (path (nth 1 project-and-path)) ) (dojo-cdes-jsgen-insert-header) (dojo-jsgen-insert-imports (list (list "cdes/util/ActionHelper" "ActionHelper") (list "clazzes/TinyLog" "TinyLog") (list "clazzes/util/ErrorHelper" "ErrorHelper") (list "clazzes/widgets/layout/ContentWidget" "ContentWidget") (list "dgrid/OnDemandGrid" "OnDemandGrid") (list "dgrid/extensions/ColumnResizer" "ColumnResizer") (list "dgrid/extensions/DijitRegistry" "DijitRegistry") (list "dojo/dom-class" "domClass") (list "dojo/dom-construct" "domConstruct") (list "dojo/_base/declare" "declare") (list "dojo/_base/lang" "lang") (list "dstore/Memory" "Memory") (list "dstore/Trackable" "Trackable") (list "dojo/i18n!/cdes/nls/cdes-web-i18n.js" "i18n"))) (dojo-jsgen-insert-declare-section (dojo-cdes-jsgen-get-package-name directory) name) (dojo-jsgen-insert-default-content-widget-functions name) (dojo-insert-fct "constructColumns" "" (list "var columns = [];" "columns.push({" "field : \"TODO\", // TODO" "id : \"actions\"," "renderCell : lang.hitch(this, this.renderActionCell)," "sortable : false," "label : i18n.actionColumnCaption" "});" nil "return columns;")) (dojo-insert-fct "fooFormatter" "field, dataObject" "// TODO") (dojo-insert-fct "renderActionCell" "dataObject, data, cell" (list "var buttonDiv = domConstruct.create(\"div\", null, null);" nil "if (true) { // TODO" "var fooButton = this.constructFooButton();" "domConstruct.place(fooButton.domNode, buttonDiv);" "}" "return buttonDiv;" )) (dojo-insert-fct "constructTopDiv" "" (list "var columns = this.constructColumns();" "var TrackableMemory = declare([Memory, Trackable]);" "this.store = new TrackableMemory({data : [], idProperty : \"id\"}); // TODO" nil "var MyGrid = declare([OnDemandGrid, ColumnResizer, DijitRegistry]);" "this.grid = new MyGrid({" "collection : this.store," "columns : columns," (concat "id : \"" name "Grid\",") "keepScrollPosition : true" "});" nil "this.grid.startup();" nil ; TODO maybe add flag to enable column configuration (enable/disable) from outside ; this.gridRuleSelectorPrefix = "#" + dgridMiscUtil.escapeCssIdentifier(this.grid.domNode.id) + " .dgrid-column-"; "return this.grid.domNode;")) (dojo-insert-fct "resize" "newSize" "this.grid.resize(newSize);") (dojo-insert-fct "setData" "params" (list "this.updateAuxiliaryData();" nil ;"if (params.columnSettings) {" ;"this.setColumnSettings(params.columnSettings);" ;"}" "this.reload();")) (dojo-insert-fct "updateAuxiliaryData" "" (list "for (var n = 0; n < this.fooJoins.length; n++) { // TODO" "var joinDto = this.fooJoins[n]; // TODO" "this.updateAuxiliaryDataForJoinDto(joinDto);" "}")) (dojo-insert-fct "updateAuxiliaryDataForJoinDto" "joinDto" "// TODO") (dojo-insert-fct "reload" "params" (list ;this.updateColumns(); nil "this.store.setData(this.fooJoins); // TODO" nil "this.grid.set(\"sort\", \"_bar\", false); // TODO" "this.grid.updateSortArrow(this.grid.sort);" "this.grid.refresh();")) (dojo-insert-fct "getRowId" "joinDto" "return \"\"; // TODO") ; setColumns : function(columnSettings) { ; setColumnSettings : function(columnSettings) { ; updateColumns : function(columnSettings) { ; updateColumn : function(id, show, triggerStateChangeAlways) { ; filter : function(searchString) { ; filterRow : function(joinDto, searchStrings) { ; doesJoinMatchSearchModel : function(certificateJoin) { (dojo-insert-fct "destroy" "" (list "this.inherited(arguments);" nil ;// Remove columnHider CSS rules, to avoid that they get active again when such a grid is constructed again at a later time. ;for (id in this.columnHiderRules) { ;this.columnHiderRules[id].remove(); ;} ; nil "this.grid.destroy();") t) (dojo-insert-js "});") (newline) (dojo-insert-js (list (concat name ".AsyncOperation = {") nil "};")) (newline) (dojo-insert-js (concat "return " name ";")) (dojo-insert-js "});") ) ) (defun dojo-cdes-jsgen-generate-title-pane-widget (directory name css-prefix) (interactive "DDirectory: \nsClass name: \nsCSS and i18n prefix: ") (let* ((project-and-path (dojo-jsgen-open-file directory name)) (css-file-path (dojo-cdes-jsgen-get-css-file-path)) (project (nth 0 project-and-path)) (path (nth 1 project-and-path)) (css-full-class (concat css-prefix "Full")) (css-reduced-class (concat css-prefix "Reduced")) (i18n-full-caption (concat css-prefix "FullCaption")) (i18n-reduced-caption (concat css-prefix "ReducedCaption")) ) (dojo-cdes-jsgen-insert-header) (dojo-jsgen-insert-imports (list (list "clazzes/TinyLog" "TinyLog") (list "clazzes/util/DOMHelper" "DOMHelper") (list "clazzes/widgets/IconTitlePane" "IconTitlePane") (list "clazzes/widgets/layout/ContentWidget" "ContentWidget") (list "dojo/dom-class" "domClass") (list "dojo/dom-construct" "domConstruct") (list "dojo/on" "on") (list "dojo/_base/declare" "declare") (list "dojo/_base/lang" "lang") (list "dojo/i18n!/cdes/nls/cdes-web-i18n.js" "i18n"))) (dojo-js-i18n-insert-i18n-at-point-by-symbol project path "cdes/nls/cdes-web-i18n" i18n-full-caption) (dojo-js-i18n-insert-i18n-at-point-by-symbol project path "cdes/nls/cdes-web-i18n" i18n-reduced-caption) (dojo-css-gen-insert-rule-into-file css-file-path path (concat "." css-full-class) (list "left" "0px" "right" "0px" "height" "TODOpx")) (dojo-css-gen-insert-rule-into-file css-file-path path (concat "." css-reduced-class) (list "left" "0px" "right" "0px" "height" "30px")) (dojo-jsgen-insert-declare-section (dojo-cdes-jsgen-get-package-name directory) name) (dojo-jsgen-insert-default-content-widget-functions name) (dojo-insert-fct "constructTopDiv" "" (list "var topDiv = domConstruct.create(\"div\", null, null);" (concat "domClass.add(topDiv, \"refNodeOfPositionAbsolute " css-full-class "\");") nil "this.titlePane = this.constructTitlePane();" "domConstruct.place(this.titlePane.domNode, topDiv);" nil "return topDiv;")) (dojo-insert-fct "postTitleClick" "" (list "var open = this.titlePane.get(\"open\");" nil "if (open) {" (concat "this.titlePane.set(\"title\", i18n." i18n-full-caption ");") (concat "domClass.replace(this.topDiv, \"" css-full-class "\", \"" css-reduced-class "\");") "} else {" (concat "this.titlePane.set(\"title\", i18n." i18n-reduced-caption ");") (concat "domClass.replace(this.topDiv, \"" css-reduced-class "\", \"" css-full-class "\");") "}" nil "on.emit(this, \"titlePaneToggled\");")) (dojo-insert-fct "constructTitlePane" "" (list "var contentDiv = this.constructContentDiv();" nil "var titlePane = new IconTitlePane({" (concat "title : i18n." i18n-full-caption ",") "content : contentDiv," "toggleable : true," "open : true," "postTitleClick : lang.hitch(this, this.postTitleClick)" "});" "domClass.add(titlePane.domNode, \"occupyWholeParent\");" nil "return titlePane;")) (dojo-insert-fct "constructContentDiv" "" nil) (dojo-insert-fct "updateWidgetState" "" nil t) (dojo-insert-js "});") (newline) (dojo-insert-js (list (concat name ".AsyncOperation = {") nil "};")) (newline) (dojo-insert-js (concat "return " name ";")) (dojo-insert-js "});") ) ) (defun dojo-cdes-jsgen-insert-header () (dojo-insert-js "/***********************************************************") (dojo-insert-js " * $Id$") (dojo-insert-js " *") (dojo-insert-js " * Copyright (C) 2017 ev-i Informationstechnologie Gmbh") (dojo-insert-js " *") (dojo-insert-js " **********************************************************/") (newline) ) (defun dojo-cdes-jsgen-get-package-name (directory) (let* ((webapp-pos (string-match "webapp" directory)) (postfix (if webapp-pos (substring directory (+ webapp-pos (length "webapp/cdes/"))) nil)) ) (if postfix (concat "at.cdes.web." (replace-regexp-in-string "/" "." postfix)) "Not known, please replace" ) ) ) (provide 'dojo-cdes-jsgen-classes)