use of com.intellij.openapi.externalSystem.model.project.ProjectData in project intellij-community by JetBrains.
the class GradleModuleWizardStep method updateComponents.
private void updateComponents() {
final boolean isAddToVisible = myParentProjectForm.isVisible();
myInheritGroupIdCheckBox.setVisible(isAddToVisible);
myInheritVersionCheckBox.setVisible(isAddToVisible);
myParentProjectForm.updateComponents();
ProjectData parentProject = myParentProjectForm.getParentProject();
if (parentProject == null) {
myContext.putUserData(ExternalModuleSettingsStep.SKIP_STEP_KEY, Boolean.FALSE);
myGroupIdField.setEnabled(true);
myVersionField.setEnabled(true);
myInheritGroupIdCheckBox.setEnabled(false);
myInheritVersionCheckBox.setEnabled(false);
setTestIfEmpty(myArtifactIdField, myBuilder.getName());
setTestIfEmpty(myGroupIdField, "");
setTestIfEmpty(myVersionField, DEFAULT_VERSION);
} else {
myContext.putUserData(ExternalModuleSettingsStep.SKIP_STEP_KEY, Boolean.TRUE);
myGroupIdField.setEnabled(!myInheritGroupIdCheckBox.isSelected());
myVersionField.setEnabled(!myInheritVersionCheckBox.isSelected());
if (myInheritGroupIdCheckBox.isSelected() || myGroupIdField.getText().equals(myInheritedGroupId)) {
myGroupIdField.setText(parentProject.getGroup());
}
if (myInheritVersionCheckBox.isSelected() || myVersionField.getText().equals(myInheritedVersion)) {
myVersionField.setText(parentProject.getVersion());
}
myInheritedGroupId = myGroupIdField.getText();
myInheritedVersion = myVersionField.getText();
myInheritGroupIdCheckBox.setEnabled(true);
myInheritVersionCheckBox.setEnabled(true);
}
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project intellij-community by JetBrains.
the class GradleModuleWizardStep method updateDataModel.
@Override
public void updateDataModel() {
myContext.setProjectBuilder(myBuilder);
ProjectData parentProject = myParentProjectForm.getParentProject();
myBuilder.setParentProject(parentProject);
myBuilder.setProjectId(new ProjectId(myGroupIdField.getText(), myArtifactIdField.getText(), myVersionField.getText()));
myBuilder.setInheritGroupId(myInheritGroupIdCheckBox.isSelected());
myBuilder.setInheritVersion(myInheritVersionCheckBox.isSelected());
if (StringUtil.isNotEmpty(myBuilder.getProjectId().getArtifactId())) {
myContext.setProjectName(myBuilder.getProjectId().getArtifactId());
}
if (parentProject != null) {
myContext.setProjectFileDirectory(parentProject.getLinkedExternalProjectPath() + '/' + myContext.getProjectName());
} else {
if (myProjectOrNull != null) {
myContext.setProjectFileDirectory(myProjectOrNull.getBaseDir().getPath() + '/' + myContext.getProjectName());
}
}
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project intellij-community by JetBrains.
the class GradleModuleWizardStep method updateStep.
@Override
public void updateStep() {
ProjectData parentProject = myParentProjectForm.getParentProject();
ProjectId projectId = myBuilder.getProjectId();
if (projectId == null) {
setTestIfEmpty(myArtifactIdField, myBuilder.getName());
setTestIfEmpty(myGroupIdField, parentProject == null ? myBuilder.getName() : parentProject.getGroup());
setTestIfEmpty(myVersionField, parentProject == null ? DEFAULT_VERSION : parentProject.getVersion());
} else {
setTestIfEmpty(myArtifactIdField, projectId.getArtifactId());
setTestIfEmpty(myGroupIdField, projectId.getGroupId());
setTestIfEmpty(myVersionField, projectId.getVersion());
}
myInheritGroupIdCheckBox.setSelected(myBuilder.isInheritGroupId());
myInheritVersionCheckBox.setSelected(myBuilder.isInheritVersion());
updateComponents();
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project kotlin by JetBrains.
the class ExternalSystemImportingTestCase method doImportProject.
private void doImportProject() {
AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(myProject, getExternalSystemId());
ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
projectSettings.setExternalProjectPath(getProjectPath());
@SuppressWarnings("unchecked") Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
projects.remove(projectSettings);
projects.add(projectSettings);
//noinspection unchecked
systemSettings.setLinkedProjectsSettings(projects);
final Ref<Couple<String>> error = Ref.create();
ExternalSystemUtil.refreshProjects(new ImportSpecBuilder(myProject, getExternalSystemId()).use(ProgressExecutionMode.MODAL_SYNC).callback(new ExternalProjectRefreshCallback() {
@Override
public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
if (externalProject == null) {
System.err.println("Got null External project after import");
return;
}
ServiceManager.getService(ProjectDataManager.class).importData(externalProject, myProject, true);
System.out.println("External project was successfully imported");
}
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
error.set(Couple.of(errorMessage, errorDetails));
}
}).forceWhenUptodate());
if (!error.isNull()) {
String failureMsg = "Import failed: " + error.get().first;
if (StringUtil.isNotEmpty(error.get().second)) {
failureMsg += "\nError details: \n" + error.get().second;
}
fail(failureMsg);
}
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project android by JetBrains.
the class ProjectSubset method findAndIncludeModuleContainingSourceFile.
/**
* Finds and includes the module that contains the given file.
* <p>
* When using the "Project Subset" feature it is possible that the user knows which file she wants to edit but not the module where
* such file is. This method tries to find the module that includes the given file in the folders that it marked as "source", either
* production or test code.
* </p>
* <p>
* The search is based on the Gradle models for both Android and Java modules. If the search finds more than one module that might contain
* the file, the IDE will display a dialog where the user can see the potential matches and choose the module to include in the project.
* </p>
*
* @param virtualFile the given file.
*/
public void findAndIncludeModuleContainingSourceFile(@NotNull VirtualFile virtualFile) {
DataNode<ProjectData> projectInfo = DataNodeCaches.getInstance(myProject).getCachedProjectData();
if (projectInfo == null) {
return;
}
Collection<DataNode<ModuleData>> moduleInfos = findAll(projectInfo, MODULE);
if (!moduleInfos.isEmpty()) {
File file = virtualToIoFile(virtualFile);
new Task.Modal(myProject, "Looking up Module", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
List<ModuleSearchResult> results = Lists.newArrayList();
String[] storedSelection = getSelection();
Set<String> selection = storedSelection != null ? Sets.newHashSet(storedSelection) : Sets.newHashSet();
List<DataNode<ModuleData>> selectedModules = Lists.newArrayList();
int doneCount = 0;
for (DataNode<ModuleData> moduleNode : moduleInfos) {
indicator.setFraction(++doneCount / moduleInfos.size());
ModuleData module = moduleNode.getData();
String name = module.getExternalName();
boolean selected = selection.contains(name);
if (selected) {
// This module is already included in the project. We need to mark it as "selected" so when we are done searching we don't
// exclude it by accident.
selectedModules.add(moduleNode);
}
ModuleSearchResult result = containsSourceFile(moduleNode, file, selected);
if (result != null) {
// Even though the module is already included, we add it to the search results, because the module might not be the one that
// actually contains the file, and the user might need to exclude it in the case that the module that contains the file has
// the same path as the already-included module.
results.add(result);
}
}
int resultCount = results.size();
if (resultCount == 0) {
// Nothing found.
invokeLaterIfNeeded(() -> {
String text = String.format("Unable to find a module containing the file '%1$s' in a source directory.", file.getName());
AndroidGradleNotification notification = AndroidGradleNotification.getInstance(ProjectSubset.this.myProject);
notification.showBalloon(MODULE_LOOKUP_MESSAGE_TITLE, text, ERROR);
});
} else if (resultCount == 1) {
// If there is one result,just apply it.
addResultAndPopulateProject(results.get(0), projectInfo, selectedModules, file);
} else {
// We need to let user decide which modules to include.
showModuleSelectionDialog(results, projectInfo, selectedModules, file);
}
}
}.queue();
}
}
Aggregations