use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.
the class SupportForFrameworksStep method updateStep.
@Override
public void updateStep() {
ProjectBuilder builder = myContext.getProjectBuilder();
if (builder instanceof ModuleBuilder) {
myBuilder.updateFrom((ModuleBuilder) builder);
((ModuleBuilder) builder).addModuleConfigurationUpdater(myConfigurationUpdater);
}
myFrameworkSupportModel.fireWizardStepUpdated();
}
use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.
the class ModulesConfigurator method runModuleWizard.
@Nullable
ProjectBuilder runModuleWizard(Component dialogParent, boolean anImport) {
AbstractProjectWizard wizard;
if (anImport) {
wizard = ImportModuleAction.selectFileAndCreateWizard(myProject, dialogParent);
if (wizard == null)
return null;
if (wizard.getStepCount() == 0) {
ProjectBuilder builder = wizard.getProjectBuilder();
Disposer.dispose(wizard.getDisposable());
return builder;
}
} else {
wizard = new NewProjectWizard(myProject, dialogParent, this);
}
if (wizard.showAndGet()) {
final ProjectBuilder builder = wizard.getProjectBuilder();
if (builder instanceof ModuleBuilder) {
final ModuleBuilder moduleBuilder = (ModuleBuilder) builder;
if (moduleBuilder.getName() == null) {
moduleBuilder.setName(wizard.getProjectName());
}
if (moduleBuilder.getModuleFilePath() == null) {
moduleBuilder.setModuleFilePath(wizard.getModuleFilePath());
}
}
if (!builder.validate(myProject, myProject)) {
return null;
}
return wizard.getProjectBuilder();
}
return null;
}
use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.
the class NewModuleAction method createModuleFromWizard.
@Nullable
public Module createModuleFromWizard(Project project, @Nullable Object dataFromContext, AbstractProjectWizard wizard) {
final ProjectBuilder builder = wizard.getProjectBuilder();
if (builder instanceof ModuleBuilder) {
final ModuleBuilder moduleBuilder = (ModuleBuilder) builder;
if (moduleBuilder.getName() == null) {
moduleBuilder.setName(wizard.getProjectName());
}
if (moduleBuilder.getModuleFilePath() == null) {
moduleBuilder.setModuleFilePath(wizard.getModuleFilePath());
}
}
if (!builder.validate(project, project)) {
return null;
}
Module module;
if (builder instanceof ModuleBuilder) {
module = ((ModuleBuilder) builder).commitModule(project, null);
if (module != null) {
processCreatedModule(module, dataFromContext);
}
return module;
} else {
List<Module> modules = builder.commit(project, null, new DefaultModulesProvider(project));
if (builder.isOpenProjectSettingsAfter()) {
ModulesConfigurator.showDialog(project, null, null);
}
module = modules == null || modules.isEmpty() ? null : modules.get(0);
}
project.save();
return module;
}
use of com.intellij.ide.util.projectWizard.ProjectBuilder in project android by JetBrains.
the class AndroidImportProjectAction method doCreate.
private static void doCreate(@NotNull AddModuleWizard wizard) throws IOException {
// TODO: Now we need to add as module if file does not exist
ProjectBuilder projectBuilder = wizard.getProjectBuilder();
try {
File projectFilePath = new File(wizard.getNewProjectFilePath());
File projectDirPath = projectFilePath.isDirectory() ? projectFilePath : projectFilePath.getParentFile();
LOG.assertTrue(projectDirPath != null, "Cannot create project in '" + projectFilePath + "': no parent file exists");
ensureExists(projectDirPath);
if (StorageScheme.DIRECTORY_BASED == wizard.getStorageScheme()) {
ensureExists(new File(projectDirPath, DIRECTORY_STORE_FOLDER));
}
boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();
ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
Project project = projectManager.newProject(wizard.getProjectName(), projectDirPath.getPath(), true, false);
if (project == null) {
return;
}
if (!unitTestMode) {
project.save();
}
if (projectBuilder != null) {
if (!projectBuilder.validate(null, project)) {
return;
}
projectBuilder.commit(project, null, EMPTY_MODULES_PROVIDER);
}
if (!unitTestMode) {
project.save();
}
} finally {
if (projectBuilder != null) {
projectBuilder.cleanup();
}
}
}
use of com.intellij.ide.util.projectWizard.ProjectBuilder in project intellij-community by JetBrains.
the class CloudModuleBuilderSourceContribution method detectModuleStructure.
private void detectModuleStructure(Module module, final String contentPath) {
final Project project = module.getProject();
final CreateFromSourcesMode mode = new CreateFromSourcesMode() {
@Override
public boolean isAvailable(WizardContext context) {
return true;
}
@Override
public void addSteps(WizardContext context, ModulesProvider modulesProvider, StepSequence sequence, String specific) {
super.addSteps(context, modulesProvider, sequence, specific);
myProjectBuilder.setFileToImport(contentPath);
}
};
final WizardContext context = new WizardContext(project);
final StepSequence stepSequence = mode.getSteps(context, DefaultModulesProvider.createForProject(context.getProject()));
if (stepSequence == null) {
return;
}
Disposer.register(project, new Disposable() {
@Override
public void dispose() {
for (ModuleWizardStep step : stepSequence.getAllSteps()) {
step.disposeUIResources();
}
}
});
ProgressManager.getInstance().run(new Task.Backgroundable(project, CloudBundle.getText("detect.module.structure", getCloudType().getPresentableName()), false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
for (ModuleWizardStep step = ContainerUtil.getFirstItem(stepSequence.getSelectedSteps()); step != null; step = stepSequence.getNextStep(step)) {
if (step instanceof AbstractStepWithProgress<?>) {
((AbstractStepWithProgress) step).performStep();
} else {
step.updateDataModel();
}
}
CloudAccountSelectionEditor.unsetAccountOnContext(context, getCloudType());
}
@Override
public boolean shouldStartInBackground() {
return false;
}
@Override
public void onSuccess() {
ProjectBuilder moduleBuilder = mode.getModuleBuilder();
if (moduleBuilder == null) {
return;
}
moduleBuilder.commit(project);
getNotifier().showMessage(CloudBundle.getText("cloud.support.added", getCloudType().getPresentableName()), MessageType.INFO);
}
});
}
Aggregations