0009700: Improvement of application generator
authorFlávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
Wed, 26 Feb 2014 16:49:41 +0000 (13:49 -0300)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 6 Mar 2014 19:47:30 +0000 (20:47 +0100)
- Creates mainscreen with panels North, East and West (avoid)

Change-Id: I31fbf75b0b56d4b18576184897f4464eaba73941
Reviewed-on: https://gerrit.tine20.org/tine20/2804
Tested-by: jenkins user
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/ExampleApplication/ExampleApplication.jsb2
tine20/ExampleApplication/js/Example.js [new file with mode: 0644]
tine20/ExampleApplication/js/ExampleDetailsPanel.js [moved from tine20/ExampleApplication/js/ExampleRecordDetailsPanel.js with 92% similarity]
tine20/ExampleApplication/js/ExampleEditDialog.js [moved from tine20/ExampleApplication/js/ExampleRecordEditDialog.js with 90% similarity]
tine20/ExampleApplication/js/ExampleGridPanel.js [moved from tine20/ExampleApplication/js/ExampleRecordGridPanel.js with 60% similarity]
tine20/ExampleApplication/js/Models.js [new file with mode: 0644]
tine20/Tool/CodeGenerator/Application.php

index 55583bf..78f532c 100644 (file)
@@ -1,7 +1,7 @@
 {
   "projectName": "Tine 2.0 - ExampleApplication",
   "deployDir": "ExampleApplication",
-  "licenseText": "Tine 2.0 - ExampleApplication \nCopyright (c) 2007-2011 Metaways Infosystems GmbH (http://www.metaways.de)\nhttp://www.gnu.org/licenses/agpl.html AGPL Version 3",
+  "licenseText": "Tine 2.0 - ExampleApplication \nCopyright (c) 2007-2014 Metaways Infosystems GmbH (http://www.metaways.de)\nhttp://www.gnu.org/licenses/agpl.html AGPL Version 3",
   "resources": [
     
   ],
       "isDebug": true,
       "fileIncludes": [
         {
-          "text": "ExampleRecordEditDialog.js",
+          "text": "Models.js",
+          "path": "js/"
+        },      
+        {
+          "text": "Example.js",
           "path": "js/"
         },
         {
-          "text": "ExampleRecordDetailsPanel.js",
+          "text": "ExampleGridPanel.js",
+          "path": "js/"
+        },            
+        {
+          "text": "ExampleEditDialog.js",
           "path": "js/"
         },
         {
-          "text": "ExampleRecordGridPanel.js",
+          "text": "ExampleDetailsPanel.js",
           "path": "js/"
         }
       ]
diff --git a/tine20/ExampleApplication/js/Example.js b/tine20/ExampleApplication/js/Example.js
new file mode 100644 (file)
index 0000000..61aae96
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * Tine 2.0
+ * 
+ * @package     Example
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @author      Flávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
+ * @copyright   Copyright (c) 2007-2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ *
+ */
+
+Ext.ns('Tine', 'Tine.Example');
+
+/**
+ * @namespace   Tine.Example
+ * @class       Tine.Example.Application
+ * @extends     Tine.Tinebase.Application
+ * Example Application Object <br>
+ * 
+ * @author      Flávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
+ */
+Tine.Example.Application = Ext.extend(Tine.Tinebase.Application, {
+    
+    /**
+     * auto hook text _('New Example')
+     */
+    addButtonText: 'New Example'
+});
+
+// default mainscreen
+Tine.Example.MainScreen = Ext.extend(Tine.widgets.MainScreen, {
+    activeContentType: 'Example'
+});
+
+Tine.Example.ExampleTreePanel = function(config) {
+    Ext.apply(this, config);
+    
+    this.id = 'ExampleTreePanel';
+    this.recordClass = Tine.Example.Model.Example;
+    
+    this.filterMode = 'filterToolbar';
+    Tine.Example.ExampleTreePanel.superclass.constructor.call(this);
+};
+Ext.extend(Tine.Example.ExampleTreePanel, Tine.widgets.container.TreePanel, {
+    afterRender: function() {
+        this.supr().afterRender.apply(this, arguments);
+    }
+});
+
+Tine.Example.ExampleFilterPanel = function(config) {
+    Ext.apply(this, config);
+    Tine.Example.ExampleFilterPanel.superclass.constructor.call(this);
+};
+Ext.extend(Tine.Example.ExampleFilterPanel, Tine.widgets.persistentfilter.PickerPanel, {
+    filter: [{field: 'model', operator: 'equals', value: 'Example_Model_ExampleFilter'}]
+});
@@ -9,13 +9,13 @@
 Ext.ns('Tine.ExampleApplication');
 
 /**
- * @class     Tine.ExampleApplication.ExampleRecordDetailsPanel
+ * @class     Tine.ExampleApplication.ExampleDetailsPanel
  * @namespace ExampleApplication
  * @extends   Tine.widgets.grid.DetailsPanel
  * @author    Alexander Stintzing <a.stintzing@metaways.de>
  */
 
-Tine.ExampleApplication.ExampleRecordDetailsPanel = Ext.extend(Tine.widgets.grid.DetailsPanel, {
+Tine.ExampleApplication.ExampleDetailsPanel = Ext.extend(Tine.widgets.grid.DetailsPanel, {
     
     app: null,
     
@@ -30,7 +30,7 @@ Tine.ExampleApplication.ExampleRecordDetailsPanel = Ext.extend(Tine.widgets.grid
             count: 0
         }, 0);
         
-        Tine.ExampleApplication.ExampleRecordDetailsPanel.superclass.initComponent.call(this);
+        Tine.ExampleApplication.ExampleDetailsPanel.superclass.initComponent.call(this);
     },
     
     /**
@@ -9,10 +9,10 @@ Ext.ns('Tine.ExampleApplication');
 
 /**
  * @namespace   Tine.ExampleApplication
- * @class       Tine.ExampleApplication.ExampleRecordEditDialog
+ * @class       Tine.ExampleApplication.ExampleEditDialog
  * @extends     Tine.widgets.dialog.EditDialog
  * 
- * <p>ExampleRecord Compose Dialog</p>
+ * <p>Example Compose Dialog</p>
  * <p></p>
  * 
  *  @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
@@ -21,15 +21,15 @@ Ext.ns('Tine.ExampleApplication');
  * 
  * @param       {Object} config
  * @constructor
- * Create a new Tine.ExampleApplication.ExampleRecordEditDialog
+ * Create a new Tine.ExampleApplication.ExampleEditDialog
  */
-Tine.ExampleApplication.ExampleRecordEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
+Tine.ExampleApplication.ExampleEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
     
     /**
      * @private
      */
     appName: 'ExampleApplication',
-    modelName: 'ExampleRecord',
+    modelName: 'Example',
     
     windowHeight: 470,
     windowWidth: 800,
@@ -50,7 +50,7 @@ Tine.ExampleApplication.ExampleRecordEditDialog = Ext.extend(Tine.widgets.dialog
             activeTab: 0,
             border: false,
             items:[{
-                title: this.app.i18n._('ExampleRecord'),
+                title: this.app.i18n._('Example'),
                 autoScroll: true,
                 border: false,
                 frame: true,
 Ext.namespace('Tine.ExampleApplication');
 
 /**
- * ExampleRecord grid panel
+ * Example grid panel
  * 
  * @namespace   Tine.ExampleApplication
- * @class       Tine.ExampleApplication.ExampleRecordGridPanel
+ * @class       Tine.ExampleApplication.ExampleGridPanel
  * @extends     Tine.widgets.grid.GridPanel
  * 
- * <p>ExampleRecord Grid Panel</p>
+ * <p>Example Grid Panel</p>
  * <p><pre>
  * </pre></p>
  * 
@@ -26,20 +26,25 @@ Ext.namespace('Tine.ExampleApplication');
  * 
  * @param       {Object} config
  * @constructor
- * Create a new Tine.ExampleApplication.ExampleRecordGridPanel
+ * Create a new Tine.ExampleApplication.ExampleGridPanel
  */
-Tine.ExampleApplication.ExampleRecordGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
-
+Tine.ExampleApplication.ExampleGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
+    /**
+     * record class
+     * @cfg {Tine.Example.Model.Task} recordClass
+     */
+    recordClass: Tine.Example.Model.Example,
+    
     initComponent: function() {
         this.initDetailsPanel();
-        Tine.ExampleApplication.ExampleRecordGridPanel.superclass.initComponent.call(this);
+        Tine.ExampleApplication.ExampleGridPanel.superclass.initComponent.call(this);
     },
     
     /**
      * @private
      */
     initDetailsPanel: function() {
-        this.detailsPanel = new Tine.ExampleApplication.ExampleRecordDetailsPanel({
+        this.detailsPanel = new Tine.ExampleApplication.ExampleDetailsPanel({
             grid : this,
             app: this.app
         });
diff --git a/tine20/ExampleApplication/js/Models.js b/tine20/ExampleApplication/js/Models.js
new file mode 100644 (file)
index 0000000..65bfc88
--- /dev/null
@@ -0,0 +1,32 @@
+Ext.namespace('Tine', 'Tine.Example.Model');
+
+Tine.Example.Model.RecordArray = Tine.Tinebase.Model.genericFields.concat([
+   { name: 'id' },
+   { name: 'container_id' },
+   /*** define more fields here ***/
+]);
+
+Tine.Example.Model.Record = Tine.Tinebase.data.Record.create(Tine.Example.Model.RecordArray, {
+   appName: 'Example',
+   modelName: 'Record',
+   idProperty: 'id',
+   //titleProperty: 'title',
+   recordName: 'Record',
+   recordsName: 'Records',
+   containerProperty: 'container_id',
+   containerName: 'Record list',
+   containersName: 'Record lists'
+});
+
+Tine.Example.Model.Record.getFilterModel = function() {
+   var app = Tine.Tinebase.appMgr.get('Example');
+   
+   return [
+       {label : _('Quick search'), field : 'query', operators : [ 'contains' ]},
+       {filtertype : 'tine.widget.container.filtermodel', app : app
+           , recordClass : Tine.Example.Model.Record},
+       {filtertype : 'tinebase.tag', app : app}
+   ];
+};
+
+/*** add more models here if you need them ***/
index 7146bca..88d1138 100644 (file)
@@ -42,25 +42,25 @@ class Tool_CodeGenerator_Application implements Tool_CodeGenerator_Interface
     );
 
     /**
-     * 
+     *
      * @var application root directory
      */
     protected $_applicationFolder = null;
 
     /**
-     * 
+     *
      * @var name of application applied to every class
      */
     protected $_applicationName = null;
 
     /**
-     * 
-     * @var reference folder for finding templates 
+     *
+     * @var reference folder for finding templates
      */
     protected $_rootFolder = null;
     
     /**
-     * 
+     *
      * @var absolute path for templates
      */
     protected $_templateFolder = null;
@@ -76,9 +76,11 @@ class Tool_CodeGenerator_Application implements Tool_CodeGenerator_Interface
             'Frontend/Cli.php' => 'Frontend/Cli.php',
             'Frontend/Http.php' => 'Frontend/Http.php',
             'Frontend/Json.php' => 'Frontend/Json.php',
-            'js/ExampleRecordDetailsPanel.js' => "js/{$applicationName}RecordDetailsPanel.js",
-            'js/ExampleRecordEditDialog.js' => "js/{$applicationName}RecordEditDialog.js",
-            'js/ExampleRecordGridPanel.js' => "js/{$applicationName}RecordGridPanel.js",
+            'js/Example.js' => "js/{$applicationName}.js",
+            'js/Models.js' => "js/Models.js",
+            'js/ExampleDetailsPanel.js' => "js/{$applicationName}DetailsPanel.js",
+            'js/ExampleEditDialog.js' => "js/{$applicationName}EditDialog.js",
+            'js/ExampleGridPanel.js' => "js/{$applicationName}GridPanel.js",
             'Model/ExampleRecord.php' => "Model/{$applicationName}Record.php",
             'Model/ExampleRecordFilter.php' => "Model/{$applicationName}RecordFilter.php",
             'Model/Status.php' => "Model/Status.php",
@@ -93,10 +95,6 @@ class Tool_CodeGenerator_Application implements Tool_CodeGenerator_Interface
         );
     }
 
-    /**
-     * (non-PHPdoc)
-     * @see Tool_CodeGenerator_Interface::build()
-     */
     public function build(array $args)
     {
         try {
@@ -126,11 +124,20 @@ class Tool_CodeGenerator_Application implements Tool_CodeGenerator_Interface
      */
     protected function _createFolders()
     {
+        if (file_exists($this->_applicationFolder)) {
+            throw new Exception($this->_applicationFolder . ' already exists! Remove it and run application generator again!');            
+        }
+                    
         mkdir($this->_fsOsSintax($this->_applicationFolder));
 
         foreach ($this->_folders as $folder)
         {
-            mkdir($this->_fsOsSintax($this->_applicationFolder . self::DS . $folder));
+            $subFolder = $this->_applicationFolder . self::DS . $folder;
+            if (file_exists($subFolder)) {
+                throw new Exception($subFolder . ' already exists! Remove it and run application generator again!');
+            }
+            
+            mkdir($this->_fsOsSintax($subFolder));
         }
     }
 
@@ -183,6 +190,7 @@ class Tool_CodeGenerator_Application implements Tool_CodeGenerator_Interface
         $content = str_replace('ExampleApplication', $this->_applicationName, $content);
         $content = str_replace('ExampleRecord', $this->_applicationName . 'Record', $content);
         $content = str_replace('EXAMPLERECORD', strtoupper($this->_applicationName) . 'RECORD', $content);
+        $content = str_replace('Example', $this->_applicationName, $content);
         $chainFilter = new Zend_Filter();
         $chainFilter->addFilter(new Zend_Filter_Word_CamelCaseToUnderscore())
                     ->addFilter(new Zend_Filter_StringToLower());
@@ -200,5 +208,5 @@ class Tool_CodeGenerator_Application implements Tool_CodeGenerator_Interface
     protected function _fsOsSintax($path)
     {
         return str_replace('/', self::DS, $path);
-    }  
-}
+    }    
+}
\ No newline at end of file