use of io.flutter.run.FlutterRunConfigurationType in project flutter-intellij by flutter.
the class FlutterModuleUtils method ensureRunConfigSelected.
/**
* Ensures a Flutter run configuration is selected in the run pull down.
*/
public static void ensureRunConfigSelected(@NotNull Project project) {
if (project.isDisposed())
return;
final FlutterRunConfigurationType configType = FlutterRunConfigurationType.getInstance();
final RunManager runManager = RunManager.getInstance(project);
if (!runManager.getConfigurationsList(configType).isEmpty()) {
if (runManager.getSelectedConfiguration() == null) {
final List<RunnerAndConfigurationSettings> flutterConfigs = runManager.getConfigurationSettingsList(configType);
if (!flutterConfigs.isEmpty()) {
runManager.setSelectedConfiguration(flutterConfigs.get(0));
}
}
}
}
use of io.flutter.run.FlutterRunConfigurationType in project flutter-intellij by flutter.
the class FlutterModuleUtils method autoCreateRunConfig.
/**
* Creates a Flutter run configuration if none exists.
*/
public static void autoCreateRunConfig(@NotNull Project project, @NotNull PubRoot root) {
assert ApplicationManager.getApplication().isReadAccessAllowed();
if (project.isDisposed())
return;
VirtualFile main = root.getLibMain();
if (main == null || !main.exists()) {
// Check for example main.dart in plugins
main = root.getExampleLibMain();
if (main == null || !main.exists()) {
return;
}
}
final FlutterRunConfigurationType configType = FlutterRunConfigurationType.getInstance();
final RunManager runManager = RunManager.getInstance(project);
if (!runManager.getConfigurationsList(configType).isEmpty()) {
// Don't create a run config if one already exists.
return;
}
final RunnerAndConfigurationSettings settings = runManager.createConfiguration(project.getName(), configType.getFactory());
final SdkRunConfig config = (SdkRunConfig) settings.getConfiguration();
// Set config name.
config.setName("main.dart");
// Set fields.
final SdkFields fields = new SdkFields();
fields.setFilePath(main.getPath());
config.setFields(fields);
runManager.addConfiguration(settings);
runManager.setSelectedConfiguration(settings);
}
Aggregations