use of io.flutter.module.FlutterModuleBuilder in project flutter-intellij by flutter.
the class FlutterProjectCreator method createModule.
public void createModule() {
Project project = myModel.project().getValue();
VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) {
// Project was deleted.
return;
}
String baseDirPath = baseDir.getPath();
String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, myModel.projectName().get(), "");
String contentRoot = baseDirPath + "/" + moduleName;
File location = new File(contentRoot);
if (!location.exists() && !location.mkdirs()) {
String message = ActionsBundle.message("action.NewDirectoryProject.cannot.create.dir", location.getAbsolutePath());
Messages.showErrorDialog(project, message, ActionsBundle.message("action.NewDirectoryProject.title"));
return;
}
// ModuleBuilder mixes UI and model code too much to easily reuse. We have to override a bunch of stuff to ensure
// that methods which expect a live UI do not get called.
FlutterModuleBuilder builder = new FlutterModuleBuilder() {
@NotNull
@Override
public FlutterCreateAdditionalSettings getAdditionalSettings() {
return makeAdditionalSettings();
}
@Override
protected FlutterSdk getFlutterSdk() {
return FlutterSdk.forPath(myModel.flutterSdk().get());
}
@Override
public boolean validate(Project current, Project dest) {
return true;
}
@Override
public ModuleWizardStep getCustomOptionsStep(final WizardContext context, final Disposable parentDisposable) {
return null;
}
@Override
public void setFlutterSdkPath(String s) {
}
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
return null;
}
};
builder.setName(myModel.projectName().get());
builder.setModuleFilePath(toSystemIndependentName(contentRoot) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
builder.commitModule(project, null);
}
Aggregations