Browse Source

added action in project explorer pop menu; added text fields for template and config paths

tags/v1.1.0
Robin Thoni 7 years ago
parent
commit
d4f206b2d0

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

@@ -30,6 +30,8 @@
30 30
     <action id="codefromds-generate" class="com.rthoni.intellij.codefromds.ui.actions.GenerateAction"
31 31
             text="Generate code from data source" description="Generate models from an intellij data source">
32 32
       <add-to-group group-id="ToolsMenu" anchor="last"/>
33
+      <add-to-group group-id="ProjectViewPopupMenu" anchor="last" />
34
+      <add-to-group group-id="SolutionExplorerPopupMenu" anchor="last" />
33 35
       <keyboard-shortcut keymap="$default" first-keystroke="ctrl alt G"/>
34 36
     </action>
35 37
   </actions>

+ 35
- 5
src/com/rthoni/intellij/codefromds/dbo/GenerateOptions.java View File

@@ -6,7 +6,13 @@ package com.rthoni.intellij.codefromds.dbo;
6 6
 public class GenerateOptions {
7 7
     private DataSourceSelection _selection;
8 8
 
9
-    private String _modelsFolder;
9
+    private String _modelsPath;
10
+
11
+    private String _dataSourceTemplatePath;
12
+
13
+    private String _modelsTemplatePath;
14
+
15
+    private String _configPath;
10 16
 
11 17
     public DataSourceSelection getSelection() {
12 18
         return _selection;
@@ -16,11 +22,35 @@ public class GenerateOptions {
16 22
         _selection = selection;
17 23
     }
18 24
 
19
-    public String getModelsFolder() {
20
-        return _modelsFolder;
25
+    public String getModelsPath() {
26
+        return _modelsPath;
27
+    }
28
+
29
+    public void setModelsPath(String modelsPath) {
30
+        _modelsPath = modelsPath;
31
+    }
32
+
33
+    public String getDataSourceTemplatePath() {
34
+        return _dataSourceTemplatePath;
35
+    }
36
+
37
+    public void setDataSourceTemplatePath(String dataSourceTemplatePath) {
38
+        _dataSourceTemplatePath = dataSourceTemplatePath;
39
+    }
40
+
41
+    public String getModelsTemplatePath() {
42
+        return _modelsTemplatePath;
43
+    }
44
+
45
+    public void setModelsTemplatePath(String modelsTemplatePath) {
46
+        _modelsTemplatePath = modelsTemplatePath;
47
+    }
48
+
49
+    public String getConfigPath() {
50
+        return _configPath;
21 51
     }
22 52
 
23
-    public void setModelsFolder(String modelsFolder) {
24
-        _modelsFolder = modelsFolder;
53
+    public void setConfigPath(String configPath) {
54
+        _configPath = configPath;
25 55
     }
26 56
 }

+ 14
- 0
src/com/rthoni/intellij/codefromds/ui/actions/GenerateAction.java View File

@@ -2,9 +2,12 @@ package com.rthoni.intellij.codefromds.ui.actions;
2 2
 
3 3
 import com.intellij.openapi.actionSystem.AnAction;
4 4
 import com.intellij.openapi.actionSystem.AnActionEvent;
5
+import com.intellij.openapi.actionSystem.CommonDataKeys;
6
+import com.intellij.openapi.actionSystem.DataContext;
5 7
 import com.intellij.openapi.project.Project;
6 8
 import com.intellij.openapi.project.ProjectManager;
7 9
 import com.intellij.openapi.ui.DialogWrapper;
10
+import com.intellij.openapi.vfs.VirtualFile;
8 11
 import com.rthoni.intellij.codefromds.dbo.GenerateOptions;
9 12
 import com.rthoni.intellij.codefromds.ui.dialogs.GenerateDialog;
10 13
 
@@ -25,4 +28,15 @@ public class GenerateAction extends AnAction {
25 28
             options.getSelection();
26 29
         }
27 30
     }
31
+
32
+    @Override
33
+    public void update(AnActionEvent e) {
34
+        if (e.getPlace().equals("MainMenu")) {
35
+            super.update(e);
36
+        }
37
+        else {
38
+            final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
39
+            e.getPresentation().setVisible(file != null && file.getName().endsWith(".json"));
40
+        }
41
+    }
28 42
 }

+ 6
- 3
src/com/rthoni/intellij/codefromds/ui/dialogs/GenerateDialog.java View File

@@ -5,6 +5,7 @@ import com.intellij.database.model.DasTable;
5 5
 import com.intellij.database.psi.DbDataSource;
6 6
 import com.intellij.database.psi.DbPsiFacade;
7 7
 import com.intellij.database.util.DasUtil;
8
+import com.intellij.openapi.actionSystem.ActionManager;
8 9
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
9 10
 import com.intellij.openapi.project.Project;
10 11
 import com.intellij.openapi.project.ProjectManager;
@@ -25,7 +26,6 @@ import javax.swing.*;
25 26
 import javax.swing.event.DocumentEvent;
26 27
 import javax.swing.event.DocumentListener;
27 28
 import javax.swing.event.ListSelectionListener;
28
-import java.awt.*;
29 29
 import java.awt.event.ActionListener;
30 30
 import java.io.File;
31 31
 import java.util.Arrays;
@@ -44,6 +44,9 @@ public class GenerateDialog extends DialogWrapper {
44 44
     private JBList _listTables;
45 45
     private JBList _listColumns;
46 46
     private TextFieldWithBrowseButton _textModels;
47
+    private TextFieldWithBrowseButton _textDataSOurceTemplate;
48
+    private TextFieldWithBrowseButton _textModelsTemplate;
49
+    private TextFieldWithBrowseButton _textConfigPath;
47 50
 
48 51
     private GenerateOptions _options;
49 52
 
@@ -62,7 +65,7 @@ public class GenerateDialog extends DialogWrapper {
62 65
     @Override
63 66
     protected ValidationInfo doValidate() {
64 67
         ValidationInfo info = null;
65
-        File modelDir = _options == null ? null : new File(_options.getModelsFolder());
68
+        File modelDir = _options == null ? null : new File(_options.getModelsPath());
66 69
         if (_options == null) {
67 70
             info = new ValidationInfo("No Data Source Selected", _listDatasources);
68 71
         }
@@ -121,7 +124,7 @@ public class GenerateDialog extends DialogWrapper {
121 124
             }
122 125
 
123 126
             public void changed() {
124
-                _options.setModelsFolder(_textModels.getText());
127
+                _options.setModelsPath(_textModels.getText());
125 128
             }
126 129
         });
127 130
 

+ 43
- 1
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="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
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">
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"/>
@@ -35,6 +35,48 @@
35 35
             </constraints>
36 36
             <properties/>
37 37
           </component>
38
+          <component id="f3fdd" class="javax.swing.JLabel">
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"/>
41
+            </constraints>
42
+            <properties>
43
+              <text value="Data Source Template:"/>
44
+            </properties>
45
+          </component>
46
+          <component id="91f63" class="javax.swing.JLabel">
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"/>
49
+            </constraints>
50
+            <properties>
51
+              <text value="Models Template:"/>
52
+            </properties>
53
+          </component>
54
+          <component id="a074b" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textDataSOurceTemplate">
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"/>
57
+            </constraints>
58
+            <properties/>
59
+          </component>
60
+          <component id="88c45" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textModelsTemplate">
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"/>
63
+            </constraints>
64
+            <properties/>
65
+          </component>
66
+          <component id="22d0d" class="javax.swing.JLabel">
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"/>
69
+            </constraints>
70
+            <properties>
71
+              <text value="Configuration File:"/>
72
+            </properties>
73
+          </component>
74
+          <component id="4c3cb" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="_textConfigPath">
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"/>
77
+            </constraints>
78
+            <properties/>
79
+          </component>
38 80
         </children>
39 81
       </grid>
40 82
       <grid id="39adc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

Loading…
Cancel
Save