K2JS editor improvements.

Get rid of the nasty "make before launch" checkbox.
This commit is contained in:
Pavel V. Talanov
2012-03-30 15:49:35 +04:00
parent df4f842f52
commit 428c517ee6
5 changed files with 61 additions and 39 deletions
@@ -37,7 +37,8 @@ public final class K2JSConfigurationSettings {
private BrowsersConfiguration.BrowserFamily browserFamily = BrowsersConfiguration.getInstance().getActiveBrowsers().get(0);
public K2JSConfigurationSettings(@NotNull Project project) {
generatedFilePath = project.getBasePath() + "/generated.js";
String basePath = project.getBasePath();
generatedFilePath = basePath != null ? basePath : "";
}
public K2JSConfigurationSettings() {
@@ -26,9 +26,8 @@ import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.runners.RunConfigurationWithSuppressedDefaultRunAction;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
@@ -36,31 +35,17 @@ import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
/**
* @author Pavel Talanov
*/
public final class K2JSRunConfiguration extends ModuleBasedConfiguration<RunConfigurationModule>
public final class K2JSRunConfiguration extends RunConfigurationBase
implements RunConfigurationWithSuppressedDefaultRunAction {
@NotNull
private K2JSConfigurationSettings settings = new K2JSConfigurationSettings(getProject());
public K2JSRunConfiguration(String name, RunConfigurationModule runConfigurationModule, ConfigurationFactory factory) {
super(name, runConfigurationModule, factory);
runConfigurationModule.init();
}
@Override
public Collection<Module> getValidModules() {
return Arrays.asList(ModuleManager.getInstance(getProject()).getModules());
}
@Override
protected ModuleBasedConfiguration createInstance() {
return new K2JSRunConfiguration(getName(), getConfigurationModule(), getFactory());
public K2JSRunConfiguration(String name, Project project, ConfigurationFactory factory) {
super(project, factory, name);
}
@Override
@@ -68,13 +53,28 @@ public final class K2JSRunConfiguration extends ModuleBasedConfiguration<RunConf
return new K2JSRunConfigurationEditor(getProject());
}
@Override
public JDOMExternalizable createRunnerSettings(ConfigurationInfoProvider provider) {
return null;
}
@Override
public SettingsEditor<JDOMExternalizable> getRunnerSettingsEditor(ProgramRunner runner) {
return null;
}
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment)
throws ExecutionException {
return new MyProfileState();
}
private class MyProfileState implements RunProfileState {
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
//do nothing
}
private final class MyProfileState implements RunProfileState {
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
return new ExecutionResult() {
@@ -16,38 +16,42 @@
<properties/>
<border type="none"/>
<children>
<component id="5ba6" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="htmlChooseFile">
<component id="cf71a" class="javax.swing.JLabel" binding="htmlFileLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="cf71a" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="155" height="16"/>
</grid>
</constraints>
<properties>
<enabled value="false"/>
<text value="HTML file"/>
</properties>
</component>
<component id="f4230" class="javax.swing.JLabel">
<component id="f4230" class="javax.swing.JLabel" binding="chooseBrowserLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="155" height="16"/>
</grid>
</constraints>
<properties>
<enabled value="false"/>
<labelFor value="a2cc0"/>
<text value="Browser"/>
</properties>
</component>
<component id="a2cc0" class="javax.swing.JComboBox" binding="browserComboBox">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<properties>
<enabled value="false"/>
</properties>
</component>
<component id="beb35" class="javax.swing.JCheckBox" binding="openInBrowserCheckBox">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="155" height="24"/>
</grid>
</constraints>
<properties>
<text value="Open in browser after translation"/>
@@ -55,18 +59,28 @@
</component>
<component id="f6a73" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="155" height="16"/>
</grid>
</constraints>
<properties>
<text value="Generated file directory"/>
<text value="Generated JavaScript file directory"/>
</properties>
</component>
<component id="12973" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="generatedChooseFile">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="5ba6" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="htmlChooseFile">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
</component>
</children>
</grid>
<vspacer id="e9321">
@@ -44,6 +44,8 @@ public final class K2JSRunConfigurationEditor extends SettingsEditor<K2JSRunConf
private JComboBox browserComboBox;
private JCheckBox openInBrowserCheckBox;
private TextFieldWithBrowseButton generatedChooseFile;
private JLabel chooseBrowserLabel;
private JLabel htmlFileLabel;
@NotNull
private final Project project;
@@ -95,6 +97,8 @@ public final class K2JSRunConfigurationEditor extends SettingsEditor<K2JSRunConf
boolean selected = openInBrowserCheckBox.isSelected();
htmlChooseFile.setEnabled(selected);
browserComboBox.setEnabled(selected);
htmlFileLabel.setEnabled(selected);
chooseBrowserLabel.setEnabled(selected);
}
});
}
@@ -16,7 +16,10 @@
package org.jetbrains.jet.plugin.k2jsrun;
import com.intellij.execution.configurations.*;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationTypeBase;
import com.intellij.execution.configurations.ConfigurationTypeUtil;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.plugin.JetFileType;
@@ -40,7 +43,7 @@ public final class K2JSRunConfigurationType extends ConfigurationTypeBase {
@Override
public RunConfiguration createTemplateConfiguration(Project project) {
return new K2JSRunConfiguration("", new RunConfigurationModule(project), this);
return new K2JSRunConfiguration("Kotlin to JavaScript", project, this);
}
}
}