From 3821d29f1c17e21eadc8a00bccb534e550ea0d4f Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 26 Feb 2017 07:36:07 +0300 Subject: [PATCH] Don't allow user to change minifier settings via IDEA facet UI --- .../idea/jps/model/TeaVMJpsConfiguration.java | 8 -------- .../main/java/org/teavm/idea/jps/TeaVMBuild.java | 1 - .../org/teavm/idea/maven/TeaVMMavenImporter.java | 13 ++++++++----- .../org/teavm/idea/ui/TeaVMConfigurationPanel.java | 14 -------------- .../plugin/src/main/resources/META-INF/plugin.xml | 2 +- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMJpsConfiguration.java b/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMJpsConfiguration.java index f33cae0ed..f8de6b826 100644 --- a/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMJpsConfiguration.java +++ b/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMJpsConfiguration.java @@ -66,14 +66,6 @@ public class TeaVMJpsConfiguration extends JpsElementBase this.targetDirectory = targetDirectory; } - public boolean isMinifying() { - return minifying; - } - - public void setMinifying(boolean minifying) { - this.minifying = minifying; - } - public boolean isSourceMapsFileGenerated() { return sourceMapsFileGenerated; } diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java index 8a88cb3d6..0b74e3803 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java @@ -137,7 +137,6 @@ class TeaVMBuild { tool.setDebugInformationGenerated(config.isSourceMapsFileGenerated()); tool.setSourceFilesCopied(config.isSourceFilesCopied()); - tool.setMinifying(config.isMinifying()); for (SourceFileProvider fileProvider : sourceFileProviders) { tool.addSourceFileProvider(fileProvider); } diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/maven/TeaVMMavenImporter.java b/tools/idea/plugin/src/main/java/org/teavm/idea/maven/TeaVMMavenImporter.java index 6e3ec6149..b25208505 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/maven/TeaVMMavenImporter.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/maven/TeaVMMavenImporter.java @@ -100,9 +100,11 @@ public class TeaVMMavenImporter extends MavenImporter { TeaVMFacet facet = facetManager.getFacetByType(facetType.getId()); + boolean justCreated = false; if (facet == null) { facet = facetManager.createFacet(facetType, facetType.getDefaultFacetName(), null); facetModel.addFacet(facet); + justCreated = true; } TeaVMJpsConfiguration configuration = facet.getConfiguration().getState(); @@ -110,13 +112,14 @@ public class TeaVMMavenImporter extends MavenImporter { for (Element child : source.getChildren()) { switch (child.getName()) { case "sourceFilesCopied": - configuration.setSourceFilesCopied(Boolean.parseBoolean(child.getTextTrim())); + if (justCreated) { + configuration.setSourceFilesCopied(true); + } break; case "sourceMapsGenerated": - configuration.setSourceMapsFileGenerated(Boolean.parseBoolean(child.getTextTrim())); - break; - case "minifying": - configuration.setMinifying(Boolean.parseBoolean(child.getTextTrim())); + if (justCreated) { + configuration.setSourceMapsFileGenerated(true); + } break; case "targetDirectory": configuration.setTargetDirectory(child.getTextTrim()); diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/ui/TeaVMConfigurationPanel.java b/tools/idea/plugin/src/main/java/org/teavm/idea/ui/TeaVMConfigurationPanel.java index 6a7d86821..72ce92122 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/ui/TeaVMConfigurationPanel.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/ui/TeaVMConfigurationPanel.java @@ -45,15 +45,11 @@ import org.teavm.idea.jps.model.TeaVMJpsConfiguration; class TeaVMConfigurationPanel extends JPanel { private final TextFieldWithBrowseButton mainClassField = new TextFieldWithBrowseButton(event -> chooseMainClass()); private final TextFieldWithBrowseButton targetDirectoryField = new TextFieldWithBrowseButton(); - private final JComboBox> minifyingField = new JComboBox<>(new DefaultComboBoxModel<>()); private final JComboBox> sourceMapsField = new JComboBox<>(new DefaultComboBoxModel<>()); private final JComboBox> copySourcesField = new JComboBox<>(new DefaultComboBoxModel<>()); private final TeaVMJpsConfiguration initialConfiguration = new TeaVMJpsConfiguration(); private final Project project; - private final List> minifiedOptions = Arrays.asList(new ComboBoxItem<>(false, "Readable"), - new ComboBoxItem<>(true, "Minified (obfuscated)")); - private final List> sourceMapsOptions = Arrays.asList(new ComboBoxItem<>(true, "Generate"), new ComboBoxItem<>(false, "Skip")); @@ -65,9 +61,6 @@ class TeaVMConfigurationPanel extends JPanel { mainClassField::setText, mainClassField::getText), new Field<>(TeaVMJpsConfiguration::setTargetDirectory, TeaVMJpsConfiguration::getTargetDirectory, targetDirectoryField::setText, targetDirectoryField::getText), - new Field<>(TeaVMJpsConfiguration::setMinifying, TeaVMJpsConfiguration::isMinifying, - value -> minifyingField.setSelectedIndex(value ? 1 : 0), - () -> minifiedOptions.get(minifyingField.getSelectedIndex()).value), new Field<>(TeaVMJpsConfiguration::setSourceMapsFileGenerated, TeaVMJpsConfiguration::isSourceMapsFileGenerated, value -> sourceMapsField.setSelectedIndex(value ? 0 : 1), @@ -87,7 +80,6 @@ class TeaVMConfigurationPanel extends JPanel { targetDirectoryField.addBrowseFolderListener("Target Directory", "Please, select folder where TeaVM should" + "write generated JS files", project, targetDirectoryChooserDescriptor); - minifiedOptions.forEach(minifyingField::addItem); sourceMapsOptions.forEach(sourceMapsField::addItem); copySourcesOptions.forEach(copySourcesField::addItem); } @@ -126,12 +118,6 @@ class TeaVMConfigurationPanel extends JPanel { add(targetDirectoryField, fieldConstraints); fieldConstraints.fill = GridBagConstraints.NONE; - add(bold(new JBLabel("Minification")), labelConstraints); - add(new JBLabel("Indicates whether TeaVM should minify (obfuscate) generated JavaScript."), - descriptionConstraints); - add(new JBLabel("It is highly desirable for production environment, since minified code is up to 3 " - + "times smaller."), descriptionConstraints); - add(minifyingField, fieldConstraints); add(bold(new JBLabel("Source maps")), labelConstraints); add(new JBLabel("Indicates whether TeaVM should generate source maps."), descriptionConstraints); diff --git a/tools/idea/plugin/src/main/resources/META-INF/plugin.xml b/tools/idea/plugin/src/main/resources/META-INF/plugin.xml index 3a54b0e24..93d383452 100644 --- a/tools/idea/plugin/src/main/resources/META-INF/plugin.xml +++ b/tools/idea/plugin/src/main/resources/META-INF/plugin.xml @@ -17,7 +17,7 @@ ]]> - +