@@ -27,13 +27,16 @@ define(function (require, exports, module) {
27
27
28
28
var PreferencesManager = brackets . getModule ( "preferences/PreferencesManager" ) ,
29
29
Strings = brackets . getModule ( "strings" ) ,
30
- ProjectManager = brackets . getModule ( "project/ProjectManager" ) ;
30
+ ProjectManager = brackets . getModule ( "project/ProjectManager" ) ,
31
+ Dialogs = brackets . getModule ( "widgets/Dialogs" ) ,
32
+ DefaultDialogs = brackets . getModule ( "widgets/DefaultDialogs" ) ;
31
33
32
34
33
35
var _requestID = 0 ,
34
36
_initialized = false ;
35
37
36
38
var _graphicsFileTypes = [ "jpg" , "jpeg" , "png" , "svg" , "xd" , "psd" , "ai" ] ;
39
+ //var _graphicsFileTypes = [ "psd"];
37
40
38
41
var _nodeDomain ;
39
42
@@ -64,6 +67,10 @@ define(function (require, exports, module) {
64
67
65
68
function _checkForGraphicsFileInPrjct ( ) {
66
69
70
+ if ( PreferencesManager . getViewState ( "AssociateGraphicsFileDialogShown" ) ) {
71
+ return ;
72
+ }
73
+
67
74
_nodeDomain . exec ( "checkFileTypesInFolder" , {
68
75
extensions : _graphicsFileTypes . join ( ) ,
69
76
folder : ProjectManager . getProjectRoot ( ) . fullPath ,
@@ -74,7 +81,50 @@ define(function (require, exports, module) {
74
81
75
82
function _graphicsFilePresentInProject ( isPresent ) {
76
83
77
- console . log ( "Graphics File present in project" , isPresent ) ;
84
+ if ( ! isPresent ) {
85
+ return ;
86
+ }
87
+
88
+ Dialogs . showModalDialog (
89
+ DefaultDialogs . DIALOG_ID_INFO ,
90
+ Strings . ASSOCIATE_GRAPHICS_FILE_TO_DEFAULT_APP_TITLE ,
91
+ Strings . ASSOCIATE_GRAPHICS_FILE_TO_DEFAULT_APP_MSG ,
92
+ [
93
+ { className : Dialogs . DIALOG_BTN_CLASS_NORMAL , id : Dialogs . DIALOG_BTN_CANCEL ,
94
+ text : Strings . BUTTON_NO
95
+ } ,
96
+ { className : Dialogs . DIALOG_BTN_CLASS_PRIMARY , id : Dialogs . DIALOG_BTN_OK ,
97
+ text : Strings . BUTTON_YES
98
+ }
99
+ ]
100
+ ) . done ( function ( id ) {
101
+
102
+ if ( id !== Dialogs . DIALOG_BTN_OK )
103
+ return ;
104
+
105
+ brackets . app . getSystemDefaultApp ( _graphicsFileTypes . join ( ) , function ( err , out ) {
106
+ var associateApp = out . split ( ',' ) ,
107
+ fileTypeToAppMap = { } ;
108
+
109
+ associateApp . forEach ( function ( item ) {
110
+ fileTypeToAppMap [ item . split ( ':' ) [ 0 ] ] = item . split ( ':' ) [ 1 ]
111
+ } ) ;
112
+ Dialogs . showModalDialog (
113
+ DefaultDialogs . DIALOG_ID_INFO ,
114
+ Strings . ASSOCIATE_GRAPHICS_FILE_TO_DEFAULT_APP_TITLE ,
115
+ out ,
116
+ [
117
+ { className : Dialogs . DIALOG_BTN_CLASS_NORMAL , id : Dialogs . DIALOG_BTN_CANCEL ,
118
+ text : Strings . BUTTON_NO
119
+ } ,
120
+ { className : Dialogs . DIALOG_BTN_CLASS_PRIMARY , id : Dialogs . DIALOG_BTN_OK ,
121
+ text : Strings . BUTTON_YES
122
+ }
123
+ ]
124
+ )
125
+ } ) ;
126
+ } ) ;
127
+ PreferencesManager . setViewState ( "AssociateGraphicsFileDialogShown" , true ) ;
78
128
79
129
}
80
130
0 commit comments