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
     <action id="codefromds-generate" class="com.rthoni.intellij.codefromds.ui.actions.GenerateAction"
30
     <action id="codefromds-generate" class="com.rthoni.intellij.codefromds.ui.actions.GenerateAction"
31
             text="Generate code from data source" description="Generate models from an intellij data source">
31
             text="Generate code from data source" description="Generate models from an intellij data source">
32
       <add-to-group group-id="ToolsMenu" anchor="last"/>
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
       <keyboard-shortcut keymap="$default" first-keystroke="ctrl alt G"/>
35
       <keyboard-shortcut keymap="$default" first-keystroke="ctrl alt G"/>
34
     </action>
36
     </action>
35
   </actions>
37
   </actions>

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

6
 public class GenerateOptions {
6
 public class GenerateOptions {
7
     private DataSourceSelection _selection;
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
     public DataSourceSelection getSelection() {
17
     public DataSourceSelection getSelection() {
12
         return _selection;
18
         return _selection;
16
         _selection = selection;
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
 
2
 
3
 import com.intellij.openapi.actionSystem.AnAction;
3
 import com.intellij.openapi.actionSystem.AnAction;
4
 import com.intellij.openapi.actionSystem.AnActionEvent;
4
 import com.intellij.openapi.actionSystem.AnActionEvent;
5
+import com.intellij.openapi.actionSystem.CommonDataKeys;
6
+import com.intellij.openapi.actionSystem.DataContext;
5
 import com.intellij.openapi.project.Project;
7
 import com.intellij.openapi.project.Project;
6
 import com.intellij.openapi.project.ProjectManager;
8
 import com.intellij.openapi.project.ProjectManager;
7
 import com.intellij.openapi.ui.DialogWrapper;
9
 import com.intellij.openapi.ui.DialogWrapper;
10
+import com.intellij.openapi.vfs.VirtualFile;
8
 import com.rthoni.intellij.codefromds.dbo.GenerateOptions;
11
 import com.rthoni.intellij.codefromds.dbo.GenerateOptions;
9
 import com.rthoni.intellij.codefromds.ui.dialogs.GenerateDialog;
12
 import com.rthoni.intellij.codefromds.ui.dialogs.GenerateDialog;
10
 
13
 
25
             options.getSelection();
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
 import com.intellij.database.psi.DbDataSource;
5
 import com.intellij.database.psi.DbDataSource;
6
 import com.intellij.database.psi.DbPsiFacade;
6
 import com.intellij.database.psi.DbPsiFacade;
7
 import com.intellij.database.util.DasUtil;
7
 import com.intellij.database.util.DasUtil;
8
+import com.intellij.openapi.actionSystem.ActionManager;
8
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
9
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
9
 import com.intellij.openapi.project.Project;
10
 import com.intellij.openapi.project.Project;
10
 import com.intellij.openapi.project.ProjectManager;
11
 import com.intellij.openapi.project.ProjectManager;
25
 import javax.swing.event.DocumentEvent;
26
 import javax.swing.event.DocumentEvent;
26
 import javax.swing.event.DocumentListener;
27
 import javax.swing.event.DocumentListener;
27
 import javax.swing.event.ListSelectionListener;
28
 import javax.swing.event.ListSelectionListener;
28
-import java.awt.*;
29
 import java.awt.event.ActionListener;
29
 import java.awt.event.ActionListener;
30
 import java.io.File;
30
 import java.io.File;
31
 import java.util.Arrays;
31
 import java.util.Arrays;
44
     private JBList _listTables;
44
     private JBList _listTables;
45
     private JBList _listColumns;
45
     private JBList _listColumns;
46
     private TextFieldWithBrowseButton _textModels;
46
     private TextFieldWithBrowseButton _textModels;
47
+    private TextFieldWithBrowseButton _textDataSOurceTemplate;
48
+    private TextFieldWithBrowseButton _textModelsTemplate;
49
+    private TextFieldWithBrowseButton _textConfigPath;
47
 
50
 
48
     private GenerateOptions _options;
51
     private GenerateOptions _options;
49
 
52
 
62
     @Override
65
     @Override
63
     protected ValidationInfo doValidate() {
66
     protected ValidationInfo doValidate() {
64
         ValidationInfo info = null;
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
         if (_options == null) {
69
         if (_options == null) {
67
             info = new ValidationInfo("No Data Source Selected", _listDatasources);
70
             info = new ValidationInfo("No Data Source Selected", _listDatasources);
68
         }
71
         }
121
             }
124
             }
122
 
125
 
123
             public void changed() {
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
           <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"/>
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
         </constraints>
14
         </constraints>
15
       </vspacer>
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
         <margin top="0" left="0" bottom="0" right="0"/>
17
         <margin top="0" left="0" bottom="0" right="0"/>
18
         <constraints>
18
         <constraints>
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"/>
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
             </constraints>
35
             </constraints>
36
             <properties/>
36
             <properties/>
37
           </component>
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
         </children>
80
         </children>
39
       </grid>
81
       </grid>
40
       <grid id="39adc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
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