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,7 +14,6 @@ import com.rthoni.intellij.codefromds.dbo.template.ColumnDataSourceDbo;
14 14
 import com.rthoni.intellij.codefromds.dbo.template.DataSourceDbo;
15 15
 import com.rthoni.intellij.codefromds.dbo.template.ForeignKeyDbo;
16 16
 import com.rthoni.intellij.codefromds.dbo.template.TableDataSourceDbo;
17
-import org.json.JSONArray;
18 17
 import org.json.JSONObject;
19 18
 import org.jtwig.JtwigModel;
20 19
 import org.jtwig.JtwigTemplate;
@@ -22,9 +21,6 @@ import org.jtwig.JtwigTemplate;
22 21
 import java.io.File;
23 22
 import java.io.FileOutputStream;
24 23
 import java.io.IOException;
25
-import java.nio.charset.StandardCharsets;
26
-import java.nio.file.Files;
27
-import java.nio.file.Paths;
28 24
 import java.util.HashMap;
29 25
 import java.util.List;
30 26
 import java.util.Vector;
@@ -83,15 +79,9 @@ public abstract class Generator {
83 79
 
84 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 85
         boolean isArray = type.typeName.endsWith("[]");
96 86
         String sqlTypeName = isArray ? type.typeName.substring(0, type.typeName.length() - 2) : type.typeName;
97 87
         String typeName = type.typeName;
@@ -109,7 +99,16 @@ public abstract class Generator {
109 99
         if (isArray) {
110 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 113
         return dbo;
115 114
     }
@@ -156,14 +155,14 @@ public abstract class Generator {
156 155
             HashMap<String, String> typeMap = new HashMap<>();
157 156
             String type = objTypes.optString(key);
158 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 159
                 for (String subtype : typeObject.keySet()) {
164 160
                     typeMap.put(subtype, typeObject.getString(subtype));
165 161
                 }
166 162
             }
163
+            else if (type != null) {
164
+                typeMap.put("*", type);
165
+            }
167 166
             map.put(key, typeMap);
168 167
         }
169 168
         dbo.setTypes(map);

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

@@ -149,17 +149,22 @@
149 149
         <properties/>
150 150
         <border type="none" title="Select Data Source"/>
151 151
         <children>
152
-          <component id="ad455" class="com.intellij.ui.components.JBList" binding="_listDatasources">
152
+          <scrollpane id="ddb50">
153 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 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 168
         </children>
164 169
       </grid>
165 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,16 +175,21 @@
170 175
         <properties/>
171 176
         <border type="none" title="Select Table"/>
172 177
         <children>
173
-          <component id="81c7e" class="com.intellij.ui.components.JBList" binding="_listTables">
178
+          <scrollpane id="86ae7">
174 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 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 193
         </children>
184 194
       </grid>
185 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,14 +200,19 @@
190 200
         <properties/>
191 201
         <border type="none" title="Select Columns To Map"/>
192 202
         <children>
193
-          <component id="15ba0" class="com.intellij.ui.components.JBList" binding="_listColumns">
203
+          <scrollpane id="57c71">
194 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 206
             </constraints>
199 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 216
         </children>
202 217
       </grid>
203 218
     </children>

Loading…
Cancel
Save