Browse Source

added scroll for lists; fixed types cast loading

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

+ 16
- 17
src/com/rthoni/intellij/codefromds/business/Generator.java View File

14
 import com.rthoni.intellij.codefromds.dbo.template.DataSourceDbo;
14
 import com.rthoni.intellij.codefromds.dbo.template.DataSourceDbo;
15
 import com.rthoni.intellij.codefromds.dbo.template.ForeignKeyDbo;
15
 import com.rthoni.intellij.codefromds.dbo.template.ForeignKeyDbo;
16
 import com.rthoni.intellij.codefromds.dbo.template.TableDataSourceDbo;
16
 import com.rthoni.intellij.codefromds.dbo.template.TableDataSourceDbo;
17
-import org.json.JSONArray;
18
 import org.json.JSONObject;
17
 import org.json.JSONObject;
19
 import org.jtwig.JtwigModel;
18
 import org.jtwig.JtwigModel;
20
 import org.jtwig.JtwigTemplate;
19
 import org.jtwig.JtwigTemplate;
22
 import java.io.File;
21
 import java.io.File;
23
 import java.io.FileOutputStream;
22
 import java.io.FileOutputStream;
24
 import java.io.IOException;
23
 import java.io.IOException;
25
-import java.nio.charset.StandardCharsets;
26
-import java.nio.file.Files;
27
-import java.nio.file.Paths;
28
 import java.util.HashMap;
24
 import java.util.HashMap;
29
 import java.util.List;
25
 import java.util.List;
30
 import java.util.Vector;
26
 import java.util.Vector;
83
 
79
 
84
         return dbo;
80
         return dbo;
85
     }
81
     }
86
-
87
-    public static ColumnDataSourceDbo convertColumn(ColumnSelection columnSelection, TypesCastOptions options)
82
+    
83
+    public static String convertSqlType(DataType type, TypesCastOptions options)
88
     {
84
     {
89
-        ColumnDataSourceDbo dbo = new ColumnDataSourceDbo();
90
-        dbo.setName(columnSelection.getColumn().getName());
91
-        dbo.setPrimary(DasUtil.isPrimary(columnSelection.getColumn()));
92
-        dbo.setSelected(columnSelection.isSelected());
93
-
94
-        DataType type = columnSelection.getColumn().getDataType();
95
         boolean isArray = type.typeName.endsWith("[]");
85
         boolean isArray = type.typeName.endsWith("[]");
96
         String sqlTypeName = isArray ? type.typeName.substring(0, type.typeName.length() - 2) : type.typeName;
86
         String sqlTypeName = isArray ? type.typeName.substring(0, type.typeName.length() - 2) : type.typeName;
97
         String typeName = type.typeName;
87
         String typeName = type.typeName;
109
         if (isArray) {
99
         if (isArray) {
110
             typeName = options.getArrayTemplate().replace("%t", typeName);
100
             typeName = options.getArrayTemplate().replace("%t", typeName);
111
         }
101
         }
112
-        dbo.setType(typeName);
102
+        return typeName;
103
+    }
104
+
105
+    public static ColumnDataSourceDbo convertColumn(ColumnSelection columnSelection, TypesCastOptions options)
106
+    {
107
+        ColumnDataSourceDbo dbo = new ColumnDataSourceDbo();
108
+        dbo.setName(columnSelection.getColumn().getName());
109
+        dbo.setPrimary(DasUtil.isPrimary(columnSelection.getColumn()));
110
+        dbo.setSelected(columnSelection.isSelected());
111
+        dbo.setType(convertSqlType(columnSelection.getColumn().getDataType(), options));
113
 
112
 
114
         return dbo;
113
         return dbo;
115
     }
114
     }
156
             HashMap<String, String> typeMap = new HashMap<>();
155
             HashMap<String, String> typeMap = new HashMap<>();
157
             String type = objTypes.optString(key);
156
             String type = objTypes.optString(key);
158
             JSONObject typeObject = objTypes.optJSONObject(key);
157
             JSONObject typeObject = objTypes.optJSONObject(key);
159
-            if (type != null) {
160
-                typeMap.put("*", type);
161
-            }
162
-            else if (typeObject != null) {
158
+            if (typeObject != null) {
163
                 for (String subtype : typeObject.keySet()) {
159
                 for (String subtype : typeObject.keySet()) {
164
                     typeMap.put(subtype, typeObject.getString(subtype));
160
                     typeMap.put(subtype, typeObject.getString(subtype));
165
                 }
161
                 }
166
             }
162
             }
163
+            else if (type != null) {
164
+                typeMap.put("*", type);
165
+            }
167
             map.put(key, typeMap);
166
             map.put(key, typeMap);
168
         }
167
         }
169
         dbo.setTypes(map);
168
         dbo.setTypes(map);

+ 37
- 22
src/com/rthoni/intellij/codefromds/ui/forms/GenerateForm.form View File

149
         <properties/>
149
         <properties/>
150
         <border type="none" title="Select Data Source"/>
150
         <border type="none" title="Select Data Source"/>
151
         <children>
151
         <children>
152
-          <component id="ad455" class="com.intellij.ui.components.JBList" binding="_listDatasources">
152
+          <scrollpane id="ddb50">
153
             <constraints>
153
             <constraints>
154
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
155
-                <preferred-size width="150" height="50"/>
156
-              </grid>
154
+              <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"/>
157
             </constraints>
155
             </constraints>
158
-            <properties>
159
-              <model/>
160
-              <selectionMode value="0"/>
161
-            </properties>
162
-          </component>
156
+            <properties/>
157
+            <border type="none"/>
158
+            <children>
159
+              <component id="ad455" class="com.intellij.ui.components.JBList" binding="_listDatasources">
160
+                <constraints/>
161
+                <properties>
162
+                  <model/>
163
+                  <selectionMode value="0"/>
164
+                </properties>
165
+              </component>
166
+            </children>
167
+          </scrollpane>
163
         </children>
168
         </children>
164
       </grid>
169
       </grid>
165
       <grid id="ae3e9" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
170
       <grid id="ae3e9" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
170
         <properties/>
175
         <properties/>
171
         <border type="none" title="Select Table"/>
176
         <border type="none" title="Select Table"/>
172
         <children>
177
         <children>
173
-          <component id="81c7e" class="com.intellij.ui.components.JBList" binding="_listTables">
178
+          <scrollpane id="86ae7">
174
             <constraints>
179
             <constraints>
175
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
176
-                <preferred-size width="150" height="50"/>
177
-              </grid>
180
+              <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"/>
178
             </constraints>
181
             </constraints>
179
-            <properties>
180
-              <selectionMode value="0"/>
181
-            </properties>
182
-          </component>
182
+            <properties/>
183
+            <border type="none"/>
184
+            <children>
185
+              <component id="81c7e" class="com.intellij.ui.components.JBList" binding="_listTables">
186
+                <constraints/>
187
+                <properties>
188
+                  <selectionMode value="0"/>
189
+                </properties>
190
+              </component>
191
+            </children>
192
+          </scrollpane>
183
         </children>
193
         </children>
184
       </grid>
194
       </grid>
185
       <grid id="cab88" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
195
       <grid id="cab88" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
190
         <properties/>
200
         <properties/>
191
         <border type="none" title="Select Columns To Map"/>
201
         <border type="none" title="Select Columns To Map"/>
192
         <children>
202
         <children>
193
-          <component id="15ba0" class="com.intellij.ui.components.JBList" binding="_listColumns">
203
+          <scrollpane id="57c71">
194
             <constraints>
204
             <constraints>
195
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
196
-                <preferred-size width="150" height="50"/>
197
-              </grid>
205
+              <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"/>
198
             </constraints>
206
             </constraints>
199
             <properties/>
207
             <properties/>
200
-          </component>
208
+            <border type="none"/>
209
+            <children>
210
+              <component id="15ba0" class="com.intellij.ui.components.JBList" binding="_listColumns">
211
+                <constraints/>
212
+                <properties/>
213
+              </component>
214
+            </children>
215
+          </scrollpane>
201
         </children>
216
         </children>
202
       </grid>
217
       </grid>
203
     </children>
218
     </children>

Loading…
Cancel
Save