Browse Source

switched to relative paths; added file extension

tags/v1.1.0
Robin Thoni 8 years ago
parent
commit
2dafad8ef9

+ 9
- 0
.idea/codeStyleSettings.xml View File

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectCodeStyleSettingsManager">
4
+    <option name="PER_PROJECT_SETTINGS">
5
+      <value />
6
+    </option>
7
+    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
8
+  </component>
9
+</project>

+ 2
- 0
resources/META-INF/plugin.xml View File

@@ -22,6 +22,8 @@
22 22
   <depends>com.intellij.database</depends>
23 23
 
24 24
   <extensions defaultExtensionNs="com.intellij">
25
+    <applicationService serviceImplementation="com.rthoni.intellij.codefromds.ui.others.NotificationsService"
26
+                        serviceInterface="com.rthoni.intellij.codefromds.ui.others.NotificationsService"/>
25 27
     <!-- Add your extensions here -->
26 28
   </extensions>
27 29
 

+ 12
- 5
src/com/rthoni/intellij/codefromds/business/Generator.java View File

@@ -1,6 +1,7 @@
1 1
 package com.rthoni.intellij.codefromds.business;
2 2
 
3 3
 import com.intellij.database.psi.DbDataSource;
4
+import com.intellij.openapi.project.Project;
4 5
 import com.rthoni.intellij.codefromds.dbo.GenerateOptions;
5 6
 import com.rthoni.intellij.codefromds.dbo.TableSelection;
6 7
 import org.json.JSONObject;
@@ -24,7 +25,7 @@ public abstract class Generator {
24 25
     {
25 26
         HashMap<String, Object> map = options.toMap();
26 27
         JSONObject obj = new JSONObject(map);
27
-        FileOutputStream file = new FileOutputStream(options.getConfigPath());
28
+        FileOutputStream file = new FileOutputStream(options.getConfigAbsolutePath());
28 29
         file.write(obj.toString(4).getBytes());
29 30
         file.close();
30 31
     }
@@ -42,7 +43,7 @@ public abstract class Generator {
42 43
         }
43 44
 
44 45
         GenerateOptions options = new GenerateOptions(dataSource);
45
-        options.setConfigPath(configPath);
46
+        options.setConfigAbsolutePath(configPath);
46 47
         options.fromJson(obj);
47 48
         return options;
48 49
     }
@@ -61,12 +62,18 @@ public abstract class Generator {
61 62
         file.close();
62 63
     }
63 64
 
64
-    public static void generate(GenerateOptions options) throws IOException
65
+    public static void generate(GenerateOptions options, Project project) throws IOException
65 66
     {
66
-        generateFile(options.getDataSourceTemplatePath(), options.getModelsPath() + File.separator + "Database.cs", options, null);
67
+        String modelsAbsolutePath = Helper.getAbsolutePath(project, options.getModelsRelativePath());
68
+        String dataSourceTemplateAbsolutePath = Helper.getAbsolutePath(project, options.getDataSourceTemplateRelativePath());
69
+        String modelsTemplateAbsolutePath = Helper.getAbsolutePath(project, options.getModelsTemplateRelativePath());
70
+
71
+        generateFile(dataSourceTemplateAbsolutePath, modelsAbsolutePath + File.separator +
72
+                "Database." + options.getFilesExtension(), options, null);
67 73
         for (TableSelection table : options.getSelection().getTables()) {
68 74
             if (!table.hasNone()) {
69
-                generateFile(options.getModelsTemplatePath(), options.getModelsPath() + File.separator + table.getTable().getName() + ".cs", options, table);
75
+                generateFile(modelsTemplateAbsolutePath, modelsAbsolutePath + File.separator +
76
+                        table.getTable().getName() + "." + options.getFilesExtension(), options, table);
70 77
             }
71 78
         }
72 79
     }

+ 44
- 0
src/com/rthoni/intellij/codefromds/business/Helper.java View File

@@ -8,9 +8,12 @@ import com.rthoni.intellij.codefromds.dbo.TableSelection;
8 8
 import org.json.JSONArray;
9 9
 import org.json.JSONObject;
10 10
 
11
+import java.io.File;
11 12
 import java.io.IOException;
12 13
 import java.nio.charset.StandardCharsets;
13 14
 import java.nio.file.Files;
15
+import java.nio.file.LinkOption;
16
+import java.nio.file.Path;
14 17
 import java.nio.file.Paths;
15 18
 import java.util.Arrays;
16 19
 import java.util.Collection;
@@ -64,4 +67,45 @@ public abstract class Helper {
64 67
         return Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8)
65 68
                 .stream().reduce("", (s1, s2) -> s1 + s2 + "\n");
66 69
     }
70
+
71
+    public static String getJsonString(JSONObject obj, String key, String defaultValue)
72
+    {
73
+        try {
74
+            return obj.getString(key);
75
+        }
76
+        catch (Exception ignored)
77
+        {
78
+            return defaultValue;
79
+        }
80
+    }
81
+
82
+    public static String getJsonString(JSONObject obj, String key)
83
+    {
84
+        return getJsonString(obj, key, "");
85
+    }
86
+
87
+    public static String getRelativePath(String base, String absolute)
88
+    {
89
+        if (absolute == null || absolute.isEmpty()) {
90
+            return "";
91
+        }
92
+        Path basePath = Paths.get(base);
93
+        Path absolutePath = Paths.get(absolute);
94
+        return basePath.relativize(absolutePath).toString();
95
+    }
96
+
97
+    public static String getRelativePath(Project project, String absolute)
98
+    {
99
+        return getRelativePath(project.getBasePath(), absolute);
100
+    }
101
+
102
+    public static String getAbsolutePath(String base, String relative)
103
+    {
104
+        return Paths.get(base, relative).toString();
105
+    }
106
+
107
+    public static String getAbsolutePath(Project project, String relative)
108
+    {
109
+        return getAbsolutePath(project.getBasePath(), relative);
110
+    }
67 111
 }

+ 47
- 30
src/com/rthoni/intellij/codefromds/dbo/GenerateOptions.java View File

@@ -3,9 +3,13 @@ package com.rthoni.intellij.codefromds.dbo;
3 3
 import com.intellij.database.model.DasTable;
4 4
 import com.intellij.database.psi.DbDataSource;
5 5
 import com.intellij.database.util.DasUtil;
6
+import com.intellij.openapi.project.Project;
7
+import com.rthoni.intellij.codefromds.business.Helper;
6 8
 import org.json.JSONObject;
7 9
 
8 10
 import java.io.File;
11
+import java.nio.file.Path;
12
+import java.nio.file.Paths;
9 13
 import java.util.HashMap;
10 14
 import java.util.List;
11 15
 import java.util.Vector;
@@ -17,10 +21,11 @@ import java.util.stream.Collectors;
17 21
 public class GenerateOptions {
18 22
 
19 23
     public GenerateOptions(DbDataSource source) {
20
-        _modelsPath = source.getProject().getBasePath() + File.separator + "Models";
21
-        _dataSourceTemplatePath = source.getProject().getBasePath() + File.separator + "Templates" + File.separator + "DataSource.twig";
22
-        _modelsTemplatePath = source.getProject().getBasePath() + File.separator + "Templates" + File.separator + "Models.twig";
23
-        _configPath = source.getProject().getBasePath() + File.separator + "code-from-ds.json";
24
+        _modelsRelativePath = "Models";
25
+        _dataSourceTemplateRelativePath = "Templates" + File.separator + "DataSource.twig";
26
+        _modelsTemplateRelativePath = "Templates" + File.separator + "Models.twig";
27
+        _configAbsolutePath = source.getProject().getBasePath() + File.separator + "code-from-ds.json";
28
+        _filesExtension = "cs";
24 29
         _selection = new DataSourceSelection(source);
25 30
         _selection.setSource(source);
26 31
         final List<? extends DasTable> tables = DasUtil.getTables(source).toList();
@@ -41,21 +46,24 @@ public class GenerateOptions {
41 46
 
42 47
     private DataSourceSelection _selection;
43 48
 
44
-    private String _modelsPath;
49
+    private String _modelsRelativePath;
45 50
 
46
-    private String _dataSourceTemplatePath;
51
+    private String _dataSourceTemplateRelativePath;
47 52
 
48
-    private String _modelsTemplatePath;
53
+    private String _modelsTemplateRelativePath;
49 54
 
50
-    private String _configPath;
55
+    private String _configAbsolutePath;
56
+
57
+    private String _filesExtension;
51 58
 
52 59
     public HashMap<String, Object> toMap()
53 60
     {
54 61
         HashMap<String, Object> map = new HashMap<>();
55 62
 
56
-        map.put("modelsPath", _modelsPath);
57
-        map.put("dataSourceTemplatePath", _dataSourceTemplatePath);
58
-        map.put("modelsTemplatePath", _modelsTemplatePath);
63
+        map.put("modelsRelativePath", _modelsRelativePath);
64
+        map.put("dataSourceTemplateRelativePath", _dataSourceTemplateRelativePath);
65
+        map.put("modelsTemplateRelativePath", _modelsTemplateRelativePath);
66
+        map.put("filesExtension", _filesExtension);
59 67
         map.put("selection", _selection == null ? null : new JSONObject(_selection.toMap()));
60 68
 
61 69
         return map;
@@ -63,9 +71,10 @@ public class GenerateOptions {
63 71
 
64 72
     public void fromJson(JSONObject json)
65 73
     {
66
-        _modelsPath = json.getString("modelsPath");
67
-        _dataSourceTemplatePath = json.getString("dataSourceTemplatePath");
68
-        _modelsTemplatePath = json.getString("modelsTemplatePath");
74
+        _modelsRelativePath = Helper.getJsonString(json, "modelsRelativePath");
75
+        _dataSourceTemplateRelativePath = Helper.getJsonString(json, "dataSourceTemplateRelativePath");
76
+        _modelsTemplateRelativePath = Helper.getJsonString(json, "modelsTemplateRelativePath");
77
+        _filesExtension = Helper.getJsonString(json, "filesExtension");
69 78
         _selection.fromJson(json.getJSONObject("selection"));
70 79
     }
71 80
 
@@ -77,35 +86,43 @@ public class GenerateOptions {
77 86
         _selection = selection;
78 87
     }
79 88
 
80
-    public String getModelsPath() {
81
-        return _modelsPath;
89
+    public String getModelsRelativePath() {
90
+        return _modelsRelativePath;
91
+    }
92
+
93
+    public void setModelsRelativePath(String modelsRelativePath) {
94
+        _modelsRelativePath = modelsRelativePath;
95
+    }
96
+
97
+    public String getDataSourceTemplateRelativePath() {
98
+        return _dataSourceTemplateRelativePath;
82 99
     }
83 100
 
84
-    public void setModelsPath(String modelsPath) {
85
-        _modelsPath = modelsPath;
101
+    public void setDataSourceTemplateRelativePath(String dataSourceTemplateRelativePath) {
102
+        _dataSourceTemplateRelativePath = dataSourceTemplateRelativePath;
86 103
     }
87 104
 
88
-    public String getDataSourceTemplatePath() {
89
-        return _dataSourceTemplatePath;
105
+    public String getModelsTemplateRelativePath() {
106
+        return _modelsTemplateRelativePath;
90 107
     }
91 108
 
92
-    public void setDataSourceTemplatePath(String dataSourceTemplatePath) {
93
-        _dataSourceTemplatePath = dataSourceTemplatePath;
109
+    public void setModelsTemplateRelativePath(String modelsTemplateRelativePath) {
110
+        _modelsTemplateRelativePath = modelsTemplateRelativePath;
94 111
     }
95 112
 
96
-    public String getModelsTemplatePath() {
97
-        return _modelsTemplatePath;
113
+    public String getConfigAbsolutePath() {
114
+        return _configAbsolutePath;
98 115
     }
99 116
 
100
-    public void setModelsTemplatePath(String modelsTemplatePath) {
101
-        _modelsTemplatePath = modelsTemplatePath;
117
+    public void setConfigAbsolutePath(String configAbsolutePath) {
118
+        _configAbsolutePath = configAbsolutePath;
102 119
     }
103 120
 
104
-    public String getConfigPath() {
105
-        return _configPath;
121
+    public String getFilesExtension() {
122
+        return _filesExtension;
106 123
     }
107 124
 
108
-    public void setConfigPath(String configPath) {
109
-        _configPath = configPath;
125
+    public void setFilesExtension(String filesExtension) {
126
+        _filesExtension = filesExtension;
110 127
     }
111 128
 }

+ 18
- 2
src/com/rthoni/intellij/codefromds/ui/actions/GenerateAction.java View File

@@ -1,5 +1,8 @@
1 1
 package com.rthoni.intellij.codefromds.ui.actions;
2 2
 
3
+import com.intellij.notification.Notification;
4
+import com.intellij.notification.NotificationType;
5
+import com.intellij.notification.Notifications;
3 6
 import com.intellij.openapi.actionSystem.AnAction;
4 7
 import com.intellij.openapi.actionSystem.AnActionEvent;
5 8
 import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -11,6 +14,7 @@ import com.intellij.openapi.vfs.VirtualFile;
11 14
 import com.rthoni.intellij.codefromds.business.Generator;
12 15
 import com.rthoni.intellij.codefromds.dbo.GenerateOptions;
13 16
 import com.rthoni.intellij.codefromds.ui.dialogs.GenerateDialog;
17
+import com.rthoni.intellij.codefromds.ui.others.NotificationsService;
14 18
 
15 19
 import javax.swing.*;
16 20
 
@@ -21,7 +25,15 @@ public class GenerateAction extends AnAction {
21 25
 
22 26
     @Override
23 27
     public void actionPerformed(AnActionEvent e) {
24
-        GenerateDialog dlg = new GenerateDialog(null);
28
+        NotificationsService notificationsService = NotificationsService.getInstance();
29
+
30
+        Project project = e.getProject();
31
+        if (project == null) {
32
+            notificationsService.showErrorNotification("Error", "Code FROM ds needs a current project to run");
33
+            return;
34
+        }
35
+
36
+        GenerateDialog dlg = new GenerateDialog(project);
25 37
         if (!e.getPlace().equals("MainMenu")) {
26 38
             final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
27 39
             if (file != null) {
@@ -29,6 +41,7 @@ public class GenerateAction extends AnAction {
29 41
                     GenerateOptions options = Generator.loadOptions(file.getPath());
30 42
                     dlg.setOptions(options);
31 43
                 } catch (Exception e1) {
44
+                    notificationsService.showErrorNotification("Error while loading configuration file", e1.toString());
32 45
                     e1.printStackTrace();
33 46
                 }
34 47
             }
@@ -40,11 +53,14 @@ public class GenerateAction extends AnAction {
40 53
             try {
41 54
                 Generator.saveOptions(options);
42 55
             } catch (Exception e1) {
56
+                notificationsService.showErrorNotification("Error while saving configuration", e1.toString());
43 57
                 e1.printStackTrace();
44 58
             }
45 59
             try {
46
-                Generator.generate(options);
60
+                Generator.generate(options, project);
61
+                notificationsService.showInfoNotification("Generation successful", "Files have been successfully generated");
47 62
             } catch (Exception e1) {
63
+                notificationsService.showErrorNotification("Error while generating files", e1.toString());
48 64
                 e1.printStackTrace();
49 65
             }
50 66
         }

+ 43
- 24
src/com/rthoni/intellij/codefromds/ui/dialogs/GenerateDialog.java View File

@@ -1,14 +1,9 @@
1 1
 package com.rthoni.intellij.codefromds.ui.dialogs;
2 2
 
3 3
 import com.intellij.database.model.DasObject;
4
-import com.intellij.database.model.DasTable;
5 4
 import com.intellij.database.psi.DbDataSource;
6
-import com.intellij.database.psi.DbPsiFacade;
7
-import com.intellij.database.util.DasUtil;
8
-import com.intellij.openapi.actionSystem.ActionManager;
9 5
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
10 6
 import com.intellij.openapi.project.Project;
11
-import com.intellij.openapi.project.ProjectManager;
12 7
 import com.intellij.openapi.ui.DialogWrapper;
13 8
 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
14 9
 import com.intellij.openapi.ui.ValidationInfo;
@@ -29,8 +24,6 @@ import javax.swing.event.DocumentListener;
29 24
 import javax.swing.event.ListSelectionListener;
30 25
 import java.awt.event.ActionListener;
31 26
 import java.io.File;
32
-import java.util.Arrays;
33
-import java.util.Collection;
34 27
 import java.util.List;
35 28
 import java.util.Vector;
36 29
 import java.util.function.Consumer;
@@ -46,14 +39,21 @@ public class GenerateDialog extends DialogWrapper {
46 39
     private JBList _listTables;
47 40
     private JBList _listColumns;
48 41
     private TextFieldWithBrowseButton _textModels;
49
-    private TextFieldWithBrowseButton _textDataSOurceTemplate;
42
+    private TextFieldWithBrowseButton _textDataSourceTemplate;
50 43
     private TextFieldWithBrowseButton _textModelsTemplate;
51 44
     private TextFieldWithBrowseButton _textConfigPath;
45
+    private JTextField _textFilesExtension;
46
+    private JLabel _lblDataSourceTemplatePath;
47
+    private JLabel _lblModelsPath;
48
+    private JLabel _lblModelsTemplatePath;
52 49
 
53 50
     private GenerateOptions _options;
54 51
 
55
-    public GenerateDialog(@Nullable Project project) {
52
+    private Project _project;
53
+
54
+    public GenerateDialog(Project project) {
56 55
         super(project);
56
+        _project = project;
57 57
         setTitle("Code FROM data source");
58 58
         setOptions(null);
59 59
         init();
@@ -67,16 +67,18 @@ public class GenerateDialog extends DialogWrapper {
67 67
         _options = options;
68 68
         if (_options != null) {
69 69
             showSource(_options.getSelection());
70
-            _textModels.setText(_options.getModelsPath());
71
-            _textDataSOurceTemplate.setText(_options.getDataSourceTemplatePath());
72
-            _textModelsTemplate.setText(_options.getModelsTemplatePath());
73
-            _textConfigPath.setText(_options.getConfigPath());
70
+            _textModels.setText(Helper.getAbsolutePath(_project, _options.getModelsRelativePath()));
71
+            _textDataSourceTemplate.setText(Helper.getAbsolutePath(_project, _options.getDataSourceTemplateRelativePath()));
72
+            _textModelsTemplate.setText(Helper.getAbsolutePath(_project, _options.getModelsTemplateRelativePath()));
73
+            _textFilesExtension.setText(_options.getFilesExtension());
74
+            _textConfigPath.setText(_options.getConfigAbsolutePath());
74 75
         }
75 76
         else {
76 77
             showSource(null);
77 78
             _textModels.setText("");
78
-            _textDataSOurceTemplate.setText("");
79
+            _textDataSourceTemplate.setText("");
79 80
             _textModelsTemplate.setText("");
81
+            _textFilesExtension.setText("");
80 82
             _textConfigPath.setText("");
81 83
         }
82 84
     }
@@ -85,11 +87,12 @@ public class GenerateDialog extends DialogWrapper {
85 87
     @Override
86 88
     protected ValidationInfo doValidate() {
87 89
         ValidationInfo info = null;
88
-        File modelDir = _options == null ? null : new File(_options.getModelsPath());
89
-        File dataSourceTemplatePath = _options == null ? null : new File(_options.getDataSourceTemplatePath());
90
-        File modelsTemplatePath = _options == null ? null : new File(_options.getModelsTemplatePath());
91
-        File configPath = _options == null ? null : new File(_options.getConfigPath());
90
+        File modelDir = _options == null ? null : new File(Helper.getAbsolutePath(_project, _options.getModelsRelativePath()));
91
+        File dataSourceTemplatePath = _options == null ? null : new File(Helper.getAbsolutePath(_project, _options.getDataSourceTemplateRelativePath()));
92
+        File modelsTemplatePath = _options == null ? null : new File(Helper.getAbsolutePath(_project, _options.getModelsTemplateRelativePath()));
93
+        File configPath = _options == null ? null : new File(_options.getConfigAbsolutePath());
92 94
         File configDir = _options == null ? null : new File(configPath.getParent());
95
+        String extension = _options == null ? null : _options.getFilesExtension();
93 96
         if (_options == null) {
94 97
             info = new ValidationInfo("No Data Source Selected", _listDatasources);
95 98
         }
@@ -97,7 +100,7 @@ public class GenerateDialog extends DialogWrapper {
97 100
             info = new ValidationInfo("Models folder does not exists", _textModels.getTextField());
98 101
         }
99 102
         else if (!dataSourceTemplatePath.exists() || !dataSourceTemplatePath.isFile()) {
100
-            info = new ValidationInfo("Data source template file does not exists", _textDataSOurceTemplate.getTextField());
103
+            info = new ValidationInfo("Data source template file does not exists", _textDataSourceTemplate.getTextField());
101 104
         }
102 105
         else if (!modelsTemplatePath.exists() || !modelsTemplatePath.isFile()) {
103 106
             info = new ValidationInfo("Models template file does not exists", _textModelsTemplate.getTextField());
@@ -105,6 +108,12 @@ public class GenerateDialog extends DialogWrapper {
105 108
         else if (!configDir.exists() || !configDir.isDirectory()) {
106 109
             info = new ValidationInfo("Configuration file parent folder does not exists", _textConfigPath.getTextField());
107 110
         }
111
+        else if (extension == null || extension.isEmpty()) {
112
+            info = new ValidationInfo("Files extension is required", _textFilesExtension);
113
+        }
114
+        else if (extension.startsWith(".")) {
115
+            info = new ValidationInfo("Files extension must not include dot (.)", _textFilesExtension);
116
+        }
108 117
 
109 118
         return info;
110 119
     }
@@ -140,14 +149,24 @@ public class GenerateDialog extends DialogWrapper {
140 149
         });
141 150
 
142 151
         setupTextField(_textModels, null, true);
143
-        setupTextField(_textDataSOurceTemplate, null, false);
152
+        setupTextField(_textDataSourceTemplate, null, false);
144 153
         setupTextField(_textModelsTemplate, null, false);
145 154
         setupTextField(_textConfigPath, null, false);
146 155
 
147
-        setupTextFieldListener(_textModels.getTextField(), s -> _options.setModelsPath(s));
148
-        setupTextFieldListener(_textDataSOurceTemplate.getTextField(), s -> _options.setDataSourceTemplatePath(s));
149
-        setupTextFieldListener(_textModelsTemplate.getTextField(), s -> _options.setModelsTemplatePath(s));
150
-        setupTextFieldListener(_textConfigPath.getTextField(), s -> _options.setConfigPath(s));
156
+        setupTextFieldListener(_textModels.getTextField(), s -> {
157
+            _options.setModelsRelativePath(Helper.getRelativePath(_project, s));
158
+            _lblModelsTemplatePath.setText("$ProjectRoot/" + _options.getModelsRelativePath());
159
+        });
160
+        setupTextFieldListener(_textDataSourceTemplate.getTextField(), s -> {
161
+            _options.setDataSourceTemplateRelativePath(Helper.getRelativePath(_project, s));
162
+            _lblDataSourceTemplatePath.setText("$ProjectRoot/" + _options.getDataSourceTemplateRelativePath());
163
+        });
164
+        setupTextFieldListener(_textModelsTemplate.getTextField(), s -> {
165
+            _options.setModelsTemplateRelativePath(Helper.getRelativePath(_project, s));
166
+            _lblModelsPath.setText("$ProjectRoot/" + _options.getModelsTemplateRelativePath());
167
+        });
168
+        setupTextFieldListener(_textFilesExtension, s -> _options.setFilesExtension(s));
169
+        setupTextFieldListener(_textConfigPath.getTextField(), s -> _options.setConfigAbsolutePath(s));
151 170
 
152 171
         _listTables.setCellRenderer(new ColoredListCellRenderer() {
153 172
             @Override

+ 48
- 8
src/com/rthoni/intellij/codefromds/ui/forms/GenerateForm.form View File

@@ -13,7 +13,7 @@
13 13
           <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
14 14
         </constraints>
15 15
       </vspacer>
16
-      <grid id="6946b" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
16
+      <grid id="6946b" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
17 17
         <margin top="0" left="0" bottom="0" right="0"/>
18 18
         <constraints>
19 19
           <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -37,7 +37,7 @@
37 37
           </component>
38 38
           <component id="f3fdd" class="javax.swing.JLabel">
39 39
             <constraints>
40
-              <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
40
+              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
41 41
             </constraints>
42 42
             <properties>
43 43
               <text value="Data Source Template:"/>
@@ -45,27 +45,27 @@
45 45
           </component>
46 46
           <component id="91f63" class="javax.swing.JLabel">
47 47
             <constraints>
48
-              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
48
+              <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
49 49
             </constraints>
50 50
             <properties>
51 51
               <text value="Models Template:"/>
52 52
             </properties>
53 53
           </component>
54
-          <component id="a074b" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textDataSOurceTemplate">
54
+          <component id="a074b" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textDataSourceTemplate">
55 55
             <constraints>
56
-              <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
56
+              <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
57 57
             </constraints>
58 58
             <properties/>
59 59
           </component>
60 60
           <component id="88c45" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textModelsTemplate">
61 61
             <constraints>
62
-              <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
62
+              <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
63 63
             </constraints>
64 64
             <properties/>
65 65
           </component>
66 66
           <component id="22d0d" class="javax.swing.JLabel">
67 67
             <constraints>
68
-              <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
68
+              <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
69 69
             </constraints>
70 70
             <properties>
71 71
               <text value="Configuration File:"/>
@@ -73,10 +73,50 @@
73 73
           </component>
74 74
           <component id="4c3cb" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textConfigPath">
75 75
             <constraints>
76
-              <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
76
+              <grid row="6" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
77 77
             </constraints>
78 78
             <properties/>
79 79
           </component>
80
+          <component id="c0c9e" class="javax.swing.JLabel">
81
+            <constraints>
82
+              <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
83
+            </constraints>
84
+            <properties>
85
+              <text value="Files extension:"/>
86
+            </properties>
87
+          </component>
88
+          <component id="880ce" class="javax.swing.JTextField" binding="_textFilesExtension">
89
+            <constraints>
90
+              <grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
91
+                <preferred-size width="150" height="-1"/>
92
+              </grid>
93
+            </constraints>
94
+            <properties/>
95
+          </component>
96
+          <component id="3c89d" class="javax.swing.JLabel" binding="_lblModelsPath">
97
+            <constraints>
98
+              <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
99
+            </constraints>
100
+            <properties>
101
+              <text value="$ProjectRoot/"/>
102
+            </properties>
103
+          </component>
104
+          <component id="1ec86" class="javax.swing.JLabel" binding="_lblDataSourceTemplatePath">
105
+            <constraints>
106
+              <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
107
+            </constraints>
108
+            <properties>
109
+              <text value="$ProjectRoot/"/>
110
+            </properties>
111
+          </component>
112
+          <component id="fab09" class="javax.swing.JLabel" binding="_lblModelsTemplatePath">
113
+            <constraints>
114
+              <grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
115
+            </constraints>
116
+            <properties>
117
+              <text value="$ProjectRoot/"/>
118
+            </properties>
119
+          </component>
80 120
         </children>
81 121
       </grid>
82 122
       <grid id="39adc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

+ 35
- 0
src/com/rthoni/intellij/codefromds/ui/others/NotificationsService.java View File

@@ -0,0 +1,35 @@
1
+package com.rthoni.intellij.codefromds.ui.others;
2
+
3
+import com.intellij.notification.Notification;
4
+import com.intellij.notification.NotificationType;
5
+import com.intellij.notification.Notifications;
6
+import com.intellij.openapi.application.ApplicationManager;
7
+import com.intellij.openapi.components.ServiceManager;
8
+
9
+/**
10
+ * Created by robin on 11/18/16.
11
+ */
12
+public class NotificationsService {
13
+
14
+    public static NotificationsService getInstance() {
15
+        return ServiceManager.getService(NotificationsService.class);
16
+    }
17
+
18
+    public void showNotification(String title, String content, NotificationType type)
19
+    {
20
+        ApplicationManager.getApplication().invokeLater(() -> {
21
+            Notification n = new Notification("Code From Ds", title, content, type);
22
+            Notifications.Bus.notify(n);
23
+        });
24
+    }
25
+
26
+    public void showErrorNotification(String title, String content)
27
+    {
28
+        showNotification(title, content, NotificationType.ERROR);
29
+    }
30
+
31
+    public void showInfoNotification(String title, String content)
32
+    {
33
+        showNotification(title, content, NotificationType.INFORMATION);
34
+    }
35
+}

Loading…
Cancel
Save