Browse Source

added sp support

develop
Robin Thoni 7 years ago
parent
commit
fbe8dc59a0

+ 3
- 1
TODO View File

@@ -1,3 +1,5 @@
1 1
 proc stock
2 2
 many to many
3
-table inheritance
3
+table inheritance
4
+generate custom types (sp return)
5
+UI for sp selection

+ 14
- 16
src/com/rthoni/intellij/codefromds/DataAccess/DataSourcesDataAccess.java View File

@@ -1,5 +1,6 @@
1 1
 package com.rthoni.intellij.codefromds.DataAccess;
2 2
 
3
+import com.intellij.database.model.DasArgument;
3 4
 import com.intellij.database.psi.*;
4 5
 import com.intellij.database.util.DasUtil;
5 6
 import com.rthoni.intellij.codefromds.business.Helper;
@@ -64,7 +65,6 @@ public class DataSourcesDataAccess {
64 65
             if (dasObject instanceof DbTable) {
65 66
                 DbTable table = (DbTable) dasObject;
66 67
                 tableDataSourceDbo.data = dataSourceDbo.findTable(table.getName());
67
-//                System.out.println("Table: " + tableDataSourceDbo.data.getName());
68 68
                 DasUtil.getForeignKeys(table).forEach(fk ->
69 69
                 {
70 70
                     if (fk.getRefTable() == null) {
@@ -77,9 +77,9 @@ public class DataSourcesDataAccess {
77 77
                     ForeignKeyDbo fkDbo = new ForeignKeyDbo();
78 78
                     fkDbo.setName(fk.getName());
79 79
                     fkDbo.setSourceTable(srcTable);
80
-                    fkDbo.setSourceForeignKeyName("fk_" + targetTable.getName());//TODO find if it already exists
80
+                    fkDbo.setSourceForeignKeyName(fkDbo.getName());//TODO find if it already exists
81 81
                     fkDbo.setTargetTable(targetTable);
82
-                    fkDbo.setTargetForeignKeyName(srcTable.getName() + "_fk");//TODO find if it already exists
82
+                    fkDbo.setTargetForeignKeyName(fkDbo.getName());//TODO find if it already exists
83 83
 
84 84
                     fk.getColumnsRef().names().forEach(s -> fkDbo.addSourceColumn(srcTable.findColumn(s)));
85 85
                     fk.getRefColumns().names().forEach(s -> fkDbo.addTargetColumn(targetTable.findColumn(s)));
@@ -87,29 +87,25 @@ public class DataSourcesDataAccess {
87 87
                     srcTable.addSourceForeignKey(fkDbo);
88 88
                     targetTable.addTargetForeignKey(fkDbo);
89 89
 
90
-//                    System.out.println("FK: " + fkDbo.getName());
91 90
                 });
92 91
             }
93 92
             else if (dasObject instanceof DbColumn) {
94 93
                 DbColumn column = (DbColumn) dasObject;
95 94
                 columnDataSourceDbo.data = tableDataSourceDbo.data.findColumn(column.getName());
96
-//                System.out.println("Column: " + columnDataSourceDbo.data.getName());
97 95
             }
98 96
             else if (dasObject instanceof DbIndex) {
99 97
                 DbIndex index = (DbIndex) dasObject;
100
-//                System.out.println("Index: " + index.getName());
101 98
             }
102 99
             else if (dasObject instanceof DbConstraint) {
103 100
                 DbConstraint constraint = (DbConstraint) dasObject;
104
-//                System.out.println("Constraint: " + constraint.getName());
105 101
             }
106 102
             else if (dasObject instanceof DbRoutine) {
107 103
                 DbRoutine sp = (DbRoutine) dasObject;
108 104
                 StoredProcedureDbo spDbo = new StoredProcedureDbo();
109 105
                 spDbo.setSelected(true);
110
-                dataSourceDbo.addStoredProcedure(spDbo);
111 106
                 spDbo.setName(sp.getName());
112
-//                System.out.println("SP: " + spDbo.getName());
107
+                spDbo.setFullName(sp.getText());
108
+                dataSourceDbo.addStoredProcedure(spDbo);
113 109
                 DataHolder<Integer> position = new DataHolder<>();
114 110
                 position.data = 0;
115 111
                 sp.getArguments().forEach(o ->
@@ -118,24 +114,26 @@ public class DataSourcesDataAccess {
118 114
                     sqlTypeDbo.setType(o.getDataType().typeName);
119 115
                     sqlTypeDbo.setVagueArg(o.getDataType().vagueArg);
120 116
 
121
-                    if (o.getArgumentDirection().isReturnOrResult()) {
117
+                    DasArgument.Direction dir = o.getArgumentDirection();
118
+
119
+
120
+
121
+                    if (dir.isReturnOrResult()) {
122 122
                         spDbo.setSqlType(sqlTypeDbo);
123
-//                        System.out.println("SP return: " + sqlTypeDbo.getType());
124 123
                     }
125
-                    else {
124
+                    if (dir.isIn()) {
126 125
                         StoredProcedureArgDbo argDbo = new StoredProcedureArgDbo();
127 126
                         argDbo.setName(o.getName().isEmpty() ? "arg" + position.data : o.getName());
128 127
                         argDbo.setSqlType(sqlTypeDbo);
129 128
                         argDbo.setOut(o.getArgumentDirection().isOut());
130 129
                         spDbo.addArgument(argDbo);
131 130
                         ++position.data;
132
-//                        System.out.println("SP arg: " + o.getName());
133 131
                     }
134 132
                 });
133
+//                DasArgument arg = sp.getReturnArgument();
134
+//                if (arg != null)
135
+//                    arg.toString();
135 136
             }
136
-//            else {
137
-//                System.out.println(dasObject.getClass().getName());
138
-//            }
139 137
         });
140 138
         return dataSourceDbo;
141 139
     }

+ 31
- 10
src/com/rthoni/intellij/codefromds/business/Generator.java View File

@@ -2,10 +2,7 @@ package com.rthoni.intellij.codefromds.business;
2 2
 
3 3
 import com.intellij.database.psi.DbDataSource;
4 4
 import com.intellij.openapi.project.Project;
5
-import com.rthoni.intellij.codefromds.dbo.options.ColumnSelection;
6
-import com.rthoni.intellij.codefromds.dbo.options.GenerateOptions;
7
-import com.rthoni.intellij.codefromds.dbo.options.TableSelection;
8
-import com.rthoni.intellij.codefromds.dbo.options.TypesCastOptions;
5
+import com.rthoni.intellij.codefromds.dbo.options.*;
9 6
 import com.rthoni.intellij.codefromds.dbo.template.*;
10 7
 import groovy.json.StringEscapeUtils;
11 8
 import org.json.JSONArray;
@@ -70,13 +67,18 @@ public abstract class Generator {
70 67
         return StringEscapeUtils.escapeJava(str);
71 68
     }
72 69
 
73
-    public static void convertSqlType(SqlTypeDbo type, TypesCastOptions options)
70
+    public static void convertSqlType(SqlTypeDbo type, TypesCastOptions options, DataSourceDbo dataSourceDbo)
74 71
     {
75 72
         if (type == null) {
76 73
             return;
77 74
         }
78 75
         boolean isArray = type.getType().endsWith("[]");
76
+        boolean isSetOf = type.getType().startsWith("setof ");
79 77
         String sqlTypeName = isArray ? type.getType().substring(0, type.getType().length() - 2) : type.getType();
78
+        if (isSetOf)
79
+        {
80
+            sqlTypeName = sqlTypeName.substring(6);
81
+        }
80 82
         String typeName = null;
81 83
         HashMap<String, HashMap<String, String>> types = options.getTypes();
82 84
 
@@ -90,11 +92,20 @@ public abstract class Generator {
90 92
             }
91 93
         }
92 94
         if (typeName == null) {
93
-            typeName = types.get("*").get("*");
95
+            TableDataSourceDbo table = dataSourceDbo.findTable(sqlTypeName);
96
+            if (table == null) {
97
+                typeName = types.get("*").get("*");
98
+            }
99
+            else {
100
+                typeName = table.getName();
101
+            }
94 102
         }
95 103
         if (isArray) {
96 104
             typeName = options.getArrayTemplate().replace("%t", typeName);
97 105
         }
106
+        if (isSetOf) {
107
+            typeName = options.getSetOfTemplate().replace("%t", typeName);
108
+        }
98 109
         type.setLanguageType(typeName);
99 110
         type.setLanguageTypeNotNull(options.getNonNullableTypes().contains(typeName));
100 111
     }
@@ -130,16 +141,20 @@ public abstract class Generator {
130 141
                 ColumnSelection columnSelection = tableSelection.getColumns().stream()
131 142
                         .filter(c -> c.getColumn().getName().equals(column.getName()))
132 143
                         .findFirst().orElse(null);
133
-                convertSqlType(column.getSqlType(), types);
144
+                convertSqlType(column.getSqlType(), types, dataSourceDbo);
134 145
                 column.setSelected(columnSelection.isSelected());
135 146
             }
136 147
         }
137 148
 
138 149
         for (StoredProcedureDbo spDbo : dataSourceDbo.getStoredProcedures())
139 150
         {
140
-            convertSqlType(spDbo.getSqlType(), types);
151
+            StoredProcedureSelection sp = options.getSelection().getStoredProcedures().stream()
152
+                    .filter(s -> s.getStoredProcedure().getText().equals(spDbo.getFullName()))
153
+                    .findFirst().orElse(null);
154
+            convertSqlType(spDbo.getSqlType(), types, dataSourceDbo);
155
+            spDbo.setSelected(sp.isSelected());
141 156
             for (StoredProcedureArgDbo arg : spDbo.getArguments()) {
142
-                convertSqlType(arg.getSqlType(), types);
157
+                convertSqlType(arg.getSqlType(), types, dataSourceDbo);
143 158
             }
144 159
         }
145 160
 
@@ -186,6 +201,7 @@ public abstract class Generator {
186 201
         dbo.setReservedWords(reservedWords);
187 202
 
188 203
         dbo.setArrayTemplate(obj.getString("arrayTemplate"));
204
+        dbo.setSetOfTemplate(obj.getString("setOfTemplate"));
189 205
 
190 206
         return dbo;
191 207
     }
@@ -205,7 +221,12 @@ public abstract class Generator {
205 221
 
206 222
             @Override
207 223
             public Object execute(FunctionRequest functionRequest) {
208
-                String arg = (String) functionRequest.get(0);
224
+                Object obj = functionRequest.get(0);
225
+                if (obj == null)
226
+                {
227
+                    return null;
228
+                }
229
+                String arg = (String) obj;
209 230
                 String v = escapeReservedWords(arg, options);
210 231
                 return v;
211 232
             }

+ 27
- 11
src/com/rthoni/intellij/codefromds/business/Helper.java View File

@@ -1,12 +1,15 @@
1 1
 package com.rthoni.intellij.codefromds.business;
2 2
 
3
+import com.intellij.database.model.DasRoutine;
3 4
 import com.intellij.database.psi.DbDataSource;
4 5
 import com.intellij.database.psi.DbPsiFacade;
6
+import com.intellij.database.psi.DbRoutine;
5 7
 import com.intellij.openapi.project.Project;
6 8
 import com.intellij.openapi.project.ProjectManager;
7 9
 import org.json.JSONArray;
8 10
 import org.json.JSONObject;
9 11
 
12
+import javax.sql.DataSource;
10 13
 import java.io.IOException;
11 14
 import java.nio.charset.StandardCharsets;
12 15
 import java.nio.file.Files;
@@ -15,6 +18,7 @@ import java.nio.file.Paths;
15 18
 import java.util.Arrays;
16 19
 import java.util.Collection;
17 20
 import java.util.List;
21
+import java.util.Vector;
18 22
 import java.util.stream.Collectors;
19 23
 
20 24
 /**
@@ -22,6 +26,18 @@ import java.util.stream.Collectors;
22 26
  */
23 27
 public abstract class Helper {
24 28
 
29
+    public static List<DbRoutine> getRoutines(DbDataSource dataSource)
30
+    {
31
+        List<DbRoutine> routines = new Vector<>();
32
+        dataSource.getModel().traverser().forEach(dasObject ->
33
+        {
34
+            if (dasObject instanceof DbRoutine) {
35
+                routines.add((DbRoutine) dasObject);
36
+            }
37
+        });
38
+        return routines;
39
+    }
40
+
25 41
     public static List<DbDataSource> getDataSources()
26 42
     {
27 43
         ProjectManager pm = ProjectManager.getInstance();
@@ -35,25 +51,25 @@ public abstract class Helper {
35 51
         return getDataSources().stream().filter(d -> d.getName().equals(name)).findFirst().orElse(null);
36 52
     }
37 53
 
38
-    public static JSONObject findTableInJson(JSONArray tables, String name)
54
+    public static JSONObject findInJson(JSONArray tables, String key, String name)
39 55
     {
40 56
         for (int i = 0; i < tables.length(); ++i) {
41
-            if (tables.getJSONObject(i).getString("table").equals(name)) {
57
+            if (tables.getJSONObject(i).getString(key).equals(name)) {
42 58
                 return tables.getJSONObject(i);
43 59
             }
44 60
         }
45 61
         return null;
46 62
     }
47 63
 
48
-    public static JSONObject findColumnInJson(JSONArray tables, String name)
49
-    {
50
-        for (int i = 0; i < tables.length(); ++i) {
51
-            if (tables.getJSONObject(i).getString("column").equals(name)) {
52
-                return tables.getJSONObject(i);
53
-            }
54
-        }
55
-        return null;
56
-    }
64
+//    public static JSONObject findColumnInJson(JSONArray tables, String name)
65
+//    {
66
+//        for (int i = 0; i < tables.length(); ++i) {
67
+//            if (tables.getJSONObject(i).getString("column").equals(name)) {
68
+//                return tables.getJSONObject(i);
69
+//            }
70
+//        }
71
+//        return null;
72
+//    }
57 73
 
58 74
     public static String readFile(String path) throws IOException {
59 75
         String data = Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8)

+ 27
- 1
src/com/rthoni/intellij/codefromds/dbo/options/DataSourceSelection.java View File

@@ -20,9 +20,12 @@ public class DataSourceSelection {
20 20
 
21 21
     private List<TableSelection> _tables;
22 22
 
23
+    private List<StoredProcedureSelection> _storedProcedures;
24
+
23 25
     public DataSourceSelection(DbDataSource source) {
24 26
         _source = source;
25 27
         _tables = DasUtil.getTables(source).toList().stream().map(TableSelection::new).collect(Collectors.toList());
28
+        _storedProcedures = Helper.getRoutines(source).stream().map(StoredProcedureSelection::new).collect(Collectors.toList());
26 29
     }
27 30
 
28 31
     public HashMap<String, Object> toMap()
@@ -30,12 +33,19 @@ public class DataSourceSelection {
30 33
         HashMap<String, Object> map = new HashMap<>();
31 34
 
32 35
         map.put("source", _source == null ? null : _source.getName());
36
+
33 37
         List<Object> tables = new Vector<>();
34 38
         for (TableSelection table : _tables) {
35 39
             tables.add(table.toMap());
36 40
         }
37 41
         map.put("tables", tables);
38 42
 
43
+        List<Object> sps = new Vector<>();
44
+        for (StoredProcedureSelection sp : _storedProcedures) {
45
+            sps.add(sp.toMap());
46
+        }
47
+        map.put("storedProcedures", sps);
48
+
39 49
         return map;
40 50
     }
41 51
 
@@ -43,7 +53,7 @@ public class DataSourceSelection {
43 53
     {
44 54
         JSONArray array = json.getJSONArray("tables");
45 55
         for (TableSelection table : _tables) {
46
-            JSONObject obj = Helper.findTableInJson(array, table.getTable().getName());
56
+            JSONObject obj = Helper.findInJson(array, "table", table.getTable().getName());
47 57
             if (obj != null) {
48 58
                 table.fromJson(obj);
49 59
             } else {
@@ -52,6 +62,14 @@ public class DataSourceSelection {
52 62
                 }
53 63
             }
54 64
         }
65
+
66
+        array = json.getJSONArray("storedProcedures");
67
+        for (StoredProcedureSelection sp : _storedProcedures) {
68
+            JSONObject obj = Helper.findInJson(array, "name", sp.getStoredProcedure().getText());
69
+            if (obj != null) {
70
+                sp.fromJson(obj);
71
+            }
72
+        }
55 73
     }
56 74
 
57 75
     public DbDataSource getSource() {
@@ -69,4 +87,12 @@ public class DataSourceSelection {
69 87
     public void setTables(List<TableSelection> tables) {
70 88
         _tables = tables;
71 89
     }
90
+
91
+    public List<StoredProcedureSelection> getStoredProcedures() {
92
+        return _storedProcedures;
93
+    }
94
+
95
+    public void setStoredProcedures(List<StoredProcedureSelection> storedProcedures) {
96
+        _storedProcedures = storedProcedures;
97
+    }
72 98
 }

+ 52
- 0
src/com/rthoni/intellij/codefromds/dbo/options/StoredProcedureSelection.java View File

@@ -0,0 +1,52 @@
1
+package com.rthoni.intellij.codefromds.dbo.options;
2
+
3
+import com.intellij.database.psi.DbRoutine;
4
+import org.json.JSONObject;
5
+
6
+import java.util.HashMap;
7
+
8
+/**
9
+ * Created by robin on 4/14/17.
10
+ */
11
+public class StoredProcedureSelection {
12
+
13
+    private DbRoutine _storedProcedure;
14
+
15
+    private boolean _isSelected;
16
+
17
+    public StoredProcedureSelection(DbRoutine storedProcedure) {
18
+        _storedProcedure = storedProcedure;
19
+        _isSelected = true;
20
+    }
21
+
22
+    public DbRoutine getStoredProcedure() {
23
+        return _storedProcedure;
24
+    }
25
+
26
+    public void setStoredProcedure(DbRoutine storedProcedure) {
27
+        _storedProcedure = storedProcedure;
28
+    }
29
+
30
+    public boolean isSelected() {
31
+        return _isSelected;
32
+    }
33
+
34
+    public void setSelected(boolean selected) {
35
+        _isSelected = selected;
36
+    }
37
+
38
+    public HashMap<String, Object> toMap()
39
+    {
40
+        HashMap<String, Object> map = new HashMap<>();
41
+
42
+        map.put("name", _storedProcedure == null ? null : _storedProcedure.getText());
43
+        map.put("selected", _isSelected);
44
+
45
+        return map;
46
+    }
47
+
48
+    public void fromJson(JSONObject json)
49
+    {
50
+        _isSelected = json.getBoolean("selected");
51
+    }
52
+}

+ 1
- 1
src/com/rthoni/intellij/codefromds/dbo/options/TableSelection.java View File

@@ -44,7 +44,7 @@ public class TableSelection {
44 44
     {
45 45
         JSONArray array = json.getJSONArray("columns");
46 46
         for (ColumnSelection column : _columns) {
47
-            JSONObject obj = Helper.findColumnInJson(array, column.getColumn().getName());
47
+            JSONObject obj = Helper.findInJson(array, "column", column.getColumn().getName());
48 48
             if (obj != null) {
49 49
                 column.fromJson(obj);
50 50
             } else {

+ 10
- 0
src/com/rthoni/intellij/codefromds/dbo/options/TypesCastOptions.java View File

@@ -10,6 +10,8 @@ public class TypesCastOptions {
10 10
 
11 11
     private String _arrayTemplate;
12 12
 
13
+    private String _setOfTemplate;
14
+
13 15
     private HashMap<String, HashMap<String, String>> _types;
14 16
 
15 17
     private List<String> _nonNullableTypes;
@@ -47,4 +49,12 @@ public class TypesCastOptions {
47 49
     public void setReservedWords(List<String> reservedWords) {
48 50
         _reservedWords = reservedWords;
49 51
     }
52
+
53
+    public String getSetOfTemplate() {
54
+        return _setOfTemplate;
55
+    }
56
+
57
+    public void setSetOfTemplate(String setOfTemplate) {
58
+        _setOfTemplate = setOfTemplate;
59
+    }
50 60
 }

+ 10
- 0
src/com/rthoni/intellij/codefromds/dbo/template/StoredProcedureDbo.java View File

@@ -16,6 +16,8 @@ public class StoredProcedureDbo {
16 16
 
17 17
     private boolean _isSelected;
18 18
 
19
+    private String _fullName;
20
+
19 21
     public String getName() {
20 22
         return _name;
21 23
     }
@@ -51,4 +53,12 @@ public class StoredProcedureDbo {
51 53
     public void setSelected(boolean selected) {
52 54
         _isSelected = selected;
53 55
     }
56
+
57
+    public String getFullName() {
58
+        return _fullName;
59
+    }
60
+
61
+    public void setFullName(String fullName) {
62
+        _fullName = fullName;
63
+    }
54 64
 }

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

@@ -11,10 +11,7 @@ import com.intellij.ui.ColoredListCellRenderer;
11 11
 import com.intellij.ui.JBColor;
12 12
 import com.intellij.ui.components.JBList;
13 13
 import com.rthoni.intellij.codefromds.business.Helper;
14
-import com.rthoni.intellij.codefromds.dbo.options.ColumnSelection;
15
-import com.rthoni.intellij.codefromds.dbo.options.DataSourceSelection;
16
-import com.rthoni.intellij.codefromds.dbo.options.GenerateOptions;
17
-import com.rthoni.intellij.codefromds.dbo.options.TableSelection;
14
+import com.rthoni.intellij.codefromds.dbo.options.*;
18 15
 import org.jetbrains.annotations.NotNull;
19 16
 import org.jetbrains.annotations.Nullable;
20 17
 
@@ -50,6 +47,7 @@ public class GenerateDialog extends DialogWrapper {
50 47
     private JLabel _lblModelsTemplatePath;
51 48
     private TextFieldWithBrowseButton _textCastFile;
52 49
     private JLabel _lblCastFile;
50
+    private JBList _listStoredProcedure;
53 51
 
54 52
     private GenerateOptions _options;
55 53
 
@@ -165,6 +163,12 @@ public class GenerateDialog extends DialogWrapper {
165 163
             }
166 164
         });
167 165
 
166
+        _listStoredProcedure.addListSelectionListener(e -> {
167
+            if (!e.getValueIsAdjusting()) {
168
+                updateSpSelection();
169
+            }
170
+        });
171
+
168 172
         setupTextField(_textModels, null, true, "Models");
169 173
         setupTextField(_textDataSource, null, false, "Data Source");
170 174
         setupTextField(_textDataSourceTemplate, null, false, "Data Source Template");
@@ -213,6 +217,20 @@ public class GenerateDialog extends DialogWrapper {
213 217
             }
214 218
         });
215 219
 
220
+        _listStoredProcedure.setCellRenderer(new ColoredListCellRenderer() {
221
+            @Override
222
+            protected void customizeCellRenderer(@NotNull JList jList, Object o, int i, boolean b, boolean b1) {
223
+                StoredProcedureSelection spSelection = _options.getSelection().getStoredProcedures().get(i);
224
+                if (spSelection.isSelected()) {
225
+                    setBackground(JBColor.GREEN);
226
+                }
227
+                else {
228
+                    setBackground(JBColor.RED);
229
+                }
230
+                append(spSelection.getStoredProcedure().getText());
231
+            }
232
+        });
233
+
216 234
         if (dataSources.size() > 0) {
217 235
             _listDatasources.setSelectedIndices(new int[]{0});
218 236
         }
@@ -264,9 +282,12 @@ public class GenerateDialog extends DialogWrapper {
264 282
             else {
265 283
                 showTable(null);
266 284
             }
285
+            List<String> sps = source.getStoredProcedures().stream().map(t -> t.getStoredProcedure().getText()).collect(Collectors.toList());
286
+            _listStoredProcedure.setListData(sps.toArray(new String[sps.size()]));
267 287
         }
268 288
         else {
269 289
             _listTables.setListData(new String[]{});
290
+            _listStoredProcedure.setListData(new String[]{});
270 291
             showTable(null);
271 292
         }
272 293
     }
@@ -283,7 +304,7 @@ public class GenerateDialog extends DialogWrapper {
283 304
         return indices.stream().mapToInt(Integer::intValue).toArray();
284 305
     }
285 306
 
286
-    private void updateSelection(final TableSelection table)
307
+    private void updateColumnSelection(final TableSelection table)
287 308
     {
288 309
         List<ColumnSelection> columns = table.getColumns();
289 310
         for (int i = 0; i < columns.size(); ++i) {
@@ -291,6 +312,14 @@ public class GenerateDialog extends DialogWrapper {
291 312
         }
292 313
     }
293 314
 
315
+    private void updateSpSelection()
316
+    {
317
+        List<StoredProcedureSelection> sps = _options.getSelection().getStoredProcedures();
318
+        for (int i = 0; i < sps.size(); ++i) {
319
+            sps.get(i).setSelected(_listStoredProcedure.isSelectedIndex(i));
320
+        }
321
+    }
322
+
294 323
     private void showTable(TableSelection table)
295 324
     {
296 325
         for (ListSelectionListener e : _listColumns.getListSelectionListeners()) {
@@ -303,7 +332,7 @@ public class GenerateDialog extends DialogWrapper {
303 332
             _listColumns.addListSelectionListener(e -> {
304 333
                 if (!e.getValueIsAdjusting()) {
305 334
                     _listTables.updateUI();
306
-                    updateSelection(table);
335
+                    updateColumnSelection(table);
307 336
                 }
308 337
             });
309 338
         }

+ 27
- 4
src/com/rthoni/intellij/codefromds/ui/forms/GenerateForm.form View File

@@ -1,22 +1,22 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.rthoni.intellij.codefromds.ui.dialogs.GenerateDialog">
3
-  <grid id="27dc6" binding="_panel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3
+  <grid id="27dc6" binding="_panel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4 4
     <margin top="0" left="0" bottom="0" right="0"/>
5 5
     <constraints>
6
-      <xy x="20" y="20" width="934" height="526"/>
6
+      <xy x="20" y="20" width="934" height="652"/>
7 7
     </constraints>
8 8
     <properties/>
9 9
     <border type="none"/>
10 10
     <children>
11 11
       <vspacer id="cffbd">
12 12
         <constraints>
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="4" 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 16
       <grid id="6946b" layout-manager="GridLayoutManager" row-count="12" 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
-          <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="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
20 20
         </constraints>
21 21
         <properties/>
22 22
         <border type="none"/>
@@ -237,6 +237,29 @@
237 237
           </scrollpane>
238 238
         </children>
239 239
       </grid>
240
+      <grid id="484d8" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
241
+        <margin top="0" left="0" bottom="0" right="0"/>
242
+        <constraints>
243
+          <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"/>
244
+        </constraints>
245
+        <properties/>
246
+        <border type="none" title="Select Stored Procedures To Map"/>
247
+        <children>
248
+          <scrollpane id="705ec">
249
+            <constraints>
250
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
251
+            </constraints>
252
+            <properties/>
253
+            <border type="none"/>
254
+            <children>
255
+              <component id="77e75" class="com.intellij.ui.components.JBList" binding="_listStoredProcedure">
256
+                <constraints/>
257
+                <properties/>
258
+              </component>
259
+            </children>
260
+          </scrollpane>
261
+        </children>
262
+      </grid>
240 263
     </children>
241 264
   </grid>
242 265
 </form>

Loading…
Cancel
Save