use of com.intellij.ide.util.projectWizard.WizardContext 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);
}
});
}
use of com.intellij.ide.util.projectWizard.WizardContext 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);
}
use of com.intellij.ide.util.projectWizard.WizardContext in project android by JetBrains.
the class SourceToGradleModuleStep method createDependentSteps.
@NotNull
@Override
protected Collection<? extends ModelWizardStep> createDependentSteps() {
WizardContext context = getModel().getContext();
ArrayList<ModelWizardStep> wrappedSteps = new ArrayList<>();
for (ModuleImporter importer : ModuleImporter.getAllImporters(context)) {
for (ModuleWizardStep inputStep : importer.createWizardSteps()) {
wrappedSteps.add(new ModuleWizardStepAdapter(context, inputStep));
}
}
return wrappedSteps;
}
use of com.intellij.ide.util.projectWizard.WizardContext in project android by JetBrains.
the class AdtImportLocationStep method validate.
@Override
public boolean validate() throws ConfigurationException {
WizardContext context = getWizardContext();
GradleImport importer = AdtImportProvider.getImporter(context);
if (importer != null) {
List<String> errors = importer.getErrors();
if (!errors.isEmpty()) {
throw new ConfigurationException(errors.get(0));
}
}
// The following code is based on similar code in com.intellij.ide.util.newProjectWizard.ProjectNameStep
String projectFileDirectory = getProjectFileDirectory();
if (projectFileDirectory.length() == 0) {
throw new ConfigurationException(String.format("Enter %1$s file location", context.getPresentationName()));
}
boolean shouldPromptCreation = myIsPathChangedByUser;
if (!ProjectWizardUtil.createDirectoryIfNotExists(String.format("The %1$s file directory\n", context.getPresentationName()), projectFileDirectory, shouldPromptCreation)) {
return false;
}
boolean shouldContinue = true;
File projectFile = new File(getProjectFileDirectory());
String title = "New Project";
if (projectFile.isFile()) {
shouldContinue = false;
String message = String.format("%s exists and is a file.\nPlease specify a different project location", projectFile.getAbsolutePath());
Messages.showErrorDialog(message, title);
} else if (projectFile.isDirectory()) {
File[] files = projectFile.listFiles();
if (files != null && files.length > 0) {
String message = String.format("%1$s folder already exists and is not empty.\nIts content may be overwritten.\nContinue?", projectFile.getAbsolutePath());
int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
shouldContinue = answer == 0;
}
}
return shouldContinue;
}
use of com.intellij.ide.util.projectWizard.WizardContext in project liferay-ide by liferay.
the class LiferayProjectTypeStep method getTemplatesMap.
public static MultiMap<TemplatesGroup, ProjectTemplate> getTemplatesMap(WizardContext context) {
MultiMap<TemplatesGroup, ProjectTemplate> groups = new MultiMap<>();
for (ProjectTemplatesFactory factory : ProjectTemplatesFactory.EP_NAME.getExtensions()) {
Stream<String> stream = Stream.of(factory.getGroups());
stream.map(group -> new AbstractMap.SimpleEntry<>(group, factory.createTemplates(group, context))).filter(pair -> !CoreUtil.isNullOrEmpty(pair.getValue())).forEach(pair -> {
String group = pair.getKey();
Icon icon = factory.getGroupIcon(group);
String parentGroup = factory.getParentGroup(group);
TemplatesGroup templatesGroup = new TemplatesGroup(group, null, icon, factory.getGroupWeight(group), parentGroup, group, null);
groups.putValues(templatesGroup, Arrays.asList(pair.getValue()));
});
}
return groups;
}
Aggregations