OSDN Git Service

MainTabs.jsに持たせていた業務タブ表示時のロジックを、contorollerのMenu.jsに移動。
authormasamitsu <oicawa@users.sourceforge.jp>
Fri, 30 Sep 2011 08:54:40 +0000 (17:54 +0900)
committermasamitsu <oicawa@users.sourceforge.jp>
Fri, 30 Sep 2011 08:54:40 +0000 (17:54 +0900)
app/controller/Menu.js
app/view/platform/MainTabs.js

index 304f61c..be200b7 100644 (file)
@@ -32,12 +32,59 @@ Ext.define(
            console.log('Double clicked on ' + record.get('caption'));
            var caption = record.get('caption');
            var id = record.get('id');
+           var tabId = id + '-tab';
 
            console.log('clicked the ShowMenu entry { text: ' + caption +  ', id:' + id + '}');
            var viewport = grid.up('viewport');
            //var maintabs = viewport.child('#maintabs');
            var maintabs = Decshee.Viewport.child('#maintabs');
-           maintabs.showTab(record);
+           var tab = maintabs.child('#' + tabId);
+
+           // タブが生成されていない場合は生成する。
+           if (tab == null) {
+               // アドインをロードするための諸パラメータを生成
+               var srcPath = 'addins/' + id;
+               var packagePath = 'Decshee.' + id;
+               var rootPath = packagePath + '.controller.Root';
+               var rootPanelPath = packagePath + '.view.Panel';
+
+               console.log(srcPath);
+               console.log(packagePath);
+               console.log(rootPath);
+
+               var addin = Decshee.AddIns[id];
+               if (addin == null) {
+                   console.log('AddIn [' + id + '] has not loaded.');
+
+                   // アドインのパスをローダに設定し、かつクラスをロードする。
+                   Ext.Loader.setPath(packagePath, srcPath);
+                   Ext.require(packagePath + '.*');
+
+                   // アドインのコントローラを取得して初期化。
+                   var rootController = Decshee.Application.getController(rootPath);
+                   rootController.init();
+                   
+                   Decshee.AddIns[id] = rootController;
+               }
+
+               // タブを追加
+               maintabs.add(
+                   {
+                       title: caption,
+                       itemId: tabId,
+                       iconCls: 'tabs',
+                       closable: true,
+                       layout: 'fit',
+                       items: [
+                           { xtype: id + 'rootpanel' }
+                       ]
+                   }
+               )
+               tab = maintabs.child('#' + tabId);
+           }
+
+           // タブをアクティブ化
+           tab.show();
        }
     }
 );
\ No newline at end of file
index 0268b70..53ccd4f 100644 (file)
@@ -23,63 +23,6 @@ Ext.define(
            );
 
            this.callParent(arguments);
-       },
-
-       showTab: function(entryRecord) {
-           var me = this;
-
-           var caption = entryRecord.get('caption');
-           var id = entryRecord.get('id');
-           var tabId = id + '-tab';
-           var tab = me.child('#' + tabId);
-
-           // 指定したアドインのタブが存在しない場合のみ動的にパス設定を行い、
-           // 該当する業務機能の全コンポーネントをロードしてタブを追加する。
-           if (tab == null) {
-               // アドインのロード
-               var srcPath = 'addins/' + id;
-               var packagePath = 'Decshee.' + id;
-               var rootPath = packagePath + '.controller.Root';
-               var rootPanelPath = packagePath + '.view.Panel';
-
-               console.log(srcPath);
-               console.log(packagePath);
-               console.log(rootPath);
-
-               var addin = Decshee.AddIns[id];
-               if (addin == null) {
-
-                   Ext.Loader.setPath(packagePath, srcPath);
-                   Ext.require(packagePath + '.*');
-
-                   var rootController = Decshee.Application.getController(rootPath);
-                   console.log(rootController);
-                   rootController.init();
-                   
-                   Decshee.AddIns[id] = rootController;
-                   console.log('AddIn [' + id + '] has not loaded.');
-               }
-
-               try {
-                   // タブを追加。
-                   me.add(
-                       {
-                           title: caption,
-                           itemId: tabId,
-                           iconCls: 'tabs',
-                           closable: true,
-                           layout: 'fit',
-                           items: [
-                               { xtype: id + 'rootpanel' }
-                           ]
-                       }
-                   );
-                   tab = me.child('#' + tabId);
-               } catch(e) {
-                   alert(e);
-               }
-           }
-           tab.show();
        }
     }
 );
\ No newline at end of file