From 748205523b2de1d0acbd98c2e9a1f84ce0ec0ed4 Mon Sep 17 00:00:00 2001 From: Shim Heungwoon Date: Wed, 23 Sep 2015 16:26:33 +0900 Subject: [PATCH 1/6] [TASK] Topic 'data-source/written' sends dataSourceId as a parameter --- .../src/plugins/webida.workspace.model.file/FileDataSource.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js b/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js index 706322ad..0f1650e4 100644 --- a/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js +++ b/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js @@ -139,7 +139,7 @@ define([ file.setFlag(Persistence.READ, true); callback(file.getContents()); that.emit(DataSource.AFTER_SAVE); - topic.publish('data-source/written', that); + topic.publish('data-source/written', that.getId()); } }); }, From e03c2eebaddd9068cebd40b04c1f810649f694cf Mon Sep 17 00:00:00 2001 From: Shim Heungwoon Date: Wed, 23 Sep 2015 17:59:05 +0900 Subject: [PATCH 2/6] [TASK] PartModelManager : getSavedData removed --- .../ui/AbstractEditorModelManager.js | 10 ---- .../plugins/workbench/ui/PartModelManager.js | 15 ----- .../webida/plugins/workbench/ui/doc/Parts.uml | 59 +++++++------------ 3 files changed, 21 insertions(+), 63 deletions(-) diff --git a/common/src/webida/plugins/workbench/ui/AbstractEditorModelManager.js b/common/src/webida/plugins/workbench/ui/AbstractEditorModelManager.js index 74690824..bffc037b 100644 --- a/common/src/webida/plugins/workbench/ui/AbstractEditorModelManager.js +++ b/common/src/webida/plugins/workbench/ui/AbstractEditorModelManager.js @@ -235,16 +235,6 @@ define([ */ getDataSource: function() { return this.dataSource; - }, - - /** - * For the EditorPart, saved data could be retrived - * from dataSource. So setSavedData() is not required. - * @override - * @return {string} - */ - getSavedData: function() { - return this.getDataSource().getPersistence().getContents(); } }); diff --git a/common/src/webida/plugins/workbench/ui/PartModelManager.js b/common/src/webida/plugins/workbench/ui/PartModelManager.js index ffe42145..2595f51c 100644 --- a/common/src/webida/plugins/workbench/ui/PartModelManager.js +++ b/common/src/webida/plugins/workbench/ui/PartModelManager.js @@ -88,21 +88,6 @@ define([ return this.model; }, - /** - * @param {Object} data - */ - setSavedData: function(data) { - logger.info('setSavedData(' + data + ')'); - this.savedData = data; - }, - - /** - * @return {Object} - */ - getSavedData: function() { - return this.savedData; - }, - /** * @private */ diff --git a/common/src/webida/plugins/workbench/ui/doc/Parts.uml b/common/src/webida/plugins/workbench/ui/doc/Parts.uml index 01e98f06..85b1a51a 100644 --- a/common/src/webida/plugins/workbench/ui/doc/Parts.uml +++ b/common/src/webida/plugins/workbench/ui/doc/Parts.uml @@ -6605,7 +6605,7 @@ our application will be working with. $00F2A753 $00FDE1BB 583 -159 +160 177 121 sdkNone @@ -6633,7 +6633,7 @@ our application will be working with. $00F2A753 $00E4E4E4 824 -24 +23 207 394 sdkNone @@ -6661,7 +6661,7 @@ our application will be working with. $00F2A753 $00E4E4E4 1087 -87 +88 182 264 sdkNone @@ -6841,7 +6841,7 @@ our application will be working with. $00F2A753 $00FDE1BB -759,219;824,219 +759,220;824,220 nRzj3jTj7kOMyzdWm3FJ7gAA sMVyS8IN8kWnY6YR1cSLQwAA B/V5lcTmaUOdx44RxUDLiAAA @@ -6926,7 +6926,7 @@ our application will be working with. $00F2A753 $00E4E4E4 -670,520;671,279 +670,520;671,280 JkUY7sp4+UGmOtzZ2siytAAA B/V5lcTmaUOdx44RxUDLiAAA nkkqvoaN9UG/awAjNU3GkAAA @@ -7344,7 +7344,7 @@ our application will be working with. $00F2A753 $00B9FFFF -1177,501;1177,350 +1177,501;1177,351 DabV4QlII0WObnnqTWYTHgAA FFVEG7n/rkmBRp1CJCSlfAAA QcOseVhqCUio/J75UTE++gAA @@ -7370,7 +7370,7 @@ our application will be working with. $00F2A753 $00B9FFFF -927,507;927,417 +927,507;927,416 FHcUe1GwJ0GEn3sODNlt4AAA sMVyS8IN8kWnY6YR1cSLQwAA YjGRqj/9pkqYEN6zyi2o7wAA @@ -7655,9 +7655,9 @@ our application will be working with. $00F2A753 $00FDE1BB 375 -157 +171 148 -124 +98 NLb1Y0FDn0SXtf9udRHwZwAA @@ -7686,7 +7686,7 @@ our application will be working with. $00F2A753 $00B9FFFF -583,219;522,219 +583,220;522,220 J6NXsFlqm0mMZ7ZYpFxSegAA 1Uhhcdl+/UmWzwktO3BuFwAA B/V5lcTmaUOdx44RxUDLiAAA @@ -7770,7 +7770,7 @@ our application will be working with. $00F2A753 $00B9FFFF -448,514;448,486 +448,514;448,479 m1zndYRQ/Um5EP94IHFJTQAA SSKi3BwWs0COm+0mEfaebwAA h1qUrrLvOEuzbIEVLIr0qAAA @@ -7797,7 +7797,7 @@ our application will be working with. $00F2A753 $00FDE1BB 112 -254 +253 171 290 sdkNone @@ -7824,7 +7824,7 @@ our application will be working with. $00F2A753 $00B9FFFF -282,398;361,398 +282,397;361,397 hC4ZL8IHE0u2o0SoziDW8wAA SSKi3BwWs0COm+0mEfaebwAA PHZKGfT0k0yV0aMY8vvdEQAA @@ -7941,9 +7941,9 @@ our application will be working with. $00F2A753 $00FDE1BB 361 -311 +317 176 -176 +163 OoPGOUb9L0mxuKpmKWIT2AAA @@ -7972,7 +7972,7 @@ our application will be working with. $00F2A753 $00B9FFFF -448,311;448,280 +448,317;448,268 BWsdK3mtdE6yK7GgfpHHtwAA 1Uhhcdl+/UmWzwktO3BuFwAA SSKi3BwWs0COm+0mEfaebwAA @@ -12852,7 +12852,7 @@ our application will be working with. CCLNNI9JwEexS91pFazmgAAA 1 BWsdK3mtdE6yK7GgfpHHtwAA -7 +5 createModel NLb1Y0FDn0SXtf9udRHwZwAA @@ -12874,20 +12874,7 @@ our application will be working with. getModel NLb1Y0FDn0SXtf9udRHwZwAA - -setSavedData -NLb1Y0FDn0SXtf9udRHwZwAA -1 - -Object -495QEGZS+Uu2fUbnfNyygQAA - - - -getSavedData -NLb1Y0FDn0SXtf9udRHwZwAA - - + _execFunc vkPrivate NLb1Y0FDn0SXtf9udRHwZwAA @@ -13072,7 +13059,7 @@ our application will be working with. BWsdK3mtdE6yK7GgfpHHtwAA 1 m1zndYRQ/Um5EP94IHFJTQAA -11 +10 saveModel OoPGOUb9L0mxuKpmKWIT2AAA @@ -13125,15 +13112,11 @@ our application will be working with. getDataSource OoPGOUb9L0mxuKpmKWIT2AAA - -getSavedData -OoPGOUb9L0mxuKpmKWIT2AAA - - + syncTo OoPGOUb9L0mxuKpmKWIT2AAA - + syncFrom OoPGOUb9L0mxuKpmKWIT2AAA From c49a51027cc626b010316fdd48fb60478182cca2 Mon Sep 17 00:00:00 2001 From: Shim Heungwoon Date: Wed, 23 Sep 2015 18:00:30 +0900 Subject: [PATCH 3/6] [TASK] EditorModelManager : resetModel() updated --- .../src/webida/plugins/workbench/ui/EditorModelManager.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/webida/plugins/workbench/ui/EditorModelManager.js b/common/src/webida/plugins/workbench/ui/EditorModelManager.js index 2897ad44..b6f09aea 100644 --- a/common/src/webida/plugins/workbench/ui/EditorModelManager.js +++ b/common/src/webida/plugins/workbench/ui/EditorModelManager.js @@ -108,10 +108,11 @@ define([ * Resets the given EditorModel to its last saved state. */ resetModel: function() { - logger.info('resetModel()'); + logger.info('resetModel()'); var model = this.getModel(); - logger.info('this.getSavedData() = ', this.getSavedData()); - model.createContents(this.getSavedData()); + this.getDataSource().getData(function(data) { + model.createContents(data); + }); }, }); From f394a133d5939790616aba9e728b815fb7c45edd Mon Sep 17 00:00:00 2001 From: Shim Heungwoon Date: Wed, 23 Sep 2015 18:02:07 +0900 Subject: [PATCH 4/6] [TASK] DataSource : DataSource's events added --- .../webida.workspace.model.file/FileDataSource.js | 3 +++ .../src/webida/plugins/workbench/ui/DataSource.js | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js b/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js index 0f1650e4..4ee555d6 100644 --- a/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js +++ b/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js @@ -106,13 +106,16 @@ define([ var that = this; var file = this.getPersistence(); if (file.getFlag(Persistence.READ) === false) { + this.emit(DataSource.LOAD_START, this); fsCache.readFile(file.getPath(), function(error, data) { if (error) { notify.error('Failed to read file "' + file.getPath() + '" (' + error + ')'); + that.emit(DataSource.LOAD_FAIL, that); } else { logger.info('data arrived'); file.setContents(data); file.setFlag(Persistence.READ, true); + that.emit(DataSource.LOAD_COMPLETE, data); callback(file.getContents()); } }); diff --git a/common/src/webida/plugins/workbench/ui/DataSource.js b/common/src/webida/plugins/workbench/ui/DataSource.js index 6a957841..93d58a09 100644 --- a/common/src/webida/plugins/workbench/ui/DataSource.js +++ b/common/src/webida/plugins/workbench/ui/DataSource.js @@ -142,14 +142,21 @@ define([ /** * Emit this event when DataSource's - * getContents() start to load the contents + * getContents() starts to load the contents * @constant {string} */ DataSource.LOAD_START = 'loadStart'; /** * Emit this event when DataSource's - * getContents() complete to load the contents + * getContents() fails to load the contents + * @constant {string} + */ + DataSource.LOAD_FAIL = 'loadFail'; + + /** + * Emit this event when DataSource's + * getContents() completes to load the contents * @constant {string} */ DataSource.LOAD_COMPLETE = 'loadComplete'; @@ -168,12 +175,12 @@ define([ */ DataSource.AFTER_SAVE = 'afterSave'; - /** + /** * Emit this event when error occured * during setData(contents, callback) * @constant {string} */ - DataSource.SAVE_FAIL = 'saveFail'; + DataSource.SAVE_FAIL = 'saveFail'; /** * This event is emitted when setId(newId) is called From f7786e7e22e0f4465e338dc0f373432bfe373b36 Mon Sep 17 00:00:00 2001 From: Shim Heungwoon Date: Wed, 23 Sep 2015 18:12:06 +0900 Subject: [PATCH 5/6] [TASK] DataSource : reload() interface added --- .../FileDataSource.js | 10 +++ .../webida/plugins/workbench/ui/DataSource.js | 7 +++ .../workbench/ui/EditorModelManager.js | 2 +- .../webida/plugins/workbench/ui/doc/Parts.uml | 61 +++++++++++-------- 4 files changed, 53 insertions(+), 27 deletions(-) diff --git a/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js b/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js index 4ee555d6..8387b801 100644 --- a/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js +++ b/apps/ide/src/plugins/webida.workspace.model.file/FileDataSource.js @@ -98,6 +98,16 @@ define([ return false; }, + /** + * @param {Function} callback + */ + reload: function(callback) { + logger.info('reload(callback)'); + var file = this.getPersistence(); + file.setFlag(Persistence.READ, false); + this.getData(callback); + }, + /** * @param {Function} callback */ diff --git a/common/src/webida/plugins/workbench/ui/DataSource.js b/common/src/webida/plugins/workbench/ui/DataSource.js index 93d58a09..5d1975f8 100644 --- a/common/src/webida/plugins/workbench/ui/DataSource.js +++ b/common/src/webida/plugins/workbench/ui/DataSource.js @@ -113,6 +113,13 @@ define([ throw new Error('getData(callback) should be implemented by ' + this.constructor.name); }, + /** + * @param {Function} callback + */ + reload: function(callback) { + throw new Error('reload(callback) should be implemented by ' + this.constructor.name); + }, + /** * @return {string} title */ diff --git a/common/src/webida/plugins/workbench/ui/EditorModelManager.js b/common/src/webida/plugins/workbench/ui/EditorModelManager.js index b6f09aea..b40c122f 100644 --- a/common/src/webida/plugins/workbench/ui/EditorModelManager.js +++ b/common/src/webida/plugins/workbench/ui/EditorModelManager.js @@ -110,7 +110,7 @@ define([ resetModel: function() { logger.info('resetModel()'); var model = this.getModel(); - this.getDataSource().getData(function(data) { + this.getDataSource().reload(function(data) { model.createContents(data); }); }, diff --git a/common/src/webida/plugins/workbench/ui/doc/Parts.uml b/common/src/webida/plugins/workbench/ui/doc/Parts.uml index 85b1a51a..7d8b0a5d 100644 --- a/common/src/webida/plugins/workbench/ui/doc/Parts.uml +++ b/common/src/webida/plugins/workbench/ui/doc/Parts.uml @@ -1821,9 +1821,9 @@ $00F2A753 $00FDE1BB 1052 -234 +230 171 -290 +303 sdkNone YKwkdEIodkC4pz12F+CpxAAA @@ -1848,7 +1848,7 @@ $00F2A753 $00FDE1BB -1189,523;1260,720;1260,1056;1164,1224;951,1225 +1192,532;1260,720;1260,1056;1164,1224;951,1225 cGD7bZq690iECmzrvqLWTAAA kc+XTU8ZREKzpZ/2itAQRgAA Mrp67zC/nEG/5DD7kQQO4QAA @@ -1933,7 +1933,7 @@ $00F2A753 $00B9FFFF -1137,523;1138,756 +1137,532;1138,756 DuxZWMKrnEyXYFy6M7PxgQAA QTv8/bdafUO2YE7d/VvO0QAA Mrp67zC/nEG/5DD7kQQO4QAA @@ -2213,7 +2213,7 @@ $00F2A753 $00FDE1BB 744 -312 +314 220 134 Fyxd4XK/wkqtn9NvCOBHewAA @@ -2243,7 +2243,7 @@ $00F2A753 $00FDE1BB -744,378;665,378 +744,380;665,380 AeiN0lSzyUuDdFmqwkCC7QAA mEXWZCiLRUaVK0t+iYRMlQAA d5G/Cvex4EanJ1nn2hzlvwAA @@ -2328,7 +2328,7 @@ $00F2A753 $00B9FFFF -1052,378;963,378 +1052,381;963,381 wLr5nDy5HEaAHf2iTxChVgAA d5G/Cvex4EanJ1nn2hzlvwAA Mrp67zC/nEG/5DD7kQQO4QAA @@ -2526,7 +2526,7 @@ $00F2A753 $00FDE1BB -1138,157;1138,234 +1138,157;1138,230 IMNGhaMLq0K+/ld6+rY5iwAA Mrp67zC/nEG/5DD7kQQO4QAA 2OG9RoSopUKmrB+7Z7U/9AAA @@ -3194,7 +3194,7 @@ A factoryId is a path of the DataSourceFactory module. $00F2A753 $00B9FFFF -900,445;1080,704;1108,756 +900,447;1080,704;1108,756 6p1ovGZoYEqg5QeTigKu8wAA QTv8/bdafUO2YE7d/VvO0QAA d5G/Cvex4EanJ1nn2hzlvwAA @@ -4298,7 +4298,7 @@ A factoryId is a path of the DataSourceFactory module. $00F2A753 $00FDE1BB 1270 -273 +275 146 212 sdkNone @@ -4325,7 +4325,7 @@ A factoryId is a path of the DataSourceFactory module. $00F2A753 $00FDE1BB -1270,378;1222,378 +1270,380;1222,380 ih2a01Kt6UuK19ifNq1pfwAA Mrp67zC/nEG/5DD7kQQO4QAA Y6oAdMqFxk2exv1m2cI2TgAA @@ -4409,7 +4409,7 @@ A factoryId is a path of the DataSourceFactory module. $00F2A753 $00FDE1BB -1343,216;1343,273 +1343,216;1343,275 GTLicH1qX0anhYBROl8bUAAA Y6oAdMqFxk2exv1m2cI2TgAA YUTcz9KyUEWXNhFkiOKbCQAA @@ -4466,7 +4466,7 @@ A factoryId is a path of the DataSourceFactory module. $00F2A753 $00B9FFFF -1468,214;1415,283 +1468,214;1415,284 R1ZePh8zAUG/s0/QOQf46QAA Y6oAdMqFxk2exv1m2cI2TgAA /Re2jLa6jUeDFhpkeHbaeQAA @@ -4828,7 +4828,7 @@ our application will be working with. $00F2A753 $00B9FFFF 454 -312 +314 212 134 iktmRuCEZ0yzOj3njuoUlAAA @@ -4858,7 +4858,7 @@ our application will be working with. $00F2A753 $00B9FFFF -559,445;559,485 +559,447;559,485 A5vG3kcTZkaRlbqHPqB2CAAA uvEYY0omvk+iOrau4hp6dQAA mEXWZCiLRUaVK0t+iYRMlQAA @@ -5083,7 +5083,7 @@ our application will be working with. $00F2A753 $00B9FFFF -559,258;559,312 +559,258;559,314 qt+Feypem0+PSmgwLN7+aQAA mEXWZCiLRUaVK0t+iYRMlQAA nTsR4YXFrkeVoOvVMVo3aAAA @@ -7770,7 +7770,7 @@ our application will be working with. $00F2A753 $00B9FFFF -448,514;448,479 +448,514;448,480 m1zndYRQ/Um5EP94IHFJTQAA SSKi3BwWs0COm+0mEfaebwAA h1qUrrLvOEuzbIEVLIr0qAAA @@ -7797,9 +7797,9 @@ our application will be working with. $00F2A753 $00FDE1BB 112 -253 +248 171 -290 +303 sdkNone YKwkdEIodkC4pz12F+CpxAAA @@ -7824,7 +7824,7 @@ our application will be working with. $00F2A753 $00B9FFFF -282,397;361,397 +282,399;361,399 hC4ZL8IHE0u2o0SoziDW8wAA SSKi3BwWs0COm+0mEfaebwAA PHZKGfT0k0yV0aMY8vvdEQAA @@ -7941,7 +7941,7 @@ our application will be working with. $00F2A753 $00FDE1BB 361 -317 +318 176 163 OoPGOUb9L0mxuKpmKWIT2AAA @@ -7972,7 +7972,7 @@ our application will be working with. $00F2A753 $00B9FFFF -448,317;448,268 +448,318;448,268 BWsdK3mtdE6yK7GgfpHHtwAA 1Uhhcdl+/UmWzwktO3BuFwAA SSKi3BwWs0COm+0mEfaebwAA @@ -9826,7 +9826,7 @@ our application will be working with. DuxZWMKrnEyXYFy6M7PxgQAA 1 IMNGhaMLq0K+/ld6+rY5iwAA -11 +12 DataSource YKwkdEIodkC4pz12F+CpxAAA @@ -9893,15 +9893,24 @@ our application will be working with. Ah17N1sb4kadaRbctIUZOgAA - + +reload +YKwkdEIodkC4pz12F+CpxAAA +1 + +callback +tw8kfQpYJ0aVrztvnenxTQAA + + + getTitle YKwkdEIodkC4pz12F+CpxAAA - + getToolTip YKwkdEIodkC4pz12F+CpxAAA - + getTitleImage YKwkdEIodkC4pz12F+CpxAAA From 5712b3621326f102e8e0e20319be990e2b3bed7d Mon Sep 17 00:00:00 2001 From: Shim Heungwoon Date: Wed, 23 Sep 2015 18:22:25 +0900 Subject: [PATCH 6/6] [BUGFIX] Reloading file updated from another ide --- .../plugins/editors/DataSourceHandler.js | 36 +++++++++++++- common/src/webida/plugins/editors/plugin.js | 48 ++----------------- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/common/src/webida/plugins/editors/DataSourceHandler.js b/common/src/webida/plugins/editors/DataSourceHandler.js index 224124a3..23b0ba2c 100644 --- a/common/src/webida/plugins/editors/DataSourceHandler.js +++ b/common/src/webida/plugins/editors/DataSourceHandler.js @@ -77,9 +77,12 @@ define([ * @private */ _subscribe: function() { - //open + //on deleted this.subscribed.push(topic.subscribe('workspace.nodes.deleting', this._onNodesDeleted.bind(this))); this.subscribed.push(topic.subscribe('fs.cache.node.deleted', this._checkCase.bind(this))); + + //on content changed + this.subscribed.push(topic.subscribe('data-source/content-change', this._onContentChange.bind(this))); }, /** @@ -210,6 +213,14 @@ define([ } }, + // ************* On Content Changed ************* // + + _onContentChange: function(dataSourceId) { + var dsRegistry = workbench.getDataSourceRegistry(); + var dataSource = dsRegistry.getDataSourceById(dataSourceId); + _askReload(dataSource); + }, + /** * @private */ @@ -238,5 +249,28 @@ define([ }); } + function _askReload(dataSource) { + var dataSourceId = dataSource.getId(); + var persistence = dataSource.getPersistence(); + require(['popup-dialog'], function(PopupDialog) { + // @formatter:off + PopupDialog.yesno({ + title: "Reload '" + persistence.getName() + "'?", + message: "'" + persistence.getPath() + "' has been changed. " + + 'Reload the editor(s) for the resource?', + type: 'warning' + }).then(function() { + var page = workbench.getCurrentPage(); + var registry = page.getPartRegistry(); + var parts = registry.getPartsByDataSource(dataSource); + parts.forEach(function(part) { + part.resetModel(); + }); + }, function() { + }); + // @formatter:on + }); + } + return DataSourceHandler; }); diff --git a/common/src/webida/plugins/editors/plugin.js b/common/src/webida/plugins/editors/plugin.js index badd6f61..17139e97 100644 --- a/common/src/webida/plugins/editors/plugin.js +++ b/common/src/webida/plugins/editors/plugin.js @@ -24,12 +24,9 @@ define([ 'dojo/topic', 'external/lodash/lodash.min', - 'external/URIjs/src/URI', 'webida-lib/app', - 'webida-lib/util/path', 'webida-lib/util/arrays/BubblingArray', 'webida-lib/util/logger/logger-client', - 'webida-lib/util/notify', 'webida-lib/plugin-manager-0.1', 'webida-lib/plugins/workbench/plugin', 'webida-lib/plugins/workbench/ui/CompatibleTabPartContainer', @@ -37,23 +34,17 @@ define([ 'webida-lib/plugins/workbench/ui/LayoutPane', 'webida-lib/plugins/workbench/ui/PartContainer', 'webida-lib/plugins/workbench/ui/Workbench', - 'webida-lib/widgets/views/view', 'webida-lib/widgets/views/viewmanager', 'webida-lib/widgets/views/viewFocusController', - 'external/async/dist/async.min', 'plugins/webida.notification/notification-message', - 'plugins/webida.workspace.model.file/FileDataSource', //TODO : temp for 7.21 './DataSourceHandler', './LifecycleManager' ], function ( topic, _, - URI, ide, - pathUtil, BubblingArray, Logger, - notify, pm, workbench, CompatibleTabPartContainer, @@ -61,12 +52,9 @@ define([ LayoutPane, PartContainer, Workbench, - View, vm, ViewFocusController, - async, toastr, - FileDataSource, DataSourceHandler, LifecycleManager ) { @@ -90,6 +78,7 @@ define([ }); topic.subscribe('fs.cache.file.invalidated', function(fsURL, path) { + logger.info('fs.cache.file.invalidated arrived'); var file = editors.getFile(path); if (file) { if (file === editors.currentFile) { @@ -102,14 +91,7 @@ define([ topic.subscribe('fs.cache.file.set', function(fsUrl, target, reason) { if (reason === 'refreshed') { - var file = editors.getFile(target); - if (file) { - if (file === editors.currentFile) { - _.defer(askAndReload.bind(null, file)); - } else { - file.toAskAndReload = true; - } - } + topic.publish('data-source/content-change', target); } }); @@ -121,7 +103,7 @@ define([ //Compatibility topic.subscribe('current-part-changed', function(oldPart, newPart) { - console.log('current-part-changed'); + logger.info('current-part-changed arrived'); if (oldPart !== newPart) { @@ -141,7 +123,7 @@ define([ key: 'E' }); - /////////////////////// TODO refactor + //------------ TODO refactor --------------- var file = newPart.getDataSource().getPersistence(); @@ -156,10 +138,6 @@ define([ fsCache.refreshFileContents(file.path); } - if (file.toAskAndReload) { - file.toAskAndReload = false; - _.defer(askAndReload.bind(null, file)); - } topic.publish('editors.selected', file.path, file); } } else { @@ -175,24 +153,6 @@ define([ var fsCache = ide.getFSCache(); var asked = []; - function askAndReload(file) { - require(['popup-dialog'], function(PopupDialog) { - if (asked.indexOf(file) === -1) { - console.assert(asked.length === 0, 'assertion fail: only one file is asked to reload at any point of time'); - asked.push(file); - PopupDialog.yesno({ - title: 'Reload File', - message: file.path + '

' + 'File \'' + file.name + '\' has changed.
' + 'Do you want to reload?', - type: 'warning' - }).then(function() { - asked.pop(); - topic.publish('editor/open', file.getPersistenceId()); - }, function() { - asked.pop(); - }); - } - }); - } /** @module editors */ var editors = {