From 8f8c0ceaa6bfb039e40216b5632d404a33612143 Mon Sep 17 00:00:00 2001 From: Boris Farber Date: Tue, 13 Feb 2018 11:57:19 +0200 Subject: [PATCH 1/2] fixed frame positioning --- SampleConfig.json | 29 +++++++++---------- .../androidstudiopoet/AndroidStudioPoet.kt | 16 +++++----- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/SampleConfig.json b/SampleConfig.json index 4d81fe6c..2b4dfb88 100644 --- a/SampleConfig.json +++ b/SampleConfig.json @@ -1,6 +1,6 @@ { - "projectName": "gennyCLI", - "root": "./modules/", + "projectName": "genny", + "root": "././", "gradleVersion": "4.3.1", "androidGradlePluginVersion": "3.0.1", "kotlinVersion": "1.1.60", @@ -13,18 +13,17 @@ "kotlinClassCount": "8", "androidModules": "2", "numActivitiesPerAndroidModule": "8", + "productFlavors": [ + 2, 3 + ], + "topologies": [ + {"type": "random_connected", "seed": "2"} + ], "dependencies": [ - { - "from": 3, - "to": 2 - }, - { - "from": 4, - "to": 2 - }, - { - "from": 4, - "to": 3 - } - ] + {"from": "module2", "to": "module3"}, + {"from": "module2", "to": "module4"}, + {"from": "module3", "to": "module4"} + ], + "buildTypes": 6, + "generateTests": true } \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt b/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt index de884cdc..ece9133a 100644 --- a/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt +++ b/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt @@ -25,16 +25,14 @@ import com.google.gson.JsonObject import com.google.gson.JsonParser import com.google.gson.JsonSyntaxException import org.intellij.lang.annotations.Language -import java.awt.BorderLayout -import java.awt.Color -import java.awt.EventQueue -import java.awt.Font +import java.awt.* import java.io.File import javax.swing.* import javax.swing.JFrame.EXIT_ON_CLOSE import javax.swing.border.EmptyBorder import kotlin.system.measureTimeMillis + class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private val filename: String?, private val configPojoToProjectConfigConverter: ConfigPojoToProjectConfigConverter, private val dependencyValidator: DependencyValidator, private val gson: Gson) { @@ -51,7 +49,7 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v val SAMPLE_CONFIG = """ { "projectName": "genny", - "root": "./modules/", + "root": "././", "gradleVersion": "4.3.1", "androidGradlePluginVersion": "3.0.1", "kotlinVersion": "1.1.60", @@ -127,11 +125,15 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v add(btnGenerate, BorderLayout.SOUTH) } - frame.defaultCloseOperation = EXIT_ON_CLOSE + val dim = Toolkit.getDefaultToolkit().screenSize - frame.contentPane = contentPane + frame.setLocation((dim.width - frame.size.width)/3, + (dim.height - frame.height)/5 ) + frame.defaultCloseOperation = EXIT_ON_CLOSE + frame.contentPane = contentPane frame.pack() + return frame } From 385f0eed4de182cb6604b8319007c358b6312d41 Mon Sep 17 00:00:00 2001 From: Boris Farber Date: Tue, 13 Feb 2018 12:35:03 +0200 Subject: [PATCH 2/2] Renamed config files to compact and full --- ConfigCompact.json | 27 ++++++++++++++++ ...leGenerationConfig.json => ConfigFull.json | 0 SampleConfig.json | 29 ----------------- .../androidstudiopoet/AndroidStudioPoet.kt | 32 +++++++++---------- 4 files changed, 42 insertions(+), 46 deletions(-) create mode 100644 ConfigCompact.json rename SampleGenerationConfig.json => ConfigFull.json (100%) delete mode 100644 SampleConfig.json diff --git a/ConfigCompact.json b/ConfigCompact.json new file mode 100644 index 00000000..a02f0707 --- /dev/null +++ b/ConfigCompact.json @@ -0,0 +1,27 @@ +{ + "projectName": "GeneratedASProject", + "root": "./../", + "gradleVersion": "4.3.1", + "androidGradlePluginVersion": "3.0.1", + "kotlinVersion": "1.1.60", + "numModules": "2", + "allMethods": "40", + "javaPackageCount": "1", + "javaClassCount": "4", + "javaMethodCount": "20", + "kotlinPackageCount": "1", + "kotlinClassCount": "4", + "androidModules": "2", + "numActivitiesPerAndroidModule": "2", + "productFlavors": [ + 2, 3 + ], + "topologies": [ + {"type": "star", "seed": "2"} + ], + "dependencies": [ + {"from": "module1", "to": "module0"} + ], + "buildTypes": 2, + "generateTests": true +} \ No newline at end of file diff --git a/SampleGenerationConfig.json b/ConfigFull.json similarity index 100% rename from SampleGenerationConfig.json rename to ConfigFull.json diff --git a/SampleConfig.json b/SampleConfig.json deleted file mode 100644 index 2b4dfb88..00000000 --- a/SampleConfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "projectName": "genny", - "root": "././", - "gradleVersion": "4.3.1", - "androidGradlePluginVersion": "3.0.1", - "kotlinVersion": "1.1.60", - "numModules": "5", - "allMethods": "4000", - "javaPackageCount": "20", - "javaClassCount": "8", - "javaMethodCount": "2000", - "kotlinPackageCount": "20", - "kotlinClassCount": "8", - "androidModules": "2", - "numActivitiesPerAndroidModule": "8", - "productFlavors": [ - 2, 3 - ], - "topologies": [ - {"type": "random_connected", "seed": "2"} - ], - "dependencies": [ - {"from": "module2", "to": "module3"}, - {"from": "module2", "to": "module4"}, - {"from": "module3", "to": "module4"} - ], - "buildTypes": 6, - "generateTests": true -} \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt b/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt index ece9133a..9722ebcf 100644 --- a/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt +++ b/src/main/kotlin/com/google/androidstudiopoet/AndroidStudioPoet.kt @@ -46,34 +46,32 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v } @Language("JSON") - val SAMPLE_CONFIG = """ + val CONFIG_COMPACT = """ { - "projectName": "genny", - "root": "././", + "projectName": "GeneratedASProject", + "root": "./../", "gradleVersion": "4.3.1", "androidGradlePluginVersion": "3.0.1", "kotlinVersion": "1.1.60", - "numModules": "5", - "allMethods": "4000", - "javaPackageCount": "20", - "javaClassCount": "8", - "javaMethodCount": "2000", - "kotlinPackageCount": "20", - "kotlinClassCount": "8", + "numModules": "2", + "allMethods": "40", + "javaPackageCount": "1", + "javaClassCount": "4", + "javaMethodCount": "20", + "kotlinPackageCount": "1", + "kotlinClassCount": "4", "androidModules": "2", - "numActivitiesPerAndroidModule": "8", + "numActivitiesPerAndroidModule": "2", "productFlavors": [ 2, 3 ], "topologies": [ - {"type": "random_connected", "seed": "2"} + {"type": "star", "seed": "2"} ], "dependencies": [ - {"from": "module2", "to": "module3"}, - {"from": "module2", "to": "module4"}, - {"from": "module3", "to": "module4"} + {"from": "module1", "to": "module0"} ], - "buildTypes": 6, + "buildTypes": 2, "generateTests": true } """.trimIndent() @@ -82,7 +80,7 @@ class AndroidStudioPoet(private val modulesWriter: SourceModuleWriter, private v fun run() { when { filename != null -> processFile(filename) - else -> showUI(SAMPLE_CONFIG) + else -> showUI(CONFIG_COMPACT) } }